From 864a6528fda29e42ff91cd5a1a574a25d7c6a941 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 13 Dec 2006 13:02:26 +0100 Subject: [PATCH] --- yaml --- r: 44546 b: refs/heads/master c: 7749a8d423c483a51983b666613acda1a4dd9c1b h: refs/heads/master v: v3 --- [refs] | 2 +- .../feature-removal-schedule.txt | 9 + trunk/Documentation/filesystems/bfs.txt | 2 +- trunk/Documentation/hwmon/f71805f | 56 +- trunk/Documentation/hwmon/it87 | 15 +- trunk/Documentation/hwmon/k8temp | 2 +- trunk/Documentation/hwmon/pc87427 | 38 - trunk/Documentation/hwmon/sysfs-interface | 4 +- trunk/Documentation/hwmon/w83627ehf | 2 +- trunk/Documentation/hwmon/w83791d | 2 +- trunk/Documentation/hwmon/w83793 | 110 -- trunk/Documentation/kernel-parameters.txt | 6 - trunk/MAINTAINERS | 22 +- trunk/Makefile | 14 +- trunk/arch/arm/kernel/apm.c | 2 +- trunk/arch/arm/kernel/ecard.c | 2 +- trunk/arch/arm/mach-omap1/Kconfig | 1 - trunk/arch/arm/mach-omap1/board-osk.c | 1 - trunk/arch/arm26/kernel/ecard.c | 2 +- trunk/arch/arm26/kernel/irq.c | 2 +- .../arch/cris/arch-v10/drivers/axisflashmap.c | 2 +- trunk/arch/cris/arch-v10/drivers/gpio.c | 2 +- .../arch/cris/arch-v32/drivers/axisflashmap.c | 2 +- trunk/arch/cris/arch-v32/drivers/gpio.c | 2 +- trunk/arch/cris/arch-v32/kernel/signal.c | 2 +- trunk/arch/cris/kernel/profile.c | 2 +- trunk/arch/h8300/kernel/ints.c | 2 +- trunk/arch/h8300/platform/h8s/ints.c | 2 +- trunk/arch/i386/kernel/apm.c | 2 +- trunk/arch/i386/kernel/microcode.c | 6 +- trunk/arch/i386/kernel/smpboot.c | 2 + trunk/arch/ia64/sn/kernel/sn2/sn_hwperf.c | 2 +- trunk/arch/m68k/mm/kmap.c | 2 +- trunk/arch/mips/kernel/apm.c | 2 +- trunk/arch/parisc/hpux/sys_hpux.c | 2 +- trunk/arch/parisc/kernel/unwind.c | 2 +- trunk/arch/powerpc/kernel/nvram_64.c | 4 +- trunk/arch/powerpc/kernel/pci_32.c | 2 +- trunk/arch/powerpc/mm/imalloc.c | 6 +- .../powerpc/platforms/pseries/eeh_cache.c | 2 +- trunk/arch/ppc/8260_io/fcc_enet.c | 4 +- trunk/arch/ppc/8xx_io/cs4218_tdm.c | 2 +- trunk/arch/s390/Kconfig | 2 +- trunk/arch/s390/kernel/debug.c | 8 +- trunk/arch/s390/kernel/s390_ext.c | 2 +- trunk/arch/sparc/kernel/irq.c | 4 +- trunk/arch/sparc/kernel/sun4d_irq.c | 2 +- trunk/arch/sparc64/kernel/sys_sunos32.c | 4 +- trunk/arch/um/drivers/net_kern.c | 15 +- trunk/arch/um/include/net_kern.h | 2 - trunk/arch/um/sys-i386/ldt.c | 4 +- trunk/arch/xtensa/kernel/Makefile | 2 +- trunk/arch/xtensa/kernel/syscall.c | 2 +- trunk/block/cfq-iosched.c | 18 +- trunk/block/ll_rw_blk.c | 28 +- trunk/crypto/blkcipher.c | 1 + trunk/drivers/acorn/block/fd1772.c | 4 +- trunk/drivers/ata/pdc_adma.c | 4 +- trunk/drivers/atm/eni.c | 4 +- trunk/drivers/atm/he.c | 2 +- trunk/drivers/atm/lanai.c | 2 +- trunk/drivers/atm/nicstar.c | 4 +- trunk/drivers/atm/zatm.c | 4 +- trunk/drivers/base/dmapool.c | 2 +- trunk/drivers/block/Kconfig | 7 + trunk/drivers/block/Makefile | 1 + trunk/drivers/block/cciss.c | 23 +- trunk/drivers/block/cpqarray.c | 10 +- trunk/drivers/block/swim_iop.c | 578 ++++++ trunk/drivers/cdrom/cdrom.c | 8 +- trunk/drivers/cdrom/cm206.c | 2 +- trunk/drivers/char/Kconfig | 8 +- trunk/drivers/char/consolemap.c | 2 +- trunk/drivers/char/lcd.c | 2 +- trunk/drivers/char/lp.c | 2 +- trunk/drivers/char/mxser_new.c | 8 - trunk/drivers/char/n_r3964.c | 37 +- trunk/drivers/char/n_tty.c | 1 + trunk/drivers/char/pcmcia/synclink_cs.c | 2 +- trunk/drivers/char/rio/riocmd.c | 2 +- trunk/drivers/char/rtc.c | 38 +- trunk/drivers/char/sx.c | 8 - trunk/drivers/char/synclink.c | 2 +- trunk/drivers/char/synclinkmp.c | 4 +- trunk/drivers/char/sysrq.c | 37 +- trunk/drivers/char/tty_io.c | 8 +- trunk/drivers/char/viocons.c | 10 +- trunk/drivers/char/vt.c | 2 +- trunk/drivers/char/vt_ioctl.c | 10 +- trunk/drivers/fc4/fc.c | 10 +- trunk/drivers/hwmon/Kconfig | 56 +- trunk/drivers/hwmon/Makefile | 3 - trunk/drivers/hwmon/ams/Makefile | 8 - trunk/drivers/hwmon/ams/ams-core.c | 265 --- trunk/drivers/hwmon/ams/ams-i2c.c | 299 --- trunk/drivers/hwmon/ams/ams-input.c | 160 -- trunk/drivers/hwmon/ams/ams-pmu.c | 207 --- trunk/drivers/hwmon/ams/ams.h | 72 - trunk/drivers/hwmon/f71805f.c | 569 +----- trunk/drivers/hwmon/hdaps.c | 68 +- trunk/drivers/hwmon/hwmon-vid.c | 4 +- trunk/drivers/hwmon/it87.c | 202 ++- trunk/drivers/hwmon/k8temp.c | 4 +- trunk/drivers/hwmon/pc87360.c | 2 +- trunk/drivers/hwmon/pc87427.c | 627 ------- trunk/drivers/hwmon/w83627ehf.c | 2 +- trunk/drivers/hwmon/w83792d.c | 2 +- trunk/drivers/hwmon/w83793.c | 1609 ----------------- trunk/drivers/i2c/busses/i2c-ali1563.c | 2 +- trunk/drivers/i2c/chips/tps65010.c | 21 +- trunk/drivers/ide/ide-floppy.c | 2 +- trunk/drivers/ide/ide-tape.c | 8 +- trunk/drivers/ide/pci/hpt366.c | 886 +++++---- trunk/drivers/input/keyboard/hilkbd.c | 5 - trunk/drivers/isdn/act2000/act2000_isa.c | 2 +- trunk/drivers/isdn/capi/capidrv.c | 2 +- trunk/drivers/isdn/divert/divert_procfs.c | 2 +- trunk/drivers/isdn/divert/isdn_divert.c | 6 +- trunk/drivers/isdn/gigaset/bas-gigaset.c | 118 +- trunk/drivers/isdn/hysdn/hysdn_procconf.c | 2 +- trunk/drivers/isdn/hysdn/hysdn_proclog.c | 2 +- trunk/drivers/isdn/i4l/isdn_audio.c | 6 +- trunk/drivers/isdn/i4l/isdn_net.c | 2 +- trunk/drivers/isdn/i4l/isdn_ppp.c | 2 +- trunk/drivers/isdn/pcbit/layer2.c | 2 +- trunk/drivers/kvm/Kconfig | 4 - trunk/drivers/kvm/kvm.h | 8 +- trunk/drivers/kvm/kvm_main.c | 38 +- trunk/drivers/kvm/kvm_svm.h | 2 +- trunk/drivers/kvm/kvm_vmx.h | 2 +- trunk/drivers/kvm/mmu.c | 17 +- trunk/drivers/kvm/paging_tmpl.h | 20 +- trunk/drivers/kvm/svm.c | 78 +- trunk/drivers/kvm/vmx.c | 62 +- trunk/drivers/kvm/x86_emulate.c | 8 +- trunk/drivers/kvm/x86_emulate.h | 2 +- trunk/drivers/macintosh/adb.c | 2 +- trunk/drivers/macintosh/apm_emu.c | 2 +- trunk/drivers/macintosh/smu.c | 2 +- trunk/drivers/macintosh/via-pmu68k.c | 2 +- trunk/drivers/md/faulty.c | 2 +- trunk/drivers/md/raid1.c | 2 +- trunk/drivers/md/raid10.c | 6 +- trunk/drivers/md/raid5.c | 20 +- trunk/drivers/media/dvb/bt8xx/dst_ca.c | 2 +- trunk/drivers/media/dvb/bt8xx/dvb-bt8xx.c | 2 +- .../drivers/media/dvb/ttusb-dec/ttusbdecfe.c | 4 +- trunk/drivers/media/video/dabusb.c | 4 +- trunk/drivers/media/video/planb.c | 2 +- trunk/drivers/media/video/usbvideo/usbvideo.c | 2 +- trunk/drivers/media/video/videocodec.c | 2 +- trunk/drivers/message/i2o/core.h | 4 +- trunk/drivers/message/i2o/driver.c | 2 +- trunk/drivers/message/i2o/exec-osm.c | 2 +- trunk/drivers/message/i2o/i2o_config.c | 4 +- trunk/drivers/mtd/devices/mtd_dataflash.c | 2 +- trunk/drivers/mtd/rfd_ftl.c | 2 +- trunk/drivers/net/appletalk/ipddp.c | 2 +- trunk/drivers/net/bsd_comp.c | 2 +- trunk/drivers/net/irda/donauboe.c | 2 +- trunk/drivers/net/irda/irda-usb.c | 2 +- trunk/drivers/net/irda/irport.c | 2 +- trunk/drivers/net/lp486e.c | 4 +- trunk/drivers/net/phy/phy_device.c | 2 +- trunk/drivers/net/ppp_deflate.c | 4 +- trunk/drivers/net/ppp_mppe.c | 2 +- trunk/drivers/net/skge.c | 2 +- trunk/drivers/net/slip.c | 6 +- trunk/drivers/net/wan/hostess_sv11.c | 2 +- trunk/drivers/net/wan/pc300_drv.c | 2 +- trunk/drivers/net/wan/pc300_tty.c | 2 +- trunk/drivers/net/wan/x25_asy.c | 8 +- trunk/drivers/net/wireless/hostap/hostap_ap.c | 2 +- .../net/wireless/hostap/hostap_download.c | 2 +- trunk/drivers/net/wireless/hostap/hostap_hw.c | 2 +- .../net/wireless/hostap/hostap_ioctl.c | 2 +- .../drivers/net/wireless/hostap/hostap_main.c | 2 +- trunk/drivers/net/wireless/ipw2100.c | 2 +- .../drivers/net/wireless/prism54/isl_ioctl.c | 2 +- trunk/drivers/net/wireless/wavelan_cs.c | 2 +- trunk/drivers/net/wireless/zd1211rw/zd_chip.c | 2 +- trunk/drivers/parisc/iosapic.c | 2 +- trunk/drivers/pci/hotplug/cpqphp_nvram.c | 8 +- trunk/drivers/pci/hotplug/pciehp_hpc.c | 2 +- trunk/drivers/pci/pcie/aer/aerdrv.c | 2 +- trunk/drivers/pcmcia/at91_cf.c | 2 +- trunk/drivers/pcmcia/omap_cf.c | 2 +- trunk/drivers/pnp/isapnp/core.c | 22 +- trunk/drivers/pnp/pnpacpi/core.c | 6 +- trunk/drivers/pnp/pnpacpi/rsparser.c | 22 +- trunk/drivers/pnp/pnpbios/core.c | 16 +- trunk/drivers/pnp/pnpbios/proc.c | 8 +- trunk/drivers/pnp/pnpbios/rsparser.c | 16 +- trunk/drivers/rtc/rtc-at91rm9200.c | 5 +- trunk/drivers/rtc/rtc-dev.c | 2 +- trunk/drivers/rtc/rtc-omap.c | 3 +- trunk/drivers/rtc/rtc-proc.c | 4 +- trunk/drivers/rtc/rtc-s3c.c | 6 +- trunk/drivers/rtc/rtc-sa1100.c | 4 +- trunk/drivers/rtc/rtc-sysfs.c | 2 +- trunk/drivers/s390/char/con3215.c | 2 +- trunk/drivers/s390/char/keyboard.c | 2 +- trunk/drivers/s390/char/sclp_cpi.c | 2 +- trunk/drivers/s390/crypto/zcrypt_cex2a.c | 4 +- trunk/drivers/s390/crypto/zcrypt_pcica.c | 4 +- trunk/drivers/s390/crypto/zcrypt_pcixcc.c | 2 +- trunk/drivers/s390/net/ctcmain.c | 6 +- trunk/drivers/s390/net/iucv.c | 2 +- trunk/drivers/s390/scsi/zfcp_aux.c | 2 +- trunk/drivers/sbus/char/vfc_dev.c | 2 +- trunk/drivers/scsi/aacraid/aachba.c | 2 +- trunk/drivers/scsi/aacraid/comminit.c | 2 +- trunk/drivers/scsi/aha1542.c | 2 +- trunk/drivers/scsi/aic7xxx_old.c | 2 +- trunk/drivers/scsi/dc395x.c | 2 +- trunk/drivers/scsi/dpt_i2o.c | 10 +- trunk/drivers/scsi/initio.c | 2 +- trunk/drivers/scsi/osst.c | 2 +- trunk/drivers/scsi/pluto.c | 2 +- trunk/drivers/scsi/sr_ioctl.c | 2 +- trunk/drivers/scsi/sr_vendor.c | 4 +- trunk/drivers/scsi/sym53c8xx_2/sym_hipd.c | 2 +- trunk/drivers/usb/gadget/at91_udc.c | 2 +- trunk/drivers/usb/gadget/serial.c | 2 +- trunk/drivers/usb/host/hc_crisv10.c | 2 +- trunk/drivers/usb/misc/auerswald.c | 4 +- trunk/drivers/usb/misc/uss720.c | 2 +- trunk/drivers/usb/net/rndis_host.c | 2 +- trunk/drivers/usb/serial/cypress_m8.c | 2 +- trunk/drivers/usb/serial/digi_acceleport.c | 4 +- trunk/drivers/usb/serial/io_ti.c | 2 +- trunk/drivers/usb/serial/ipaq.c | 2 +- trunk/drivers/usb/serial/kobil_sct.c | 4 +- trunk/drivers/usb/serial/pl2303.c | 2 +- trunk/drivers/usb/serial/ti_usb_3410_5052.c | 2 +- trunk/drivers/usb/serial/whiteheat.c | 4 +- trunk/drivers/usb/storage/sddr09.c | 2 +- trunk/drivers/video/amba-clcd.c | 2 +- trunk/drivers/video/amifb.c | 8 + trunk/drivers/video/aty/atyfb_base.c | 4 + trunk/drivers/video/matrox/i2c-matroxfb.c | 2 +- trunk/drivers/video/matrox/matroxfb_base.c | 2 +- trunk/drivers/video/matrox/matroxfb_crtc2.c | 2 +- trunk/drivers/video/sstfb.c | 335 ++-- trunk/drivers/w1/slaves/Kconfig | 4 +- trunk/fs/aio.c | 2 +- trunk/fs/autofs4/inode.c | 2 +- trunk/fs/befs/btree.c | 2 +- trunk/fs/befs/debug.c | 6 +- trunk/fs/bfs/inode.c | 4 +- trunk/fs/binfmt_misc.c | 2 +- trunk/fs/bio.c | 2 +- trunk/fs/block_dev.c | 202 +-- trunk/fs/cifs/cifssmb.c | 2 +- trunk/fs/inode.c | 43 +- trunk/fs/jffs/inode-v23.c | 4 +- trunk/fs/jffs/intrep.c | 14 +- trunk/fs/jfs/jfs_dtree.c | 4 +- trunk/fs/jfs/jfs_imap.c | 2 +- trunk/fs/lockd/clntlock.c | 10 +- trunk/fs/lockd/clntproc.c | 39 +- trunk/fs/lockd/svclock.c | 4 +- trunk/fs/lockd/svcshare.c | 2 +- trunk/fs/lockd/xdr.c | 8 +- trunk/fs/lockd/xdr4.c | 8 +- trunk/fs/namespace.c | 5 +- trunk/fs/ncpfs/inode.c | 34 +- trunk/fs/nfs/nfs4proc.c | 2 +- trunk/fs/nfsd/export.c | 33 +- trunk/fs/nfsd/lockd.c | 2 +- trunk/fs/nfsd/nfs4proc.c | 625 +++---- trunk/fs/nfsd/nfs4state.c | 91 +- trunk/fs/nfsd/nfs4xdr.c | 14 +- trunk/fs/nfsd/nfsfh.c | 6 +- trunk/fs/nfsd/vfs.c | 2 +- trunk/fs/ocfs2/alloc.c | 2 +- trunk/fs/ocfs2/cluster/heartbeat.c | 4 +- trunk/fs/ocfs2/cluster/nodemanager.c | 6 +- trunk/fs/ocfs2/cluster/tcp.c | 10 +- trunk/fs/ocfs2/dlm/dlmdomain.c | 4 +- trunk/fs/ocfs2/dlm/dlmlock.c | 4 +- trunk/fs/ocfs2/dlm/dlmmaster.c | 2 +- trunk/fs/ocfs2/dlm/dlmrecovery.c | 6 +- trunk/fs/ocfs2/file.c | 8 - trunk/fs/ocfs2/localalloc.c | 2 +- trunk/fs/ocfs2/slot_map.c | 2 +- trunk/fs/ocfs2/suballoc.c | 6 +- trunk/fs/ocfs2/super.c | 6 +- trunk/fs/ocfs2/vote.c | 4 +- trunk/fs/pipe.c | 12 +- trunk/fs/read_write.c | 2 + trunk/fs/reiserfs/xattr_acl.c | 2 +- trunk/fs/smbfs/inode.c | 5 +- trunk/fs/smbfs/proc.c | 6 +- trunk/fs/smbfs/smbiod.c | 5 +- trunk/fs/splice.c | 8 +- trunk/include/asm-arm/thread_info.h | 2 - trunk/include/asm-avr32/pgalloc.h | 2 +- trunk/include/asm-frv/thread_info.h | 2 - trunk/include/asm-i386/thread_info.h | 2 - trunk/include/asm-ia64/thread_info.h | 2 - trunk/include/asm-m68k/swim_iop.h | 221 +++ trunk/include/asm-powerpc/thread_info.h | 2 - trunk/include/asm-sh/thread_info.h | 2 - trunk/include/asm-sh64/pgalloc.h | 2 +- trunk/include/asm-x86_64/thread_info.h | 2 - trunk/include/asm-xtensa/termbits.h | 11 - trunk/include/asm-xtensa/uaccess.h | 1 + trunk/include/linux/aio.h | 1 - trunk/include/linux/bio.h | 1 - trunk/include/linux/coda_linux.h | 2 +- trunk/include/linux/cpuset.h | 22 +- trunk/include/linux/fb.h | 2 + trunk/include/linux/freezer.h | 11 +- trunk/include/linux/fs.h | 1 - trunk/include/linux/gameport.h | 2 +- trunk/include/linux/i2c-id.h | 1 + trunk/include/linux/init_task.h | 1 + trunk/include/linux/lockd/bind.h | 2 +- trunk/include/linux/lockd/lockd.h | 2 +- trunk/include/linux/lockd/sm_inter.h | 2 +- trunk/include/linux/lockd/xdr.h | 8 +- trunk/include/linux/lockdep.h | 16 +- trunk/include/linux/mount.h | 1 - trunk/include/linux/n_r3964.h | 2 +- trunk/include/linux/ncp_mount.h | 2 +- trunk/include/linux/nfsd/nfsd.h | 4 +- trunk/include/linux/nfsd/state.h | 1 + trunk/include/linux/nfsd/xdr4.h | 40 +- trunk/include/linux/nsproxy.h | 1 + trunk/include/linux/pipe_fs_i.h | 5 +- trunk/include/linux/reciprocal_div.h | 32 - trunk/include/linux/sched.h | 1 + trunk/include/linux/slab.h | 306 ++-- trunk/include/linux/slab_def.h | 100 - trunk/include/linux/smb_fs_sb.h | 2 +- trunk/include/linux/sysrq.h | 22 +- trunk/include/net/bluetooth/hci.h | 4 +- trunk/include/video/sstfb.h | 13 +- trunk/ipc/msgutil.c | 4 +- trunk/kernel/cpuset.c | 82 +- trunk/kernel/lockdep.c | 203 +-- trunk/kernel/nsproxy.c | 4 +- trunk/kernel/power/process.c | 21 +- trunk/kernel/relay.c | 4 +- trunk/kernel/sched.c | 4 - trunk/kernel/signal.c | 4 +- trunk/kernel/sysctl.c | 3 +- trunk/kernel/timer.c | 14 +- trunk/lib/Kconfig | 5 - trunk/lib/Makefile | 5 +- trunk/lib/ioremap.c | 1 + trunk/lib/reciprocal_div.c | 9 - trunk/mm/hugetlb.c | 2 +- trunk/mm/oom_kill.c | 2 +- trunk/mm/page_alloc.c | 2 +- trunk/mm/slab.c | 28 +- trunk/mm/slob.c | 16 +- trunk/mm/vmscan.c | 8 +- trunk/net/bluetooth/hci_sock.c | 4 +- trunk/net/sunrpc/auth_gss/svcauth_gss.c | 11 +- trunk/net/sunrpc/cache.c | 31 +- trunk/net/sunrpc/svc.c | 2 +- trunk/net/sunrpc/svcauth_unix.c | 5 - trunk/net/tipc/config.c | 2 +- trunk/scripts/kconfig/conf.c | 2 +- trunk/scripts/kconfig/confdata.c | 37 +- trunk/scripts/kconfig/gconf.c | 35 +- trunk/scripts/kconfig/gconf.glade | 4 +- trunk/scripts/kconfig/lkc.h | 2 - trunk/scripts/kconfig/lkc_proto.h | 3 +- trunk/scripts/kconfig/mconf.c | 21 +- trunk/scripts/kconfig/qconf.cc | 15 +- trunk/scripts/kconfig/qconf.h | 3 - trunk/scripts/kconfig/symbol.c | 3 +- trunk/scripts/kconfig/zconf.tab.c_shipped | 2 +- trunk/scripts/kconfig/zconf.y | 2 +- trunk/scripts/mod/modpost.c | 1 - trunk/sound/core/oss/mixer_oss.c | 2 +- trunk/sound/oss/ad1848.c | 2 +- trunk/sound/oss/cs4232.c | 2 +- trunk/sound/oss/emu10k1/audio.c | 6 +- trunk/sound/oss/emu10k1/cardmi.c | 2 +- trunk/sound/oss/emu10k1/cardmo.c | 2 +- trunk/sound/oss/emu10k1/midi.c | 10 +- trunk/sound/oss/emu10k1/mixer.c | 2 +- trunk/sound/oss/hal2.c | 2 +- trunk/sound/oss/mpu401.c | 2 +- trunk/sound/oss/opl3.c | 2 +- trunk/sound/oss/sb_common.c | 2 +- trunk/sound/oss/sb_midi.c | 4 +- trunk/sound/oss/sb_mixer.c | 2 +- trunk/sound/oss/v_midi.c | 2 +- trunk/sound/oss/waveartist.c | 2 +- 394 files changed, 3472 insertions(+), 6812 deletions(-) delete mode 100644 trunk/Documentation/hwmon/pc87427 delete mode 100644 trunk/Documentation/hwmon/w83793 create mode 100644 trunk/drivers/block/swim_iop.c delete mode 100644 trunk/drivers/hwmon/ams/Makefile delete mode 100644 trunk/drivers/hwmon/ams/ams-core.c delete mode 100644 trunk/drivers/hwmon/ams/ams-i2c.c delete mode 100644 trunk/drivers/hwmon/ams/ams-input.c delete mode 100644 trunk/drivers/hwmon/ams/ams-pmu.c delete mode 100644 trunk/drivers/hwmon/ams/ams.h delete mode 100644 trunk/drivers/hwmon/pc87427.c delete mode 100644 trunk/drivers/hwmon/w83793.c create mode 100644 trunk/include/asm-m68k/swim_iop.h delete mode 100644 trunk/include/linux/reciprocal_div.h delete mode 100644 trunk/include/linux/slab_def.h delete mode 100644 trunk/lib/reciprocal_div.c diff --git a/[refs] b/[refs] index c8e192acec40..54cb73119be7 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: bbc7610c062074468f362b37d33603536e87fb96 +refs/heads/master: 7749a8d423c483a51983b666613acda1a4dd9c1b diff --git a/trunk/Documentation/feature-removal-schedule.txt b/trunk/Documentation/feature-removal-schedule.txt index 040f437c421b..64ce44da5936 100644 --- a/trunk/Documentation/feature-removal-schedule.txt +++ b/trunk/Documentation/feature-removal-schedule.txt @@ -151,6 +151,15 @@ Who: Thomas Gleixner --------------------------- +What: I2C interface of the it87 driver +When: January 2007 +Why: The ISA interface is faster and should be always available. The I2C + probing is also known to cause trouble in at least one case (see + bug #5889.) +Who: Jean Delvare + +--------------------------- + What: Unused EXPORT_SYMBOL/EXPORT_SYMBOL_GPL exports (temporary transition config option provided until then) The transition config option will also be removed at the same time. diff --git a/trunk/Documentation/filesystems/bfs.txt b/trunk/Documentation/filesystems/bfs.txt index ea825e178e79..d2841e0bcf02 100644 --- a/trunk/Documentation/filesystems/bfs.txt +++ b/trunk/Documentation/filesystems/bfs.txt @@ -54,4 +54,4 @@ The first 4 bytes should be 0x1badface. If you have any patches, questions or suggestions regarding this BFS implementation please contact the author: -Tigran Aivazian +Tigran A. Aivazian diff --git a/trunk/Documentation/hwmon/f71805f b/trunk/Documentation/hwmon/f71805f index bfd0f154959c..2ca69df669c3 100644 --- a/trunk/Documentation/hwmon/f71805f +++ b/trunk/Documentation/hwmon/f71805f @@ -6,10 +6,6 @@ Supported chips: Prefix: 'f71805f' Addresses scanned: none, address read from Super I/O config space Datasheet: Provided by Fintek on request - * Fintek F71872F/FG - Prefix: 'f71872f' - Addresses scanned: none, address read from Super I/O config space - Datasheet: Provided by Fintek on request Author: Jean Delvare @@ -17,8 +13,8 @@ Thanks to Denis Kieft from Barracuda Networks for the donation of a test system (custom Jetway K8M8MS motherboard, with CPU and RAM) and for providing initial documentation. -Thanks to Kris Chen and Aaron Huang from Fintek for answering technical -questions and providing additional documentation. +Thanks to Kris Chen from Fintek for answering technical questions and +providing additional documentation. Thanks to Chris Lin from Jetway for providing wiring schematics and answering technical questions. @@ -32,11 +28,8 @@ capabilities. It can monitor up to 9 voltages (counting its own power source), 3 fans and 3 temperature sensors. This chip also has fan controlling features, using either DC or PWM, in -three different modes (one manual, two automatic). - -The Fintek F71872F/FG Super I/O chip is almost the same, with two -additional internal voltages monitored (VSB and battery). It also features -6 VID inputs. The VID inputs are not yet supported by this driver. +three different modes (one manual, two automatic). The driver doesn't +support these features yet. The driver assumes that no more than one chip is present, which seems reasonable. @@ -49,8 +42,7 @@ Voltages are sampled by an 8-bit ADC with a LSB of 8 mV. The supported range is thus from 0 to 2.040 V. Voltage values outside of this range need external resistors. An exception is in0, which is used to monitor the chip's own power source (+3.3V), and is divided internally by a -factor 2. For the F71872F/FG, in9 (VSB) and in10 (battery) are also -divided internally by a factor 2. +factor 2. The two LSB of the voltage limit registers are not used (always 0), so you can only set the limits in steps of 32 mV (before scaling). @@ -69,12 +61,9 @@ in5 VIN5 +12V 200K 20K 11.00 1.05 V in6 VIN6 VCC1.5V 10K - 1.00 1.50 V in7 VIN7 VCORE 10K - 1.00 ~1.40 V (1) in8 VIN8 VSB5V 200K 47K 1.00 0.95 V -in10 VSB VSB3.3V int. int. 2.00 1.65 V (3) -in9 VBAT VBATTERY int. int. 2.00 1.50 V (3) (1) Depends on your hardware setup. (2) Obviously not correct, swapping R1 and R2 would make more sense. -(3) F71872F/FG only. These values can be used as hints at best, as motherboard manufacturers are free to use a completely different setup. As a matter of fact, the @@ -114,38 +103,3 @@ sensor. Each channel can be used for connecting either a thermal diode or a thermistor. The driver reports the currently selected mode, but doesn't allow changing it. In theory, the BIOS should have configured everything properly. - - -Fan Control ------------ - -Both PWM (pulse-width modulation) and DC fan speed control methods are -supported. The right one to use depends on external circuitry on the -motherboard, so the driver assumes that the BIOS set the method -properly. The driver will report the method, but won't let you change -it. - -When the PWM method is used, you can select the operating frequency, -from 187.5 kHz (default) to 31 Hz. The best frequency depends on the -fan model. As a rule of thumb, lower frequencies seem to give better -control, but may generate annoying high-pitch noise. Fintek recommends -not going below 1 kHz, as the fan tachometers get confused by lower -frequencies as well. - -When the DC method is used, Fintek recommends not going below 5 V, which -corresponds to a pwm value of 106 for the driver. The driver doesn't -enforce this limit though. - -Three different fan control modes are supported: - -* Manual mode - You ask for a specific PWM duty cycle or DC voltage. - -* Fan speed mode - You ask for a specific fan speed. This mode assumes that pwm1 - corresponds to fan1, pwm2 to fan2 and pwm3 to fan3. - -* Temperature mode - You define 3 temperature/fan speed trip points, and the fan speed is - adjusted depending on the measured temperature, using interpolation. - This mode is not yet supported by the driver. diff --git a/trunk/Documentation/hwmon/it87 b/trunk/Documentation/hwmon/it87 index 74a80992d237..e783fd62e308 100644 --- a/trunk/Documentation/hwmon/it87 +++ b/trunk/Documentation/hwmon/it87 @@ -9,7 +9,8 @@ Supported chips: http://www.ite.com.tw/ * IT8712F Prefix: 'it8712' - Addresses scanned: from Super I/O config space (8 I/O ports) + Addresses scanned: I2C 0x2d + from Super I/O config space (8 I/O ports) Datasheet: Publicly available at the ITE website http://www.ite.com.tw/ * IT8716F @@ -52,18 +53,6 @@ Module Parameters misconfigured by BIOS - PWM values would be inverted. This option tries to fix this. Please contact your BIOS manufacturer and ask him for fix. - -Hardware Interfaces -------------------- - -All the chips suported by this driver are LPC Super-I/O chips, accessed -through the LPC bus (ISA-like I/O ports). The IT8712F additionally has an -SMBus interface to the hardware monitoring functions. This driver no -longer supports this interface though, as it is slower and less reliable -than the ISA access, and was only available on a small number of -motherboard models. - - Description ----------- diff --git a/trunk/Documentation/hwmon/k8temp b/trunk/Documentation/hwmon/k8temp index 0005c7166146..30d123b8d920 100644 --- a/trunk/Documentation/hwmon/k8temp +++ b/trunk/Documentation/hwmon/k8temp @@ -8,7 +8,7 @@ Supported chips: Datasheet: http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/32559.pdf Author: Rudolf Marek -Contact: Rudolf Marek +Contact: Rudolf Marek Description ----------- diff --git a/trunk/Documentation/hwmon/pc87427 b/trunk/Documentation/hwmon/pc87427 deleted file mode 100644 index 9a0708f9f49e..000000000000 --- a/trunk/Documentation/hwmon/pc87427 +++ /dev/null @@ -1,38 +0,0 @@ -Kernel driver pc87427 -===================== - -Supported chips: - * National Semiconductor PC87427 - Prefix: 'pc87427' - Addresses scanned: none, address read from Super I/O config space - Datasheet: http://www.winbond.com.tw/E-WINBONDHTM/partner/apc_007.html - -Author: Jean Delvare - -Thanks to Amir Habibi at Candelis for setting up a test system, and to -Michael Kress for testing several iterations of this driver. - - -Description ------------ - -The National Semiconductor Super I/O chip includes complete hardware -monitoring capabilities. It can monitor up to 18 voltages, 8 fans and -6 temperature sensors. Only the fans are supported at the moment. - -This chip also has fan controlling features, which are not yet supported -by this driver either. - -The driver assumes that no more than one chip is present, which seems -reasonable. - - -Fan Monitoring --------------- - -Fan rotation speeds are reported as 14-bit values from a gated clock -signal. Speeds down to 83 RPM can be measured. - -An alarm is triggered if the rotation speed drops below a programmable -limit. Another alarm is triggered if the speed is too low to to be measured -(including stalled or missing fan). diff --git a/trunk/Documentation/hwmon/sysfs-interface b/trunk/Documentation/hwmon/sysfs-interface index efef3b962cd3..d1d390aaf620 100644 --- a/trunk/Documentation/hwmon/sysfs-interface +++ b/trunk/Documentation/hwmon/sysfs-interface @@ -208,14 +208,12 @@ temp[1-*]_auto_point[1-*]_temp_hyst **************** temp[1-*]_type Sensor type selection. - Integers 1 to 6 or thermistor Beta value (typically 3435) + Integers 1 to 4 or thermistor Beta value (typically 3435) RW 1: PII/Celeron Diode 2: 3904 transistor 3: thermal diode 4: thermistor (default/unknown Beta) - 5: AMD AMDSI - 6: Intel PECI Not all types are supported by all chips temp[1-*]_max Temperature max value. diff --git a/trunk/Documentation/hwmon/w83627ehf b/trunk/Documentation/hwmon/w83627ehf index 8a15a7408753..caa610a297e8 100644 --- a/trunk/Documentation/hwmon/w83627ehf +++ b/trunk/Documentation/hwmon/w83627ehf @@ -10,7 +10,7 @@ Supported chips: Authors: Jean Delvare Yuan Mu (Winbond) - Rudolf Marek + Rudolf Marek Description ----------- diff --git a/trunk/Documentation/hwmon/w83791d b/trunk/Documentation/hwmon/w83791d index db9881df88a5..19b2ed739fa1 100644 --- a/trunk/Documentation/hwmon/w83791d +++ b/trunk/Documentation/hwmon/w83791d @@ -18,7 +18,7 @@ Credits: and Mark Studebaker w83792d.c: Chunhao Huang , - Rudolf Marek + Rudolf Marek Additional contributors: Sven Anders diff --git a/trunk/Documentation/hwmon/w83793 b/trunk/Documentation/hwmon/w83793 deleted file mode 100644 index 45e5408340e0..000000000000 --- a/trunk/Documentation/hwmon/w83793 +++ /dev/null @@ -1,110 +0,0 @@ -Kernel driver w83793 -==================== - -Supported chips: - * Winbond W83793G/W83793R - Prefix: 'w83793' - Addresses scanned: I2C 0x2c - 0x2f - Datasheet: Still not published - -Authors: - Yuan Mu (Winbond Electronics) - Rudolf Marek - - -Module parameters ------------------ - -* reset int - (default 0) - This parameter is not recommended, it will lose motherboard specific - settings. Use 'reset=1' to reset the chip when loading this module. - -* force_subclients=bus,caddr,saddr1,saddr2 - This is used to force the i2c addresses for subclients of - a certain chip. Typical usage is `force_subclients=0,0x2f,0x4a,0x4b' - to force the subclients of chip 0x2f on bus 0 to i2c addresses - 0x4a and 0x4b. - - -Description ------------ - -This driver implements support for Winbond W83793G/W83793R chips. - -* Exported features - This driver exports 10 voltage sensors, up to 12 fan tachometer inputs, - 6 remote temperatures, up to 8 sets of PWM fan controls, SmartFan - (automatic fan speed control) on all temperature/PWM combinations, 2 - sets of 6-pin CPU VID input. - -* Sensor resolutions - If your motherboard maker used the reference design, the resolution of - voltage0-2 is 2mV, resolution of voltage3/4/5 is 16mV, 8mV for voltage6, - 24mV for voltage7/8. Temp1-4 have a 0.25 degree Celsius resolution, - temp5-6 have a 1 degree Celsiis resolution. - -* Temperature sensor types - Temp1-4 have 3 possible types. It can be read from (and written to) - temp[1-4]_type. - - If the value of 0, the related temperature channel stops - monitoring. - - If the value is 3, it starts monitoring using a remote termal diode - (default). - - If the value is 5, it starts monitoring using the temperature sensor - in AMD CPU and get result by AMDSI. - - If the value is 6, it starts monitoring using the temperature sensor - in Intel CPU and get result by PECI. - Temp5-6 can be connected to external thermistors (value of - temp[5-6]_type is 4). They can also be disabled (value is 0). - -* Alarm mechanism - For voltage sensors, an alarm triggers if the measured value is below - the low voltage limit or over the high voltage limit. - For temperature sensors, an alarm triggers if the measured value goes - above the high temperature limit, and wears off only after the measured - value drops below the hysteresis value. - For fan sensors, an alarm triggers if the measured value is below the - low speed limit. - -* SmartFan/PWM control - If you want to set a pwm fan to manual mode, you just need to make sure it - is not controlled by any temp channel, for example, you want to set fan1 - to manual mode, you need to check the value of temp[1-6]_fan_map, make - sure bit 0 is cleared in the 6 values. And then set the pwm1 value to - control the fan. - - Each temperature channel can control all the 8 PWM outputs (by setting the - corresponding bit in tempX_fan_map), you can set the temperature channel - mode using temp[1-6]_pwm_enable, 2 is Thermal Cruise mode and 3 - is the SmartFanII mode. Temperature channels will try to speed up or - slow down all controlled fans, this means one fan can receive different - PWM value requests from different temperature channels, but the chip - will always pick the safest (max) PWM value for each fan. - - In Thermal Cruise mode, the chip attempts to keep the temperature at a - predefined value, within a tolerance margin. So if tempX_input > - thermal_cruiseX + toleranceX, the chip will increase the PWM value, - if tempX_input < thermal_cruiseX - toleranceX, the chip will decrease - the PWM value. If the temperature is within the tolerance range, the PWM - value is left unchanged. - - SmartFanII works differently, you have to define up to 7 PWM, temperature - trip points, defining a PWM/temperature curve which the chip will follow. - While not fundamentally different from the Thermal Cruise mode, the - implementation is quite different, giving you a finer-grained control. - -* Chassis - If the case open alarm triggers, it will stay in this state unless cleared - by any write to the sysfs file "chassis". - -* VID and VRM - The VRM version is detected automatically, don't modify the it unless you - *do* know the cpu VRM version and it's not properly detected. - - -Notes ------ - - Only Fan1-5 and PWM1-3 are guaranteed to always exist, other fan inputs and - PWM outputs may or may not exist depending on the chip pin configuration. diff --git a/trunk/Documentation/kernel-parameters.txt b/trunk/Documentation/kernel-parameters.txt index ef69c75780bf..d8323b8893c3 100644 --- a/trunk/Documentation/kernel-parameters.txt +++ b/trunk/Documentation/kernel-parameters.txt @@ -1656,12 +1656,6 @@ and is between 256 and 4096 characters. It is defined in the file sym53c416= [HW,SCSI] See header of drivers/scsi/sym53c416.c. - sysrq_always_enabled - [KNL] - Ignore sysrq setting - this boot parameter will - neutralize any effect of /proc/sys/kernel/sysrq. - Useful for debugging. - t128= [HW,SCSI] See header of drivers/scsi/t128.c. diff --git a/trunk/MAINTAINERS b/trunk/MAINTAINERS index dea5b2a6de0a..8a0bfeca55c9 100644 --- a/trunk/MAINTAINERS +++ b/trunk/MAINTAINERS @@ -277,7 +277,7 @@ S: Maintained ALI1563 I2C DRIVER P: Rudolf Marek -M: r.marek@assembler.cz +M: r.marek@sh.cvut.cz L: i2c@lm-sensors.org S: Maintained @@ -296,13 +296,6 @@ L: info-linux@geode.amd.com W: http://www.amd.com/us-en/ConnectivitySolutions/TechnicalResources/0,,50_2334_2452_11363,00.html S: Supported -AMS (Apple Motion Sensor) DRIVER -P: Stelian Pop -M: stelian@popies.net -P: Michael Hanselmann -M: linux-kernel@hansmi.ch -S: Supported - AMSO1100 RNIC DRIVER P: Tom Tucker M: tom@opengridcomputing.com @@ -1754,13 +1747,6 @@ W: http://nfs.sourceforge.net/ W: http://www.cse.unsw.edu.au/~neilb/patches/linux-devel/ S: Maintained -KERNEL VIRTUAL MACHINE (KVM) -P: Avi Kivity -M: avi@qumranet.com -L: kvm-devel@lists.sourceforge.net -W: kvm.sourceforge.net -S: Supported - KEXEC P: Eric Biederman M: ebiederm@xmission.com @@ -3443,12 +3429,6 @@ M: bezaur@gmail.com L: lm-sensors@lm-sensors.org S: Maintained -W83793 HARDWARE MONITORING DRIVER -P: Rudolf Marek -M: r.marek@assembler.cz -L: lm-sensors@lm-sensors.org -S: Maintained - W83L51xD SD/MMC CARD INTERFACE DRIVER P: Pierre Ossman M: drzeus-wbsd@drzeus.cx diff --git a/trunk/Makefile b/trunk/Makefile index f732e75be43d..4eabaa8afbff 100644 --- a/trunk/Makefile +++ b/trunk/Makefile @@ -1390,18 +1390,12 @@ endif #ifeq ($(mixed-targets),1) PHONY += checkstack kernelrelease kernelversion -# UML needs a little special treatment here. It wants to use the host -# toolchain, so needs $(SUBARCH) passed to checkstack.pl. Everyone -# else wants $(ARCH), including people doing cross-builds, which means -# that $(SUBARCH) doesn't work here. -ifeq ($(ARCH), um) -CHECKSTACK_ARCH := $(SUBARCH) -else -CHECKSTACK_ARCH := $(ARCH) -endif +# Use $(SUBARCH) here instead of $(ARCH) so that this works for UML. +# In the UML case, $(SUBARCH) is the name of the underlying +# architecture, while for all other arches, it is the same as $(ARCH). checkstack: $(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \ - $(PERL) $(src)/scripts/checkstack.pl $(CHECKSTACK_ARCH) + $(PERL) $(src)/scripts/checkstack.pl $(SUBARCH) kernelrelease: $(if $(wildcard include/config/kernel.release), $(Q)echo $(KERNELRELEASE), \ diff --git a/trunk/arch/arm/kernel/apm.c b/trunk/arch/arm/kernel/apm.c index 2c37b70b17ab..a11fb9a40c04 100644 --- a/trunk/arch/arm/kernel/apm.c +++ b/trunk/arch/arm/kernel/apm.c @@ -423,7 +423,7 @@ static int apm_open(struct inode * inode, struct file * filp) { struct apm_user *as; - as = kzalloc(sizeof(*as), GFP_KERNEL); + as = (struct apm_user *)kzalloc(sizeof(*as), GFP_KERNEL); if (as) { /* * XXX - this is a tiny bit broken, when we consider BSD diff --git a/trunk/arch/arm/kernel/ecard.c b/trunk/arch/arm/kernel/ecard.c index 71257e3d513f..a786f769035d 100644 --- a/trunk/arch/arm/kernel/ecard.c +++ b/trunk/arch/arm/kernel/ecard.c @@ -353,7 +353,7 @@ int ecard_readchunk(struct in_chunk_dir *cd, ecard_t *ec, int id, int num) } if (c_id(&excd) == 0x80) { /* loader */ if (!ec->loader) { - ec->loader = kmalloc(c_len(&excd), + ec->loader = (loader_t)kmalloc(c_len(&excd), GFP_KERNEL); if (ec->loader) ecard_readbytes(ec->loader, ec, diff --git a/trunk/arch/arm/mach-omap1/Kconfig b/trunk/arch/arm/mach-omap1/Kconfig index 8781aaeb576b..d135568dc9e7 100644 --- a/trunk/arch/arm/mach-omap1/Kconfig +++ b/trunk/arch/arm/mach-omap1/Kconfig @@ -43,7 +43,6 @@ config MACH_OMAP_H3 config MACH_OMAP_OSK bool "TI OSK Support" depends on ARCH_OMAP1 && ARCH_OMAP16XX - select TPS65010 help TI OMAP 5912 OSK (OMAP Starter Kit) board support. Say Y here if you have such a board. diff --git a/trunk/arch/arm/mach-omap1/board-osk.c b/trunk/arch/arm/mach-omap1/board-osk.c index 7d0cf7af88ce..3a622801d7b0 100644 --- a/trunk/arch/arm/mach-omap1/board-osk.c +++ b/trunk/arch/arm/mach-omap1/board-osk.c @@ -30,7 +30,6 @@ #include #include #include -#include #include #include diff --git a/trunk/arch/arm26/kernel/ecard.c b/trunk/arch/arm26/kernel/ecard.c index 9dbc17247c6f..43dd41be71fb 100644 --- a/trunk/arch/arm26/kernel/ecard.c +++ b/trunk/arch/arm26/kernel/ecard.c @@ -215,7 +215,7 @@ int ecard_readchunk(struct in_chunk_dir *cd, ecard_t *ec, int id, int num) } if (c_id(&excd) == 0x80) { /* loader */ if (!ec->loader) { - ec->loader = kmalloc(c_len(&excd), + ec->loader = (loader_t)kmalloc(c_len(&excd), GFP_KERNEL); if (ec->loader) ecard_readbytes(ec->loader, ec, diff --git a/trunk/arch/arm26/kernel/irq.c b/trunk/arch/arm26/kernel/irq.c index d53382c83bf9..d87d68b77d66 100644 --- a/trunk/arch/arm26/kernel/irq.c +++ b/trunk/arch/arm26/kernel/irq.c @@ -545,7 +545,7 @@ int request_irq(unsigned int irq, irqreturn_t (*handler)(int, void *, struct pt_ (irq_flags & IRQF_SHARED && !dev_id)) return -EINVAL; - action = kmalloc(sizeof(struct irqaction), GFP_KERNEL); + action = (struct irqaction *)kmalloc(sizeof(struct irqaction), GFP_KERNEL); if (!action) return -ENOMEM; diff --git a/trunk/arch/cris/arch-v10/drivers/axisflashmap.c b/trunk/arch/cris/arch-v10/drivers/axisflashmap.c index ffade19a14e6..4fa81abab0c7 100644 --- a/trunk/arch/cris/arch-v10/drivers/axisflashmap.c +++ b/trunk/arch/cris/arch-v10/drivers/axisflashmap.c @@ -516,7 +516,7 @@ static int __init init_axis_flash(void) #else struct mtd_info *mtd_ram; - mtd_ram = kmalloc(sizeof(struct mtd_info), + mtd_ram = (struct mtd_info *)kmalloc(sizeof(struct mtd_info), GFP_KERNEL); if (!mtd_ram) { panic("axisflashmap couldn't allocate memory for " diff --git a/trunk/arch/cris/arch-v10/drivers/gpio.c b/trunk/arch/cris/arch-v10/drivers/gpio.c index 9aba18b931dd..fcba6632ed7b 100644 --- a/trunk/arch/cris/arch-v10/drivers/gpio.c +++ b/trunk/arch/cris/arch-v10/drivers/gpio.c @@ -440,7 +440,7 @@ gpio_open(struct inode *inode, struct file *filp) if (p > GPIO_MINOR_LAST) return -EINVAL; - priv = kmalloc(sizeof(struct gpio_private), + priv = (struct gpio_private *)kmalloc(sizeof(struct gpio_private), GFP_KERNEL); if (!priv) diff --git a/trunk/arch/cris/arch-v32/drivers/axisflashmap.c b/trunk/arch/cris/arch-v32/drivers/axisflashmap.c index 5180d45412fc..41952320e00a 100644 --- a/trunk/arch/cris/arch-v32/drivers/axisflashmap.c +++ b/trunk/arch/cris/arch-v32/drivers/axisflashmap.c @@ -427,7 +427,7 @@ static int __init init_axis_flash(void) #else struct mtd_info *mtd_ram; - mtd_ram = kmalloc(sizeof(struct mtd_info), + mtd_ram = (struct mtd_info *)kmalloc(sizeof(struct mtd_info), GFP_KERNEL); if (!mtd_ram) { panic("axisflashmap couldn't allocate memory for " diff --git a/trunk/arch/cris/arch-v32/drivers/gpio.c b/trunk/arch/cris/arch-v32/drivers/gpio.c index 08d36f0955c6..c3f876b4da6b 100644 --- a/trunk/arch/cris/arch-v32/drivers/gpio.c +++ b/trunk/arch/cris/arch-v32/drivers/gpio.c @@ -423,7 +423,7 @@ gpio_open(struct inode *inode, struct file *filp) if (p > GPIO_MINOR_LAST) return -EINVAL; - priv = kmalloc(sizeof(struct gpio_private), + priv = (struct gpio_private *)kmalloc(sizeof(struct gpio_private), GFP_KERNEL); if (!priv) diff --git a/trunk/arch/cris/arch-v32/kernel/signal.c b/trunk/arch/cris/arch-v32/kernel/signal.c index 7cd6ac803409..99e59b3eacf8 100644 --- a/trunk/arch/cris/arch-v32/kernel/signal.c +++ b/trunk/arch/cris/arch-v32/kernel/signal.c @@ -686,7 +686,7 @@ keep_debug_flags(unsigned long oldccs, unsigned long oldspc, int __init cris_init_signal(void) { - u16* data = kmalloc(PAGE_SIZE, GFP_KERNEL); + u16* data = (u16*)kmalloc(PAGE_SIZE, GFP_KERNEL); /* This is movu.w __NR_sigreturn, r9; break 13; */ data[0] = 0x9c5f; diff --git a/trunk/arch/cris/kernel/profile.c b/trunk/arch/cris/kernel/profile.c index f60ab785f235..69c52189f044 100644 --- a/trunk/arch/cris/kernel/profile.c +++ b/trunk/arch/cris/kernel/profile.c @@ -59,7 +59,7 @@ static int __init init_cris_profile(void) { struct proc_dir_entry *entry; - sample_buffer = kmalloc(SAMPLE_BUFFER_SIZE, GFP_KERNEL); + sample_buffer = (char*)kmalloc(SAMPLE_BUFFER_SIZE, GFP_KERNEL); sample_buffer_pos = sample_buffer; entry = create_proc_entry("system_profile", S_IWUSR | S_IRUGO, NULL); if (entry) { diff --git a/trunk/arch/h8300/kernel/ints.c b/trunk/arch/h8300/kernel/ints.c index 587ef7f4fcc7..1bfc77e391d5 100644 --- a/trunk/arch/h8300/kernel/ints.c +++ b/trunk/arch/h8300/kernel/ints.c @@ -141,7 +141,7 @@ int request_irq(unsigned int irq, return -EBUSY; if (use_kmalloc) - irq_handle = kmalloc(sizeof(irq_handler_t), GFP_ATOMIC); + irq_handle = (irq_handler_t *)kmalloc(sizeof(irq_handler_t), GFP_ATOMIC); else { /* use bootmem allocater */ irq_handle = (irq_handler_t *)alloc_bootmem(sizeof(irq_handler_t)); diff --git a/trunk/arch/h8300/platform/h8s/ints.c b/trunk/arch/h8300/platform/h8s/ints.c index 567f681ddfec..270440de4610 100644 --- a/trunk/arch/h8300/platform/h8s/ints.c +++ b/trunk/arch/h8300/platform/h8s/ints.c @@ -176,7 +176,7 @@ int request_irq(unsigned int irq, } if (use_kmalloc) - irq_handle = kmalloc(sizeof(irq_handler_t), GFP_ATOMIC); + irq_handle = (irq_handler_t *)kmalloc(sizeof(irq_handler_t), GFP_ATOMIC); else { /* use bootmem allocater */ irq_handle = (irq_handler_t *)alloc_bootmem(sizeof(irq_handler_t)); diff --git a/trunk/arch/i386/kernel/apm.c b/trunk/arch/i386/kernel/apm.c index b75cff25de4b..a97847da9ed5 100644 --- a/trunk/arch/i386/kernel/apm.c +++ b/trunk/arch/i386/kernel/apm.c @@ -1604,7 +1604,7 @@ static int do_open(struct inode * inode, struct file * filp) { struct apm_user * as; - as = kmalloc(sizeof(*as), GFP_KERNEL); + as = (struct apm_user *)kmalloc(sizeof(*as), GFP_KERNEL); if (as == NULL) { printk(KERN_ERR "apm: cannot allocate struct of size %d bytes\n", sizeof(*as)); diff --git a/trunk/arch/i386/kernel/microcode.c b/trunk/arch/i386/kernel/microcode.c index 47ffec57c0cb..972346604f9d 100644 --- a/trunk/arch/i386/kernel/microcode.c +++ b/trunk/arch/i386/kernel/microcode.c @@ -1,7 +1,7 @@ /* * Intel CPU Microcode Update Driver for Linux * - * Copyright (C) 2000-2006 Tigran Aivazian + * Copyright (C) 2000-2004 Tigran Aivazian * 2006 Shaohua Li * * This driver allows to upgrade microcode on Intel processors @@ -92,7 +92,7 @@ #include MODULE_DESCRIPTION("Intel CPU (IA-32) Microcode Update Driver"); -MODULE_AUTHOR("Tigran Aivazian "); +MODULE_AUTHOR("Tigran Aivazian "); MODULE_LICENSE("GPL"); #define MICROCODE_VERSION "1.14a" @@ -752,7 +752,7 @@ static int __init microcode_init (void) register_hotcpu_notifier(&mc_cpu_notifier); printk(KERN_INFO - "IA-32 Microcode Update Driver: v" MICROCODE_VERSION " \n"); + "IA-32 Microcode Update Driver: v" MICROCODE_VERSION " \n"); return 0; } diff --git a/trunk/arch/i386/kernel/smpboot.c b/trunk/arch/i386/kernel/smpboot.c index aef39be81361..b0f84e5778ad 100644 --- a/trunk/arch/i386/kernel/smpboot.c +++ b/trunk/arch/i386/kernel/smpboot.c @@ -69,7 +69,9 @@ static int __devinitdata smp_b_stepping; /* Number of siblings per CPU package */ int smp_num_siblings = 1; +#ifdef CONFIG_SMP EXPORT_SYMBOL(smp_num_siblings); +#endif /* Last level cache ID of each logical CPU */ int cpu_llc_id[NR_CPUS] __cpuinitdata = {[0 ... NR_CPUS-1] = BAD_APICID}; diff --git a/trunk/arch/ia64/sn/kernel/sn2/sn_hwperf.c b/trunk/arch/ia64/sn/kernel/sn2/sn_hwperf.c index 33367996d72d..462ea178f49a 100644 --- a/trunk/arch/ia64/sn/kernel/sn2/sn_hwperf.c +++ b/trunk/arch/ia64/sn/kernel/sn2/sn_hwperf.c @@ -189,7 +189,7 @@ static void print_pci_topology(struct seq_file *s) int e; for (sz = PAGE_SIZE; sz < 16 * PAGE_SIZE; sz += PAGE_SIZE) { - if (!(p = kmalloc(sz, GFP_KERNEL))) + if (!(p = (char *)kmalloc(sz, GFP_KERNEL))) break; e = ia64_sn_ioif_get_pci_topology(__pa(p), sz); if (e == SALRET_OK) diff --git a/trunk/arch/m68k/mm/kmap.c b/trunk/arch/m68k/mm/kmap.c index 46b7d6035aab..b54ef1726c55 100644 --- a/trunk/arch/m68k/mm/kmap.c +++ b/trunk/arch/m68k/mm/kmap.c @@ -59,7 +59,7 @@ static struct vm_struct *get_io_area(unsigned long size) unsigned long addr; struct vm_struct **p, *tmp, *area; - area = kmalloc(sizeof(*area), GFP_KERNEL); + area = (struct vm_struct *)kmalloc(sizeof(*area), GFP_KERNEL); if (!area) return NULL; addr = KMAP_START; diff --git a/trunk/arch/mips/kernel/apm.c b/trunk/arch/mips/kernel/apm.c index ba16d07588cb..528e731049c1 100644 --- a/trunk/arch/mips/kernel/apm.c +++ b/trunk/arch/mips/kernel/apm.c @@ -356,7 +356,7 @@ static int apm_open(struct inode * inode, struct file * filp) { struct apm_user *as; - as = kzalloc(sizeof(*as), GFP_KERNEL); + as = (struct apm_user *)kzalloc(sizeof(*as), GFP_KERNEL); if (as) { /* * XXX - this is a tiny bit broken, when we consider BSD diff --git a/trunk/arch/parisc/hpux/sys_hpux.c b/trunk/arch/parisc/hpux/sys_hpux.c index 04c2ff444396..d88309209f56 100644 --- a/trunk/arch/parisc/hpux/sys_hpux.c +++ b/trunk/arch/parisc/hpux/sys_hpux.c @@ -475,7 +475,7 @@ int hpux_sysfs(int opcode, unsigned long arg1, unsigned long arg2) printk(KERN_DEBUG "len of arg1 = %d\n", len); if (len == 0) return 0; - fsname = kmalloc(len, GFP_KERNEL); + fsname = (char *) kmalloc(len, GFP_KERNEL); if ( !fsname ) { printk(KERN_DEBUG "failed to kmalloc fsname\n"); return 0; diff --git a/trunk/arch/parisc/kernel/unwind.c b/trunk/arch/parisc/kernel/unwind.c index c10ab47d81fa..920bdbf8404f 100644 --- a/trunk/arch/parisc/kernel/unwind.c +++ b/trunk/arch/parisc/kernel/unwind.c @@ -343,7 +343,7 @@ void unwind_frame_init_from_blocked_task(struct unwind_frame_info *info, struct struct pt_regs *r = &t->thread.regs; struct pt_regs *r2; - r2 = kmalloc(sizeof(struct pt_regs), GFP_KERNEL); + r2 = (struct pt_regs *)kmalloc(sizeof(struct pt_regs), GFP_KERNEL); if (!r2) return; *r2 = *r; diff --git a/trunk/arch/powerpc/kernel/nvram_64.c b/trunk/arch/powerpc/kernel/nvram_64.c index 869cebbba967..6960f090991e 100644 --- a/trunk/arch/powerpc/kernel/nvram_64.c +++ b/trunk/arch/powerpc/kernel/nvram_64.c @@ -505,7 +505,7 @@ static int nvram_scan_partitions(void) return -ENODEV; total_size = ppc_md.nvram_size(); - header = kmalloc(NVRAM_HEADER_LEN, GFP_KERNEL); + header = (char *) kmalloc(NVRAM_HEADER_LEN, GFP_KERNEL); if (!header) { printk(KERN_ERR "nvram_scan_partitions: Failed kmalloc\n"); return -ENOMEM; @@ -574,7 +574,7 @@ static int __init nvram_init(void) } /* initialize our anchor for the nvram partition list */ - nvram_part = kmalloc(sizeof(struct nvram_partition), GFP_KERNEL); + nvram_part = (struct nvram_partition *) kmalloc(sizeof(struct nvram_partition), GFP_KERNEL); if (!nvram_part) { printk(KERN_ERR "nvram_init: Failed kmalloc\n"); return -ENOMEM; diff --git a/trunk/arch/powerpc/kernel/pci_32.c b/trunk/arch/powerpc/kernel/pci_32.c index 2847cd51a2d7..8336deafc624 100644 --- a/trunk/arch/powerpc/kernel/pci_32.c +++ b/trunk/arch/powerpc/kernel/pci_32.c @@ -670,7 +670,7 @@ pcibios_make_OF_bus_map(void) struct pci_controller* hose; struct property *map_prop; - pci_to_OF_bus_map = kmalloc(pci_bus_count, GFP_KERNEL); + pci_to_OF_bus_map = (u8*)kmalloc(pci_bus_count, GFP_KERNEL); if (!pci_to_OF_bus_map) { printk(KERN_ERR "Can't allocate OF bus map !\n"); return; diff --git a/trunk/arch/powerpc/mm/imalloc.c b/trunk/arch/powerpc/mm/imalloc.c index c831815c31f0..add8c1a9af68 100644 --- a/trunk/arch/powerpc/mm/imalloc.c +++ b/trunk/arch/powerpc/mm/imalloc.c @@ -138,7 +138,7 @@ static struct vm_struct * split_im_region(unsigned long v_addr, struct vm_struct *vm2 = NULL; struct vm_struct *new_vm = NULL; - vm1 = kmalloc(sizeof(*vm1), GFP_KERNEL); + vm1 = (struct vm_struct *) kmalloc(sizeof(*vm1), GFP_KERNEL); if (vm1 == NULL) { printk(KERN_ERR "%s() out of memory\n", __FUNCTION__); return NULL; @@ -172,7 +172,7 @@ static struct vm_struct * split_im_region(unsigned long v_addr, * uppermost remainder, and use existing parent one for the * lower remainder of parent range */ - vm2 = kmalloc(sizeof(*vm2), GFP_KERNEL); + vm2 = (struct vm_struct *) kmalloc(sizeof(*vm2), GFP_KERNEL); if (vm2 == NULL) { printk(KERN_ERR "%s() out of memory\n", __FUNCTION__); kfree(vm1); @@ -206,7 +206,7 @@ static struct vm_struct * __add_new_im_area(unsigned long req_addr, break; } - area = kmalloc(sizeof(*area), GFP_KERNEL); + area = (struct vm_struct *) kmalloc(sizeof(*area), GFP_KERNEL); if (!area) return NULL; area->flags = 0; diff --git a/trunk/arch/powerpc/platforms/pseries/eeh_cache.c b/trunk/arch/powerpc/platforms/pseries/eeh_cache.c index f2bae04424f8..b6b462d3c604 100644 --- a/trunk/arch/powerpc/platforms/pseries/eeh_cache.c +++ b/trunk/arch/powerpc/platforms/pseries/eeh_cache.c @@ -153,7 +153,7 @@ pci_addr_cache_insert(struct pci_dev *dev, unsigned long alo, return piar; } } - piar = kmalloc(sizeof(struct pci_io_addr_range), GFP_ATOMIC); + piar = (struct pci_io_addr_range *)kmalloc(sizeof(struct pci_io_addr_range), GFP_ATOMIC); if (!piar) return NULL; diff --git a/trunk/arch/ppc/8260_io/fcc_enet.c b/trunk/arch/ppc/8260_io/fcc_enet.c index 06b84c372e58..709952c25f29 100644 --- a/trunk/arch/ppc/8260_io/fcc_enet.c +++ b/trunk/arch/ppc/8260_io/fcc_enet.c @@ -1892,10 +1892,10 @@ init_fcc_param(fcc_info_t *fip, struct net_device *dev, /* Allocate space for the buffer descriptors from regular memory. * Initialize base addresses for the buffer descriptors. */ - cep->rx_bd_base = kmalloc(sizeof(cbd_t) * RX_RING_SIZE, + cep->rx_bd_base = (cbd_t *)kmalloc(sizeof(cbd_t) * RX_RING_SIZE, GFP_KERNEL | GFP_DMA); ep->fen_genfcc.fcc_rbase = __pa(cep->rx_bd_base); - cep->tx_bd_base = kmalloc(sizeof(cbd_t) * TX_RING_SIZE, + cep->tx_bd_base = (cbd_t *)kmalloc(sizeof(cbd_t) * TX_RING_SIZE, GFP_KERNEL | GFP_DMA); ep->fen_genfcc.fcc_tbase = __pa(cep->tx_bd_base); diff --git a/trunk/arch/ppc/8xx_io/cs4218_tdm.c b/trunk/arch/ppc/8xx_io/cs4218_tdm.c index b7bb5f0b3c5f..c71ef3c2e7bf 100644 --- a/trunk/arch/ppc/8xx_io/cs4218_tdm.c +++ b/trunk/arch/ppc/8xx_io/cs4218_tdm.c @@ -2601,7 +2601,7 @@ int __init tdm8xx_sound_init(void) /* Initialize beep stuff */ orig_mksound = kd_mksound; kd_mksound = cs_mksound; - beep_buf = kmalloc(BEEP_BUFLEN * 4, GFP_KERNEL); + beep_buf = (short *) kmalloc(BEEP_BUFLEN * 4, GFP_KERNEL); if (beep_buf == NULL) printk(KERN_WARNING "dmasound: no memory for " "beep buffer\n"); diff --git a/trunk/arch/s390/Kconfig b/trunk/arch/s390/Kconfig index 12272361c018..ff690564edbd 100644 --- a/trunk/arch/s390/Kconfig +++ b/trunk/arch/s390/Kconfig @@ -407,7 +407,7 @@ config APPLDATA_BASE config APPLDATA_MEM tristate "Monitor memory management statistics" - depends on APPLDATA_BASE && VM_EVENT_COUNTERS + depends on APPLDATA_BASE help This provides memory management related data to the Linux - VM Monitor Stream, like paging/swapping rate, memory utilisation, etc. diff --git a/trunk/arch/s390/kernel/debug.c b/trunk/arch/s390/kernel/debug.c index bb57bc0e3fc8..ef5266fbce62 100644 --- a/trunk/arch/s390/kernel/debug.c +++ b/trunk/arch/s390/kernel/debug.c @@ -191,13 +191,13 @@ debug_areas_alloc(int pages_per_area, int nr_areas) debug_entry_t*** areas; int i,j; - areas = kmalloc(nr_areas * + areas = (debug_entry_t ***) kmalloc(nr_areas * sizeof(debug_entry_t**), GFP_KERNEL); if (!areas) goto fail_malloc_areas; for (i = 0; i < nr_areas; i++) { - areas[i] = kmalloc(pages_per_area * + areas[i] = (debug_entry_t**) kmalloc(pages_per_area * sizeof(debug_entry_t*),GFP_KERNEL); if (!areas[i]) { goto fail_malloc_areas2; @@ -242,7 +242,7 @@ debug_info_alloc(char *name, int pages_per_area, int nr_areas, int buf_size, /* alloc everything */ - rc = kmalloc(sizeof(debug_info_t), GFP_KERNEL); + rc = (debug_info_t*) kmalloc(sizeof(debug_info_t), GFP_KERNEL); if(!rc) goto fail_malloc_rc; rc->active_entries = kcalloc(nr_areas, sizeof(int), GFP_KERNEL); @@ -634,7 +634,7 @@ debug_open(struct inode *inode, struct file *file) rc = -ENOMEM; goto out; } - p_info = kmalloc(sizeof(file_private_info_t), + p_info = (file_private_info_t *) kmalloc(sizeof(file_private_info_t), GFP_KERNEL); if(!p_info){ if(debug_info_snapshot) diff --git a/trunk/arch/s390/kernel/s390_ext.c b/trunk/arch/s390/kernel/s390_ext.c index bc5beaa8f98e..4faf96f8a834 100644 --- a/trunk/arch/s390/kernel/s390_ext.c +++ b/trunk/arch/s390/kernel/s390_ext.c @@ -37,7 +37,7 @@ int register_external_interrupt(__u16 code, ext_int_handler_t handler) ext_int_info_t *p; int index; - p = kmalloc(sizeof(ext_int_info_t), GFP_ATOMIC); + p = (ext_int_info_t *) kmalloc(sizeof(ext_int_info_t), GFP_ATOMIC); if (p == NULL) return -ENOMEM; p->code = code; diff --git a/trunk/arch/sparc/kernel/irq.c b/trunk/arch/sparc/kernel/irq.c index 5b4841d067c1..c8cb211b9072 100644 --- a/trunk/arch/sparc/kernel/irq.c +++ b/trunk/arch/sparc/kernel/irq.c @@ -425,7 +425,7 @@ int request_fast_irq(unsigned int irq, } if (action == NULL) - action = kmalloc(sizeof(struct irqaction), + action = (struct irqaction *)kmalloc(sizeof(struct irqaction), GFP_ATOMIC); if (!action) { @@ -528,7 +528,7 @@ int request_irq(unsigned int irq, } if (action == NULL) - action = kmalloc(sizeof(struct irqaction), + action = (struct irqaction *)kmalloc(sizeof(struct irqaction), GFP_ATOMIC); if (!action) { diff --git a/trunk/arch/sparc/kernel/sun4d_irq.c b/trunk/arch/sparc/kernel/sun4d_irq.c index 0e27e226e0e2..cf1b8baa57ea 100644 --- a/trunk/arch/sparc/kernel/sun4d_irq.c +++ b/trunk/arch/sparc/kernel/sun4d_irq.c @@ -327,7 +327,7 @@ int sun4d_request_irq(unsigned int irq, } if (action == NULL) - action = kmalloc(sizeof(struct irqaction), + action = (struct irqaction *)kmalloc(sizeof(struct irqaction), GFP_ATOMIC); if (!action) { diff --git a/trunk/arch/sparc64/kernel/sys_sunos32.c b/trunk/arch/sparc64/kernel/sys_sunos32.c index 2ebc2c051383..4446f66590fa 100644 --- a/trunk/arch/sparc64/kernel/sys_sunos32.c +++ b/trunk/arch/sparc64/kernel/sys_sunos32.c @@ -1055,7 +1055,7 @@ asmlinkage int sunos_msgsys(int op, u32 arg1, u32 arg2, u32 arg3, u32 arg4) break; case 2: rval = -EFAULT; - kmbuf = kmalloc(sizeof(struct msgbuf) + arg3, + kmbuf = (struct msgbuf *)kmalloc(sizeof(struct msgbuf) + arg3, GFP_KERNEL); if (!kmbuf) break; @@ -1078,7 +1078,7 @@ asmlinkage int sunos_msgsys(int op, u32 arg1, u32 arg2, u32 arg3, u32 arg4) break; case 3: rval = -EFAULT; - kmbuf = kmalloc(sizeof(struct msgbuf) + arg3, + kmbuf = (struct msgbuf *)kmalloc(sizeof(struct msgbuf) + arg3, GFP_KERNEL); if (!kmbuf || sunos_msgbuf_get((struct msgbuf32 __user *)(unsigned long)arg2, kmbuf, arg3)) diff --git a/trunk/arch/um/drivers/net_kern.c b/trunk/arch/um/drivers/net_kern.c index afe3d427ddfa..b2e9762e13c5 100644 --- a/trunk/arch/um/drivers/net_kern.c +++ b/trunk/arch/um/drivers/net_kern.c @@ -72,11 +72,9 @@ static int uml_net_rx(struct net_device *dev) return pkt_len; } -static void uml_dev_close(struct work_struct *work) +static void uml_dev_close(void* dev) { - struct uml_net_private *lp = - container_of(work, struct uml_net_private, work); - dev_close(lp->dev); + dev_close( (struct net_device *) dev); } irqreturn_t uml_net_interrupt(int irq, void *dev_id) @@ -91,6 +89,7 @@ irqreturn_t uml_net_interrupt(int irq, void *dev_id) spin_lock(&lp->lock); while((err = uml_net_rx(dev)) > 0) ; if(err < 0) { + DECLARE_WORK(close_work, uml_dev_close, dev); printk(KERN_ERR "Device '%s' read returned %d, shutting it down\n", dev->name, err); @@ -98,10 +97,9 @@ irqreturn_t uml_net_interrupt(int irq, void *dev_id) * again lp->lock. * And dev_close() can be safely called multiple times on the * same device, since it tests for (dev->flags & IFF_UP). So - * there's no harm in delaying the device shutdown. - * Furthermore, the workqueue will not re-enqueue an already - * enqueued work item. */ - schedule_work(&lp->work); + * there's no harm in delaying the device shutdown. */ + schedule_work(&close_work); +#error this is not permitted - close_work will go out of scope goto out; } reactivate_fd(lp->fd, UM_ETH_IRQ); @@ -367,7 +365,6 @@ static int eth_configure(int n, void *init, char *mac, /* This points to the transport private data. It's still clear, but we * must memset it to 0 *now*. Let's help the drivers. */ memset(lp, 0, size); - INIT_WORK(&lp->work, uml_dev_close); /* sysfs register */ if (!driver_registered) { diff --git a/trunk/arch/um/include/net_kern.h b/trunk/arch/um/include/net_kern.h index 218f8b47fdcd..280459fb0b26 100644 --- a/trunk/arch/um/include/net_kern.h +++ b/trunk/arch/um/include/net_kern.h @@ -11,7 +11,6 @@ #include #include #include -#include struct uml_net { struct list_head list; @@ -27,7 +26,6 @@ struct uml_net_private { struct net_device *dev; struct timer_list tl; struct net_device_stats stats; - struct work_struct work; int fd; unsigned char mac[ETH_ALEN]; unsigned short (*protocol)(struct sk_buff *); diff --git a/trunk/arch/um/sys-i386/ldt.c b/trunk/arch/um/sys-i386/ldt.c index 5db7737df0ff..49057d8bc668 100644 --- a/trunk/arch/um/sys-i386/ldt.c +++ b/trunk/arch/um/sys-i386/ldt.c @@ -166,7 +166,7 @@ static long read_ldt_from_host(void __user * ptr, unsigned long bytecount) struct ptrace_ldt ptrace_ldt = (struct ptrace_ldt) { .func = 0, .bytecount = bytecount, - .ptr = kmalloc(bytecount, GFP_KERNEL)}; + .ptr = (void *)kmalloc(bytecount, GFP_KERNEL)}; u32 cpu; if(ptrace_ldt.ptr == NULL) @@ -426,7 +426,7 @@ void ldt_get_host_info(void) host_ldt_entries = dummy_list; else { size = (size + 1) * sizeof(dummy_list[0]); - host_ldt_entries = kmalloc(size, GFP_KERNEL); + host_ldt_entries = (short *)kmalloc(size, GFP_KERNEL); if(host_ldt_entries == NULL) { printk("ldt_get_host_info: couldn't allocate host ldt list\n"); goto out_free; diff --git a/trunk/arch/xtensa/kernel/Makefile b/trunk/arch/xtensa/kernel/Makefile index 71f733c4f66d..d573017a5dde 100644 --- a/trunk/arch/xtensa/kernel/Makefile +++ b/trunk/arch/xtensa/kernel/Makefile @@ -6,7 +6,7 @@ extra-y := head.o vmlinux.lds obj-y := align.o entry.o irq.o coprocessor.o process.o ptrace.o semaphore.o \ - setup.o signal.o syscall.o time.o traps.o vectors.o platform.o \ + setup.o signal.o syscalls.o time.o traps.o vectors.o platform.o \ pci-dma.o ## windowspill.o diff --git a/trunk/arch/xtensa/kernel/syscall.c b/trunk/arch/xtensa/kernel/syscall.c index fe3834bc1dbf..418268f49766 100644 --- a/trunk/arch/xtensa/kernel/syscall.c +++ b/trunk/arch/xtensa/kernel/syscall.c @@ -16,7 +16,7 @@ * */ #include -#include +#include #include #include #include diff --git a/trunk/block/cfq-iosched.c b/trunk/block/cfq-iosched.c index 78c6b312bd30..533a2938ffd6 100644 --- a/trunk/block/cfq-iosched.c +++ b/trunk/block/cfq-iosched.c @@ -219,9 +219,12 @@ static int cfq_queue_empty(request_queue_t *q) return !cfqd->busy_queues; } -static inline pid_t cfq_queue_pid(struct task_struct *task, int rw) +static inline pid_t cfq_queue_pid(struct task_struct *task, int rw, int is_sync) { - if (rw == READ || rw == WRITE_SYNC) + /* + * Use the per-process queue, for read requests and syncronous writes + */ + if (!(rw & REQ_RW) || is_sync) return task->pid; return CFQ_KEY_ASYNC; @@ -473,7 +476,7 @@ static struct request * cfq_find_rq_fmerge(struct cfq_data *cfqd, struct bio *bio) { struct task_struct *tsk = current; - pid_t key = cfq_queue_pid(tsk, bio_data_dir(bio)); + pid_t key = cfq_queue_pid(tsk, bio_data_dir(bio), bio_sync(bio)); struct cfq_queue *cfqq; cfqq = cfq_find_cfq_hash(cfqd, key, tsk->ioprio); @@ -1748,6 +1751,9 @@ static int cfq_may_queue(request_queue_t *q, int rw) struct cfq_data *cfqd = q->elevator->elevator_data; struct task_struct *tsk = current; struct cfq_queue *cfqq; + unsigned int key; + + key = cfq_queue_pid(tsk, rw, rw & REQ_RW_SYNC); /* * 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) * so just lookup a possibly existing queue, or return 'may queue' * if that fails */ - cfqq = cfq_find_cfq_hash(cfqd, cfq_queue_pid(tsk, rw), tsk->ioprio); + cfqq = cfq_find_cfq_hash(cfqd, key, tsk->ioprio); if (cfqq) { cfq_init_prio_data(cfqq); cfq_prio_boost(cfqq); @@ -1798,10 +1804,10 @@ cfq_set_request(request_queue_t *q, struct request *rq, gfp_t gfp_mask) struct task_struct *tsk = current; struct cfq_io_context *cic; const int rw = rq_data_dir(rq); - pid_t key = cfq_queue_pid(tsk, rw); + const int is_sync = rq_is_sync(rq); + pid_t key = cfq_queue_pid(tsk, rw, is_sync); struct cfq_queue *cfqq; unsigned long flags; - int is_sync = key != CFQ_KEY_ASYNC; might_sleep_if(gfp_mask & __GFP_WAIT); diff --git a/trunk/block/ll_rw_blk.c b/trunk/block/ll_rw_blk.c index a541b42c08e3..79807dbc306e 100644 --- a/trunk/block/ll_rw_blk.c +++ b/trunk/block/ll_rw_blk.c @@ -2058,15 +2058,16 @@ static void freed_request(request_queue_t *q, int rw, int priv) * Returns NULL on failure, with queue_lock held. * Returns !NULL on success, with queue_lock *not held*. */ -static struct request *get_request(request_queue_t *q, int rw, struct bio *bio, - gfp_t gfp_mask) +static struct request *get_request(request_queue_t *q, int rw_flags, + struct bio *bio, gfp_t gfp_mask) { struct request *rq = NULL; struct request_list *rl = &q->rq; struct io_context *ioc = NULL; + const int rw = rw_flags & 0x01; int may_queue, priv; - may_queue = elv_may_queue(q, rw); + may_queue = elv_may_queue(q, rw_flags); if (may_queue == ELV_MQUEUE_NO) goto rq_starved; @@ -2114,7 +2115,7 @@ static struct request *get_request(request_queue_t *q, int rw, struct bio *bio, spin_unlock_irq(q->queue_lock); - rq = blk_alloc_request(q, rw, priv, gfp_mask); + rq = blk_alloc_request(q, rw_flags, priv, gfp_mask); if (unlikely(!rq)) { /* * Allocation failed presumably due to memory. Undo anything @@ -2162,12 +2163,13 @@ static struct request *get_request(request_queue_t *q, int rw, struct bio *bio, * * Called with q->queue_lock held, and returns with it unlocked. */ -static struct request *get_request_wait(request_queue_t *q, int rw, +static struct request *get_request_wait(request_queue_t *q, int rw_flags, struct bio *bio) { + const int rw = rw_flags & 0x01; struct request *rq; - rq = get_request(q, rw, bio, GFP_NOIO); + rq = get_request(q, rw_flags, bio, GFP_NOIO); while (!rq) { DEFINE_WAIT(wait); struct request_list *rl = &q->rq; @@ -2175,7 +2177,7 @@ static struct request *get_request_wait(request_queue_t *q, int rw, prepare_to_wait_exclusive(&rl->wait[rw], &wait, TASK_UNINTERRUPTIBLE); - rq = get_request(q, rw, bio, GFP_NOIO); + rq = get_request(q, rw_flags, bio, GFP_NOIO); if (!rq) { struct io_context *ioc; @@ -2910,6 +2912,7 @@ static int __make_request(request_queue_t *q, struct bio *bio) int el_ret, nr_sectors, barrier, err; const unsigned short prio = bio_prio(bio); const int sync = bio_sync(bio); + int rw_flags; nr_sectors = bio_sectors(bio); @@ -2983,11 +2986,20 @@ static int __make_request(request_queue_t *q, struct bio *bio) } get_rq: + /* + * This sync check and mask will be re-done in init_request_from_bio(), + * but we need to set it earlier to expose the sync flag to the + * rq allocator and io schedulers. + */ + rw_flags = bio_data_dir(bio); + if (sync) + rw_flags |= REQ_RW_SYNC; + /* * Grab a free request. This is might sleep but can not fail. * Returns with the queue unlocked. */ - req = get_request_wait(q, bio_data_dir(bio), bio); + req = get_request_wait(q, rw_flags, bio); /* * After dropping the lock and possibly sleeping here, our request diff --git a/trunk/crypto/blkcipher.c b/trunk/crypto/blkcipher.c index 6e93004f2181..034c939bf91a 100644 --- a/trunk/crypto/blkcipher.c +++ b/trunk/crypto/blkcipher.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include diff --git a/trunk/drivers/acorn/block/fd1772.c b/trunk/drivers/acorn/block/fd1772.c index 674bf81c6e66..048542341204 100644 --- a/trunk/drivers/acorn/block/fd1772.c +++ b/trunk/drivers/acorn/block/fd1772.c @@ -1549,12 +1549,12 @@ int fd1772_init(void) #ifdef TRACKBUFFER BufferDrive = BufferSide = BufferTrack = -1; /* Atari uses 512 - I want to eventually cope with 1K sectors */ - DMABuffer = kmalloc((FD1772_MAX_SECTORS+1)*512,GFP_KERNEL); + DMABuffer = (char *)kmalloc((FD1772_MAX_SECTORS+1)*512,GFP_KERNEL); TrackBuffer = DMABuffer + 512; #else /* Allocate memory for the DMAbuffer - on the Atari this takes it out of some special memory... */ - DMABuffer = kmalloc(2048); /* Copes with pretty large sectors */ + DMABuffer = (char *) kmalloc(2048); /* Copes with pretty large sectors */ #endif err = -ENOMEM; if (!DMAbuffer) diff --git a/trunk/drivers/ata/pdc_adma.c b/trunk/drivers/ata/pdc_adma.c index 90786d7a20bb..9021e34d2096 100644 --- a/trunk/drivers/ata/pdc_adma.c +++ b/trunk/drivers/ata/pdc_adma.c @@ -551,7 +551,7 @@ static int adma_port_start(struct ata_port *ap) return rc; adma_enter_reg_mode(ap); rc = -ENOMEM; - pp = kzalloc(sizeof(*pp), GFP_KERNEL); + pp = kcalloc(1, sizeof(*pp), GFP_KERNEL); if (!pp) goto err_out; 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, if (rc) goto err_out_iounmap; - probe_ent = kzalloc(sizeof(*probe_ent), GFP_KERNEL); + probe_ent = kcalloc(1, sizeof(*probe_ent), GFP_KERNEL); if (probe_ent == NULL) { rc = -ENOMEM; goto err_out_iounmap; diff --git a/trunk/drivers/atm/eni.c b/trunk/drivers/atm/eni.c index 5aab7bd473ac..bc1b13c8f5d7 100644 --- a/trunk/drivers/atm/eni.c +++ b/trunk/drivers/atm/eni.c @@ -1832,7 +1832,7 @@ static int __devinit eni_start(struct atm_dev *dev) /* initialize memory management */ buffer_mem = eni_dev->mem - (buf - eni_dev->ram); eni_dev->free_list_size = buffer_mem/MID_MIN_BUF_SIZE/2; - eni_dev->free_list = kmalloc( + eni_dev->free_list = (struct eni_free *) kmalloc( sizeof(struct eni_free)*(eni_dev->free_list_size+1),GFP_KERNEL); if (!eni_dev->free_list) { 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, goto out0; } - eni_dev = kmalloc(sizeof(struct eni_dev),GFP_KERNEL); + eni_dev = (struct eni_dev *) kmalloc(sizeof(struct eni_dev),GFP_KERNEL); if (!eni_dev) goto out0; if (!cpu_zeroes) { cpu_zeroes = pci_alloc_consistent(pci_dev,ENI_ZEROES_SIZE, diff --git a/trunk/drivers/atm/he.c b/trunk/drivers/atm/he.c index db33f6f4dd2a..7d9b4e52f0bf 100644 --- a/trunk/drivers/atm/he.c +++ b/trunk/drivers/atm/he.c @@ -2351,7 +2351,7 @@ he_open(struct atm_vcc *vcc) cid = he_mkcid(he_dev, vpi, vci); - he_vcc = kmalloc(sizeof(struct he_vcc), GFP_ATOMIC); + he_vcc = (struct he_vcc *) kmalloc(sizeof(struct he_vcc), GFP_ATOMIC); if (he_vcc == NULL) { hprintk("unable to allocate he_vcc during open\n"); return -ENOMEM; diff --git a/trunk/drivers/atm/lanai.c b/trunk/drivers/atm/lanai.c index 09f477d4237a..267825501dfe 100644 --- a/trunk/drivers/atm/lanai.c +++ b/trunk/drivers/atm/lanai.c @@ -2602,7 +2602,7 @@ static int __devinit lanai_init_one(struct pci_dev *pci, struct atm_dev *atmdev; int result; - lanai = kmalloc(sizeof(*lanai), GFP_KERNEL); + lanai = (struct lanai_dev *) kmalloc(sizeof(*lanai), GFP_KERNEL); if (lanai == NULL) { printk(KERN_ERR DEV_LABEL ": couldn't allocate dev_data structure!\n"); diff --git a/trunk/drivers/atm/nicstar.c b/trunk/drivers/atm/nicstar.c index aab9b3733d52..bd0904594805 100644 --- a/trunk/drivers/atm/nicstar.c +++ b/trunk/drivers/atm/nicstar.c @@ -997,7 +997,7 @@ static scq_info *get_scq(int size, u32 scd) if (size != VBR_SCQSIZE && size != CBR_SCQSIZE) return NULL; - scq = kmalloc(sizeof(scq_info), GFP_KERNEL); + scq = (scq_info *) kmalloc(sizeof(scq_info), GFP_KERNEL); if (scq == NULL) return NULL; scq->org = kmalloc(2 * size, GFP_KERNEL); @@ -1006,7 +1006,7 @@ static scq_info *get_scq(int size, u32 scd) kfree(scq); return NULL; } - scq->skb = kmalloc(sizeof(struct sk_buff *) * + scq->skb = (struct sk_buff **) kmalloc(sizeof(struct sk_buff *) * (size / NS_SCQE_SIZE), GFP_KERNEL); if (scq->skb == NULL) { diff --git a/trunk/drivers/atm/zatm.c b/trunk/drivers/atm/zatm.c index 756d4f760da3..7df0f373188e 100644 --- a/trunk/drivers/atm/zatm.c +++ b/trunk/drivers/atm/zatm.c @@ -996,7 +996,7 @@ static int start_tx(struct atm_dev *dev) DPRINTK("start_tx\n"); zatm_dev = ZATM_DEV(dev); - zatm_dev->tx_map = kmalloc(sizeof(struct atm_vcc *)* + zatm_dev->tx_map = (struct atm_vcc **) kmalloc(sizeof(struct atm_vcc *)* zatm_dev->chans,GFP_KERNEL); if (!zatm_dev->tx_map) return -ENOMEM; zatm_dev->tx_bw = ATM_OC3_PCR; @@ -1591,7 +1591,7 @@ static int __devinit zatm_init_one(struct pci_dev *pci_dev, struct zatm_dev *zatm_dev; int ret = -ENOMEM; - zatm_dev = kmalloc(sizeof(*zatm_dev), GFP_KERNEL); + zatm_dev = (struct zatm_dev *) kmalloc(sizeof(*zatm_dev), GFP_KERNEL); if (!zatm_dev) { printk(KERN_EMERG "%s: memory shortage\n", DEV_LABEL); goto out; diff --git a/trunk/drivers/base/dmapool.c b/trunk/drivers/base/dmapool.c index f95d50277274..dbe0735f8c9e 100644 --- a/trunk/drivers/base/dmapool.c +++ b/trunk/drivers/base/dmapool.c @@ -173,7 +173,7 @@ pool_alloc_page (struct dma_pool *pool, gfp_t mem_flags) mapsize = (mapsize + BITS_PER_LONG - 1) / BITS_PER_LONG; mapsize *= sizeof (long); - page = kmalloc(mapsize + sizeof *page, mem_flags); + page = (struct dma_page *) kmalloc (mapsize + sizeof *page, mem_flags); if (!page) return NULL; page->vaddr = dma_alloc_coherent (pool->dev, diff --git a/trunk/drivers/block/Kconfig b/trunk/drivers/block/Kconfig index 58c1debf86f1..ce9cfcb6071c 100644 --- a/trunk/drivers/block/Kconfig +++ b/trunk/drivers/block/Kconfig @@ -28,6 +28,13 @@ config ATARI_FLOPPY tristate "Atari floppy support" depends on ATARI +config BLK_DEV_SWIM_IOP + bool "Macintosh IIfx/Quadra 900/Quadra 950 floppy support (EXPERIMENTAL)" + depends on MAC && EXPERIMENTAL && BROKEN + help + Say Y here to support the SWIM (Super Woz Integrated Machine) IOP + floppy controller on the Macintosh IIfx and Quadra 900/950. + config MAC_FLOPPY tristate "Support for PowerMac floppy" depends on PPC_PMAC && !PPC_PMAC64 diff --git a/trunk/drivers/block/Makefile b/trunk/drivers/block/Makefile index dd88e33c1eb1..410f259a8031 100644 --- a/trunk/drivers/block/Makefile +++ b/trunk/drivers/block/Makefile @@ -9,6 +9,7 @@ obj-$(CONFIG_MAC_FLOPPY) += swim3.o obj-$(CONFIG_BLK_DEV_FD) += floppy.o obj-$(CONFIG_AMIGA_FLOPPY) += amiflop.o obj-$(CONFIG_ATARI_FLOPPY) += ataflop.o +obj-$(CONFIG_BLK_DEV_SWIM_IOP) += swim_iop.o obj-$(CONFIG_ATARI_ACSI) += acsi.o obj-$(CONFIG_ATARI_SLM) += acsi_slm.o obj-$(CONFIG_AMIGA_Z2RAM) += z2ram.o diff --git a/trunk/drivers/block/cciss.c b/trunk/drivers/block/cciss.c index acb2fa9cf6b1..ee159edb6b88 100644 --- a/trunk/drivers/block/cciss.c +++ b/trunk/drivers/block/cciss.c @@ -1039,7 +1039,7 @@ static int cciss_ioctl(struct inode *inode, struct file *filep, status = -ENOMEM; goto cleanup1; } - buff_size = kmalloc(MAXSGENTRIES * sizeof(int), + buff_size = (int *)kmalloc(MAXSGENTRIES * sizeof(int), GFP_KERNEL); if (!buff_size) { status = -ENOMEM; @@ -2837,7 +2837,7 @@ static int cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev) if (err) { printk(KERN_ERR "cciss: Cannot obtain PCI resources, " "aborting\n"); - return err; + goto err_out_disable_pdev; } subsystem_vendor_id = pdev->subsystem_vendor; @@ -2865,7 +2865,7 @@ static int cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev) #ifdef CCISS_DEBUG printk("address 0 = %x\n", c->paddr); #endif /* CCISS_DEBUG */ - c->vaddr = remap_pci_mem(c->paddr, 0x250); + c->vaddr = remap_pci_mem(c->paddr, 200); /* Wait for the board to become ready. (PCI hotplug needs this.) * We poll for up to 120 secs, once per 100ms. */ @@ -3005,11 +3005,10 @@ static int cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev) return 0; err_out_free_res: - /* - * Deliberately omit pci_disable_device(): it does something nasty to - * Smart Array controllers that pci_enable_device does not undo - */ pci_release_regions(pdev); + + err_out_disable_pdev: + pci_disable_device(pdev); return err; } @@ -3383,11 +3382,8 @@ static int __devinit cciss_init_one(struct pci_dev *pdev, if (drv->queue) blk_cleanup_queue(drv->queue); } - /* - * Deliberately omit pci_disable_device(): it does something nasty to - * Smart Array controllers that pci_enable_device does not undo - */ pci_release_regions(pdev); + pci_disable_device(pdev); pci_set_drvdata(pdev, NULL); free_hba(i); return -1; @@ -3456,11 +3452,8 @@ static void __devexit cciss_remove_one(struct pci_dev *pdev) #ifdef CONFIG_CISS_SCSI_TAPE kfree(hba[i]->scsi_rejects.complete); #endif - /* - * Deliberately omit pci_disable_device(): it does something nasty to - * Smart Array controllers that pci_enable_device does not undo - */ pci_release_regions(pdev); + pci_disable_device(pdev); pci_set_drvdata(pdev, NULL); free_hba(i); } diff --git a/trunk/drivers/block/cpqarray.c b/trunk/drivers/block/cpqarray.c index b94cd1c32131..d5f519ebbc08 100644 --- a/trunk/drivers/block/cpqarray.c +++ b/trunk/drivers/block/cpqarray.c @@ -1625,7 +1625,7 @@ static void start_fwbk(int ctlr) " processing\n"); /* Command does not return anything, but idasend command needs a buffer */ - id_ctlr_buf = kmalloc(sizeof(id_ctlr_t), GFP_KERNEL); + id_ctlr_buf = (id_ctlr_t *)kmalloc(sizeof(id_ctlr_t), GFP_KERNEL); if(id_ctlr_buf==NULL) { printk(KERN_WARNING "cpqarray: Out of memory. " @@ -1660,14 +1660,14 @@ static void getgeometry(int ctlr) info_p->log_drv_map = 0; - id_ldrive = kmalloc(sizeof(id_log_drv_t), GFP_KERNEL); + id_ldrive = (id_log_drv_t *)kmalloc(sizeof(id_log_drv_t), GFP_KERNEL); if(id_ldrive == NULL) { printk( KERN_ERR "cpqarray: out of memory.\n"); return; } - id_ctlr_buf = kmalloc(sizeof(id_ctlr_t), GFP_KERNEL); + id_ctlr_buf = (id_ctlr_t *)kmalloc(sizeof(id_ctlr_t), GFP_KERNEL); if(id_ctlr_buf == NULL) { kfree(id_ldrive); @@ -1675,7 +1675,7 @@ static void getgeometry(int ctlr) return; } - id_lstatus_buf = kmalloc(sizeof(sense_log_drv_stat_t), GFP_KERNEL); + id_lstatus_buf = (sense_log_drv_stat_t *)kmalloc(sizeof(sense_log_drv_stat_t), GFP_KERNEL); if(id_lstatus_buf == NULL) { kfree(id_ctlr_buf); @@ -1684,7 +1684,7 @@ static void getgeometry(int ctlr) return; } - sense_config_buf = kmalloc(sizeof(config_t), GFP_KERNEL); + sense_config_buf = (config_t *)kmalloc(sizeof(config_t), GFP_KERNEL); if(sense_config_buf == NULL) { kfree(id_lstatus_buf); diff --git a/trunk/drivers/block/swim_iop.c b/trunk/drivers/block/swim_iop.c new file mode 100644 index 000000000000..ed7b06cf3e68 --- /dev/null +++ b/trunk/drivers/block/swim_iop.c @@ -0,0 +1,578 @@ +/* + * Driver for the SWIM (Super Woz Integrated Machine) IOP + * floppy controller on the Macintosh IIfx and Quadra 900/950 + * + * Written by Joshua M. Thompson (funaho@jurai.org) + * based on the SWIM3 driver (c) 1996 by Paul Mackerras. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + * + * 1999-06-12 (jmt) - Initial implementation. + */ + +/* + * ------------------- + * Theory of Operation + * ------------------- + * + * Since the SWIM IOP is message-driven we implement a simple request queue + * system. One outstanding request may be queued at any given time (this is + * an IOP limitation); only when that request has completed can a new request + * be sent. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DRIVER_VERSION "Version 0.1 (1999-06-12)" + +#define MAX_FLOPPIES 4 + +enum swim_state { + idle, + available, + revalidating, + transferring, + ejecting +}; + +struct floppy_state { + enum swim_state state; + int drive_num; /* device number */ + int secpercyl; /* disk geometry information */ + int secpertrack; + int total_secs; + int write_prot; /* 1 if write-protected, 0 if not, -1 dunno */ + int ref_count; + struct timer_list timeout; + int ejected; + struct wait_queue *wait; + int wanted; + int timeout_pending; +}; + +struct swim_iop_req { + int sent; + int complete; + __u8 command[32]; + struct floppy_state *fs; + void (*done)(struct swim_iop_req *); +}; + +static struct swim_iop_req *current_req; +static int floppy_count; + +static struct floppy_state floppy_states[MAX_FLOPPIES]; +static DEFINE_SPINLOCK(swim_iop_lock); + +#define CURRENT elv_next_request(swim_queue) + +static char *drive_names[7] = { + "not installed", /* DRV_NONE */ + "unknown (1)", /* DRV_UNKNOWN */ + "a 400K drive", /* DRV_400K */ + "an 800K drive" /* DRV_800K */ + "unknown (4)", /* ???? */ + "an FDHD", /* DRV_FDHD */ + "unknown (6)", /* ???? */ + "an Apple HD20" /* DRV_HD20 */ +}; + +int swimiop_init(void); +static void swimiop_init_request(struct swim_iop_req *); +static int swimiop_send_request(struct swim_iop_req *); +static void swimiop_receive(struct iop_msg *); +static void swimiop_status_update(int, struct swim_drvstatus *); +static int swimiop_eject(struct floppy_state *fs); + +static int floppy_ioctl(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long param); +static int floppy_open(struct inode *inode, struct file *filp); +static int floppy_release(struct inode *inode, struct file *filp); +static int floppy_check_change(struct gendisk *disk); +static int floppy_revalidate(struct gendisk *disk); +static int grab_drive(struct floppy_state *fs, enum swim_state state, + int interruptible); +static void release_drive(struct floppy_state *fs); +static void set_timeout(struct floppy_state *fs, int nticks, + void (*proc)(unsigned long)); +static void fd_request_timeout(unsigned long); +static void do_fd_request(request_queue_t * q); +static void start_request(struct floppy_state *fs); + +static struct block_device_operations floppy_fops = { + .open = floppy_open, + .release = floppy_release, + .ioctl = floppy_ioctl, + .media_changed = floppy_check_change, + .revalidate_disk= floppy_revalidate, +}; + +static struct request_queue *swim_queue; +/* + * SWIM IOP initialization + */ + +int swimiop_init(void) +{ + volatile struct swim_iop_req req; + struct swimcmd_status *cmd = (struct swimcmd_status *) &req.command[0]; + struct swim_drvstatus *ds = &cmd->status; + struct floppy_state *fs; + int i; + + current_req = NULL; + floppy_count = 0; + + if (!iop_ism_present) + return -ENODEV; + + if (register_blkdev(FLOPPY_MAJOR, "fd")) + return -EBUSY; + + swim_queue = blk_init_queue(do_fd_request, &swim_iop_lock); + if (!swim_queue) { + unregister_blkdev(FLOPPY_MAJOR, "fd"); + return -ENOMEM; + } + + printk("SWIM-IOP: %s by Joshua M. Thompson (funaho@jurai.org)\n", + DRIVER_VERSION); + + if (iop_listen(SWIM_IOP, SWIM_CHAN, swimiop_receive, "SWIM") != 0) { + printk(KERN_ERR "SWIM-IOP: IOP channel already in use; can't initialize.\n"); + unregister_blkdev(FLOPPY_MAJOR, "fd"); + blk_cleanup_queue(swim_queue); + return -EBUSY; + } + + printk(KERN_ERR "SWIM_IOP: probing for installed drives.\n"); + + for (i = 0 ; i < MAX_FLOPPIES ; i++) { + memset(&floppy_states[i], 0, sizeof(struct floppy_state)); + fs = &floppy_states[floppy_count]; + + swimiop_init_request(&req); + cmd->code = CMD_STATUS; + cmd->drive_num = i + 1; + if (swimiop_send_request(&req) != 0) continue; + while (!req.complete); + if (cmd->error != 0) { + printk(KERN_ERR "SWIM-IOP: probe on drive %d returned error %d\n", i, (uint) cmd->error); + continue; + } + if (ds->installed != 0x01) continue; + printk("SWIM-IOP: drive %d is %s (%s, %s, %s, %s)\n", i, + drive_names[ds->info.type], + ds->info.external? "ext" : "int", + ds->info.scsi? "scsi" : "floppy", + ds->info.fixed? "fixed" : "removable", + ds->info.secondary? "secondary" : "primary"); + swimiop_status_update(floppy_count, ds); + fs->state = idle; + + init_timer(&fs->timeout); + floppy_count++; + } + printk("SWIM-IOP: detected %d installed drives.\n", floppy_count); + + for (i = 0; i < floppy_count; i++) { + struct gendisk *disk = alloc_disk(1); + if (!disk) + continue; + disk->major = FLOPPY_MAJOR; + disk->first_minor = i; + disk->fops = &floppy_fops; + sprintf(disk->disk_name, "fd%d", i); + disk->private_data = &floppy_states[i]; + disk->queue = swim_queue; + set_capacity(disk, 2880 * 2); + add_disk(disk); + } + + return 0; +} + +static void swimiop_init_request(struct swim_iop_req *req) +{ + req->sent = 0; + req->complete = 0; + req->done = NULL; +} + +static int swimiop_send_request(struct swim_iop_req *req) +{ + unsigned long flags; + int err; + + /* It's doubtful an interrupt routine would try to send */ + /* a SWIM request, but I'd rather play it safe here. */ + + local_irq_save(flags); + + if (current_req != NULL) { + local_irq_restore(flags); + return -ENOMEM; + } + + current_req = req; + + /* Interrupts should be back on for iop_send_message() */ + + local_irq_restore(flags); + + err = iop_send_message(SWIM_IOP, SWIM_CHAN, (void *) req, + sizeof(req->command), (__u8 *) &req->command[0], + swimiop_receive); + + /* No race condition here; we own current_req at this point */ + + if (err) { + current_req = NULL; + } else { + req->sent = 1; + } + return err; +} + +/* + * Receive a SWIM message from the IOP. + * + * This will be called in two cases: + * + * 1. A message has been successfully sent to the IOP. + * 2. An unsolicited message was received from the IOP. + */ + +void swimiop_receive(struct iop_msg *msg) +{ + struct swim_iop_req *req; + struct swimmsg_status *sm; + struct swim_drvstatus *ds; + + req = current_req; + + switch(msg->status) { + case IOP_MSGSTATUS_COMPLETE: + memcpy(&req->command[0], &msg->reply[0], sizeof(req->command)); + req->complete = 1; + if (req->done) (*req->done)(req); + current_req = NULL; + break; + case IOP_MSGSTATUS_UNSOL: + sm = (struct swimmsg_status *) &msg->message[0]; + ds = &sm->status; + swimiop_status_update(sm->drive_num, ds); + iop_complete_message(msg); + break; + } +} + +static void swimiop_status_update(int drive_num, struct swim_drvstatus *ds) +{ + struct floppy_state *fs = &floppy_states[drive_num]; + + fs->write_prot = (ds->write_prot == 0x80); + if ((ds->disk_in_drive != 0x01) && (ds->disk_in_drive != 0x02)) { + fs->ejected = 1; + } else { + fs->ejected = 0; + } + switch(ds->info.type) { + case DRV_400K: + fs->secpercyl = 10; + fs->secpertrack = 10; + fs->total_secs = 800; + break; + case DRV_800K: + fs->secpercyl = 20; + fs->secpertrack = 10; + fs->total_secs = 1600; + break; + case DRV_FDHD: + fs->secpercyl = 36; + fs->secpertrack = 18; + fs->total_secs = 2880; + break; + default: + fs->secpercyl = 0; + fs->secpertrack = 0; + fs->total_secs = 0; + break; + } +} + +static int swimiop_eject(struct floppy_state *fs) +{ + int err, n; + struct swim_iop_req req; + struct swimcmd_eject *cmd = (struct swimcmd_eject *) &req.command[0]; + + err = grab_drive(fs, ejecting, 1); + if (err) return err; + + swimiop_init_request(&req); + cmd->code = CMD_EJECT; + cmd->drive_num = fs->drive_num; + err = swimiop_send_request(&req); + if (err) { + release_drive(fs); + return err; + } + for (n = 2*HZ; n > 0; --n) { + if (req.complete) break; + if (signal_pending(current)) { + err = -EINTR; + break; + } + schedule_timeout_interruptible(1); + } + release_drive(fs); + return cmd->error; +} + +static struct floppy_struct floppy_type = + { 2880,18,2,80,0,0x1B,0x00,0xCF,0x6C,NULL }; /* 7 1.44MB 3.5" */ + +static int floppy_ioctl(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long param) +{ + struct floppy_state *fs = inode->i_bdev->bd_disk->private_data; + int err; + + if ((cmd & 0x80) && !capable(CAP_SYS_ADMIN)) + return -EPERM; + + switch (cmd) { + case FDEJECT: + if (fs->ref_count != 1) + return -EBUSY; + err = swimiop_eject(fs); + return err; + case FDGETPRM: + if (copy_to_user((void *) param, (void *) &floppy_type, + sizeof(struct floppy_struct))) + return -EFAULT; + return 0; + } + return -ENOTTY; +} + +static int floppy_open(struct inode *inode, struct file *filp) +{ + struct floppy_state *fs = inode->i_bdev->bd_disk->private_data; + + if (fs->ref_count == -1 || filp->f_flags & O_EXCL) + return -EBUSY; + + if ((filp->f_flags & O_NDELAY) == 0 && (filp->f_mode & 3)) { + check_disk_change(inode->i_bdev); + if (fs->ejected) + return -ENXIO; + } + + if ((filp->f_mode & 2) && fs->write_prot) + return -EROFS; + + if (filp->f_flags & O_EXCL) + fs->ref_count = -1; + else + ++fs->ref_count; + + return 0; +} + +static int floppy_release(struct inode *inode, struct file *filp) +{ + struct floppy_state *fs = inode->i_bdev->bd_disk->private_data; + if (fs->ref_count > 0) + fs->ref_count--; + return 0; +} + +static int floppy_check_change(struct gendisk *disk) +{ + struct floppy_state *fs = disk->private_data; + return fs->ejected; +} + +static int floppy_revalidate(struct gendisk *disk) +{ + struct floppy_state *fs = disk->private_data; + grab_drive(fs, revalidating, 0); + /* yadda, yadda */ + release_drive(fs); + return 0; +} + +static void floppy_off(unsigned int nr) +{ +} + +static int grab_drive(struct floppy_state *fs, enum swim_state state, + int interruptible) +{ + unsigned long flags; + + local_irq_save(flags); + if (fs->state != idle) { + ++fs->wanted; + while (fs->state != available) { + if (interruptible && signal_pending(current)) { + --fs->wanted; + local_irq_restore(flags); + return -EINTR; + } + interruptible_sleep_on(&fs->wait); + } + --fs->wanted; + } + fs->state = state; + local_irq_restore(flags); + return 0; +} + +static void release_drive(struct floppy_state *fs) +{ + unsigned long flags; + + local_irq_save(flags); + fs->state = idle; + start_request(fs); + local_irq_restore(flags); +} + +static void set_timeout(struct floppy_state *fs, int nticks, + void (*proc)(unsigned long)) +{ + unsigned long flags; + + local_irq_save(flags); + if (fs->timeout_pending) + del_timer(&fs->timeout); + init_timer(&fs->timeout); + fs->timeout.expires = jiffies + nticks; + fs->timeout.function = proc; + fs->timeout.data = (unsigned long) fs; + add_timer(&fs->timeout); + fs->timeout_pending = 1; + local_irq_restore(flags); +} + +static void do_fd_request(request_queue_t * q) +{ + int i; + + for (i = 0 ; i < floppy_count ; i++) { + start_request(&floppy_states[i]); + } +} + +static void fd_request_complete(struct swim_iop_req *req) +{ + struct floppy_state *fs = req->fs; + struct swimcmd_rw *cmd = (struct swimcmd_rw *) &req->command[0]; + + del_timer(&fs->timeout); + fs->timeout_pending = 0; + fs->state = idle; + if (cmd->error) { + printk(KERN_ERR "SWIM-IOP: error %d on read/write request.\n", cmd->error); + end_request(CURRENT, 0); + } else { + CURRENT->sector += cmd->num_blocks; + CURRENT->current_nr_sectors -= cmd->num_blocks; + if (CURRENT->current_nr_sectors <= 0) { + end_request(CURRENT, 1); + return; + } + } + start_request(fs); +} + +static void fd_request_timeout(unsigned long data) +{ + struct floppy_state *fs = (struct floppy_state *) data; + + fs->timeout_pending = 0; + end_request(CURRENT, 0); + fs->state = idle; +} + +static void start_request(struct floppy_state *fs) +{ + volatile struct swim_iop_req req; + struct swimcmd_rw *cmd = (struct swimcmd_rw *) &req.command[0]; + + if (fs->state == idle && fs->wanted) { + fs->state = available; + wake_up(&fs->wait); + return; + } + while (CURRENT && fs->state == idle) { + if (CURRENT->bh && !buffer_locked(CURRENT->bh)) + panic("floppy: block not locked"); +#if 0 + printk("do_fd_req: dev=%s cmd=%d sec=%ld nr_sec=%ld buf=%p\n", + CURRENT->rq_disk->disk_name, CURRENT->cmd, + CURRENT->sector, CURRENT->nr_sectors, CURRENT->buffer); + printk(" errors=%d current_nr_sectors=%ld\n", + CURRENT->errors, CURRENT->current_nr_sectors); +#endif + + if (CURRENT->sector < 0 || CURRENT->sector >= fs->total_secs) { + end_request(CURRENT, 0); + continue; + } + if (CURRENT->current_nr_sectors == 0) { + end_request(CURRENT, 1); + continue; + } + if (fs->ejected) { + end_request(CURRENT, 0); + continue; + } + + swimiop_init_request(&req); + req.fs = fs; + req.done = fd_request_complete; + + if (CURRENT->cmd == WRITE) { + if (fs->write_prot) { + end_request(CURRENT, 0); + continue; + } + cmd->code = CMD_WRITE; + } else { + cmd->code = CMD_READ; + + } + cmd->drive_num = fs->drive_num; + cmd->buffer = CURRENT->buffer; + cmd->first_block = CURRENT->sector; + cmd->num_blocks = CURRENT->current_nr_sectors; + + if (swimiop_send_request(&req)) { + end_request(CURRENT, 0); + continue; + } + + set_timeout(fs, HZ*CURRENT->current_nr_sectors, + fd_request_timeout); + + fs->state = transferring; + } +} diff --git a/trunk/drivers/cdrom/cdrom.c b/trunk/drivers/cdrom/cdrom.c index e4a2f8f3a1d7..2df5cf4ec743 100644 --- a/trunk/drivers/cdrom/cdrom.c +++ b/trunk/drivers/cdrom/cdrom.c @@ -1810,7 +1810,7 @@ static int dvd_read_disckey(struct cdrom_device_info *cdi, dvd_struct *s) size = sizeof(s->disckey.value) + 4; - if ((buf = kmalloc(size, GFP_KERNEL)) == NULL) + if ((buf = (u_char *) kmalloc(size, GFP_KERNEL)) == NULL) return -ENOMEM; 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) size = sizeof(s->manufact.value) + 4; - if ((buf = kmalloc(size, GFP_KERNEL)) == NULL) + if ((buf = (u_char *) kmalloc(size, GFP_KERNEL)) == NULL) return -ENOMEM; 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, /* FIXME: we need upper bound checking, too!! */ if (lba < 0) return -EINVAL; - cgc.buffer = kmalloc(blocksize, GFP_KERNEL); + cgc.buffer = (char *) kmalloc(blocksize, GFP_KERNEL); if (cgc.buffer == NULL) return -ENOMEM; memset(&sense, 0, sizeof(sense)); @@ -3031,7 +3031,7 @@ static int mmc_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, int size = sizeof(dvd_struct); if (!CDROM_CAN(CDC_DVD)) return -ENOSYS; - if ((s = kmalloc(size, GFP_KERNEL)) == NULL) + if ((s = (dvd_struct *) kmalloc(size, GFP_KERNEL)) == NULL) return -ENOMEM; cdinfo(CD_DO_IOCTL, "entering DVD_READ_STRUCT\n"); if (copy_from_user(s, (dvd_struct __user *)arg, size)) { diff --git a/trunk/drivers/cdrom/cm206.c b/trunk/drivers/cdrom/cm206.c index b6c61bbb20e1..e6d8e9ededea 100644 --- a/trunk/drivers/cdrom/cm206.c +++ b/trunk/drivers/cdrom/cm206.c @@ -1420,7 +1420,7 @@ int __init cm206_init(void) return -EIO; } printk(" adapter at 0x%x", cm206_base); - cd = kmalloc(size, GFP_KERNEL); + cd = (struct cm206_struct *) kmalloc(size, GFP_KERNEL); if (!cd) goto out_base; /* Now we have found the adaptor card, try to reset it. As we have diff --git a/trunk/drivers/char/Kconfig b/trunk/drivers/char/Kconfig index 9e43e39dc35c..0a3aee29e067 100644 --- a/trunk/drivers/char/Kconfig +++ b/trunk/drivers/char/Kconfig @@ -97,7 +97,7 @@ config SERIAL_NONSTANDARD config COMPUTONE tristate "Computone IntelliPort Plus serial support" - depends on SERIAL_NONSTANDARD && (ISA || EISA || PCI) + depends on SERIAL_NONSTANDARD ---help--- This driver supports the entire family of Intelliport II/Plus controllers with the exception of the MicroChannel controllers and @@ -203,7 +203,7 @@ config MOXA_SMARTIO config MOXA_SMARTIO_NEW tristate "Moxa SmartIO support v. 2.0 (EXPERIMENTAL)" - depends on SERIAL_NONSTANDARD && (PCI || EISA || ISA) + depends on SERIAL_NONSTANDARD help Say Y here if you have a Moxa SmartIO multiport serial card and/or want to help develop a new version of this driver. @@ -218,7 +218,7 @@ config MOXA_SMARTIO_NEW config ISI tristate "Multi-Tech multiport card support (EXPERIMENTAL)" - depends on SERIAL_NONSTANDARD && PCI + depends on SERIAL_NONSTANDARD select FW_LOADER help This is a driver for the Multi-Tech cards which provide several @@ -312,7 +312,7 @@ config SPECIALIX_RTSCTS config SX tristate "Specialix SX (and SI) card support" - depends on SERIAL_NONSTANDARD && (PCI || EISA || ISA) + depends on SERIAL_NONSTANDARD help This is a driver for the SX and SI multiport serial cards. Please read the file for details. diff --git a/trunk/drivers/char/consolemap.c b/trunk/drivers/char/consolemap.c index b99b7561260d..04a12027a740 100644 --- a/trunk/drivers/char/consolemap.c +++ b/trunk/drivers/char/consolemap.c @@ -443,7 +443,7 @@ int con_clear_unimap(struct vc_data *vc, struct unimapinit *ui) p = (struct uni_pagedir *)*vc->vc_uni_pagedir_loc; if (p && p->readonly) return -EIO; if (!p || --p->refcount) { - q = kmalloc(sizeof(*p), GFP_KERNEL); + q = (struct uni_pagedir *)kmalloc(sizeof(*p), GFP_KERNEL); if (!q) { if (p) p->refcount++; return -ENOMEM; diff --git a/trunk/drivers/char/lcd.c b/trunk/drivers/char/lcd.c index d649abbf0857..da601fd6c07a 100644 --- a/trunk/drivers/char/lcd.c +++ b/trunk/drivers/char/lcd.c @@ -459,7 +459,7 @@ static int lcd_ioctl(struct inode *inode, struct file *file, (&display, (struct lcd_display *) arg, sizeof(struct lcd_display))) return -EFAULT; - rom = kmalloc((128), GFP_ATOMIC); + rom = (unsigned char *) kmalloc((128), GFP_ATOMIC); if (rom == NULL) { printk(KERN_ERR LCD "kmalloc() failed in %s\n", __FUNCTION__); diff --git a/trunk/drivers/char/lp.c b/trunk/drivers/char/lp.c index b51d08be0bcf..b70b5388b5a8 100644 --- a/trunk/drivers/char/lp.c +++ b/trunk/drivers/char/lp.c @@ -525,7 +525,7 @@ static int lp_open(struct inode * inode, struct file * file) return -EIO; } } - lp_table[minor].lp_buffer = kmalloc(LP_BUFFER_SIZE, GFP_KERNEL); + lp_table[minor].lp_buffer = (char *) kmalloc(LP_BUFFER_SIZE, GFP_KERNEL); if (!lp_table[minor].lp_buffer) { LP_F(minor) &= ~LP_BUSY; return -ENOMEM; diff --git a/trunk/drivers/char/mxser_new.c b/trunk/drivers/char/mxser_new.c index cd989dce7c53..efa8076c33e0 100644 --- a/trunk/drivers/char/mxser_new.c +++ b/trunk/drivers/char/mxser_new.c @@ -315,7 +315,6 @@ static struct mxser_mon_ext mon_data_ext; static int mxser_set_baud_method[MXSER_PORTS + 1]; static spinlock_t gm_lock; -#ifdef CONFIG_PCI static int CheckIsMoxaMust(int io) { u8 oldmcr, hwid; @@ -338,7 +337,6 @@ static int CheckIsMoxaMust(int io) } return MOXA_OTHER_UART; } -#endif static void process_txrx_fifo(struct mxser_port *info) { @@ -2382,11 +2380,9 @@ static void mxser_release_res(struct mxser_board *brd, struct pci_dev *pdev, if (irq) free_irq(brd->irq, brd); if (pdev != NULL) { /* PCI */ -#ifdef CONFIG_PCI pci_release_region(pdev, 2); pci_release_region(pdev, 3); pci_dev_put(pdev); -#endif } else { release_region(brd->ports[0].ioaddr, 8 * brd->info->nports); release_region(brd->vector, 1); @@ -2550,7 +2546,6 @@ static int __init mxser_get_ISA_conf(int cap, struct mxser_board *brd) static int __devinit mxser_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { -#ifdef CONFIG_PCI struct mxser_board *brd; unsigned int i, j; unsigned long ioaddress; @@ -2649,9 +2644,6 @@ static int __devinit mxser_probe(struct pci_dev *pdev, brd->info = NULL; err: return retval; -#else - return -ENODEV; -#endif } static void __devexit mxser_remove(struct pci_dev *pdev) diff --git a/trunk/drivers/char/n_r3964.c b/trunk/drivers/char/n_r3964.c index dc6d41841457..103d338f21e2 100644 --- a/trunk/drivers/char/n_r3964.c +++ b/trunk/drivers/char/n_r3964.c @@ -125,8 +125,8 @@ static void transmit_block(struct r3964_info *pInfo); static void receive_char(struct r3964_info *pInfo, const unsigned char c); static void receive_error(struct r3964_info *pInfo, const char flag); static void on_timeout(unsigned long priv); -static int enable_signals(struct r3964_info *pInfo, struct pid *pid, int arg); -static int read_telegram(struct r3964_info *pInfo, struct pid *pid, unsigned char __user *buf); +static int enable_signals(struct r3964_info *pInfo, pid_t pid, int arg); +static int read_telegram(struct r3964_info *pInfo, pid_t pid, unsigned char __user *buf); static void add_msg(struct r3964_client_info *pClient, int msg_id, int arg, int error_code, struct r3964_block_header *pBlock); static struct r3964_message* remove_msg(struct r3964_info *pInfo, @@ -829,7 +829,7 @@ static void on_timeout(unsigned long priv) } static struct r3964_client_info *findClient( - struct r3964_info *pInfo, struct pid *pid) + struct r3964_info *pInfo, pid_t pid) { struct r3964_client_info *pClient; @@ -843,7 +843,7 @@ static struct r3964_client_info *findClient( return NULL; } -static int enable_signals(struct r3964_info *pInfo, struct pid *pid, int arg) +static int enable_signals(struct r3964_info *pInfo, pid_t pid, int arg) { struct r3964_client_info *pClient; struct r3964_client_info **ppClient; @@ -858,7 +858,7 @@ static int enable_signals(struct r3964_info *pInfo, struct pid *pid, int arg) if(pClient->pid == pid) { - TRACE_PS("removing client %d from client list", pid_nr(pid)); + TRACE_PS("removing client %d from client list", pid); *ppClient = pClient->next; while(pClient->msg_count) { @@ -869,7 +869,6 @@ static int enable_signals(struct r3964_info *pInfo, struct pid *pid, int arg) TRACE_M("enable_signals - msg kfree %p",pMsg); } } - put_pid(pClient->pid); kfree(pClient); TRACE_M("enable_signals - kfree %p",pClient); return 0; @@ -893,10 +892,10 @@ static int enable_signals(struct r3964_info *pInfo, struct pid *pid, int arg) if(pClient==NULL) return -ENOMEM; - TRACE_PS("add client %d to client list", pid_nr(pid)); + TRACE_PS("add client %d to client list", pid); spin_lock_init(&pClient->lock); pClient->sig_flags=arg; - pClient->pid = get_pid(pid); + pClient->pid = pid; pClient->next=pInfo->firstClient; pClient->first_msg = NULL; pClient->last_msg = NULL; @@ -909,7 +908,7 @@ static int enable_signals(struct r3964_info *pInfo, struct pid *pid, int arg) return 0; } -static int read_telegram(struct r3964_info *pInfo, struct pid *pid, unsigned char __user *buf) +static int read_telegram(struct r3964_info *pInfo, pid_t pid, unsigned char __user *buf) { struct r3964_client_info *pClient; struct r3964_block_header *block; @@ -1006,7 +1005,7 @@ static void add_msg(struct r3964_client_info *pClient, int msg_id, int arg, /* Send SIGIO signal to client process: */ if(pClient->sig_flags & R3964_USE_SIGIO) { - kill_pid(pClient->pid, SIGIO, 1); + kill_proc(pClient->pid, SIGIO, 1); } } @@ -1043,7 +1042,7 @@ static void remove_client_block(struct r3964_info *pInfo, { struct r3964_block_header *block; - TRACE_PS("remove_client_block PID %d", pid_nr(pClient->pid)); + TRACE_PS("remove_client_block PID %d", pClient->pid); block=pClient->next_block_to_read; if(block) @@ -1158,7 +1157,6 @@ static void r3964_close(struct tty_struct *tty) TRACE_M("r3964_close - msg kfree %p",pMsg); } } - put_pid(pClient->pid); kfree(pClient); TRACE_M("r3964_close - client kfree %p",pClient); pClient=pNext; @@ -1195,11 +1193,12 @@ static ssize_t r3964_read(struct tty_struct *tty, struct file *file, struct r3964_client_message theMsg; DECLARE_WAITQUEUE (wait, current); + int pid = current->pid; int count; TRACE_L("read()"); - pClient=findClient(pInfo, task_pid(current)); + pClient=findClient(pInfo, pid); if(pClient) { pMsg = remove_msg(pInfo, pClient); @@ -1253,6 +1252,7 @@ static ssize_t r3964_write(struct tty_struct * tty, struct file * file, struct r3964_block_header *pHeader; struct r3964_client_info *pClient; unsigned char *new_data; + int pid; TRACE_L("write request, %d characters", count); /* @@ -1295,7 +1295,9 @@ static ssize_t r3964_write(struct tty_struct * tty, struct file * file, pHeader->locks = 0; pHeader->owner = NULL; - pClient=findClient(pInfo, task_pid(current)); + pid=current->pid; + + pClient=findClient(pInfo, pid); if(pClient) { pHeader->owner = pClient; @@ -1326,7 +1328,7 @@ static int r3964_ioctl(struct tty_struct * tty, struct file * file, switch(cmd) { case R3964_ENABLE_SIGNALS: - return enable_signals(pInfo, task_pid(current), arg); + return enable_signals(pInfo, current->pid, arg); case R3964_SETPRIORITY: if(argR3964_SLAVE) return -EINVAL; @@ -1339,7 +1341,7 @@ static int r3964_ioctl(struct tty_struct * tty, struct file * file, pInfo->flags &= ~R3964_BCC; return 0; case R3964_READ_TELEGRAM: - return read_telegram(pInfo, task_pid(current), (unsigned char __user *)arg); + return read_telegram(pInfo, current->pid, (unsigned char __user *)arg); default: return -ENOIOCTLCMD; } @@ -1355,6 +1357,7 @@ static unsigned int r3964_poll(struct tty_struct * tty, struct file * file, struct poll_table_struct *wait) { struct r3964_info *pInfo=(struct r3964_info*)tty->disc_data; + int pid=current->pid; struct r3964_client_info *pClient; struct r3964_message *pMsg=NULL; unsigned long flags; @@ -1362,7 +1365,7 @@ static unsigned int r3964_poll(struct tty_struct * tty, struct file * file, TRACE_L("POLL"); - pClient=findClient(pInfo, task_pid(current)); + pClient=findClient(pInfo,pid); if(pClient) { poll_wait(file, &pInfo->read_wait, wait); diff --git a/trunk/drivers/char/n_tty.c b/trunk/drivers/char/n_tty.c index 2bdb0144a22e..e96a00fe1389 100644 --- a/trunk/drivers/char/n_tty.c +++ b/trunk/drivers/char/n_tty.c @@ -1151,6 +1151,7 @@ static int copy_from_read_buf(struct tty_struct *tty, n = min(*nr, n); spin_unlock_irqrestore(&tty->read_lock, flags); if (n) { + mb(); retval = copy_to_user(*b, &tty->read_buf[tty->read_tail], n); n -= retval; spin_lock_irqsave(&tty->read_lock, flags); diff --git a/trunk/drivers/char/pcmcia/synclink_cs.c b/trunk/drivers/char/pcmcia/synclink_cs.c index f108c136800a..5152cedd8878 100644 --- a/trunk/drivers/char/pcmcia/synclink_cs.c +++ b/trunk/drivers/char/pcmcia/synclink_cs.c @@ -541,7 +541,7 @@ static int mgslpc_probe(struct pcmcia_device *link) if (debug_level >= DEBUG_LEVEL_INFO) printk("mgslpc_attach\n"); - info = kmalloc(sizeof(MGSLPC_INFO), GFP_KERNEL); + info = (MGSLPC_INFO *)kmalloc(sizeof(MGSLPC_INFO), GFP_KERNEL); if (!info) { printk("Error can't allocate device instance data\n"); return -ENOMEM; diff --git a/trunk/drivers/char/rio/riocmd.c b/trunk/drivers/char/rio/riocmd.c index 245f03195b7c..167ebc84e8d7 100644 --- a/trunk/drivers/char/rio/riocmd.c +++ b/trunk/drivers/char/rio/riocmd.c @@ -556,7 +556,7 @@ struct CmdBlk *RIOGetCmdBlk(void) { struct CmdBlk *CmdBlkP; - CmdBlkP = kmalloc(sizeof(struct CmdBlk), GFP_ATOMIC); + CmdBlkP = (struct CmdBlk *)kmalloc(sizeof(struct CmdBlk), GFP_ATOMIC); if (CmdBlkP) memset(CmdBlkP, 0, sizeof(struct CmdBlk)); return CmdBlkP; diff --git a/trunk/drivers/char/rtc.c b/trunk/drivers/char/rtc.c index e1d70e8b6268..66a7385bc34a 100644 --- a/trunk/drivers/char/rtc.c +++ b/trunk/drivers/char/rtc.c @@ -113,7 +113,7 @@ static int rtc_has_irq = 1; #define hpet_set_rtc_irq_bit(arg) 0 #define hpet_rtc_timer_init() do { } while (0) #define hpet_rtc_dropped_irq() 0 -static irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id) {return 0;} +static inline irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id) {return 0;} #else extern irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id); #endif @@ -165,9 +165,7 @@ static void mask_rtc_irq_bit(unsigned char bit) } #endif -#ifdef CONFIG_PROC_FS static int rtc_proc_open(struct inode *inode, struct file *file); -#endif /* * Bits in rtc_status. (6 bits of room for future expansion) @@ -908,7 +906,6 @@ static struct miscdevice rtc_dev = { .fops = &rtc_fops, }; -#ifdef CONFIG_PROC_FS static const struct file_operations rtc_proc_fops = { .owner = THIS_MODULE, .open = rtc_proc_open, @@ -916,13 +913,14 @@ static const struct file_operations rtc_proc_fops = { .llseek = seq_lseek, .release = single_release, }; + +#if defined(RTC_IRQ) && !defined(__sparc__) +static irq_handler_t rtc_int_handler_ptr; #endif static int __init rtc_init(void) { -#ifdef CONFIG_PROC_FS struct proc_dir_entry *ent; -#endif #if defined(__alpha__) || defined(__mips__) unsigned int year, ctrl; char *guess = NULL; @@ -934,11 +932,9 @@ static int __init rtc_init(void) struct sparc_isa_bridge *isa_br; struct sparc_isa_device *isa_dev; #endif -#else - void *r; -#ifdef RTC_IRQ - irq_handler_t rtc_int_handler_ptr; #endif +#ifndef __sparc__ + void *r; #endif #ifdef __sparc__ @@ -962,7 +958,6 @@ static int __init rtc_init(void) } } #endif - rtc_has_irq = 0; printk(KERN_ERR "rtc_init: no PC rtc found\n"); return -EIO; @@ -977,7 +972,6 @@ static int __init rtc_init(void) * PCI Slot 2 INTA# (and some INTx# in Slot 1). */ if (request_irq(rtc_irq, rtc_interrupt, IRQF_SHARED, "rtc", (void *)&rtc_port)) { - rtc_has_irq = 0; printk(KERN_ERR "rtc: cannot register IRQ %d\n", rtc_irq); return -EIO; } @@ -988,9 +982,6 @@ static int __init rtc_init(void) else r = request_mem_region(RTC_PORT(0), RTC_IO_EXTENT, "rtc"); if (!r) { -#ifdef RTC_IRQ - rtc_has_irq = 0; -#endif printk(KERN_ERR "rtc: I/O resource %lx is not free.\n", (long)(RTC_PORT(0))); return -EIO; @@ -1005,7 +996,6 @@ static int __init rtc_init(void) if(request_irq(RTC_IRQ, rtc_int_handler_ptr, IRQF_DISABLED, "rtc", NULL)) { /* Yeah right, seeing as irq 8 doesn't even hit the bus. */ - rtc_has_irq = 0; printk(KERN_ERR "rtc: IRQ %d is not free.\n", RTC_IRQ); if (RTC_IOMAPPED) release_region(RTC_PORT(0), RTC_IO_EXTENT); @@ -1022,19 +1012,21 @@ static int __init rtc_init(void) if (misc_register(&rtc_dev)) { #ifdef RTC_IRQ free_irq(RTC_IRQ, NULL); - rtc_has_irq = 0; #endif release_region(RTC_PORT(0), RTC_IO_EXTENT); return -ENODEV; } -#ifdef CONFIG_PROC_FS ent = create_proc_entry("driver/rtc", 0, NULL); - if (ent) - ent->proc_fops = &rtc_proc_fops; - else - printk(KERN_WARNING "rtc: Failed to register with procfs.\n"); + if (!ent) { +#ifdef RTC_IRQ + free_irq(RTC_IRQ, NULL); #endif + release_region(RTC_PORT(0), RTC_IO_EXTENT); + misc_deregister(&rtc_dev); + return -ENOMEM; + } + ent->proc_fops = &rtc_proc_fops; #if defined(__alpha__) || defined(__mips__) rtc_freq = HZ; @@ -1167,7 +1159,6 @@ static void rtc_dropped_irq(unsigned long data) } #endif -#ifdef CONFIG_PROC_FS /* * Info exported via "/proc/driver/rtc". */ @@ -1252,7 +1243,6 @@ static int rtc_proc_open(struct inode *inode, struct file *file) { return single_open(file, rtc_proc_show, NULL); } -#endif void rtc_get_rtc_time(struct rtc_time *rtc_tm) { diff --git a/trunk/drivers/char/sx.c b/trunk/drivers/char/sx.c index 1da92a689ae4..a3008ce13015 100644 --- a/trunk/drivers/char/sx.c +++ b/trunk/drivers/char/sx.c @@ -2498,10 +2498,8 @@ static void __devexit sx_remove_card(struct sx_board *board, /* It is safe/allowed to del_timer a non-active timer */ del_timer(&board->timer); if (pdev) { -#ifdef CONFIG_PCI pci_iounmap(pdev, board->base); pci_release_region(pdev, IS_CF_BOARD(board) ? 3 : 2); -#endif } else { iounmap(board->base); release_region(board->hw_base, board->hw_len); @@ -2603,7 +2601,6 @@ static struct eisa_driver sx_eisadriver = { #endif -#ifdef CONFIG_PCI /******************************************************** * Setting bit 17 in the CNTRL register of the PLX 9050 * * chip forces a retry on writes while a read is pending.* @@ -2635,12 +2632,10 @@ static void __devinit fix_sx_pci(struct pci_dev *pdev, struct sx_board *board) } iounmap(rebase); } -#endif static int __devinit sx_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { -#ifdef CONFIG_PCI struct sx_board *board; unsigned int i, reg; int retval = -EIO; @@ -2705,9 +2700,6 @@ static int __devinit sx_pci_probe(struct pci_dev *pdev, board->flags &= ~SX_BOARD_PRESENT; err: return retval; -#else - return -ENODEV; -#endif } static void __devexit sx_pci_remove(struct pci_dev *pdev) diff --git a/trunk/drivers/char/synclink.c b/trunk/drivers/char/synclink.c index 3fa625db9e4b..acc6fab601cc 100644 --- a/trunk/drivers/char/synclink.c +++ b/trunk/drivers/char/synclink.c @@ -4332,7 +4332,7 @@ static struct mgsl_struct* mgsl_allocate_device(void) { struct mgsl_struct *info; - info = kmalloc(sizeof(struct mgsl_struct), + info = (struct mgsl_struct *)kmalloc(sizeof(struct mgsl_struct), GFP_KERNEL); if (!info) { diff --git a/trunk/drivers/char/synclinkmp.c b/trunk/drivers/char/synclinkmp.c index 8f4d67afe5bf..53e8ccf94fe3 100644 --- a/trunk/drivers/char/synclinkmp.c +++ b/trunk/drivers/char/synclinkmp.c @@ -2730,7 +2730,7 @@ static int startup(SLMP_INFO * info) return 0; if (!info->tx_buf) { - info->tx_buf = kmalloc(info->max_frame_size, GFP_KERNEL); + info->tx_buf = (unsigned char *)kmalloc(info->max_frame_size, GFP_KERNEL); if (!info->tx_buf) { printk(KERN_ERR"%s(%d):%s can't allocate transmit buffer\n", __FILE__,__LINE__,info->device_name); @@ -3798,7 +3798,7 @@ static SLMP_INFO *alloc_dev(int adapter_num, int port_num, struct pci_dev *pdev) { SLMP_INFO *info; - info = kmalloc(sizeof(SLMP_INFO), + info = (SLMP_INFO *)kmalloc(sizeof(SLMP_INFO), GFP_KERNEL); if (!info) { diff --git a/trunk/drivers/char/sysrq.c b/trunk/drivers/char/sysrq.c index 13935235e066..05810c8d20bc 100644 --- a/trunk/drivers/char/sysrq.c +++ b/trunk/drivers/char/sysrq.c @@ -41,34 +41,7 @@ #include /* Whether we react on sysrq keys or just ignore them */ -int __read_mostly __sysrq_enabled = 1; - -static int __read_mostly sysrq_always_enabled; - -int sysrq_on(void) -{ - return __sysrq_enabled || sysrq_always_enabled; -} - -/* - * A value of 1 means 'all', other nonzero values are an op mask: - */ -static inline int sysrq_on_mask(int mask) -{ - return sysrq_always_enabled || __sysrq_enabled == 1 || - (__sysrq_enabled & mask); -} - -static int __init sysrq_always_enabled_setup(char *str) -{ - sysrq_always_enabled = 1; - printk(KERN_INFO "debug: sysrq always enabled.\n"); - - return 1; -} - -__setup("sysrq_always_enabled", sysrq_always_enabled_setup); - +int sysrq_enabled = 1; static void sysrq_handle_loglevel(int key, struct tty_struct *tty) { @@ -406,7 +379,8 @@ void __handle_sysrq(int key, struct tty_struct *tty, int check_mask) * Should we check for enabled operations (/proc/sysrq-trigger * should not) and is the invoked operation enabled? */ - if (!check_mask || sysrq_on_mask(op_p->enable_mask)) { + if (!check_mask || sysrq_enabled == 1 || + (sysrq_enabled & op_p->enable_mask)) { printk("%s\n", op_p->action_msg); console_loglevel = orig_log_level; op_p->handler(key, tty); @@ -440,8 +414,9 @@ void __handle_sysrq(int key, struct tty_struct *tty, int check_mask) */ void handle_sysrq(int key, struct tty_struct *tty) { - if (sysrq_on()) - __handle_sysrq(key, tty, 1); + if (!sysrq_enabled) + return; + __handle_sysrq(key, tty, 1); } EXPORT_SYMBOL(handle_sysrq); diff --git a/trunk/drivers/char/tty_io.c b/trunk/drivers/char/tty_io.c index 47a6eacb10bc..4044c864fdd4 100644 --- a/trunk/drivers/char/tty_io.c +++ b/trunk/drivers/char/tty_io.c @@ -3335,13 +3335,18 @@ static void __do_SAK(struct work_struct *work) int session; int i; struct file *filp; + struct tty_ldisc *disc; struct fdtable *fdt; if (!tty) return; session = tty->session; - tty_ldisc_flush(tty); + /* We don't want an ldisc switch during this */ + disc = tty_ldisc_ref(tty); + if (disc && disc->flush_buffer) + disc->flush_buffer(tty); + tty_ldisc_deref(disc); if (tty->driver->flush_buffer) tty->driver->flush_buffer(tty); @@ -3816,7 +3821,6 @@ struct tty_struct *get_current_tty(void) barrier(); return tty; } -EXPORT_SYMBOL_GPL(get_current_tty); /* * Initialize the console device. This is called *early*, so diff --git a/trunk/drivers/char/viocons.c b/trunk/drivers/char/viocons.c index 0e0da443cbd5..6d2e314860df 100644 --- a/trunk/drivers/char/viocons.c +++ b/trunk/drivers/char/viocons.c @@ -61,7 +61,10 @@ static DEFINE_SPINLOCK(consolelock); static DEFINE_SPINLOCK(consoleloglock); +#ifdef CONFIG_MAGIC_SYSRQ static int vio_sysrq_pressed; +extern int sysrq_enabled; +#endif #define VIOCHAR_NUM_BUF 16 @@ -933,10 +936,8 @@ static void vioHandleData(struct HvLpEvent *event) */ num_pushed = 0; for (index = 0; index < cevent->len; index++) { - /* - * Will be optimized away if !CONFIG_MAGIC_SYSRQ: - */ - if (sysrq_on()) { +#ifdef CONFIG_MAGIC_SYSRQ + if (sysrq_enabled) { /* 0x0f is the ascii character for ^O */ if (cevent->data[index] == '\x0f') { vio_sysrq_pressed = 1; @@ -955,6 +956,7 @@ static void vioHandleData(struct HvLpEvent *event) continue; } } +#endif /* * The sysrq sequence isn't included in this check if * sysrq is enabled and compiled into the kernel because diff --git a/trunk/drivers/char/vt.c b/trunk/drivers/char/vt.c index 06c32a3e3ca4..a8239dac994f 100644 --- a/trunk/drivers/char/vt.c +++ b/trunk/drivers/char/vt.c @@ -784,7 +784,7 @@ int vc_resize(struct vc_data *vc, unsigned int cols, unsigned int lines) if (new_cols == vc->vc_cols && new_rows == vc->vc_rows) return 0; - newscreen = kmalloc(new_screen_size, GFP_USER); + newscreen = (unsigned short *) kmalloc(new_screen_size, GFP_USER); if (!newscreen) return -ENOMEM; diff --git a/trunk/drivers/char/vt_ioctl.c b/trunk/drivers/char/vt_ioctl.c index dc8368ebb1ac..ac5d60edbafa 100644 --- a/trunk/drivers/char/vt_ioctl.c +++ b/trunk/drivers/char/vt_ioctl.c @@ -129,7 +129,7 @@ do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm, struct kbd_str !capable(CAP_SYS_RESOURCE)) return -EPERM; - key_map = kmalloc(sizeof(plain_map), + key_map = (ushort *) kmalloc(sizeof(plain_map), GFP_KERNEL); if (!key_map) return -ENOMEM; @@ -259,7 +259,7 @@ do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm) sz = 256; while (sz < funcbufsize - funcbufleft + delta) sz <<= 1; - fnw = kmalloc(sz, GFP_KERNEL); + fnw = (char *) kmalloc(sz, GFP_KERNEL); if(!fnw) { ret = -ENOMEM; goto reterr; @@ -1087,7 +1087,7 @@ static void complete_change_console(struct vc_data *vc) switch_screen(vc); /* - * This can't appear below a successful kill_pid(). If it did, + * This can't appear below a successful kill_proc(). If it did, * then the *blank_screen operation could occur while X, having * received acqsig, is waking up on another processor. This * condition can lead to overlapping accesses to the VGA range @@ -1110,7 +1110,7 @@ static void complete_change_console(struct vc_data *vc) */ if (vc->vt_mode.mode == VT_PROCESS) { /* - * Send the signal as privileged - kill_pid() will + * Send the signal as privileged - kill_proc() will * tell us if the process has gone or something else * is awry */ @@ -1170,7 +1170,7 @@ void change_console(struct vc_data *new_vc) vc = vc_cons[fg_console].d; if (vc->vt_mode.mode == VT_PROCESS) { /* - * Send the signal as privileged - kill_pid() will + * Send the signal as privileged - kill_proc() will * tell us if the process has gone or something else * is awry */ diff --git a/trunk/drivers/fc4/fc.c b/trunk/drivers/fc4/fc.c index 22b62b3cd14e..ca4e67a022d0 100644 --- a/trunk/drivers/fc4/fc.c +++ b/trunk/drivers/fc4/fc.c @@ -266,7 +266,7 @@ static void fcp_report_map_done(fc_channel *fc, int i, int status) printk ("FC: Bad magic from REPORT_AL_MAP on %s - %08x\n", fc->name, p->magic); fc->state = FC_STATE_OFFLINE; } else { - fc->posmap = kzalloc(sizeof(fcp_posmap)+p->len, GFP_KERNEL); + fc->posmap = (fcp_posmap *)kzalloc(sizeof(fcp_posmap)+p->len, GFP_KERNEL); if (!fc->posmap) { printk("FC: Not enough memory, offlining channel\n"); fc->state = FC_STATE_OFFLINE; @@ -355,7 +355,7 @@ void fcp_register(fc_channel *fc, u8 type, int unregister) for (i = fc->can_queue; i < fc->scsi_bitmap_end; i++) set_bit (i, fc->scsi_bitmap); fc->scsi_free = fc->can_queue; - fc->cmd_slots = kzalloc(slots * sizeof(fcp_cmnd*), GFP_KERNEL); + fc->cmd_slots = (fcp_cmnd **)kzalloc(slots * sizeof(fcp_cmnd*), GFP_KERNEL); fc->abort_count = 0; } else { fc->scsi_name[0] = 0; @@ -933,7 +933,7 @@ int fcp_scsi_dev_reset(struct scsi_cmnd *SCpnt) DECLARE_MUTEX_LOCKED(sem); if (!fc->rst_pkt) { - fc->rst_pkt = kmalloc(sizeof(SCpnt), GFP_KERNEL); + fc->rst_pkt = (struct scsi_cmnd *) kmalloc(sizeof(SCpnt), GFP_KERNEL); if (!fc->rst_pkt) return FAILED; 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) logi *l; int status; - l = kzalloc(2 * sizeof(logi), GFP_KERNEL); + l = (logi *)kzalloc(2 * sizeof(logi), GFP_KERNEL); if (!l) return -ENOMEM; l->code = LS_PLOGI; memcpy (&l->nport_wwn, &fc->wwn_nport, sizeof(fc_wwn)); @@ -1141,7 +1141,7 @@ int fc_do_prli(fc_channel *fc, unsigned char alpa) prli *p; int status; - p = kzalloc(2 * sizeof(prli), GFP_KERNEL); + p = (prli *)kzalloc(2 * sizeof(prli), GFP_KERNEL); if (!p) return -ENOMEM; p->code = LS_PRLI; p->params[0] = 0x08002000; diff --git a/trunk/drivers/hwmon/Kconfig b/trunk/drivers/hwmon/Kconfig index 891ef6d0b1bf..e76d91906c99 100644 --- a/trunk/drivers/hwmon/Kconfig +++ b/trunk/drivers/hwmon/Kconfig @@ -106,31 +106,6 @@ config SENSORS_K8TEMP This driver can also be built as a module. If so, the module will be called k8temp. -config SENSORS_AMS - tristate "Apple Motion Sensor driver" - depends on HWMON && PPC_PMAC && !PPC64 && INPUT && ((ADB_PMU && I2C = y) || (ADB_PMU && !I2C) || I2C) && EXPERIMENTAL - help - Support for the motion sensor included in PowerBooks. Includes - implementations for PMU and I2C. - - This driver can also be built as a module. If so, the module - will be called ams. - -config SENSORS_AMS_PMU - bool "PMU variant" - depends on SENSORS_AMS && ADB_PMU - default y - help - PMU variant of motion sensor, found in late 2005 PowerBooks. - -config SENSORS_AMS_I2C - bool "I2C variant" - depends on SENSORS_AMS && I2C - default y - help - I2C variant of motion sensor, found in early 2005 PowerBooks and - iBooks. - config SENSORS_ASB100 tristate "Asus ASB100 Bach" depends on HWMON && I2C && EXPERIMENTAL @@ -167,12 +142,11 @@ config SENSORS_DS1621 will be called ds1621. config SENSORS_F71805F - tristate "Fintek F71805F/FG and F71872F/FG" + tristate "Fintek F71805F/FG" depends on HWMON && EXPERIMENTAL help If you say yes here you get support for hardware monitoring - features of the Fintek F71805F/FG and F71872F/FG Super-I/O - chips. + features of the Fintek F71805F/FG chips. This driver can also be built as a module. If so, the module will be called f71805f. @@ -379,19 +353,6 @@ config SENSORS_PC87360 This driver can also be built as a module. If so, the module will be called pc87360. -config SENSORS_PC87427 - tristate "National Semiconductor PC87427" - depends on HWMON && EXPERIMENTAL - help - If you say yes here you get access to the hardware monitoring - functions of the National Semiconductor PC87427 Super-I/O chip. - The chip has two distinct logical devices, one for fan speed - monitoring and control, and one for voltage and temperature - monitoring. Only fan speed monitoring is supported right now. - - This driver can also be built as a module. If so, the module - will be called pc87427. - config SENSORS_SIS5595 tristate "Silicon Integrated Systems Corp. SiS5595" depends on HWMON && I2C && PCI && EXPERIMENTAL @@ -513,16 +474,6 @@ config SENSORS_W83792D This driver can also be built as a module. If so, the module will be called w83792d. -config SENSORS_W83793 - tristate "Winbond W83793" - depends on HWMON && I2C && EXPERIMENTAL - help - If you say yes here you get support for the Winbond W83793 - hardware monitoring chip. - - This driver can also be built as a module. If so, the module - will be called w83793. - config SENSORS_W83L785TS tristate "Winbond W83L785TS-S" depends on HWMON && I2C && EXPERIMENTAL @@ -576,9 +527,6 @@ config SENSORS_HDAPS This driver also provides an absolute input class device, allowing the laptop to act as a pinball machine-esque joystick. - If your ThinkPad is not recognized by the driver, please update to latest - BIOS. This is especially the case for some R52 ThinkPads. - Say Y here if you have an applicable laptop and want to experience the awesome power of hdaps. diff --git a/trunk/drivers/hwmon/Makefile b/trunk/drivers/hwmon/Makefile index 31661124271e..af01cc64f7d2 100644 --- a/trunk/drivers/hwmon/Makefile +++ b/trunk/drivers/hwmon/Makefile @@ -9,7 +9,6 @@ obj-$(CONFIG_HWMON_VID) += hwmon-vid.o obj-$(CONFIG_SENSORS_ASB100) += asb100.o obj-$(CONFIG_SENSORS_W83627HF) += w83627hf.o obj-$(CONFIG_SENSORS_W83792D) += w83792d.o -obj-$(CONFIG_SENSORS_W83793) += w83793.o obj-$(CONFIG_SENSORS_W83781D) += w83781d.o obj-$(CONFIG_SENSORS_W83791D) += w83791d.o @@ -19,7 +18,6 @@ obj-$(CONFIG_SENSORS_ADM1025) += adm1025.o obj-$(CONFIG_SENSORS_ADM1026) += adm1026.o obj-$(CONFIG_SENSORS_ADM1031) += adm1031.o obj-$(CONFIG_SENSORS_ADM9240) += adm9240.o -obj-$(CONFIG_SENSORS_AMS) += ams/ obj-$(CONFIG_SENSORS_ATXP1) += atxp1.o obj-$(CONFIG_SENSORS_DS1621) += ds1621.o obj-$(CONFIG_SENSORS_F71805F) += f71805f.o @@ -43,7 +41,6 @@ obj-$(CONFIG_SENSORS_LM90) += lm90.o obj-$(CONFIG_SENSORS_LM92) += lm92.o obj-$(CONFIG_SENSORS_MAX1619) += max1619.o obj-$(CONFIG_SENSORS_PC87360) += pc87360.o -obj-$(CONFIG_SENSORS_PC87427) += pc87427.o obj-$(CONFIG_SENSORS_SIS5595) += sis5595.o obj-$(CONFIG_SENSORS_SMSC47B397)+= smsc47b397.o obj-$(CONFIG_SENSORS_SMSC47M1) += smsc47m1.o diff --git a/trunk/drivers/hwmon/ams/Makefile b/trunk/drivers/hwmon/ams/Makefile deleted file mode 100644 index 41c95b2089dc..000000000000 --- a/trunk/drivers/hwmon/ams/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -# -# Makefile for Apple Motion Sensor driver -# - -ams-y := ams-core.o ams-input.o -ams-$(CONFIG_SENSORS_AMS_PMU) += ams-pmu.o -ams-$(CONFIG_SENSORS_AMS_I2C) += ams-i2c.o -obj-$(CONFIG_SENSORS_AMS) += ams.o diff --git a/trunk/drivers/hwmon/ams/ams-core.c b/trunk/drivers/hwmon/ams/ams-core.c deleted file mode 100644 index f1f0f5d0442c..000000000000 --- a/trunk/drivers/hwmon/ams/ams-core.c +++ /dev/null @@ -1,265 +0,0 @@ -/* - * Apple Motion Sensor driver - * - * Copyright (C) 2005 Stelian Pop (stelian@popies.net) - * Copyright (C) 2006 Michael Hanselmann (linux-kernel@hansmi.ch) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "ams.h" - -/* There is only one motion sensor per machine */ -struct ams ams_info; - -static unsigned int verbose; -module_param(verbose, bool, 0644); -MODULE_PARM_DESC(verbose, "Show free falls and shocks in kernel output"); - -/* Call with ams_info.lock held! */ -void ams_sensors(s8 *x, s8 *y, s8 *z) -{ - u32 orient = ams_info.vflag? ams_info.orient1 : ams_info.orient2; - - if (orient & 0x80) - /* X and Y swapped */ - ams_info.get_xyz(y, x, z); - else - ams_info.get_xyz(x, y, z); - - if (orient & 0x04) - *z = ~(*z); - if (orient & 0x02) - *y = ~(*y); - if (orient & 0x01) - *x = ~(*x); -} - -static ssize_t ams_show_current(struct device *dev, - struct device_attribute *attr, char *buf) -{ - s8 x, y, z; - - mutex_lock(&ams_info.lock); - ams_sensors(&x, &y, &z); - mutex_unlock(&ams_info.lock); - - return snprintf(buf, PAGE_SIZE, "%d %d %d\n", x, y, z); -} - -static DEVICE_ATTR(current, S_IRUGO, ams_show_current, NULL); - -static void ams_handle_irq(void *data) -{ - enum ams_irq irq = *((enum ams_irq *)data); - - spin_lock(&ams_info.irq_lock); - - ams_info.worker_irqs |= irq; - schedule_work(&ams_info.worker); - - spin_unlock(&ams_info.irq_lock); -} - -static enum ams_irq ams_freefall_irq_data = AMS_IRQ_FREEFALL; -static struct pmf_irq_client ams_freefall_client = { - .owner = THIS_MODULE, - .handler = ams_handle_irq, - .data = &ams_freefall_irq_data, -}; - -static enum ams_irq ams_shock_irq_data = AMS_IRQ_SHOCK; -static struct pmf_irq_client ams_shock_client = { - .owner = THIS_MODULE, - .handler = ams_handle_irq, - .data = &ams_shock_irq_data, -}; - -/* Once hard disk parking is implemented in the kernel, this function can - * trigger it. - */ -static void ams_worker(struct work_struct *work) -{ - mutex_lock(&ams_info.lock); - - if (ams_info.has_device) { - unsigned long flags; - - spin_lock_irqsave(&ams_info.irq_lock, flags); - - if (ams_info.worker_irqs & AMS_IRQ_FREEFALL) { - if (verbose) - printk(KERN_INFO "ams: freefall detected!\n"); - - ams_info.worker_irqs &= ~AMS_IRQ_FREEFALL; - - /* we must call this with interrupts enabled */ - spin_unlock_irqrestore(&ams_info.irq_lock, flags); - ams_info.clear_irq(AMS_IRQ_FREEFALL); - spin_lock_irqsave(&ams_info.irq_lock, flags); - } - - if (ams_info.worker_irqs & AMS_IRQ_SHOCK) { - if (verbose) - printk(KERN_INFO "ams: shock detected!\n"); - - ams_info.worker_irqs &= ~AMS_IRQ_SHOCK; - - /* we must call this with interrupts enabled */ - spin_unlock_irqrestore(&ams_info.irq_lock, flags); - ams_info.clear_irq(AMS_IRQ_SHOCK); - spin_lock_irqsave(&ams_info.irq_lock, flags); - } - - spin_unlock_irqrestore(&ams_info.irq_lock, flags); - } - - mutex_unlock(&ams_info.lock); -} - -/* Call with ams_info.lock held! */ -int ams_sensor_attach(void) -{ - int result; - u32 *prop; - - /* Get orientation */ - prop = (u32*)get_property(ams_info.of_node, "orientation", NULL); - if (!prop) - return -ENODEV; - ams_info.orient1 = *prop; - ams_info.orient2 = *(prop + 1); - - /* Register freefall interrupt handler */ - result = pmf_register_irq_client(ams_info.of_node, - "accel-int-1", - &ams_freefall_client); - if (result < 0) - return -ENODEV; - - /* Reset saved irqs */ - ams_info.worker_irqs = 0; - - /* Register shock interrupt handler */ - result = pmf_register_irq_client(ams_info.of_node, - "accel-int-2", - &ams_shock_client); - if (result < 0) - goto release_freefall; - - /* Create device */ - ams_info.of_dev = of_platform_device_create(ams_info.of_node, "ams", NULL); - if (!ams_info.of_dev) { - result = -ENODEV; - goto release_shock; - } - - /* Create attributes */ - result = device_create_file(&ams_info.of_dev->dev, &dev_attr_current); - if (result) - goto release_of; - - ams_info.vflag = !!(ams_info.get_vendor() & 0x10); - - /* Init input device */ - result = ams_input_init(); - if (result) - goto release_device_file; - - return result; -release_device_file: - device_remove_file(&ams_info.of_dev->dev, &dev_attr_current); -release_of: - of_device_unregister(ams_info.of_dev); -release_shock: - pmf_unregister_irq_client(&ams_shock_client); -release_freefall: - pmf_unregister_irq_client(&ams_freefall_client); - return result; -} - -int __init ams_init(void) -{ - struct device_node *np; - - spin_lock_init(&ams_info.irq_lock); - mutex_init(&ams_info.lock); - INIT_WORK(&ams_info.worker, ams_worker); - -#ifdef CONFIG_SENSORS_AMS_I2C - np = of_find_node_by_name(NULL, "accelerometer"); - if (np && device_is_compatible(np, "AAPL,accelerometer_1")) - /* Found I2C motion sensor */ - return ams_i2c_init(np); -#endif - -#ifdef CONFIG_SENSORS_AMS_PMU - np = of_find_node_by_name(NULL, "sms"); - if (np && device_is_compatible(np, "sms")) - /* Found PMU motion sensor */ - return ams_pmu_init(np); -#endif - - printk(KERN_ERR "ams: No motion sensor found.\n"); - - return -ENODEV; -} - -void ams_exit(void) -{ - mutex_lock(&ams_info.lock); - - if (ams_info.has_device) { - /* Remove input device */ - ams_input_exit(); - - /* Shut down implementation */ - ams_info.exit(); - - /* Flush interrupt worker - * - * We do this after ams_info.exit(), because an interrupt might - * have arrived before disabling them. - */ - flush_scheduled_work(); - - /* Remove attributes */ - device_remove_file(&ams_info.of_dev->dev, &dev_attr_current); - - /* Remove device */ - of_device_unregister(ams_info.of_dev); - - /* Remove handler */ - pmf_unregister_irq_client(&ams_shock_client); - pmf_unregister_irq_client(&ams_freefall_client); - } - - mutex_unlock(&ams_info.lock); -} - -MODULE_AUTHOR("Stelian Pop, Michael Hanselmann"); -MODULE_DESCRIPTION("Apple Motion Sensor driver"); -MODULE_LICENSE("GPL"); - -module_init(ams_init); -module_exit(ams_exit); diff --git a/trunk/drivers/hwmon/ams/ams-i2c.c b/trunk/drivers/hwmon/ams/ams-i2c.c deleted file mode 100644 index 0d24bdfea53e..000000000000 --- a/trunk/drivers/hwmon/ams/ams-i2c.c +++ /dev/null @@ -1,299 +0,0 @@ -/* - * Apple Motion Sensor driver (I2C variant) - * - * Copyright (C) 2005 Stelian Pop (stelian@popies.net) - * Copyright (C) 2006 Michael Hanselmann (linux-kernel@hansmi.ch) - * - * Clean room implementation based on the reverse engineered Mac OS X driver by - * Johannes Berg , documentation available at - * http://johannes.sipsolutions.net/PowerBook/Apple_Motion_Sensor_Specification - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#include -#include -#include -#include -#include - -#include "ams.h" - -/* AMS registers */ -#define AMS_COMMAND 0x00 /* command register */ -#define AMS_STATUS 0x01 /* status register */ -#define AMS_CTRL1 0x02 /* read control 1 (number of values) */ -#define AMS_CTRL2 0x03 /* read control 2 (offset?) */ -#define AMS_CTRL3 0x04 /* read control 3 (size of each value?) */ -#define AMS_DATA1 0x05 /* read data 1 */ -#define AMS_DATA2 0x06 /* read data 2 */ -#define AMS_DATA3 0x07 /* read data 3 */ -#define AMS_DATA4 0x08 /* read data 4 */ -#define AMS_DATAX 0x20 /* data X */ -#define AMS_DATAY 0x21 /* data Y */ -#define AMS_DATAZ 0x22 /* data Z */ -#define AMS_FREEFALL 0x24 /* freefall int control */ -#define AMS_SHOCK 0x25 /* shock int control */ -#define AMS_SENSLOW 0x26 /* sensitivity low limit */ -#define AMS_SENSHIGH 0x27 /* sensitivity high limit */ -#define AMS_CTRLX 0x28 /* control X */ -#define AMS_CTRLY 0x29 /* control Y */ -#define AMS_CTRLZ 0x2A /* control Z */ -#define AMS_UNKNOWN1 0x2B /* unknown 1 */ -#define AMS_UNKNOWN2 0x2C /* unknown 2 */ -#define AMS_UNKNOWN3 0x2D /* unknown 3 */ -#define AMS_VENDOR 0x2E /* vendor */ - -/* AMS commands - use with the AMS_COMMAND register */ -enum ams_i2c_cmd { - AMS_CMD_NOOP = 0, - AMS_CMD_VERSION, - AMS_CMD_READMEM, - AMS_CMD_WRITEMEM, - AMS_CMD_ERASEMEM, - AMS_CMD_READEE, - AMS_CMD_WRITEEE, - AMS_CMD_RESET, - AMS_CMD_START, -}; - -static int ams_i2c_attach(struct i2c_adapter *adapter); -static int ams_i2c_detach(struct i2c_adapter *adapter); - -static struct i2c_driver ams_i2c_driver = { - .driver = { - .name = "ams", - .owner = THIS_MODULE, - }, - .attach_adapter = ams_i2c_attach, - .detach_adapter = ams_i2c_detach, -}; - -static s32 ams_i2c_read(u8 reg) -{ - return i2c_smbus_read_byte_data(&ams_info.i2c_client, reg); -} - -static int ams_i2c_write(u8 reg, u8 value) -{ - return i2c_smbus_write_byte_data(&ams_info.i2c_client, reg, value); -} - -static int ams_i2c_cmd(enum ams_i2c_cmd cmd) -{ - s32 result; - int remaining = HZ / 20; - - ams_i2c_write(AMS_COMMAND, cmd); - mdelay(5); - - while (remaining) { - result = ams_i2c_read(AMS_COMMAND); - if (result == 0 || result & 0x80) - return 0; - - remaining = schedule_timeout(remaining); - } - - return -1; -} - -static void ams_i2c_set_irq(enum ams_irq reg, char enable) -{ - if (reg & AMS_IRQ_FREEFALL) { - u8 val = ams_i2c_read(AMS_CTRLX); - if (enable) - val |= 0x80; - else - val &= ~0x80; - ams_i2c_write(AMS_CTRLX, val); - } - - if (reg & AMS_IRQ_SHOCK) { - u8 val = ams_i2c_read(AMS_CTRLY); - if (enable) - val |= 0x80; - else - val &= ~0x80; - ams_i2c_write(AMS_CTRLY, val); - } - - if (reg & AMS_IRQ_GLOBAL) { - u8 val = ams_i2c_read(AMS_CTRLZ); - if (enable) - val |= 0x80; - else - val &= ~0x80; - ams_i2c_write(AMS_CTRLZ, val); - } -} - -static void ams_i2c_clear_irq(enum ams_irq reg) -{ - if (reg & AMS_IRQ_FREEFALL) - ams_i2c_write(AMS_FREEFALL, 0); - - if (reg & AMS_IRQ_SHOCK) - ams_i2c_write(AMS_SHOCK, 0); -} - -static u8 ams_i2c_get_vendor(void) -{ - return ams_i2c_read(AMS_VENDOR); -} - -static void ams_i2c_get_xyz(s8 *x, s8 *y, s8 *z) -{ - *x = ams_i2c_read(AMS_DATAX); - *y = ams_i2c_read(AMS_DATAY); - *z = ams_i2c_read(AMS_DATAZ); -} - -static int ams_i2c_attach(struct i2c_adapter *adapter) -{ - unsigned long bus; - int vmaj, vmin; - int result; - - /* There can be only one */ - if (unlikely(ams_info.has_device)) - return -ENODEV; - - if (strncmp(adapter->name, "uni-n", 5)) - return -ENODEV; - - bus = simple_strtoul(adapter->name + 6, NULL, 10); - if (bus != ams_info.i2c_bus) - return -ENODEV; - - ams_info.i2c_client.addr = ams_info.i2c_address; - ams_info.i2c_client.adapter = adapter; - ams_info.i2c_client.driver = &ams_i2c_driver; - strcpy(ams_info.i2c_client.name, "Apple Motion Sensor"); - - if (ams_i2c_cmd(AMS_CMD_RESET)) { - printk(KERN_INFO "ams: Failed to reset the device\n"); - return -ENODEV; - } - - if (ams_i2c_cmd(AMS_CMD_START)) { - printk(KERN_INFO "ams: Failed to start the device\n"); - return -ENODEV; - } - - /* get version/vendor information */ - ams_i2c_write(AMS_CTRL1, 0x02); - ams_i2c_write(AMS_CTRL2, 0x85); - ams_i2c_write(AMS_CTRL3, 0x01); - - ams_i2c_cmd(AMS_CMD_READMEM); - - vmaj = ams_i2c_read(AMS_DATA1); - vmin = ams_i2c_read(AMS_DATA2); - if (vmaj != 1 || vmin != 52) { - printk(KERN_INFO "ams: Incorrect device version (%d.%d)\n", - vmaj, vmin); - return -ENODEV; - } - - ams_i2c_cmd(AMS_CMD_VERSION); - - vmaj = ams_i2c_read(AMS_DATA1); - vmin = ams_i2c_read(AMS_DATA2); - if (vmaj != 0 || vmin != 1) { - printk(KERN_INFO "ams: Incorrect firmware version (%d.%d)\n", - vmaj, vmin); - return -ENODEV; - } - - /* Disable interrupts */ - ams_i2c_set_irq(AMS_IRQ_ALL, 0); - - result = ams_sensor_attach(); - if (result < 0) - return result; - - /* Set default values */ - ams_i2c_write(AMS_SENSLOW, 0x15); - ams_i2c_write(AMS_SENSHIGH, 0x60); - ams_i2c_write(AMS_CTRLX, 0x08); - ams_i2c_write(AMS_CTRLY, 0x0F); - ams_i2c_write(AMS_CTRLZ, 0x4F); - ams_i2c_write(AMS_UNKNOWN1, 0x14); - - /* Clear interrupts */ - ams_i2c_clear_irq(AMS_IRQ_ALL); - - ams_info.has_device = 1; - - /* Enable interrupts */ - ams_i2c_set_irq(AMS_IRQ_ALL, 1); - - printk(KERN_INFO "ams: Found I2C based motion sensor\n"); - - return 0; -} - -static int ams_i2c_detach(struct i2c_adapter *adapter) -{ - if (ams_info.has_device) { - /* Disable interrupts */ - ams_i2c_set_irq(AMS_IRQ_ALL, 0); - - /* Clear interrupts */ - ams_i2c_clear_irq(AMS_IRQ_ALL); - - printk(KERN_INFO "ams: Unloading\n"); - - ams_info.has_device = 0; - } - - return 0; -} - -static void ams_i2c_exit(void) -{ - i2c_del_driver(&ams_i2c_driver); -} - -int __init ams_i2c_init(struct device_node *np) -{ - char *tmp_bus; - int result; - u32 *prop; - - mutex_lock(&ams_info.lock); - - /* Set implementation stuff */ - ams_info.of_node = np; - ams_info.exit = ams_i2c_exit; - ams_info.get_vendor = ams_i2c_get_vendor; - ams_info.get_xyz = ams_i2c_get_xyz; - ams_info.clear_irq = ams_i2c_clear_irq; - ams_info.bustype = BUS_I2C; - - /* look for bus either using "reg" or by path */ - prop = (u32*)get_property(ams_info.of_node, "reg", NULL); - if (!prop) { - result = -ENODEV; - - goto exit; - } - - tmp_bus = strstr(ams_info.of_node->full_name, "/i2c-bus@"); - if (tmp_bus) - ams_info.i2c_bus = *(tmp_bus + 9) - '0'; - else - ams_info.i2c_bus = ((*prop) >> 8) & 0x0f; - ams_info.i2c_address = ((*prop) & 0xff) >> 1; - - result = i2c_add_driver(&ams_i2c_driver); - -exit: - mutex_unlock(&ams_info.lock); - - return result; -} diff --git a/trunk/drivers/hwmon/ams/ams-input.c b/trunk/drivers/hwmon/ams/ams-input.c deleted file mode 100644 index f126aa485134..000000000000 --- a/trunk/drivers/hwmon/ams/ams-input.c +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Apple Motion Sensor driver (joystick emulation) - * - * Copyright (C) 2005 Stelian Pop (stelian@popies.net) - * Copyright (C) 2006 Michael Hanselmann (linux-kernel@hansmi.ch) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#include - -#include -#include -#include -#include - -#include "ams.h" - -static unsigned int joystick; -module_param(joystick, bool, 0644); -MODULE_PARM_DESC(joystick, "Enable the input class device on module load"); - -static unsigned int invert; -module_param(invert, bool, 0644); -MODULE_PARM_DESC(invert, "Invert input data on X and Y axis"); - -static int ams_input_kthread(void *data) -{ - s8 x, y, z; - - while (!kthread_should_stop()) { - mutex_lock(&ams_info.lock); - - ams_sensors(&x, &y, &z); - - x -= ams_info.xcalib; - y -= ams_info.ycalib; - z -= ams_info.zcalib; - - input_report_abs(ams_info.idev, ABS_X, invert ? -x : x); - input_report_abs(ams_info.idev, ABS_Y, invert ? -y : y); - input_report_abs(ams_info.idev, ABS_Z, z); - - input_sync(ams_info.idev); - - mutex_unlock(&ams_info.lock); - - msleep(25); - } - - return 0; -} - -static int ams_input_open(struct input_dev *dev) -{ - ams_info.kthread = kthread_run(ams_input_kthread, NULL, "kams"); - return IS_ERR(ams_info.kthread) ? PTR_ERR(ams_info.kthread) : 0; -} - -static void ams_input_close(struct input_dev *dev) -{ - kthread_stop(ams_info.kthread); -} - -/* Call with ams_info.lock held! */ -static void ams_input_enable(void) -{ - s8 x, y, z; - - if (ams_info.idev) - return; - - ams_sensors(&x, &y, &z); - ams_info.xcalib = x; - ams_info.ycalib = y; - ams_info.zcalib = z; - - ams_info.idev = input_allocate_device(); - if (!ams_info.idev) - return; - - ams_info.idev->name = "Apple Motion Sensor"; - ams_info.idev->id.bustype = ams_info.bustype; - ams_info.idev->id.vendor = 0; - ams_info.idev->open = ams_input_open; - ams_info.idev->close = ams_input_close; - ams_info.idev->cdev.dev = &ams_info.of_dev->dev; - - input_set_abs_params(ams_info.idev, ABS_X, -50, 50, 3, 0); - input_set_abs_params(ams_info.idev, ABS_Y, -50, 50, 3, 0); - input_set_abs_params(ams_info.idev, ABS_Z, -50, 50, 3, 0); - - set_bit(EV_ABS, ams_info.idev->evbit); - set_bit(EV_KEY, ams_info.idev->evbit); - set_bit(BTN_TOUCH, ams_info.idev->keybit); - - if (input_register_device(ams_info.idev)) { - input_free_device(ams_info.idev); - ams_info.idev = NULL; - return; - } -} - -/* Call with ams_info.lock held! */ -static void ams_input_disable(void) -{ - if (ams_info.idev) { - input_unregister_device(ams_info.idev); - ams_info.idev = NULL; - } -} - -static ssize_t ams_input_show_joystick(struct device *dev, - struct device_attribute *attr, char *buf) -{ - return sprintf(buf, "%d\n", joystick); -} - -static ssize_t ams_input_store_joystick(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) -{ - if (sscanf(buf, "%d\n", &joystick) != 1) - return -EINVAL; - - mutex_lock(&ams_info.lock); - - if (joystick) - ams_input_enable(); - else - ams_input_disable(); - - mutex_unlock(&ams_info.lock); - - return count; -} - -static DEVICE_ATTR(joystick, S_IRUGO | S_IWUSR, - ams_input_show_joystick, ams_input_store_joystick); - -/* Call with ams_info.lock held! */ -int ams_input_init(void) -{ - int result; - - result = device_create_file(&ams_info.of_dev->dev, &dev_attr_joystick); - - if (!result && joystick) - ams_input_enable(); - return result; -} - -/* Call with ams_info.lock held! */ -void ams_input_exit() -{ - ams_input_disable(); - device_remove_file(&ams_info.of_dev->dev, &dev_attr_joystick); -} diff --git a/trunk/drivers/hwmon/ams/ams-pmu.c b/trunk/drivers/hwmon/ams/ams-pmu.c deleted file mode 100644 index 4636ae031a53..000000000000 --- a/trunk/drivers/hwmon/ams/ams-pmu.c +++ /dev/null @@ -1,207 +0,0 @@ -/* - * Apple Motion Sensor driver (PMU variant) - * - * Copyright (C) 2006 Michael Hanselmann (linux-kernel@hansmi.ch) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#include -#include -#include -#include -#include -#include - -#include "ams.h" - -/* Attitude */ -#define AMS_X 0x00 -#define AMS_Y 0x01 -#define AMS_Z 0x02 - -/* Not exactly known, maybe chip vendor */ -#define AMS_VENDOR 0x03 - -/* Freefall registers */ -#define AMS_FF_CLEAR 0x04 -#define AMS_FF_ENABLE 0x05 -#define AMS_FF_LOW_LIMIT 0x06 -#define AMS_FF_DEBOUNCE 0x07 - -/* Shock registers */ -#define AMS_SHOCK_CLEAR 0x08 -#define AMS_SHOCK_ENABLE 0x09 -#define AMS_SHOCK_HIGH_LIMIT 0x0a -#define AMS_SHOCK_DEBOUNCE 0x0b - -/* Global interrupt and power control register */ -#define AMS_CONTROL 0x0c - -static u8 ams_pmu_cmd; - -static void ams_pmu_req_complete(struct adb_request *req) -{ - complete((struct completion *)req->arg); -} - -/* Only call this function from task context */ -static void ams_pmu_set_register(u8 reg, u8 value) -{ - static struct adb_request req; - DECLARE_COMPLETION(req_complete); - - req.arg = &req_complete; - if (pmu_request(&req, ams_pmu_req_complete, 4, ams_pmu_cmd, 0x00, reg, value)) - return; - - wait_for_completion(&req_complete); -} - -/* Only call this function from task context */ -static u8 ams_pmu_get_register(u8 reg) -{ - static struct adb_request req; - DECLARE_COMPLETION(req_complete); - - req.arg = &req_complete; - if (pmu_request(&req, ams_pmu_req_complete, 3, ams_pmu_cmd, 0x01, reg)) - return 0; - - wait_for_completion(&req_complete); - - if (req.reply_len > 0) - return req.reply[0]; - else - return 0; -} - -/* Enables or disables the specified interrupts */ -static void ams_pmu_set_irq(enum ams_irq reg, char enable) -{ - if (reg & AMS_IRQ_FREEFALL) { - u8 val = ams_pmu_get_register(AMS_FF_ENABLE); - if (enable) - val |= 0x80; - else - val &= ~0x80; - ams_pmu_set_register(AMS_FF_ENABLE, val); - } - - if (reg & AMS_IRQ_SHOCK) { - u8 val = ams_pmu_get_register(AMS_SHOCK_ENABLE); - if (enable) - val |= 0x80; - else - val &= ~0x80; - ams_pmu_set_register(AMS_SHOCK_ENABLE, val); - } - - if (reg & AMS_IRQ_GLOBAL) { - u8 val = ams_pmu_get_register(AMS_CONTROL); - if (enable) - val |= 0x80; - else - val &= ~0x80; - ams_pmu_set_register(AMS_CONTROL, val); - } -} - -static void ams_pmu_clear_irq(enum ams_irq reg) -{ - if (reg & AMS_IRQ_FREEFALL) - ams_pmu_set_register(AMS_FF_CLEAR, 0x00); - - if (reg & AMS_IRQ_SHOCK) - ams_pmu_set_register(AMS_SHOCK_CLEAR, 0x00); -} - -static u8 ams_pmu_get_vendor(void) -{ - return ams_pmu_get_register(AMS_VENDOR); -} - -static void ams_pmu_get_xyz(s8 *x, s8 *y, s8 *z) -{ - *x = ams_pmu_get_register(AMS_X); - *y = ams_pmu_get_register(AMS_Y); - *z = ams_pmu_get_register(AMS_Z); -} - -static void ams_pmu_exit(void) -{ - /* Disable interrupts */ - ams_pmu_set_irq(AMS_IRQ_ALL, 0); - - /* Clear interrupts */ - ams_pmu_clear_irq(AMS_IRQ_ALL); - - ams_info.has_device = 0; - - printk(KERN_INFO "ams: Unloading\n"); -} - -int __init ams_pmu_init(struct device_node *np) -{ - u32 *prop; - int result; - - mutex_lock(&ams_info.lock); - - /* Set implementation stuff */ - ams_info.of_node = np; - ams_info.exit = ams_pmu_exit; - ams_info.get_vendor = ams_pmu_get_vendor; - ams_info.get_xyz = ams_pmu_get_xyz; - ams_info.clear_irq = ams_pmu_clear_irq; - ams_info.bustype = BUS_HOST; - - /* Get PMU command, should be 0x4e, but we can never know */ - prop = (u32*)get_property(ams_info.of_node, "reg", NULL); - if (!prop) { - result = -ENODEV; - goto exit; - } - ams_pmu_cmd = ((*prop) >> 8) & 0xff; - - /* Disable interrupts */ - ams_pmu_set_irq(AMS_IRQ_ALL, 0); - - /* Clear interrupts */ - ams_pmu_clear_irq(AMS_IRQ_ALL); - - result = ams_sensor_attach(); - if (result < 0) - goto exit; - - /* Set default values */ - ams_pmu_set_register(AMS_FF_LOW_LIMIT, 0x15); - ams_pmu_set_register(AMS_FF_ENABLE, 0x08); - ams_pmu_set_register(AMS_FF_DEBOUNCE, 0x14); - - ams_pmu_set_register(AMS_SHOCK_HIGH_LIMIT, 0x60); - ams_pmu_set_register(AMS_SHOCK_ENABLE, 0x0f); - ams_pmu_set_register(AMS_SHOCK_DEBOUNCE, 0x14); - - ams_pmu_set_register(AMS_CONTROL, 0x4f); - - /* Clear interrupts */ - ams_pmu_clear_irq(AMS_IRQ_ALL); - - ams_info.has_device = 1; - - /* Enable interrupts */ - ams_pmu_set_irq(AMS_IRQ_ALL, 1); - - printk(KERN_INFO "ams: Found PMU based motion sensor\n"); - - result = 0; - -exit: - mutex_unlock(&ams_info.lock); - - return result; -} diff --git a/trunk/drivers/hwmon/ams/ams.h b/trunk/drivers/hwmon/ams/ams.h deleted file mode 100644 index 240730e6bcde..000000000000 --- a/trunk/drivers/hwmon/ams/ams.h +++ /dev/null @@ -1,72 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -enum ams_irq { - AMS_IRQ_FREEFALL = 0x01, - AMS_IRQ_SHOCK = 0x02, - AMS_IRQ_GLOBAL = 0x04, - AMS_IRQ_ALL = - AMS_IRQ_FREEFALL | - AMS_IRQ_SHOCK | - AMS_IRQ_GLOBAL, -}; - -struct ams { - /* Locks */ - spinlock_t irq_lock; - struct mutex lock; - - /* General properties */ - struct device_node *of_node; - struct of_device *of_dev; - char has_device; - char vflag; - u32 orient1; - u32 orient2; - - /* Interrupt worker */ - struct work_struct worker; - u8 worker_irqs; - - /* Implementation - * - * Only call these functions with the main lock held. - */ - void (*exit)(void); - - void (*get_xyz)(s8 *x, s8 *y, s8 *z); - u8 (*get_vendor)(void); - - void (*clear_irq)(enum ams_irq reg); - -#ifdef CONFIG_SENSORS_AMS_I2C - /* I2C properties */ - int i2c_bus; - int i2c_address; - struct i2c_client i2c_client; -#endif - - /* Joystick emulation */ - struct task_struct *kthread; - struct input_dev *idev; - __u16 bustype; - - /* calibrated null values */ - int xcalib, ycalib, zcalib; -}; - -extern struct ams ams_info; - -extern void ams_sensors(s8 *x, s8 *y, s8 *z); -extern int ams_sensor_attach(void); - -extern int ams_pmu_init(struct device_node *np); -extern int ams_i2c_init(struct device_node *np); - -extern int ams_input_init(void); -extern void ams_input_exit(void); diff --git a/trunk/drivers/hwmon/f71805f.c b/trunk/drivers/hwmon/f71805f.c index a272cae8f60e..de17a72149d9 100644 --- a/trunk/drivers/hwmon/f71805f.c +++ b/trunk/drivers/hwmon/f71805f.c @@ -1,15 +1,12 @@ /* - * f71805f.c - driver for the Fintek F71805F/FG and F71872F/FG Super-I/O - * chips integrated hardware monitoring features + * f71805f.c - driver for the Fintek F71805F/FG Super-I/O chip integrated + * hardware monitoring features * Copyright (C) 2005-2006 Jean Delvare * * The F71805F/FG is a LPC Super-I/O chip made by Fintek. It integrates * complete hardware monitoring features: voltage, fan and temperature * sensors, and manual and automatic fan speed control. * - * The F71872F/FG is almost the same, with two more voltages monitored, - * and 6 VID inputs. - * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -40,7 +37,6 @@ static struct platform_device *pdev; #define DRVNAME "f71805f" -enum kinds { f71805f, f71872f }; /* * Super-I/O constants and functions @@ -52,13 +48,11 @@ enum kinds { f71805f, f71872f }; #define SIO_REG_DEVID 0x20 /* Device ID (2 bytes) */ #define SIO_REG_DEVREV 0x22 /* Device revision */ #define SIO_REG_MANID 0x23 /* Fintek ID (2 bytes) */ -#define SIO_REG_FNSEL1 0x29 /* Multi Function Select 1 (F71872F) */ #define SIO_REG_ENABLE 0x30 /* Logical device enable */ #define SIO_REG_ADDR 0x60 /* Logical device address (2 bytes) */ #define SIO_FINTEK_ID 0x1934 #define SIO_F71805F_ID 0x0406 -#define SIO_F71872F_ID 0x0341 static inline int superio_inb(int base, int reg) @@ -102,25 +96,22 @@ superio_exit(int base) * ISA constants */ -#define REGION_LENGTH 8 -#define ADDR_REG_OFFSET 5 -#define DATA_REG_OFFSET 6 +#define REGION_LENGTH 2 +#define ADDR_REG_OFFSET 0 +#define DATA_REG_OFFSET 1 /* * Registers */ -/* in nr from 0 to 10 (8-bit values) */ +/* in nr from 0 to 8 (8-bit values) */ #define F71805F_REG_IN(nr) (0x10 + (nr)) -#define F71805F_REG_IN_HIGH(nr) ((nr) < 10 ? 0x40 + 2 * (nr) : 0x2E) -#define F71805F_REG_IN_LOW(nr) ((nr) < 10 ? 0x41 + 2 * (nr) : 0x2F) +#define F71805F_REG_IN_HIGH(nr) (0x40 + 2 * (nr)) +#define F71805F_REG_IN_LOW(nr) (0x41 + 2 * (nr)) /* fan nr from 0 to 2 (12-bit values, two registers) */ #define F71805F_REG_FAN(nr) (0x20 + 2 * (nr)) #define F71805F_REG_FAN_LOW(nr) (0x28 + 2 * (nr)) -#define F71805F_REG_FAN_TARGET(nr) (0x69 + 16 * (nr)) #define F71805F_REG_FAN_CTRL(nr) (0x60 + 16 * (nr)) -#define F71805F_REG_PWM_FREQ(nr) (0x63 + 16 * (nr)) -#define F71805F_REG_PWM_DUTY(nr) (0x6B + 16 * (nr)) /* temp nr from 0 to 2 (8-bit values) */ #define F71805F_REG_TEMP(nr) (0x1B + (nr)) #define F71805F_REG_TEMP_HIGH(nr) (0x54 + 2 * (nr)) @@ -131,14 +122,6 @@ superio_exit(int base) /* status nr from 0 to 2 */ #define F71805F_REG_STATUS(nr) (0x36 + (nr)) -/* individual register bits */ -#define FAN_CTRL_DC_MODE 0x10 -#define FAN_CTRL_LATCH_FULL 0x08 -#define FAN_CTRL_MODE_MASK 0x03 -#define FAN_CTRL_MODE_SPEED 0x00 -#define FAN_CTRL_MODE_TEMPERATURE 0x01 -#define FAN_CTRL_MODE_MANUAL 0x02 - /* * Data structures and manipulation thereof */ @@ -155,16 +138,12 @@ struct f71805f_data { unsigned long last_limits; /* In jiffies */ /* Register values */ - u8 in[11]; - u8 in_high[11]; - u8 in_low[11]; - u16 has_in; + u8 in[9]; + u8 in_high[9]; + u8 in_low[9]; u16 fan[3]; u16 fan_low[3]; - u16 fan_target[3]; - u8 fan_ctrl[3]; - u8 pwm[3]; - u8 pwm_freq[3]; + u8 fan_enabled; /* Read once at init time */ u8 temp[3]; u8 temp_high[3]; u8 temp_hyst[3]; @@ -172,11 +151,6 @@ struct f71805f_data { unsigned long alarms; }; -struct f71805f_sio_data { - enum kinds kind; - u8 fnsel1; -}; - static inline long in_from_reg(u8 reg) { return (reg * 8); @@ -226,33 +200,6 @@ static inline u16 fan_to_reg(long rpm) return (1500000 / rpm); } -static inline unsigned long pwm_freq_from_reg(u8 reg) -{ - unsigned long clock = (reg & 0x80) ? 48000000UL : 1000000UL; - - reg &= 0x7f; - if (reg == 0) - reg++; - return clock / (reg << 8); -} - -static inline u8 pwm_freq_to_reg(unsigned long val) -{ - if (val >= 187500) /* The highest we can do */ - return 0x80; - if (val >= 1475) /* Use 48 MHz clock */ - return 0x80 | (48000000UL / (val << 8)); - if (val < 31) /* The lowest we can do */ - return 0x7f; - else /* Use 1 MHz clock */ - return 1000000UL / (val << 8); -} - -static inline int pwm_mode_from_reg(u8 reg) -{ - return !(reg & FAN_CTRL_DC_MODE); -} - static inline long temp_from_reg(u8 reg) { return (reg * 1000); @@ -327,21 +274,16 @@ static struct f71805f_data *f71805f_update_device(struct device *dev) /* Limit registers cache is refreshed after 60 seconds */ if (time_after(jiffies, data->last_updated + 60 * HZ) || !data->valid) { - for (nr = 0; nr < 11; nr++) { - if (!(data->has_in & (1 << nr))) - continue; + for (nr = 0; nr < 9; nr++) { data->in_high[nr] = f71805f_read8(data, F71805F_REG_IN_HIGH(nr)); data->in_low[nr] = f71805f_read8(data, F71805F_REG_IN_LOW(nr)); } for (nr = 0; nr < 3; nr++) { - data->fan_low[nr] = f71805f_read16(data, - F71805F_REG_FAN_LOW(nr)); - data->fan_target[nr] = f71805f_read16(data, - F71805F_REG_FAN_TARGET(nr)); - data->pwm_freq[nr] = f71805f_read8(data, - F71805F_REG_PWM_FREQ(nr)); + if (data->fan_enabled & (1 << nr)) + data->fan_low[nr] = f71805f_read16(data, + F71805F_REG_FAN_LOW(nr)); } for (nr = 0; nr < 3; nr++) { data->temp_high[nr] = f71805f_read8(data, @@ -357,19 +299,14 @@ static struct f71805f_data *f71805f_update_device(struct device *dev) /* Measurement registers cache is refreshed after 1 second */ if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { - for (nr = 0; nr < 11; nr++) { - if (!(data->has_in & (1 << nr))) - continue; + for (nr = 0; nr < 9; nr++) { data->in[nr] = f71805f_read8(data, F71805F_REG_IN(nr)); } for (nr = 0; nr < 3; nr++) { - data->fan[nr] = f71805f_read16(data, - F71805F_REG_FAN(nr)); - data->fan_ctrl[nr] = f71805f_read8(data, - F71805F_REG_FAN_CTRL(nr)); - data->pwm[nr] = f71805f_read8(data, - F71805F_REG_PWM_DUTY(nr)); + if (data->fan_enabled & (1 << nr)) + data->fan[nr] = f71805f_read16(data, + F71805F_REG_FAN(nr)); } for (nr = 0; nr < 3; nr++) { data->temp[nr] = f71805f_read8(data, @@ -396,43 +333,35 @@ static ssize_t show_in0(struct device *dev, struct device_attribute *devattr, char *buf) { struct f71805f_data *data = f71805f_update_device(dev); - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - int nr = attr->index; - return sprintf(buf, "%ld\n", in0_from_reg(data->in[nr])); + return sprintf(buf, "%ld\n", in0_from_reg(data->in[0])); } static ssize_t show_in0_max(struct device *dev, struct device_attribute *devattr, char *buf) { struct f71805f_data *data = f71805f_update_device(dev); - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - int nr = attr->index; - return sprintf(buf, "%ld\n", in0_from_reg(data->in_high[nr])); + return sprintf(buf, "%ld\n", in0_from_reg(data->in_high[0])); } static ssize_t show_in0_min(struct device *dev, struct device_attribute *devattr, char *buf) { struct f71805f_data *data = f71805f_update_device(dev); - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - int nr = attr->index; - return sprintf(buf, "%ld\n", in0_from_reg(data->in_low[nr])); + return sprintf(buf, "%ld\n", in0_from_reg(data->in_low[0])); } static ssize_t set_in0_max(struct device *dev, struct device_attribute *devattr, const char *buf, size_t count) { struct f71805f_data *data = dev_get_drvdata(dev); - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - int nr = attr->index; long val = simple_strtol(buf, NULL, 10); mutex_lock(&data->update_lock); - data->in_high[nr] = in0_to_reg(val); - f71805f_write8(data, F71805F_REG_IN_HIGH(nr), data->in_high[nr]); + data->in_high[0] = in0_to_reg(val); + f71805f_write8(data, F71805F_REG_IN_HIGH(0), data->in_high[0]); mutex_unlock(&data->update_lock); return count; @@ -442,13 +371,11 @@ static ssize_t set_in0_min(struct device *dev, struct device_attribute *devattr, const char *buf, size_t count) { struct f71805f_data *data = dev_get_drvdata(dev); - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - int nr = attr->index; long val = simple_strtol(buf, NULL, 10); mutex_lock(&data->update_lock); - data->in_low[nr] = in0_to_reg(val); - f71805f_write8(data, F71805F_REG_IN_LOW(nr), data->in_low[nr]); + data->in_low[0] = in0_to_reg(val); + f71805f_write8(data, F71805F_REG_IN_LOW(0), data->in_low[0]); mutex_unlock(&data->update_lock); return count; @@ -536,16 +463,6 @@ static ssize_t show_fan_min(struct device *dev, struct device_attribute return sprintf(buf, "%ld\n", fan_from_reg(data->fan_low[nr])); } -static ssize_t show_fan_target(struct device *dev, struct device_attribute - *devattr, char *buf) -{ - struct f71805f_data *data = f71805f_update_device(dev); - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - int nr = attr->index; - - return sprintf(buf, "%ld\n", fan_from_reg(data->fan_target[nr])); -} - static ssize_t set_fan_min(struct device *dev, struct device_attribute *devattr, const char *buf, size_t count) { @@ -562,157 +479,6 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute return count; } -static ssize_t set_fan_target(struct device *dev, struct device_attribute - *devattr, const char *buf, size_t count) -{ - struct f71805f_data *data = dev_get_drvdata(dev); - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - int nr = attr->index; - long val = simple_strtol(buf, NULL, 10); - - mutex_lock(&data->update_lock); - data->fan_target[nr] = fan_to_reg(val); - f71805f_write16(data, F71805F_REG_FAN_TARGET(nr), - data->fan_target[nr]); - mutex_unlock(&data->update_lock); - - return count; -} - -static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr, - char *buf) -{ - struct f71805f_data *data = f71805f_update_device(dev); - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - int nr = attr->index; - - return sprintf(buf, "%d\n", (int)data->pwm[nr]); -} - -static ssize_t show_pwm_enable(struct device *dev, struct device_attribute - *devattr, char *buf) -{ - struct f71805f_data *data = f71805f_update_device(dev); - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - int nr = attr->index; - int mode; - - switch (data->fan_ctrl[nr] & FAN_CTRL_MODE_MASK) { - case FAN_CTRL_MODE_SPEED: - mode = 3; - break; - case FAN_CTRL_MODE_TEMPERATURE: - mode = 2; - break; - default: /* MANUAL */ - mode = 1; - } - - return sprintf(buf, "%d\n", mode); -} - -static ssize_t show_pwm_freq(struct device *dev, struct device_attribute - *devattr, char *buf) -{ - struct f71805f_data *data = f71805f_update_device(dev); - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - int nr = attr->index; - - return sprintf(buf, "%lu\n", pwm_freq_from_reg(data->pwm_freq[nr])); -} - -static ssize_t show_pwm_mode(struct device *dev, struct device_attribute - *devattr, char *buf) -{ - struct f71805f_data *data = f71805f_update_device(dev); - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - int nr = attr->index; - - return sprintf(buf, "%d\n", pwm_mode_from_reg(data->fan_ctrl[nr])); -} - -static ssize_t set_pwm(struct device *dev, struct device_attribute *devattr, - const char *buf, size_t count) -{ - struct f71805f_data *data = dev_get_drvdata(dev); - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - int nr = attr->index; - unsigned long val = simple_strtoul(buf, NULL, 10); - - if (val > 255) - return -EINVAL; - - mutex_lock(&data->update_lock); - data->pwm[nr] = val; - f71805f_write8(data, F71805F_REG_PWM_DUTY(nr), data->pwm[nr]); - mutex_unlock(&data->update_lock); - - return count; -} - -static struct attribute *f71805f_attr_pwm[]; - -static ssize_t set_pwm_enable(struct device *dev, struct device_attribute - *devattr, const char *buf, size_t count) -{ - struct f71805f_data *data = dev_get_drvdata(dev); - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - int nr = attr->index; - unsigned long val = simple_strtoul(buf, NULL, 10); - u8 reg; - - if (val < 1 || val > 3) - return -EINVAL; - - if (val > 1) { /* Automatic mode, user can't set PWM value */ - if (sysfs_chmod_file(&dev->kobj, f71805f_attr_pwm[nr], - S_IRUGO)) - dev_dbg(dev, "chmod -w pwm%d failed\n", nr + 1); - } - - mutex_lock(&data->update_lock); - reg = f71805f_read8(data, F71805F_REG_FAN_CTRL(nr)) - & ~FAN_CTRL_MODE_MASK; - switch (val) { - case 1: - reg |= FAN_CTRL_MODE_MANUAL; - break; - case 2: - reg |= FAN_CTRL_MODE_TEMPERATURE; - break; - case 3: - reg |= FAN_CTRL_MODE_SPEED; - break; - } - data->fan_ctrl[nr] = reg; - f71805f_write8(data, F71805F_REG_FAN_CTRL(nr), reg); - mutex_unlock(&data->update_lock); - - if (val == 1) { /* Manual mode, user can set PWM value */ - if (sysfs_chmod_file(&dev->kobj, f71805f_attr_pwm[nr], - S_IRUGO | S_IWUSR)) - dev_dbg(dev, "chmod +w pwm%d failed\n", nr + 1); - } - - return count; -} - -static ssize_t set_pwm_freq(struct device *dev, struct device_attribute - *devattr, const char *buf, size_t count) -{ - struct f71805f_data *data = dev_get_drvdata(dev); - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - int nr = attr->index; - unsigned long val = simple_strtoul(buf, NULL, 10); - - mutex_lock(&data->update_lock); - data->pwm_freq[nr] = pwm_freq_to_reg(val); - f71805f_write8(data, F71805F_REG_PWM_FREQ(nr), data->pwm_freq[nr]); - mutex_unlock(&data->update_lock); - - return count; -} - static ssize_t show_temp(struct device *dev, struct device_attribute *devattr, char *buf) { @@ -791,7 +557,7 @@ static ssize_t show_alarms_in(struct device *dev, struct device_attribute { struct f71805f_data *data = f71805f_update_device(dev); - return sprintf(buf, "%lu\n", data->alarms & 0x7ff); + return sprintf(buf, "%lu\n", data->alarms & 0x1ff); } static ssize_t show_alarms_fan(struct device *dev, struct device_attribute @@ -828,11 +594,9 @@ static ssize_t show_name(struct device *dev, struct device_attribute return sprintf(buf, "%s\n", data->name); } -static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, show_in0, NULL, 0); -static SENSOR_DEVICE_ATTR(in0_max, S_IRUGO| S_IWUSR, - show_in0_max, set_in0_max, 0); -static SENSOR_DEVICE_ATTR(in0_min, S_IRUGO| S_IWUSR, - show_in0_min, set_in0_min, 0); +static DEVICE_ATTR(in0_input, S_IRUGO, show_in0, NULL); +static DEVICE_ATTR(in0_max, S_IRUGO| S_IWUSR, show_in0_max, set_in0_max); +static DEVICE_ATTR(in0_min, S_IRUGO| S_IWUSR, show_in0_min, set_in0_min); static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, show_in, NULL, 1); static SENSOR_DEVICE_ATTR(in1_max, S_IRUGO | S_IWUSR, show_in_max, set_in_max, 1); @@ -873,32 +637,16 @@ static SENSOR_DEVICE_ATTR(in8_max, S_IRUGO | S_IWUSR, show_in_max, set_in_max, 8); static SENSOR_DEVICE_ATTR(in8_min, S_IRUGO | S_IWUSR, show_in_min, set_in_min, 8); -static SENSOR_DEVICE_ATTR(in9_input, S_IRUGO, show_in0, NULL, 9); -static SENSOR_DEVICE_ATTR(in9_max, S_IRUGO | S_IWUSR, - show_in0_max, set_in0_max, 9); -static SENSOR_DEVICE_ATTR(in9_min, S_IRUGO | S_IWUSR, - show_in0_min, set_in0_min, 9); -static SENSOR_DEVICE_ATTR(in10_input, S_IRUGO, show_in0, NULL, 10); -static SENSOR_DEVICE_ATTR(in10_max, S_IRUGO | S_IWUSR, - show_in0_max, set_in0_max, 10); -static SENSOR_DEVICE_ATTR(in10_min, S_IRUGO | S_IWUSR, - show_in0_min, set_in0_min, 10); static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0); static SENSOR_DEVICE_ATTR(fan1_min, S_IRUGO | S_IWUSR, show_fan_min, set_fan_min, 0); -static SENSOR_DEVICE_ATTR(fan1_target, S_IRUGO | S_IWUSR, - show_fan_target, set_fan_target, 0); static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 1); static SENSOR_DEVICE_ATTR(fan2_min, S_IRUGO | S_IWUSR, show_fan_min, set_fan_min, 1); -static SENSOR_DEVICE_ATTR(fan2_target, S_IRUGO | S_IWUSR, - show_fan_target, set_fan_target, 1); static SENSOR_DEVICE_ATTR(fan3_input, S_IRUGO, show_fan, NULL, 2); static SENSOR_DEVICE_ATTR(fan3_min, S_IRUGO | S_IWUSR, show_fan_min, set_fan_min, 2); -static SENSOR_DEVICE_ATTR(fan3_target, S_IRUGO | S_IWUSR, - show_fan_target, set_fan_target, 2); static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0); static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO | S_IWUSR, @@ -919,27 +667,6 @@ static SENSOR_DEVICE_ATTR(temp3_max_hyst, S_IRUGO | S_IWUSR, show_temp_hyst, set_temp_hyst, 2); static SENSOR_DEVICE_ATTR(temp3_type, S_IRUGO, show_temp_type, NULL, 2); -/* pwm (value) files are created read-only, write permission is - then added or removed dynamically as needed */ -static SENSOR_DEVICE_ATTR(pwm1, S_IRUGO, show_pwm, set_pwm, 0); -static SENSOR_DEVICE_ATTR(pwm1_enable, S_IRUGO | S_IWUSR, - show_pwm_enable, set_pwm_enable, 0); -static SENSOR_DEVICE_ATTR(pwm1_freq, S_IRUGO | S_IWUSR, - show_pwm_freq, set_pwm_freq, 0); -static SENSOR_DEVICE_ATTR(pwm1_mode, S_IRUGO, show_pwm_mode, NULL, 0); -static SENSOR_DEVICE_ATTR(pwm2, S_IRUGO, show_pwm, set_pwm, 1); -static SENSOR_DEVICE_ATTR(pwm2_enable, S_IRUGO | S_IWUSR, - show_pwm_enable, set_pwm_enable, 1); -static SENSOR_DEVICE_ATTR(pwm2_freq, S_IRUGO | S_IWUSR, - show_pwm_freq, set_pwm_freq, 1); -static SENSOR_DEVICE_ATTR(pwm2_mode, S_IRUGO, show_pwm_mode, NULL, 1); -static SENSOR_DEVICE_ATTR(pwm3, S_IRUGO, show_pwm, set_pwm, 2); -static SENSOR_DEVICE_ATTR(pwm3_enable, S_IRUGO | S_IWUSR, - show_pwm_enable, set_pwm_enable, 2); -static SENSOR_DEVICE_ATTR(pwm3_freq, S_IRUGO | S_IWUSR, - show_pwm_freq, set_pwm_freq, 2); -static SENSOR_DEVICE_ATTR(pwm3_mode, S_IRUGO, show_pwm_mode, NULL, 2); - static SENSOR_DEVICE_ATTR(in0_alarm, S_IRUGO, show_alarm, NULL, 0); static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, show_alarm, NULL, 1); static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, 2); @@ -949,8 +676,6 @@ static SENSOR_DEVICE_ATTR(in5_alarm, S_IRUGO, show_alarm, NULL, 5); static SENSOR_DEVICE_ATTR(in6_alarm, S_IRUGO, show_alarm, NULL, 6); static SENSOR_DEVICE_ATTR(in7_alarm, S_IRUGO, show_alarm, NULL, 7); static SENSOR_DEVICE_ATTR(in8_alarm, S_IRUGO, show_alarm, NULL, 8); -static SENSOR_DEVICE_ATTR(in9_alarm, S_IRUGO, show_alarm, NULL, 9); -static SENSOR_DEVICE_ATTR(in10_alarm, S_IRUGO, show_alarm, NULL, 10); static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 11); static SENSOR_DEVICE_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, 12); static SENSOR_DEVICE_ATTR(temp3_alarm, S_IRUGO, show_alarm, NULL, 13); @@ -964,9 +689,9 @@ static DEVICE_ATTR(alarms_temp, S_IRUGO, show_alarms_temp, NULL); static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); static struct attribute *f71805f_attributes[] = { - &sensor_dev_attr_in0_input.dev_attr.attr, - &sensor_dev_attr_in0_max.dev_attr.attr, - &sensor_dev_attr_in0_min.dev_attr.attr, + &dev_attr_in0_input.attr, + &dev_attr_in0_max.attr, + &dev_attr_in0_min.attr, &sensor_dev_attr_in1_input.dev_attr.attr, &sensor_dev_attr_in1_max.dev_attr.attr, &sensor_dev_attr_in1_min.dev_attr.attr, @@ -976,6 +701,9 @@ static struct attribute *f71805f_attributes[] = { &sensor_dev_attr_in3_input.dev_attr.attr, &sensor_dev_attr_in3_max.dev_attr.attr, &sensor_dev_attr_in3_min.dev_attr.attr, + &sensor_dev_attr_in4_input.dev_attr.attr, + &sensor_dev_attr_in4_max.dev_attr.attr, + &sensor_dev_attr_in4_min.dev_attr.attr, &sensor_dev_attr_in5_input.dev_attr.attr, &sensor_dev_attr_in5_max.dev_attr.attr, &sensor_dev_attr_in5_min.dev_attr.attr, @@ -985,29 +713,9 @@ static struct attribute *f71805f_attributes[] = { &sensor_dev_attr_in7_input.dev_attr.attr, &sensor_dev_attr_in7_max.dev_attr.attr, &sensor_dev_attr_in7_min.dev_attr.attr, - - &sensor_dev_attr_fan1_input.dev_attr.attr, - &sensor_dev_attr_fan1_min.dev_attr.attr, - &sensor_dev_attr_fan1_alarm.dev_attr.attr, - &sensor_dev_attr_fan1_target.dev_attr.attr, - &sensor_dev_attr_fan2_input.dev_attr.attr, - &sensor_dev_attr_fan2_min.dev_attr.attr, - &sensor_dev_attr_fan2_alarm.dev_attr.attr, - &sensor_dev_attr_fan2_target.dev_attr.attr, - &sensor_dev_attr_fan3_input.dev_attr.attr, - &sensor_dev_attr_fan3_min.dev_attr.attr, - &sensor_dev_attr_fan3_alarm.dev_attr.attr, - &sensor_dev_attr_fan3_target.dev_attr.attr, - - &sensor_dev_attr_pwm1.dev_attr.attr, - &sensor_dev_attr_pwm1_enable.dev_attr.attr, - &sensor_dev_attr_pwm1_mode.dev_attr.attr, - &sensor_dev_attr_pwm2.dev_attr.attr, - &sensor_dev_attr_pwm2_enable.dev_attr.attr, - &sensor_dev_attr_pwm2_mode.dev_attr.attr, - &sensor_dev_attr_pwm3.dev_attr.attr, - &sensor_dev_attr_pwm3_enable.dev_attr.attr, - &sensor_dev_attr_pwm3_mode.dev_attr.attr, + &sensor_dev_attr_in8_input.dev_attr.attr, + &sensor_dev_attr_in8_max.dev_attr.attr, + &sensor_dev_attr_in8_min.dev_attr.attr, &sensor_dev_attr_temp1_input.dev_attr.attr, &sensor_dev_attr_temp1_max.dev_attr.attr, @@ -1026,9 +734,11 @@ static struct attribute *f71805f_attributes[] = { &sensor_dev_attr_in1_alarm.dev_attr.attr, &sensor_dev_attr_in2_alarm.dev_attr.attr, &sensor_dev_attr_in3_alarm.dev_attr.attr, + &sensor_dev_attr_in4_alarm.dev_attr.attr, &sensor_dev_attr_in5_alarm.dev_attr.attr, &sensor_dev_attr_in6_alarm.dev_attr.attr, &sensor_dev_attr_in7_alarm.dev_attr.attr, + &sensor_dev_attr_in8_alarm.dev_attr.attr, &dev_attr_alarms_in.attr, &sensor_dev_attr_temp1_alarm.dev_attr.attr, &sensor_dev_attr_temp2_alarm.dev_attr.attr, @@ -1044,59 +754,29 @@ static const struct attribute_group f71805f_group = { .attrs = f71805f_attributes, }; -static struct attribute *f71805f_attributes_optin[4][5] = { +static struct attribute *f71805f_attributes_fan[3][4] = { { - &sensor_dev_attr_in4_input.dev_attr.attr, - &sensor_dev_attr_in4_max.dev_attr.attr, - &sensor_dev_attr_in4_min.dev_attr.attr, - &sensor_dev_attr_in4_alarm.dev_attr.attr, - NULL - }, { - &sensor_dev_attr_in8_input.dev_attr.attr, - &sensor_dev_attr_in8_max.dev_attr.attr, - &sensor_dev_attr_in8_min.dev_attr.attr, - &sensor_dev_attr_in8_alarm.dev_attr.attr, + &sensor_dev_attr_fan1_input.dev_attr.attr, + &sensor_dev_attr_fan1_min.dev_attr.attr, + &sensor_dev_attr_fan1_alarm.dev_attr.attr, NULL }, { - &sensor_dev_attr_in9_input.dev_attr.attr, - &sensor_dev_attr_in9_max.dev_attr.attr, - &sensor_dev_attr_in9_min.dev_attr.attr, - &sensor_dev_attr_in9_alarm.dev_attr.attr, + &sensor_dev_attr_fan2_input.dev_attr.attr, + &sensor_dev_attr_fan2_min.dev_attr.attr, + &sensor_dev_attr_fan2_alarm.dev_attr.attr, NULL }, { - &sensor_dev_attr_in10_input.dev_attr.attr, - &sensor_dev_attr_in10_max.dev_attr.attr, - &sensor_dev_attr_in10_min.dev_attr.attr, - &sensor_dev_attr_in10_alarm.dev_attr.attr, + &sensor_dev_attr_fan3_input.dev_attr.attr, + &sensor_dev_attr_fan3_min.dev_attr.attr, + &sensor_dev_attr_fan3_alarm.dev_attr.attr, NULL } }; -static const struct attribute_group f71805f_group_optin[4] = { - { .attrs = f71805f_attributes_optin[0] }, - { .attrs = f71805f_attributes_optin[1] }, - { .attrs = f71805f_attributes_optin[2] }, - { .attrs = f71805f_attributes_optin[3] }, -}; - -/* We don't include pwm_freq files in the arrays above, because they must be - created conditionally (only if pwm_mode is 1 == PWM) */ -static struct attribute *f71805f_attributes_pwm_freq[] = { - &sensor_dev_attr_pwm1_freq.dev_attr.attr, - &sensor_dev_attr_pwm2_freq.dev_attr.attr, - &sensor_dev_attr_pwm3_freq.dev_attr.attr, - NULL -}; - -static const struct attribute_group f71805f_group_pwm_freq = { - .attrs = f71805f_attributes_pwm_freq, -}; - -/* We also need an indexed access to pwmN files to toggle writability */ -static struct attribute *f71805f_attr_pwm[] = { - &sensor_dev_attr_pwm1.dev_attr.attr, - &sensor_dev_attr_pwm2.dev_attr.attr, - &sensor_dev_attr_pwm3.dev_attr.attr, +static const struct attribute_group f71805f_group_fan[3] = { + { .attrs = f71805f_attributes_fan[0] }, + { .attrs = f71805f_attributes_fan[1] }, + { .attrs = f71805f_attributes_fan[2] }, }; /* @@ -1118,30 +798,18 @@ static void __devinit f71805f_init_device(struct f71805f_data *data) /* Fan monitoring can be disabled. If it is, we won't be polling the register values, and won't create the related sysfs files. */ for (i = 0; i < 3; i++) { - data->fan_ctrl[i] = f71805f_read8(data, - F71805F_REG_FAN_CTRL(i)); - /* Clear latch full bit, else "speed mode" fan speed control - doesn't work */ - if (data->fan_ctrl[i] & FAN_CTRL_LATCH_FULL) { - data->fan_ctrl[i] &= ~FAN_CTRL_LATCH_FULL; - f71805f_write8(data, F71805F_REG_FAN_CTRL(i), - data->fan_ctrl[i]); - } + reg = f71805f_read8(data, F71805F_REG_FAN_CTRL(i)); + if (!(reg & 0x80)) + data->fan_enabled |= (1 << i); } } static int __devinit f71805f_probe(struct platform_device *pdev) { - struct f71805f_sio_data *sio_data = pdev->dev.platform_data; struct f71805f_data *data; struct resource *res; int i, err; - static const char *names[] = { - "f71805f", - "f71872f", - }; - if (!(data = kzalloc(sizeof(struct f71805f_data), GFP_KERNEL))) { err = -ENOMEM; printk(KERN_ERR DRVNAME ": Out of memory\n"); @@ -1151,69 +819,24 @@ static int __devinit f71805f_probe(struct platform_device *pdev) res = platform_get_resource(pdev, IORESOURCE_IO, 0); data->addr = res->start; mutex_init(&data->lock); - data->name = names[sio_data->kind]; + data->name = "f71805f"; mutex_init(&data->update_lock); platform_set_drvdata(pdev, data); - /* Some voltage inputs depend on chip model and configuration */ - switch (sio_data->kind) { - case f71805f: - data->has_in = 0x1ff; - break; - case f71872f: - data->has_in = 0x6ef; - if (sio_data->fnsel1 & 0x01) - data->has_in |= (1 << 4); /* in4 */ - if (sio_data->fnsel1 & 0x02) - data->has_in |= (1 << 8); /* in8 */ - break; - } - /* Initialize the F71805F chip */ f71805f_init_device(data); /* Register sysfs interface files */ if ((err = sysfs_create_group(&pdev->dev.kobj, &f71805f_group))) goto exit_free; - if (data->has_in & (1 << 4)) { /* in4 */ - if ((err = sysfs_create_group(&pdev->dev.kobj, - &f71805f_group_optin[0]))) - goto exit_remove_files; - } - if (data->has_in & (1 << 8)) { /* in8 */ - if ((err = sysfs_create_group(&pdev->dev.kobj, - &f71805f_group_optin[1]))) - goto exit_remove_files; - } - if (data->has_in & (1 << 9)) { /* in9 (F71872F/FG only) */ - if ((err = sysfs_create_group(&pdev->dev.kobj, - &f71805f_group_optin[2]))) - goto exit_remove_files; - } - if (data->has_in & (1 << 10)) { /* in9 (F71872F/FG only) */ + for (i = 0; i < 3; i++) { + if (!(data->fan_enabled & (1 << i))) + continue; if ((err = sysfs_create_group(&pdev->dev.kobj, - &f71805f_group_optin[3]))) + &f71805f_group_fan[i]))) goto exit_remove_files; } - for (i = 0; i < 3; i++) { - /* If control mode is PWM, create pwm_freq file */ - if (!(data->fan_ctrl[i] & FAN_CTRL_DC_MODE)) { - if ((err = sysfs_create_file(&pdev->dev.kobj, - f71805f_attributes_pwm_freq[i]))) - goto exit_remove_files; - } - /* If PWM is in manual mode, add write permission */ - if (data->fan_ctrl[i] & FAN_CTRL_MODE_MANUAL) { - if ((err = sysfs_chmod_file(&pdev->dev.kobj, - f71805f_attr_pwm[i], - S_IRUGO | S_IWUSR))) { - dev_err(&pdev->dev, "chmod +w pwm%d failed\n", - i + 1); - goto exit_remove_files; - } - } - } data->class_dev = hwmon_device_register(&pdev->dev); if (IS_ERR(data->class_dev)) { @@ -1226,9 +849,8 @@ static int __devinit f71805f_probe(struct platform_device *pdev) exit_remove_files: sysfs_remove_group(&pdev->dev.kobj, &f71805f_group); - for (i = 0; i < 4; i++) - sysfs_remove_group(&pdev->dev.kobj, &f71805f_group_optin[i]); - sysfs_remove_group(&pdev->dev.kobj, &f71805f_group_pwm_freq); + for (i = 0; i < 3; i++) + sysfs_remove_group(&pdev->dev.kobj, &f71805f_group_fan[i]); exit_free: platform_set_drvdata(pdev, NULL); kfree(data); @@ -1244,9 +866,8 @@ static int __devexit f71805f_remove(struct platform_device *pdev) platform_set_drvdata(pdev, NULL); hwmon_device_unregister(data->class_dev); sysfs_remove_group(&pdev->dev.kobj, &f71805f_group); - for (i = 0; i < 4; i++) - sysfs_remove_group(&pdev->dev.kobj, &f71805f_group_optin[i]); - sysfs_remove_group(&pdev->dev.kobj, &f71805f_group_pwm_freq); + for (i = 0; i < 3; i++) + sysfs_remove_group(&pdev->dev.kobj, &f71805f_group_fan[i]); kfree(data); return 0; @@ -1261,8 +882,7 @@ static struct platform_driver f71805f_driver = { .remove = __devexit_p(f71805f_remove), }; -static int __init f71805f_device_add(unsigned short address, - const struct f71805f_sio_data *sio_data) +static int __init f71805f_device_add(unsigned short address) { struct resource res = { .start = address, @@ -1286,45 +906,26 @@ static int __init f71805f_device_add(unsigned short address, goto exit_device_put; } - pdev->dev.platform_data = kmalloc(sizeof(struct f71805f_sio_data), - GFP_KERNEL); - if (!pdev->dev.platform_data) { - err = -ENOMEM; - printk(KERN_ERR DRVNAME ": Platform data allocation failed\n"); - goto exit_device_put; - } - memcpy(pdev->dev.platform_data, sio_data, - sizeof(struct f71805f_sio_data)); - err = platform_device_add(pdev); if (err) { printk(KERN_ERR DRVNAME ": Device addition failed (%d)\n", err); - goto exit_kfree_data; + goto exit_device_put; } return 0; -exit_kfree_data: - kfree(pdev->dev.platform_data); - pdev->dev.platform_data = NULL; exit_device_put: platform_device_put(pdev); exit: return err; } -static int __init f71805f_find(int sioaddr, unsigned short *address, - struct f71805f_sio_data *sio_data) +static int __init f71805f_find(int sioaddr, unsigned short *address) { int err = -ENODEV; u16 devid; - static const char *names[] = { - "F71805F/FG", - "F71872F/FG", - }; - superio_enter(sioaddr); devid = superio_inw(sioaddr, SIO_REG_MANID); @@ -1332,15 +933,7 @@ static int __init f71805f_find(int sioaddr, unsigned short *address, goto exit; devid = superio_inw(sioaddr, SIO_REG_DEVID); - switch (devid) { - case SIO_F71805F_ID: - sio_data->kind = f71805f; - break; - case SIO_F71872F_ID: - sio_data->kind = f71872f; - sio_data->fnsel1 = superio_inb(sioaddr, SIO_REG_FNSEL1); - break; - default: + if (devid != SIO_F71805F_ID) { printk(KERN_INFO DRVNAME ": Unsupported Fintek device, " "skipping\n"); goto exit; @@ -1359,12 +952,10 @@ static int __init f71805f_find(int sioaddr, unsigned short *address, "skipping\n"); goto exit; } - *address &= ~(REGION_LENGTH - 1); /* Ignore 3 LSB */ err = 0; - printk(KERN_INFO DRVNAME ": Found %s chip at %#x, revision %u\n", - names[sio_data->kind], *address, - superio_inb(sioaddr, SIO_REG_DEVREV)); + printk(KERN_INFO DRVNAME ": Found F71805F chip at %#x, revision %u\n", + *address, superio_inb(sioaddr, SIO_REG_DEVREV)); exit: superio_exit(sioaddr); @@ -1375,10 +966,9 @@ static int __init f71805f_init(void) { int err; unsigned short address; - struct f71805f_sio_data sio_data; - if (f71805f_find(0x2e, &address, &sio_data) - && f71805f_find(0x4e, &address, &sio_data)) + if (f71805f_find(0x2e, &address) + && f71805f_find(0x4e, &address)) return -ENODEV; err = platform_driver_register(&f71805f_driver); @@ -1386,7 +976,7 @@ static int __init f71805f_init(void) goto exit; /* Sets global pdev as a side effect */ - err = f71805f_device_add(address, &sio_data); + err = f71805f_device_add(address); if (err) goto exit_driver; @@ -1400,16 +990,13 @@ static int __init f71805f_init(void) static void __exit f71805f_exit(void) { - kfree(pdev->dev.platform_data); - pdev->dev.platform_data = NULL; platform_device_unregister(pdev); - platform_driver_unregister(&f71805f_driver); } MODULE_AUTHOR("Jean Delvare "); MODULE_LICENSE("GPL"); -MODULE_DESCRIPTION("F71805F/F71872F hardware monitoring driver"); +MODULE_DESCRIPTION("F71805F hardware monitoring driver"); module_init(f71805f_init); module_exit(f71805f_exit); diff --git a/trunk/drivers/hwmon/hdaps.c b/trunk/drivers/hwmon/hdaps.c index bf759ea545ac..e8ef62b83d6b 100644 --- a/trunk/drivers/hwmon/hdaps.c +++ b/trunk/drivers/hwmon/hdaps.c @@ -478,64 +478,74 @@ static struct attribute_group hdaps_attribute_group = { /* Module stuff */ /* hdaps_dmi_match - found a match. return one, short-circuiting the hunt. */ -static int __init hdaps_dmi_match(struct dmi_system_id *id) +static int hdaps_dmi_match(struct dmi_system_id *id) { printk(KERN_INFO "hdaps: %s detected.\n", id->ident); return 1; } /* hdaps_dmi_match_invert - found an inverted match. */ -static int __init hdaps_dmi_match_invert(struct dmi_system_id *id) +static int hdaps_dmi_match_invert(struct dmi_system_id *id) { hdaps_invert = 1; printk(KERN_INFO "hdaps: inverting axis readings.\n"); return hdaps_dmi_match(id); } -#define HDAPS_DMI_MATCH_NORMAL(vendor, model) { \ - .ident = vendor " " model, \ +#define HDAPS_DMI_MATCH_NORMAL(model) { \ + .ident = "IBM " model, \ .callback = hdaps_dmi_match, \ .matches = { \ - DMI_MATCH(DMI_BOARD_VENDOR, vendor), \ + DMI_MATCH(DMI_BOARD_VENDOR, "IBM"), \ DMI_MATCH(DMI_PRODUCT_VERSION, model) \ } \ } -#define HDAPS_DMI_MATCH_INVERT(vendor, model) { \ - .ident = vendor " " model, \ +#define HDAPS_DMI_MATCH_INVERT(model) { \ + .ident = "IBM " model, \ .callback = hdaps_dmi_match_invert, \ .matches = { \ - DMI_MATCH(DMI_BOARD_VENDOR, vendor), \ + DMI_MATCH(DMI_BOARD_VENDOR, "IBM"), \ DMI_MATCH(DMI_PRODUCT_VERSION, model) \ } \ } -/* Note that HDAPS_DMI_MATCH_NORMAL("ThinkPad T42") would match - "ThinkPad T42p", so the order of the entries matters. - If your ThinkPad is not recognized, please update to latest - BIOS. This is especially the case for some R52 ThinkPads. */ -static struct dmi_system_id __initdata hdaps_whitelist[] = { - HDAPS_DMI_MATCH_INVERT("IBM", "ThinkPad R50p"), - HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad R50"), - HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad R51"), - HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad R52"), - HDAPS_DMI_MATCH_INVERT("IBM", "ThinkPad T41p"), - HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad T41"), - HDAPS_DMI_MATCH_INVERT("IBM", "ThinkPad T42p"), - HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad T42"), - HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad T43"), - HDAPS_DMI_MATCH_INVERT("LENOVO", "ThinkPad T60"), - HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad X40"), - HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad X41"), - HDAPS_DMI_MATCH_INVERT("LENOVO", "ThinkPad X60"), - HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad Z60m"), - { .ident = NULL } -}; +#define HDAPS_DMI_MATCH_LENOVO(model) { \ + .ident = "Lenovo " model, \ + .callback = hdaps_dmi_match_invert, \ + .matches = { \ + DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"), \ + DMI_MATCH(DMI_PRODUCT_VERSION, model) \ + } \ +} static int __init hdaps_init(void) { int ret; + /* Note that HDAPS_DMI_MATCH_NORMAL("ThinkPad T42") would match + "ThinkPad T42p", so the order of the entries matters */ + struct dmi_system_id hdaps_whitelist[] = { + HDAPS_DMI_MATCH_NORMAL("ThinkPad H"), + HDAPS_DMI_MATCH_INVERT("ThinkPad R50p"), + HDAPS_DMI_MATCH_NORMAL("ThinkPad R50"), + HDAPS_DMI_MATCH_NORMAL("ThinkPad R51"), + HDAPS_DMI_MATCH_NORMAL("ThinkPad R52"), + HDAPS_DMI_MATCH_NORMAL("ThinkPad H"), /* R52 (1846AQG) */ + HDAPS_DMI_MATCH_INVERT("ThinkPad T41p"), + HDAPS_DMI_MATCH_NORMAL("ThinkPad T41"), + HDAPS_DMI_MATCH_INVERT("ThinkPad T42p"), + HDAPS_DMI_MATCH_NORMAL("ThinkPad T42"), + HDAPS_DMI_MATCH_NORMAL("ThinkPad T43"), + HDAPS_DMI_MATCH_LENOVO("ThinkPad T60p"), + HDAPS_DMI_MATCH_LENOVO("ThinkPad T60"), + HDAPS_DMI_MATCH_NORMAL("ThinkPad X40"), + HDAPS_DMI_MATCH_NORMAL("ThinkPad X41"), + HDAPS_DMI_MATCH_LENOVO("ThinkPad X60"), + HDAPS_DMI_MATCH_NORMAL("ThinkPad Z60m"), + { .ident = NULL } + }; + if (!dmi_check_system(hdaps_whitelist)) { printk(KERN_WARNING "hdaps: supported laptop not found!\n"); ret = -ENODEV; diff --git a/trunk/drivers/hwmon/hwmon-vid.c b/trunk/drivers/hwmon/hwmon-vid.c index 31c42002708f..9d67320e6840 100644 --- a/trunk/drivers/hwmon/hwmon-vid.c +++ b/trunk/drivers/hwmon/hwmon-vid.c @@ -1,7 +1,7 @@ /* hwmon-vid.c - VID/VRM/VRD voltage conversions - Copyright (c) 2004 Rudolf Marek + Copyright (c) 2004 Rudolf Marek Partly imported from i2c-vid.h of the lm_sensors project Copyright (c) 2002 Mark D. Studebaker @@ -232,7 +232,7 @@ u8 vid_which_vrm(void) EXPORT_SYMBOL(vid_from_reg); EXPORT_SYMBOL(vid_which_vrm); -MODULE_AUTHOR("Rudolf Marek "); +MODULE_AUTHOR("Rudolf Marek "); MODULE_DESCRIPTION("hwmon-vid driver"); MODULE_LICENSE("GPL"); diff --git a/trunk/drivers/hwmon/it87.c b/trunk/drivers/hwmon/it87.c index 1ed8b7e2c35d..323ef06719c1 100644 --- a/trunk/drivers/hwmon/it87.c +++ b/trunk/drivers/hwmon/it87.c @@ -3,7 +3,7 @@ monitoring. Supports: IT8705F Super I/O chip w/LPC interface - IT8712F Super I/O chip w/LPC interface + IT8712F Super I/O chip w/LPC interface & SMBus IT8716F Super I/O chip w/LPC interface IT8718F Super I/O chip w/LPC interface Sis950 A clone of the IT8705F @@ -41,8 +41,12 @@ #include +/* Addresses to scan */ +static unsigned short normal_i2c[] = { 0x2d, I2C_CLIENT_END }; static unsigned short isa_address; -enum chips { it87, it8712, it8716, it8718 }; + +/* Insmod parameters */ +I2C_CLIENT_INSMOD_4(it87, it8712, it8716, it8718); #define REG 0x2e /* The register to read/write */ #define DEV 0x07 /* Register: Logical device select */ @@ -158,6 +162,8 @@ static u8 vid_value; #define IT87_REG_TEMP_HIGH(nr) (0x40 + (nr) * 2) #define IT87_REG_TEMP_LOW(nr) (0x41 + (nr) * 2) +#define IT87_REG_I2C_ADDR 0x48 + #define IT87_REG_VIN_ENABLE 0x50 #define IT87_REG_TEMP_ENABLE 0x51 @@ -236,22 +242,33 @@ struct it87_data { }; -static int it87_detect(struct i2c_adapter *adapter); +static int it87_attach_adapter(struct i2c_adapter *adapter); +static int it87_isa_attach_adapter(struct i2c_adapter *adapter); +static int it87_detect(struct i2c_adapter *adapter, int address, int kind); static int it87_detach_client(struct i2c_client *client); static int it87_read_value(struct i2c_client *client, u8 reg); -static void it87_write_value(struct i2c_client *client, u8 reg, u8 value); +static int it87_write_value(struct i2c_client *client, u8 reg, u8 value); static struct it87_data *it87_update_device(struct device *dev); static int it87_check_pwm(struct i2c_client *client); static void it87_init_client(struct i2c_client *client, struct it87_data *data); +static struct i2c_driver it87_driver = { + .driver = { + .name = "it87", + }, + .id = I2C_DRIVERID_IT87, + .attach_adapter = it87_attach_adapter, + .detach_client = it87_detach_client, +}; + static struct i2c_driver it87_isa_driver = { .driver = { .owner = THIS_MODULE, .name = "it87-isa", }, - .attach_adapter = it87_detect, + .attach_adapter = it87_isa_attach_adapter, .detach_client = it87_detach_client, }; @@ -833,6 +850,22 @@ static const struct attribute_group it87_group_opt = { .attrs = it87_attributes_opt, }; +/* This function is called when: + * it87_driver is inserted (when this module is loaded), for each + available adapter + * when a new adapter is inserted (and it87_driver is still present) */ +static int it87_attach_adapter(struct i2c_adapter *adapter) +{ + if (!(adapter->class & I2C_CLASS_HWMON)) + return 0; + return i2c_probe(adapter, &addr_data, it87_detect); +} + +static int it87_isa_attach_adapter(struct i2c_adapter *adapter) +{ + return it87_detect(adapter, isa_address, -1); +} + /* SuperIO detection - will change isa_address if a chip is found */ static int __init it87_find(unsigned short *address) { @@ -883,20 +916,29 @@ static int __init it87_find(unsigned short *address) } /* This function is called by i2c_probe */ -static int it87_detect(struct i2c_adapter *adapter) +static int it87_detect(struct i2c_adapter *adapter, int address, int kind) { + int i; struct i2c_client *new_client; struct it87_data *data; int err = 0; - const char *name; + const char *name = ""; + int is_isa = i2c_is_isa_adapter(adapter); int enable_pwm_interface; - /* Reserve the ISA region */ - if (!request_region(isa_address, IT87_EXTENT, - it87_isa_driver.driver.name)){ - err = -EBUSY; + if (!is_isa && + !i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) goto ERROR0; - } + + /* Reserve the ISA region */ + if (is_isa) + if (!request_region(address, IT87_EXTENT, + it87_isa_driver.driver.name)) + goto ERROR0; + + /* For now, we presume we have a valid client. We create the + client structure, even though we cannot fill it completely yet. + But it allows us to access it87_{read,write}_value. */ if (!(data = kzalloc(sizeof(struct it87_data), GFP_KERNEL))) { err = -ENOMEM; @@ -904,46 +946,80 @@ static int it87_detect(struct i2c_adapter *adapter) } new_client = &data->client; - mutex_init(&data->lock); + if (is_isa) + mutex_init(&data->lock); i2c_set_clientdata(new_client, data); - new_client->addr = isa_address; + new_client->addr = address; new_client->adapter = adapter; - new_client->driver = &it87_isa_driver; + new_client->driver = is_isa ? &it87_isa_driver : &it87_driver; + new_client->flags = 0; /* Now, we do the remaining detection. */ - if ((it87_read_value(new_client, IT87_REG_CONFIG) & 0x80) - || it87_read_value(new_client, IT87_REG_CHIPID) != 0x90) { - err = -ENODEV; - goto ERROR2; + + if (kind < 0) { + if ((it87_read_value(new_client, IT87_REG_CONFIG) & 0x80) + || (!is_isa + && it87_read_value(new_client, IT87_REG_I2C_ADDR) != address)) { + err = -ENODEV; + goto ERROR2; + } } /* Determine the chip type. */ - switch (chip_type) { - case IT8712F_DEVID: - data->type = it8712; + if (kind <= 0) { + i = it87_read_value(new_client, IT87_REG_CHIPID); + if (i == 0x90) { + kind = it87; + if (is_isa) { + switch (chip_type) { + case IT8712F_DEVID: + kind = it8712; + break; + case IT8716F_DEVID: + kind = it8716; + break; + case IT8718F_DEVID: + kind = it8718; + break; + } + } + } + else { + if (kind == 0) + dev_info(&adapter->dev, + "Ignoring 'force' parameter for unknown chip at " + "adapter %d, address 0x%02x\n", + i2c_adapter_id(adapter), address); + err = -ENODEV; + goto ERROR2; + } + } + + if (kind == it87) { + name = "it87"; + } else if (kind == it8712) { name = "it8712"; - break; - case IT8716F_DEVID: - data->type = it8716; + } else if (kind == it8716) { name = "it8716"; - break; - case IT8718F_DEVID: - data->type = it8718; + } else if (kind == it8718) { name = "it8718"; - break; - default: - data->type = it87; - name = "it87"; } /* Fill in the remaining client fields and put it into the global list */ strlcpy(new_client->name, name, I2C_NAME_SIZE); + data->type = kind; + data->valid = 0; mutex_init(&data->update_lock); /* Tell the I2C layer a new client has arrived */ if ((err = i2c_attach_client(new_client))) goto ERROR2; + if (!is_isa) + dev_info(&new_client->dev, "The I2C interface to IT87xxF " + "hardware monitoring chips is deprecated. Please " + "report if you still rely on it.\n"); + /* Check PWM configuration */ enable_pwm_interface = it87_check_pwm(new_client); @@ -1053,7 +1129,8 @@ static int it87_detect(struct i2c_adapter *adapter) ERROR2: kfree(data); ERROR1: - release_region(isa_address, IT87_EXTENT); + if (is_isa) + release_region(address, IT87_EXTENT); ERROR0: return err; } @@ -1070,39 +1147,50 @@ static int it87_detach_client(struct i2c_client *client) if ((err = i2c_detach_client(client))) return err; - release_region(client->addr, IT87_EXTENT); + if(i2c_is_isa_client(client)) + release_region(client->addr, IT87_EXTENT); kfree(data); return 0; } -/* ISA access must be locked explicitly! +/* The SMBus locks itself, but ISA access must be locked explicitly! + We don't want to lock the whole ISA bus, so we lock each client + separately. We ignore the IT87 BUSY flag at this moment - it could lead to deadlocks, would slow down the IT87 access and should not be necessary. */ static int it87_read_value(struct i2c_client *client, u8 reg) { struct it87_data *data = i2c_get_clientdata(client); - int res; - - mutex_lock(&data->lock); - outb_p(reg, client->addr + IT87_ADDR_REG_OFFSET); - res = inb_p(client->addr + IT87_DATA_REG_OFFSET); - mutex_unlock(&data->lock); - return res; + int res; + if (i2c_is_isa_client(client)) { + mutex_lock(&data->lock); + outb_p(reg, client->addr + IT87_ADDR_REG_OFFSET); + res = inb_p(client->addr + IT87_DATA_REG_OFFSET); + mutex_unlock(&data->lock); + return res; + } else + return i2c_smbus_read_byte_data(client, reg); } -/* ISA access must be locked explicitly! +/* The SMBus locks itself, but ISA access muse be locked explicitly! + We don't want to lock the whole ISA bus, so we lock each client + separately. We ignore the IT87 BUSY flag at this moment - it could lead to deadlocks, would slow down the IT87 access and should not be necessary. */ -static void it87_write_value(struct i2c_client *client, u8 reg, u8 value) +static int it87_write_value(struct i2c_client *client, u8 reg, u8 value) { struct it87_data *data = i2c_get_clientdata(client); - mutex_lock(&data->lock); - outb_p(reg, client->addr + IT87_ADDR_REG_OFFSET); - outb_p(value, client->addr + IT87_DATA_REG_OFFSET); - mutex_unlock(&data->lock); + if (i2c_is_isa_client(client)) { + mutex_lock(&data->lock); + outb_p(reg, client->addr + IT87_ADDR_REG_OFFSET); + outb_p(value, client->addr + IT87_DATA_REG_OFFSET); + mutex_unlock(&data->lock); + return 0; + } else + return i2c_smbus_write_byte_data(client, reg, value); } /* Return 1 if and only if the PWM interface is safe to use */ @@ -1338,14 +1426,26 @@ static int __init sm_it87_init(void) { int res; - if ((res = it87_find(&isa_address))) + res = i2c_add_driver(&it87_driver); + if (res) return res; - return i2c_isa_add_driver(&it87_isa_driver); + + if (!it87_find(&isa_address)) { + res = i2c_isa_add_driver(&it87_isa_driver); + if (res) { + i2c_del_driver(&it87_driver); + return res; + } + } + + return 0; } static void __exit sm_it87_exit(void) { - i2c_isa_del_driver(&it87_isa_driver); + if (isa_address) + i2c_isa_del_driver(&it87_isa_driver); + i2c_del_driver(&it87_driver); } diff --git a/trunk/drivers/hwmon/k8temp.c b/trunk/drivers/hwmon/k8temp.c index 5d8d0ca08fa9..f58b64ed09e3 100644 --- a/trunk/drivers/hwmon/k8temp.c +++ b/trunk/drivers/hwmon/k8temp.c @@ -1,7 +1,7 @@ /* * k8temp.c - Linux kernel module for hardware monitoring * - * Copyright (C) 2006 Rudolf Marek + * Copyright (C) 2006 Rudolf Marek * * Inspired from the w83785 and amd756 drivers. * @@ -286,7 +286,7 @@ static void __exit k8temp_exit(void) pci_unregister_driver(&k8temp_driver); } -MODULE_AUTHOR("Rudolf Marek "); +MODULE_AUTHOR("Rudolf Marek "); MODULE_DESCRIPTION("AMD K8 core temperature monitor"); MODULE_LICENSE("GPL"); diff --git a/trunk/drivers/hwmon/pc87360.c b/trunk/drivers/hwmon/pc87360.c index c8a21be09d87..3b8b81984ad4 100644 --- a/trunk/drivers/hwmon/pc87360.c +++ b/trunk/drivers/hwmon/pc87360.c @@ -1000,7 +1000,7 @@ static int pc87360_detect(struct i2c_adapter *adapter) (i&0x02) ? "external" : "internal"); data->vid_conf = confreg[3]; - data->vrm = vid_which_vrm(); + data->vrm = 90; } /* Fan clock dividers may be needed before any data is read */ diff --git a/trunk/drivers/hwmon/pc87427.c b/trunk/drivers/hwmon/pc87427.c deleted file mode 100644 index affa21a5ccfd..000000000000 --- a/trunk/drivers/hwmon/pc87427.c +++ /dev/null @@ -1,627 +0,0 @@ -/* - * pc87427.c - hardware monitoring driver for the - * National Semiconductor PC87427 Super-I/O chip - * Copyright (C) 2006 Jean Delvare - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * Supports the following chips: - * - * Chip #vin #fan #pwm #temp devid - * PC87427 - 8 - - 0xF2 - * - * This driver assumes that no more than one chip is present. - * Only fan inputs are supported so far, although the chip can do much more. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static struct platform_device *pdev; - -#define DRVNAME "pc87427" - -/* The lock mutex protects both the I/O accesses (needed because the - device is using banked registers) and the register cache (needed to keep - the data in the registers and the cache in sync at any time). */ -struct pc87427_data { - struct class_device *class_dev; - struct mutex lock; - int address[2]; - const char *name; - - unsigned long last_updated; /* in jiffies */ - u8 fan_enabled; /* bit vector */ - u16 fan[8]; /* register values */ - u16 fan_min[8]; /* register values */ - u8 fan_status[8]; /* register values */ -}; - -/* - * Super-I/O registers and operations - */ - -#define SIOREG_LDSEL 0x07 /* Logical device select */ -#define SIOREG_DEVID 0x20 /* Device ID */ -#define SIOREG_ACT 0x30 /* Device activation */ -#define SIOREG_MAP 0x50 /* I/O or memory mapping */ -#define SIOREG_IOBASE 0x60 /* I/O base address */ - -static const u8 logdev[2] = { 0x09, 0x14 }; -static const char *logdev_str[2] = { DRVNAME " FMC", DRVNAME " HMC" }; -#define LD_FAN 0 -#define LD_IN 1 -#define LD_TEMP 1 - -static inline void superio_outb(int sioaddr, int reg, int val) -{ - outb(reg, sioaddr); - outb(val, sioaddr + 1); -} - -static inline int superio_inb(int sioaddr, int reg) -{ - outb(reg, sioaddr); - return inb(sioaddr + 1); -} - -static inline void superio_exit(int sioaddr) -{ - outb(0x02, sioaddr); - outb(0x02, sioaddr + 1); -} - -/* - * Logical devices - */ - -#define REGION_LENGTH 32 -#define PC87427_REG_BANK 0x0f -#define BANK_FM(nr) (nr) -#define BANK_FT(nr) (0x08 + (nr)) -#define BANK_FC(nr) (0x10 + (nr) * 2) - -/* - * I/O access functions - */ - -/* ldi is the logical device index */ -static inline int pc87427_read8(struct pc87427_data *data, u8 ldi, u8 reg) -{ - return inb(data->address[ldi] + reg); -} - -/* Must be called with data->lock held, except during init */ -static inline int pc87427_read8_bank(struct pc87427_data *data, u8 ldi, - u8 bank, u8 reg) -{ - outb(bank, data->address[ldi] + PC87427_REG_BANK); - return inb(data->address[ldi] + reg); -} - -/* Must be called with data->lock held, except during init */ -static inline void pc87427_write8_bank(struct pc87427_data *data, u8 ldi, - u8 bank, u8 reg, u8 value) -{ - outb(bank, data->address[ldi] + PC87427_REG_BANK); - outb(value, data->address[ldi] + reg); -} - -/* - * Fan registers and conversions - */ - -/* fan data registers are 16-bit wide */ -#define PC87427_REG_FAN 0x12 -#define PC87427_REG_FAN_MIN 0x14 -#define PC87427_REG_FAN_STATUS 0x10 - -#define FAN_STATUS_STALL (1 << 3) -#define FAN_STATUS_LOSPD (1 << 1) -#define FAN_STATUS_MONEN (1 << 0) - -/* Dedicated function to read all registers related to a given fan input. - This saves us quite a few locks and bank selections. - Must be called with data->lock held. - nr is from 0 to 7 */ -static void pc87427_readall_fan(struct pc87427_data *data, u8 nr) -{ - int iobase = data->address[LD_FAN]; - - outb(BANK_FM(nr), iobase + PC87427_REG_BANK); - data->fan[nr] = inw(iobase + PC87427_REG_FAN); - data->fan_min[nr] = inw(iobase + PC87427_REG_FAN_MIN); - data->fan_status[nr] = inb(iobase + PC87427_REG_FAN_STATUS); - /* Clear fan alarm bits */ - outb(data->fan_status[nr], iobase + PC87427_REG_FAN_STATUS); -} - -/* The 2 LSB of fan speed registers are used for something different. - The actual 2 LSB of the measurements are not available. */ -static inline unsigned long fan_from_reg(u16 reg) -{ - reg &= 0xfffc; - if (reg == 0x0000 || reg == 0xfffc) - return 0; - return 5400000UL / reg; -} - -/* The 2 LSB of the fan speed limit registers are not significant. */ -static inline u16 fan_to_reg(unsigned long val) -{ - if (val < 83UL) - return 0xffff; - if (val >= 1350000UL) - return 0x0004; - return ((1350000UL + val / 2) / val) << 2; -} - -/* - * Data interface - */ - -static struct pc87427_data *pc87427_update_device(struct device *dev) -{ - struct pc87427_data *data = dev_get_drvdata(dev); - int i; - - mutex_lock(&data->lock); - if (!time_after(jiffies, data->last_updated + HZ) - && data->last_updated) - goto done; - - /* Fans */ - for (i = 0; i < 8; i++) { - if (!(data->fan_enabled & (1 << i))) - continue; - pc87427_readall_fan(data, i); - } - data->last_updated = jiffies; - -done: - mutex_unlock(&data->lock); - return data; -} - -static ssize_t show_fan_input(struct device *dev, struct device_attribute - *devattr, char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - struct pc87427_data *data = pc87427_update_device(dev); - int nr = attr->index; - - return sprintf(buf, "%lu\n", fan_from_reg(data->fan[nr])); -} - -static ssize_t show_fan_min(struct device *dev, struct device_attribute - *devattr, char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - struct pc87427_data *data = pc87427_update_device(dev); - int nr = attr->index; - - return sprintf(buf, "%lu\n", fan_from_reg(data->fan_min[nr])); -} - -static ssize_t show_fan_alarm(struct device *dev, struct device_attribute - *devattr, char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - struct pc87427_data *data = pc87427_update_device(dev); - int nr = attr->index; - - return sprintf(buf, "%d\n", !!(data->fan_status[nr] - & FAN_STATUS_LOSPD)); -} - -static ssize_t show_fan_fault(struct device *dev, struct device_attribute - *devattr, char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - struct pc87427_data *data = pc87427_update_device(dev); - int nr = attr->index; - - return sprintf(buf, "%d\n", !!(data->fan_status[nr] - & FAN_STATUS_STALL)); -} - -static ssize_t set_fan_min(struct device *dev, struct device_attribute - *devattr, const char *buf, size_t count) -{ - struct pc87427_data *data = dev_get_drvdata(dev); - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - int nr = attr->index; - unsigned long val = simple_strtoul(buf, NULL, 10); - int iobase = data->address[LD_FAN]; - - mutex_lock(&data->lock); - outb(BANK_FM(nr), iobase + PC87427_REG_BANK); - /* The low speed limit registers are read-only while monitoring - is enabled, so we have to disable monitoring, then change the - limit, and finally enable monitoring again. */ - outb(0, iobase + PC87427_REG_FAN_STATUS); - data->fan_min[nr] = fan_to_reg(val); - outw(data->fan_min[nr], iobase + PC87427_REG_FAN_MIN); - outb(FAN_STATUS_MONEN, iobase + PC87427_REG_FAN_STATUS); - mutex_unlock(&data->lock); - - return count; -} - -static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan_input, NULL, 0); -static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, show_fan_input, NULL, 1); -static SENSOR_DEVICE_ATTR(fan3_input, S_IRUGO, show_fan_input, NULL, 2); -static SENSOR_DEVICE_ATTR(fan4_input, S_IRUGO, show_fan_input, NULL, 3); -static SENSOR_DEVICE_ATTR(fan5_input, S_IRUGO, show_fan_input, NULL, 4); -static SENSOR_DEVICE_ATTR(fan6_input, S_IRUGO, show_fan_input, NULL, 5); -static SENSOR_DEVICE_ATTR(fan7_input, S_IRUGO, show_fan_input, NULL, 6); -static SENSOR_DEVICE_ATTR(fan8_input, S_IRUGO, show_fan_input, NULL, 7); - -static SENSOR_DEVICE_ATTR(fan1_min, S_IWUSR | S_IRUGO, - show_fan_min, set_fan_min, 0); -static SENSOR_DEVICE_ATTR(fan2_min, S_IWUSR | S_IRUGO, - show_fan_min, set_fan_min, 1); -static SENSOR_DEVICE_ATTR(fan3_min, S_IWUSR | S_IRUGO, - show_fan_min, set_fan_min, 2); -static SENSOR_DEVICE_ATTR(fan4_min, S_IWUSR | S_IRUGO, - show_fan_min, set_fan_min, 3); -static SENSOR_DEVICE_ATTR(fan5_min, S_IWUSR | S_IRUGO, - show_fan_min, set_fan_min, 4); -static SENSOR_DEVICE_ATTR(fan6_min, S_IWUSR | S_IRUGO, - show_fan_min, set_fan_min, 5); -static SENSOR_DEVICE_ATTR(fan7_min, S_IWUSR | S_IRUGO, - show_fan_min, set_fan_min, 6); -static SENSOR_DEVICE_ATTR(fan8_min, S_IWUSR | S_IRUGO, - show_fan_min, set_fan_min, 7); - -static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, show_fan_alarm, NULL, 0); -static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_fan_alarm, NULL, 1); -static SENSOR_DEVICE_ATTR(fan3_alarm, S_IRUGO, show_fan_alarm, NULL, 2); -static SENSOR_DEVICE_ATTR(fan4_alarm, S_IRUGO, show_fan_alarm, NULL, 3); -static SENSOR_DEVICE_ATTR(fan5_alarm, S_IRUGO, show_fan_alarm, NULL, 4); -static SENSOR_DEVICE_ATTR(fan6_alarm, S_IRUGO, show_fan_alarm, NULL, 5); -static SENSOR_DEVICE_ATTR(fan7_alarm, S_IRUGO, show_fan_alarm, NULL, 6); -static SENSOR_DEVICE_ATTR(fan8_alarm, S_IRUGO, show_fan_alarm, NULL, 7); - -static SENSOR_DEVICE_ATTR(fan1_fault, S_IRUGO, show_fan_fault, NULL, 0); -static SENSOR_DEVICE_ATTR(fan2_fault, S_IRUGO, show_fan_fault, NULL, 1); -static SENSOR_DEVICE_ATTR(fan3_fault, S_IRUGO, show_fan_fault, NULL, 2); -static SENSOR_DEVICE_ATTR(fan4_fault, S_IRUGO, show_fan_fault, NULL, 3); -static SENSOR_DEVICE_ATTR(fan5_fault, S_IRUGO, show_fan_fault, NULL, 4); -static SENSOR_DEVICE_ATTR(fan6_fault, S_IRUGO, show_fan_fault, NULL, 5); -static SENSOR_DEVICE_ATTR(fan7_fault, S_IRUGO, show_fan_fault, NULL, 6); -static SENSOR_DEVICE_ATTR(fan8_fault, S_IRUGO, show_fan_fault, NULL, 7); - -static struct attribute *pc87427_attributes_fan[8][5] = { - { - &sensor_dev_attr_fan1_input.dev_attr.attr, - &sensor_dev_attr_fan1_min.dev_attr.attr, - &sensor_dev_attr_fan1_alarm.dev_attr.attr, - &sensor_dev_attr_fan1_fault.dev_attr.attr, - NULL - }, { - &sensor_dev_attr_fan2_input.dev_attr.attr, - &sensor_dev_attr_fan2_min.dev_attr.attr, - &sensor_dev_attr_fan2_alarm.dev_attr.attr, - &sensor_dev_attr_fan2_fault.dev_attr.attr, - NULL - }, { - &sensor_dev_attr_fan3_input.dev_attr.attr, - &sensor_dev_attr_fan3_min.dev_attr.attr, - &sensor_dev_attr_fan3_alarm.dev_attr.attr, - &sensor_dev_attr_fan3_fault.dev_attr.attr, - NULL - }, { - &sensor_dev_attr_fan4_input.dev_attr.attr, - &sensor_dev_attr_fan4_min.dev_attr.attr, - &sensor_dev_attr_fan4_alarm.dev_attr.attr, - &sensor_dev_attr_fan4_fault.dev_attr.attr, - NULL - }, { - &sensor_dev_attr_fan5_input.dev_attr.attr, - &sensor_dev_attr_fan5_min.dev_attr.attr, - &sensor_dev_attr_fan5_alarm.dev_attr.attr, - &sensor_dev_attr_fan5_fault.dev_attr.attr, - NULL - }, { - &sensor_dev_attr_fan6_input.dev_attr.attr, - &sensor_dev_attr_fan6_min.dev_attr.attr, - &sensor_dev_attr_fan6_alarm.dev_attr.attr, - &sensor_dev_attr_fan6_fault.dev_attr.attr, - NULL - }, { - &sensor_dev_attr_fan7_input.dev_attr.attr, - &sensor_dev_attr_fan7_min.dev_attr.attr, - &sensor_dev_attr_fan7_alarm.dev_attr.attr, - &sensor_dev_attr_fan7_fault.dev_attr.attr, - NULL - }, { - &sensor_dev_attr_fan8_input.dev_attr.attr, - &sensor_dev_attr_fan8_min.dev_attr.attr, - &sensor_dev_attr_fan8_alarm.dev_attr.attr, - &sensor_dev_attr_fan8_fault.dev_attr.attr, - NULL - } -}; - -static const struct attribute_group pc87427_group_fan[8] = { - { .attrs = pc87427_attributes_fan[0] }, - { .attrs = pc87427_attributes_fan[1] }, - { .attrs = pc87427_attributes_fan[2] }, - { .attrs = pc87427_attributes_fan[3] }, - { .attrs = pc87427_attributes_fan[4] }, - { .attrs = pc87427_attributes_fan[5] }, - { .attrs = pc87427_attributes_fan[6] }, - { .attrs = pc87427_attributes_fan[7] }, -}; - -static ssize_t show_name(struct device *dev, struct device_attribute - *devattr, char *buf) -{ - struct pc87427_data *data = dev_get_drvdata(dev); - - return sprintf(buf, "%s\n", data->name); -} -static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); - - -/* - * Device detection, attach and detach - */ - -static void __devinit pc87427_init_device(struct device *dev) -{ - struct pc87427_data *data = dev_get_drvdata(dev); - int i; - u8 reg; - - /* The FMC module should be ready */ - reg = pc87427_read8(data, LD_FAN, PC87427_REG_BANK); - if (!(reg & 0x80)) - dev_warn(dev, "FMC module not ready!\n"); - - /* Check which fans are enabled */ - for (i = 0; i < 8; i++) { - reg = pc87427_read8_bank(data, LD_FAN, BANK_FM(i), - PC87427_REG_FAN_STATUS); - if (reg & FAN_STATUS_MONEN) - data->fan_enabled |= (1 << i); - } - - if (!data->fan_enabled) { - dev_dbg(dev, "Enabling all fan inputs\n"); - for (i = 0; i < 8; i++) - pc87427_write8_bank(data, LD_FAN, BANK_FM(i), - PC87427_REG_FAN_STATUS, - FAN_STATUS_MONEN); - data->fan_enabled = 0xff; - } -} - -static int __devinit pc87427_probe(struct platform_device *pdev) -{ - struct pc87427_data *data; - struct resource *res; - int i, err; - - if (!(data = kzalloc(sizeof(struct pc87427_data), GFP_KERNEL))) { - err = -ENOMEM; - printk(KERN_ERR DRVNAME ": Out of memory\n"); - goto exit; - } - - /* This will need to be revisited when we add support for - temperature and voltage monitoring. */ - res = platform_get_resource(pdev, IORESOURCE_IO, 0); - data->address[0] = res->start; - - mutex_init(&data->lock); - data->name = "pc87427"; - platform_set_drvdata(pdev, data); - pc87427_init_device(&pdev->dev); - - /* Register sysfs hooks */ - if ((err = device_create_file(&pdev->dev, &dev_attr_name))) - goto exit_kfree; - for (i = 0; i < 8; i++) { - if (!(data->fan_enabled & (1 << i))) - continue; - if ((err = sysfs_create_group(&pdev->dev.kobj, - &pc87427_group_fan[i]))) - goto exit_remove_files; - } - - data->class_dev = hwmon_device_register(&pdev->dev); - if (IS_ERR(data->class_dev)) { - err = PTR_ERR(data->class_dev); - dev_err(&pdev->dev, "Class registration failed (%d)\n", err); - goto exit_remove_files; - } - - return 0; - -exit_remove_files: - for (i = 0; i < 8; i++) { - if (!(data->fan_enabled & (1 << i))) - continue; - sysfs_remove_group(&pdev->dev.kobj, &pc87427_group_fan[i]); - } -exit_kfree: - platform_set_drvdata(pdev, NULL); - kfree(data); -exit: - return err; -} - -static int __devexit pc87427_remove(struct platform_device *pdev) -{ - struct pc87427_data *data = platform_get_drvdata(pdev); - int i; - - platform_set_drvdata(pdev, NULL); - hwmon_device_unregister(data->class_dev); - device_remove_file(&pdev->dev, &dev_attr_name); - for (i = 0; i < 8; i++) { - if (!(data->fan_enabled & (1 << i))) - continue; - sysfs_remove_group(&pdev->dev.kobj, &pc87427_group_fan[i]); - } - kfree(data); - - return 0; -} - - -static struct platform_driver pc87427_driver = { - .driver = { - .owner = THIS_MODULE, - .name = DRVNAME, - }, - .probe = pc87427_probe, - .remove = __devexit_p(pc87427_remove), -}; - -static int __init pc87427_device_add(unsigned short address) -{ - struct resource res = { - .start = address, - .end = address + REGION_LENGTH - 1, - .name = logdev_str[0], - .flags = IORESOURCE_IO, - }; - int err; - - pdev = platform_device_alloc(DRVNAME, address); - if (!pdev) { - err = -ENOMEM; - printk(KERN_ERR DRVNAME ": Device allocation failed\n"); - goto exit; - } - - err = platform_device_add_resources(pdev, &res, 1); - if (err) { - printk(KERN_ERR DRVNAME ": Device resource addition failed " - "(%d)\n", err); - goto exit_device_put; - } - - err = platform_device_add(pdev); - if (err) { - printk(KERN_ERR DRVNAME ": Device addition failed (%d)\n", - err); - goto exit_device_put; - } - - return 0; - -exit_device_put: - platform_device_put(pdev); -exit: - return err; -} - -static int __init pc87427_find(int sioaddr, unsigned short *address) -{ - u16 val; - int i, err = 0; - - /* Identify device */ - val = superio_inb(sioaddr, SIOREG_DEVID); - if (val != 0xf2) { /* PC87427 */ - err = -ENODEV; - goto exit; - } - - for (i = 0; i < 2; i++) { - address[i] = 0; - /* Select logical device */ - superio_outb(sioaddr, SIOREG_LDSEL, logdev[i]); - - val = superio_inb(sioaddr, SIOREG_ACT); - if (!(val & 0x01)) { - printk(KERN_INFO DRVNAME ": Logical device 0x%02x " - "not activated\n", logdev[i]); - continue; - } - - val = superio_inb(sioaddr, SIOREG_MAP); - if (val & 0x01) { - printk(KERN_WARNING DRVNAME ": Logical device 0x%02x " - "is memory-mapped, can't use\n", logdev[i]); - continue; - } - - val = (superio_inb(sioaddr, SIOREG_IOBASE) << 8) - | superio_inb(sioaddr, SIOREG_IOBASE + 1); - if (!val) { - printk(KERN_INFO DRVNAME ": I/O base address not set " - "for logical device 0x%02x\n", logdev[i]); - continue; - } - address[i] = val; - } - -exit: - superio_exit(sioaddr); - return err; -} - -static int __init pc87427_init(void) -{ - int err; - unsigned short address[2]; - - if (pc87427_find(0x2e, address) - && pc87427_find(0x4e, address)) - return -ENODEV; - - /* For now the driver only handles fans so we only care about the - first address. */ - if (!address[0]) - return -ENODEV; - - err = platform_driver_register(&pc87427_driver); - if (err) - goto exit; - - /* Sets global pdev as a side effect */ - err = pc87427_device_add(address[0]); - if (err) - goto exit_driver; - - return 0; - -exit_driver: - platform_driver_unregister(&pc87427_driver); -exit: - return err; -} - -static void __exit pc87427_exit(void) -{ - platform_device_unregister(pdev); - platform_driver_unregister(&pc87427_driver); -} - -MODULE_AUTHOR("Jean Delvare "); -MODULE_DESCRIPTION("PC87427 hardware monitoring driver"); -MODULE_LICENSE("GPL"); - -module_init(pc87427_init); -module_exit(pc87427_exit); diff --git a/trunk/drivers/hwmon/w83627ehf.c b/trunk/drivers/hwmon/w83627ehf.c index 212a1558c63b..2257806d0102 100644 --- a/trunk/drivers/hwmon/w83627ehf.c +++ b/trunk/drivers/hwmon/w83627ehf.c @@ -3,7 +3,7 @@ the Winbond W83627EHF Super-I/O chip Copyright (C) 2005 Jean Delvare Copyright (C) 2006 Yuan Mu (Winbond), - Rudolf Marek + Rudolf Marek David Hubbard Shamelessly ripped from the w83627hf driver diff --git a/trunk/drivers/hwmon/w83792d.c b/trunk/drivers/hwmon/w83792d.c index b0fa296740d1..4e108262576f 100644 --- a/trunk/drivers/hwmon/w83792d.c +++ b/trunk/drivers/hwmon/w83792d.c @@ -3,7 +3,7 @@ monitoring Copyright (C) 2004, 2005 Winbond Electronics Corp. Chunhao Huang , - Rudolf Marek + Rudolf Marek This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/trunk/drivers/hwmon/w83793.c b/trunk/drivers/hwmon/w83793.c deleted file mode 100644 index c12ac5abc2bb..000000000000 --- a/trunk/drivers/hwmon/w83793.c +++ /dev/null @@ -1,1609 +0,0 @@ -/* - w83793.c - Linux kernel driver for hardware monitoring - Copyright (C) 2006 Winbond Electronics Corp. - Yuan Mu - Rudolf Marek - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation - version 2. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301 USA. -*/ - -/* - Supports following chips: - - Chip #vin #fanin #pwm #temp wchipid vendid i2c ISA - w83793 10 12 8 6 0x7b 0x5ca3 yes no -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* Addresses to scan */ -static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, I2C_CLIENT_END }; - -/* Insmod parameters */ -I2C_CLIENT_INSMOD_1(w83793); -I2C_CLIENT_MODULE_PARM(force_subclients, "List of subclient addresses: " - "{bus, clientaddr, subclientaddr1, subclientaddr2}"); - -static int reset; -module_param(reset, bool, 0); -MODULE_PARM_DESC(reset, "Set to 1 to reset chip, not recommended"); - -/* - Address 0x00, 0x0d, 0x0e, 0x0f in all three banks are reserved - as ID, Bank Select registers -*/ -#define W83793_REG_BANKSEL 0x00 -#define W83793_REG_VENDORID 0x0d -#define W83793_REG_CHIPID 0x0e -#define W83793_REG_DEVICEID 0x0f - -#define W83793_REG_CONFIG 0x40 -#define W83793_REG_MFC 0x58 -#define W83793_REG_FANIN_CTRL 0x5c -#define W83793_REG_FANIN_SEL 0x5d -#define W83793_REG_I2C_ADDR 0x0b -#define W83793_REG_I2C_SUBADDR 0x0c -#define W83793_REG_VID_INA 0x05 -#define W83793_REG_VID_INB 0x06 -#define W83793_REG_VID_LATCHA 0x07 -#define W83793_REG_VID_LATCHB 0x08 -#define W83793_REG_VID_CTRL 0x59 - -static u16 W83793_REG_TEMP_MODE[2] = { 0x5e, 0x5f }; - -#define TEMP_READ 0 -#define TEMP_CRIT 1 -#define TEMP_CRIT_HYST 2 -#define TEMP_WARN 3 -#define TEMP_WARN_HYST 4 -/* only crit and crit_hyst affect real-time alarm status - current crit crit_hyst warn warn_hyst */ -static u16 W83793_REG_TEMP[][5] = { - {0x1c, 0x78, 0x79, 0x7a, 0x7b}, - {0x1d, 0x7c, 0x7d, 0x7e, 0x7f}, - {0x1e, 0x80, 0x81, 0x82, 0x83}, - {0x1f, 0x84, 0x85, 0x86, 0x87}, - {0x20, 0x88, 0x89, 0x8a, 0x8b}, - {0x21, 0x8c, 0x8d, 0x8e, 0x8f}, -}; - -#define W83793_REG_TEMP_LOW_BITS 0x22 - -#define W83793_REG_BEEP(index) (0x53 + (index)) -#define W83793_REG_ALARM(index) (0x4b + (index)) - -#define W83793_REG_CLR_CHASSIS 0x4a /* SMI MASK4 */ -#define W83793_REG_IRQ_CTRL 0x50 -#define W83793_REG_OVT_CTRL 0x51 -#define W83793_REG_OVT_BEEP 0x52 - -#define IN_READ 0 -#define IN_MAX 1 -#define IN_LOW 2 -static const u16 W83793_REG_IN[][3] = { - /* Current, High, Low */ - {0x10, 0x60, 0x61}, /* Vcore A */ - {0x11, 0x62, 0x63}, /* Vcore B */ - {0x12, 0x64, 0x65}, /* Vtt */ - {0x14, 0x6a, 0x6b}, /* VSEN1 */ - {0x15, 0x6c, 0x6d}, /* VSEN2 */ - {0x16, 0x6e, 0x6f}, /* +3VSEN */ - {0x17, 0x70, 0x71}, /* +12VSEN */ - {0x18, 0x72, 0x73}, /* 5VDD */ - {0x19, 0x74, 0x75}, /* 5VSB */ - {0x1a, 0x76, 0x77}, /* VBAT */ -}; - -/* Low Bits of Vcore A/B Vtt Read/High/Low */ -static const u16 W83793_REG_IN_LOW_BITS[] = { 0x1b, 0x68, 0x69 }; -static u8 scale_in[] = { 2, 2, 2, 16, 16, 16, 8, 24, 24, 16 }; - -#define W83793_REG_FAN(index) (0x23 + 2 * (index)) /* High byte */ -#define W83793_REG_FAN_MIN(index) (0x90 + 2 * (index)) /* High byte */ - -#define W83793_REG_PWM_DEFAULT 0xb2 -#define W83793_REG_PWM_ENABLE 0x207 -#define W83793_REG_PWM_UPTIME 0xc3 /* Unit in 0.1 second */ -#define W83793_REG_PWM_DOWNTIME 0xc4 /* Unit in 0.1 second */ -#define W83793_REG_TEMP_CRITICAL 0xc5 - -#define PWM_DUTY 0 -#define PWM_START 1 -#define PWM_NONSTOP 2 -#define W83793_REG_PWM(index, nr) (((nr) == 0 ? 0xb3 : \ - (nr) == 1 ? 0x220 : 0x218) + (index)) - -/* bit field, fan1 is bit0, fan2 is bit1 ... */ -#define W83793_REG_TEMP_FAN_MAP(index) (0x201 + (index)) -#define W83793_REG_TEMP_TOL(index) (0x208 + (index)) -#define W83793_REG_TEMP_CRUISE(index) (0x210 + (index)) -#define W83793_REG_PWM_STOP_TIME(index) (0x228 + (index)) -#define W83793_REG_SF2_TEMP(index, nr) (0x230 + ((index) << 4) + (nr)) -#define W83793_REG_SF2_PWM(index, nr) (0x238 + ((index) << 4) + (nr)) - -static inline unsigned long FAN_FROM_REG(u16 val) -{ - if ((val >= 0xfff) || (val == 0)) - return 0; - return (1350000UL / val); -} - -static inline u16 FAN_TO_REG(long rpm) -{ - if (rpm <= 0) - return 0x0fff; - return SENSORS_LIMIT((1350000 + (rpm >> 1)) / rpm, 1, 0xffe); -} - -static inline unsigned long TIME_FROM_REG(u8 reg) -{ - return (reg * 100); -} - -static inline u8 TIME_TO_REG(unsigned long val) -{ - return SENSORS_LIMIT((val + 50) / 100, 0, 0xff); -} - -static inline long TEMP_FROM_REG(s8 reg) -{ - return (reg * 1000); -} - -static inline s8 TEMP_TO_REG(long val, s8 min, s8 max) -{ - return SENSORS_LIMIT((val + (val < 0 ? -500 : 500)) / 1000, min, max); -} - -struct w83793_data { - struct i2c_client client; - struct i2c_client *lm75[2]; - struct class_device *class_dev; - struct mutex update_lock; - char valid; /* !=0 if following fields are valid */ - unsigned long last_updated; /* In jiffies */ - unsigned long last_nonvolatile; /* In jiffies, last time we update the - nonvolatile registers */ - - u8 bank; - u8 vrm; - u8 vid[2]; - u8 in[10][3]; /* Register value, read/high/low */ - u8 in_low_bits[3]; /* Additional resolution for VCore A/B Vtt */ - - u16 has_fan; /* Only fan1- fan5 has own pins */ - u16 fan[12]; /* Register value combine */ - u16 fan_min[12]; /* Register value combine */ - - s8 temp[6][5]; /* current, crit, crit_hyst,warn, warn_hyst */ - u8 temp_low_bits; /* Additional resolution TD1-TD4 */ - u8 temp_mode[2]; /* byte 0: Temp D1-D4 mode each has 2 bits - byte 1: Temp R1,R2 mode, each has 1 bit */ - u8 temp_critical; /* If reached all fan will be at full speed */ - u8 temp_fan_map[6]; /* Temp controls which pwm fan, bit field */ - - u8 has_pwm; - u8 pwm_enable; /* Register value, each Temp has 1 bit */ - u8 pwm_uptime; /* Register value */ - u8 pwm_downtime; /* Register value */ - u8 pwm_default; /* All fan default pwm, next poweron valid */ - u8 pwm[8][3]; /* Register value */ - u8 pwm_stop_time[8]; - u8 temp_cruise[6]; - - u8 alarms[5]; /* realtime status registers */ - u8 beeps[5]; - u8 beep_enable; - u8 tolerance[3]; /* Temp tolerance(Smart Fan I/II) */ - u8 sf2_pwm[6][7]; /* Smart FanII: Fan duty cycle */ - u8 sf2_temp[6][7]; /* Smart FanII: Temp level point */ -}; - -static u8 w83793_read_value(struct i2c_client *client, u16 reg); -static int w83793_write_value(struct i2c_client *client, u16 reg, u8 value); -static int w83793_attach_adapter(struct i2c_adapter *adapter); -static int w83793_detect(struct i2c_adapter *adapter, int address, int kind); -static int w83793_detach_client(struct i2c_client *client); -static void w83793_init_client(struct i2c_client *client); -static void w83793_update_nonvolatile(struct device *dev); -static struct w83793_data *w83793_update_device(struct device *dev); - -static struct i2c_driver w83793_driver = { - .driver = { - .name = "w83793", - }, - .attach_adapter = w83793_attach_adapter, - .detach_client = w83793_detach_client, -}; - -static ssize_t -show_vrm(struct device *dev, struct device_attribute *attr, char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct w83793_data *data = i2c_get_clientdata(client); - - return sprintf(buf, "%d\n", data->vrm); -} - -static ssize_t -show_vid(struct device *dev, struct device_attribute *attr, char *buf) -{ - struct w83793_data *data = w83793_update_device(dev); - struct sensor_device_attribute_2 *sensor_attr = - to_sensor_dev_attr_2(attr); - int index = sensor_attr->index; - - return sprintf(buf, "%d\n", vid_from_reg(data->vid[index], data->vrm)); -} - -static ssize_t -store_vrm(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct w83793_data *data = i2c_get_clientdata(client); - - data->vrm = simple_strtoul(buf, NULL, 10); - return count; -} - -#define ALARM_STATUS 0 -#define BEEP_ENABLE 1 -static ssize_t -show_alarm_beep(struct device *dev, struct device_attribute *attr, char *buf) -{ - struct w83793_data *data = w83793_update_device(dev); - struct sensor_device_attribute_2 *sensor_attr = - to_sensor_dev_attr_2(attr); - int nr = sensor_attr->nr; - int index = sensor_attr->index >> 3; - int bit = sensor_attr->index & 0x07; - u8 val; - - if (ALARM_STATUS == nr) { - val = (data->alarms[index] >> (bit)) & 1; - } else { /* BEEP_ENABLE */ - val = (data->beeps[index] >> (bit)) & 1; - } - - return sprintf(buf, "%u\n", val); -} - -static ssize_t -store_beep(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct w83793_data *data = i2c_get_clientdata(client); - struct sensor_device_attribute_2 *sensor_attr = - to_sensor_dev_attr_2(attr); - int index = sensor_attr->index >> 3; - int shift = sensor_attr->index & 0x07; - u8 beep_bit = 1 << shift; - u8 val; - - val = simple_strtoul(buf, NULL, 10); - if (val != 0 && val != 1) - return -EINVAL; - - mutex_lock(&data->update_lock); - data->beeps[index] = w83793_read_value(client, W83793_REG_BEEP(index)); - data->beeps[index] &= ~beep_bit; - data->beeps[index] |= val << shift; - w83793_write_value(client, W83793_REG_BEEP(index), data->beeps[index]); - mutex_unlock(&data->update_lock); - - return count; -} - -static ssize_t -show_beep_enable(struct device *dev, struct device_attribute *attr, char *buf) -{ - struct w83793_data *data = w83793_update_device(dev); - return sprintf(buf, "%u\n", (data->beep_enable >> 1) & 0x01); -} - -static ssize_t -store_beep_enable(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct w83793_data *data = i2c_get_clientdata(client); - u8 val = simple_strtoul(buf, NULL, 10); - - if (val != 0 && val != 1) - return -EINVAL; - - mutex_lock(&data->update_lock); - data->beep_enable = w83793_read_value(client, W83793_REG_OVT_BEEP) - & 0xfd; - data->beep_enable |= val << 1; - w83793_write_value(client, W83793_REG_OVT_BEEP, data->beep_enable); - mutex_unlock(&data->update_lock); - - return count; -} - -/* Write any value to clear chassis alarm */ -static ssize_t -store_chassis_clear(struct device *dev, - struct device_attribute *attr, const char *buf, - size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct w83793_data *data = i2c_get_clientdata(client); - u8 val; - - mutex_lock(&data->update_lock); - val = w83793_read_value(client, W83793_REG_CLR_CHASSIS); - val |= 0x80; - w83793_write_value(client, W83793_REG_CLR_CHASSIS, val); - mutex_unlock(&data->update_lock); - return count; -} - -#define FAN_INPUT 0 -#define FAN_MIN 1 -static ssize_t -show_fan(struct device *dev, struct device_attribute *attr, char *buf) -{ - struct sensor_device_attribute_2 *sensor_attr = - to_sensor_dev_attr_2(attr); - int nr = sensor_attr->nr; - int index = sensor_attr->index; - struct w83793_data *data = w83793_update_device(dev); - u16 val; - - if (FAN_INPUT == nr) { - val = data->fan[index] & 0x0fff; - } else { - val = data->fan_min[index] & 0x0fff; - } - - return sprintf(buf, "%lu\n", FAN_FROM_REG(val)); -} - -static ssize_t -store_fan_min(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) -{ - struct sensor_device_attribute_2 *sensor_attr = - to_sensor_dev_attr_2(attr); - int index = sensor_attr->index; - struct i2c_client *client = to_i2c_client(dev); - struct w83793_data *data = i2c_get_clientdata(client); - u16 val = FAN_TO_REG(simple_strtoul(buf, NULL, 10)); - - mutex_lock(&data->update_lock); - data->fan_min[index] = val; - w83793_write_value(client, W83793_REG_FAN_MIN(index), - (val >> 8) & 0xff); - w83793_write_value(client, W83793_REG_FAN_MIN(index) + 1, val & 0xff); - mutex_unlock(&data->update_lock); - - return count; -} - -#define PWM_DUTY 0 -#define PWM_START 1 -#define PWM_NONSTOP 2 -#define PWM_STOP_TIME 3 -static ssize_t -show_pwm(struct device *dev, struct device_attribute *attr, char *buf) -{ - struct sensor_device_attribute_2 *sensor_attr = - to_sensor_dev_attr_2(attr); - struct w83793_data *data = w83793_update_device(dev); - u16 val; - int nr = sensor_attr->nr; - int index = sensor_attr->index; - - if (PWM_STOP_TIME == nr) - val = TIME_FROM_REG(data->pwm_stop_time[index]); - else - val = (data->pwm[index][nr] & 0x3f) << 2; - - return sprintf(buf, "%d\n", val); -} - -static ssize_t -store_pwm(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct w83793_data *data = i2c_get_clientdata(client); - struct sensor_device_attribute_2 *sensor_attr = - to_sensor_dev_attr_2(attr); - int nr = sensor_attr->nr; - int index = sensor_attr->index; - u8 val; - - mutex_lock(&data->update_lock); - if (PWM_STOP_TIME == nr) { - val = TIME_TO_REG(simple_strtoul(buf, NULL, 10)); - data->pwm_stop_time[index] = val; - w83793_write_value(client, W83793_REG_PWM_STOP_TIME(index), - val); - } else { - val = SENSORS_LIMIT(simple_strtoul(buf, NULL, 10), 0, 0xff) - >> 2; - data->pwm[index][nr] = - w83793_read_value(client, W83793_REG_PWM(index, nr)) & 0xc0; - data->pwm[index][nr] |= val; - w83793_write_value(client, W83793_REG_PWM(index, nr), - data->pwm[index][nr]); - } - - mutex_unlock(&data->update_lock); - return count; -} - -static ssize_t -show_temp(struct device *dev, struct device_attribute *attr, char *buf) -{ - struct sensor_device_attribute_2 *sensor_attr = - to_sensor_dev_attr_2(attr); - int nr = sensor_attr->nr; - int index = sensor_attr->index; - struct w83793_data *data = w83793_update_device(dev); - long temp = TEMP_FROM_REG(data->temp[index][nr]); - - if (TEMP_READ == nr && index < 4) { /* Only TD1-TD4 have low bits */ - int low = ((data->temp_low_bits >> (index * 2)) & 0x03) * 250; - temp += temp > 0 ? low : -low; - } - return sprintf(buf, "%ld\n", temp); -} - -static ssize_t -store_temp(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) -{ - struct sensor_device_attribute_2 *sensor_attr = - to_sensor_dev_attr_2(attr); - int nr = sensor_attr->nr; - int index = sensor_attr->index; - struct i2c_client *client = to_i2c_client(dev); - struct w83793_data *data = i2c_get_clientdata(client); - long tmp = simple_strtol(buf, NULL, 10); - - mutex_lock(&data->update_lock); - data->temp[index][nr] = TEMP_TO_REG(tmp, -128, 127); - w83793_write_value(client, W83793_REG_TEMP[index][nr], - data->temp[index][nr]); - mutex_unlock(&data->update_lock); - return count; -} - -/* - TD1-TD4 - each has 4 mode:(2 bits) - 0: Stop monitor - 1: Use internal temp sensor(default) - 2: Use sensor in AMD CPU and get result by AMDSI - 3: Use sensor in Intel CPU and get result by PECI - - TR1-TR2 - each has 2 mode:(1 bit) - 0: Disable temp sensor monitor - 1: To enable temp sensors monitor -*/ - -/* 0 disable, 5 AMDSI, 6 PECI */ -static u8 TO_TEMP_MODE[] = { 0, 0, 5, 6 }; - -static ssize_t -show_temp_mode(struct device *dev, struct device_attribute *attr, char *buf) -{ - struct w83793_data *data = w83793_update_device(dev); - struct sensor_device_attribute_2 *sensor_attr = - to_sensor_dev_attr_2(attr); - int index = sensor_attr->index; - u8 mask = (index < 4) ? 0x03 : 0x01; - u8 shift = (index < 4) ? (2 * index) : (index - 4); - u8 tmp; - index = (index < 4) ? 0 : 1; - - tmp = (data->temp_mode[index] >> shift) & mask; - - /* for the internal sensor, found out if diode or thermistor */ - if (tmp == 1) { - tmp = index == 0 ? 3 : 4; - } else { - tmp = TO_TEMP_MODE[tmp]; - } - - return sprintf(buf, "%d\n", tmp); -} - -static ssize_t -store_temp_mode(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct w83793_data *data = i2c_get_clientdata(client); - struct sensor_device_attribute_2 *sensor_attr = - to_sensor_dev_attr_2(attr); - int index = sensor_attr->index; - u8 mask = (index < 4) ? 0x03 : 0x01; - u8 shift = (index < 4) ? (2 * index) : (index - 4); - u8 val = simple_strtoul(buf, NULL, 10); - - /* transform the sysfs interface values into table above */ - if ((val == 5 || val == 6) && (index < 4)) { - val -= 3; - } else if ((val == 3 && index < 4) - || (val == 4 && index >= 4) - || val == 0) { - /* transform diode or thermistor into internal enable */ - val = !!val; - } else { - return -EINVAL; - } - - index = (index < 4) ? 0 : 1; - mutex_lock(&data->update_lock); - data->temp_mode[index] = - w83793_read_value(client, W83793_REG_TEMP_MODE[index]); - data->temp_mode[index] &= ~(mask << shift); - data->temp_mode[index] |= val << shift; - w83793_write_value(client, W83793_REG_TEMP_MODE[index], - data->temp_mode[index]); - mutex_unlock(&data->update_lock); - - return count; -} - -#define SETUP_PWM_DEFAULT 0 -#define SETUP_PWM_UPTIME 1 /* Unit in 0.1s */ -#define SETUP_PWM_DOWNTIME 2 /* Unit in 0.1s */ -#define SETUP_TEMP_CRITICAL 3 -static ssize_t -show_sf_setup(struct device *dev, struct device_attribute *attr, char *buf) -{ - struct sensor_device_attribute_2 *sensor_attr = - to_sensor_dev_attr_2(attr); - int nr = sensor_attr->nr; - struct w83793_data *data = w83793_update_device(dev); - u32 val = 0; - - if (SETUP_PWM_DEFAULT == nr) { - val = (data->pwm_default & 0x3f) << 2; - } else if (SETUP_PWM_UPTIME == nr) { - val = TIME_FROM_REG(data->pwm_uptime); - } else if (SETUP_PWM_DOWNTIME == nr) { - val = TIME_FROM_REG(data->pwm_downtime); - } else if (SETUP_TEMP_CRITICAL == nr) { - val = TEMP_FROM_REG(data->temp_critical & 0x7f); - } - - return sprintf(buf, "%d\n", val); -} - -static ssize_t -store_sf_setup(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) -{ - struct sensor_device_attribute_2 *sensor_attr = - to_sensor_dev_attr_2(attr); - int nr = sensor_attr->nr; - struct i2c_client *client = to_i2c_client(dev); - struct w83793_data *data = i2c_get_clientdata(client); - - mutex_lock(&data->update_lock); - if (SETUP_PWM_DEFAULT == nr) { - data->pwm_default = - w83793_read_value(client, W83793_REG_PWM_DEFAULT) & 0xc0; - data->pwm_default |= SENSORS_LIMIT(simple_strtoul(buf, NULL, - 10), - 0, 0xff) >> 2; - w83793_write_value(client, W83793_REG_PWM_DEFAULT, - data->pwm_default); - } else if (SETUP_PWM_UPTIME == nr) { - data->pwm_uptime = TIME_TO_REG(simple_strtoul(buf, NULL, 10)); - data->pwm_uptime += data->pwm_uptime == 0 ? 1 : 0; - w83793_write_value(client, W83793_REG_PWM_UPTIME, - data->pwm_uptime); - } else if (SETUP_PWM_DOWNTIME == nr) { - data->pwm_downtime = TIME_TO_REG(simple_strtoul(buf, NULL, 10)); - data->pwm_downtime += data->pwm_downtime == 0 ? 1 : 0; - w83793_write_value(client, W83793_REG_PWM_DOWNTIME, - data->pwm_downtime); - } else { /* SETUP_TEMP_CRITICAL */ - data->temp_critical = - w83793_read_value(client, W83793_REG_TEMP_CRITICAL) & 0x80; - data->temp_critical |= TEMP_TO_REG(simple_strtol(buf, NULL, 10), - 0, 0x7f); - w83793_write_value(client, W83793_REG_TEMP_CRITICAL, - data->temp_critical); - } - - mutex_unlock(&data->update_lock); - return count; -} - -/* - Temp SmartFan control - TEMP_FAN_MAP - Temp channel control which pwm fan, bitfield, bit 0 indicate pwm1... - It's possible two or more temp channels control the same fan, w83793 - always prefers to pick the most critical request and applies it to - the related Fan. - It's possible one fan is not in any mapping of 6 temp channels, this - means the fan is manual mode - - TEMP_PWM_ENABLE - Each temp channel has its own SmartFan mode, and temp channel - control fans that are set by TEMP_FAN_MAP - 0: SmartFanII mode - 1: Thermal Cruise Mode - - TEMP_CRUISE - Target temperature in thermal cruise mode, w83793 will try to turn - fan speed to keep the temperature of target device around this - temperature. - - TEMP_TOLERANCE - If Temp higher or lower than target with this tolerance, w83793 - will take actions to speed up or slow down the fan to keep the - temperature within the tolerance range. -*/ - -#define TEMP_FAN_MAP 0 -#define TEMP_PWM_ENABLE 1 -#define TEMP_CRUISE 2 -#define TEMP_TOLERANCE 3 -static ssize_t -show_sf_ctrl(struct device *dev, struct device_attribute *attr, char *buf) -{ - struct sensor_device_attribute_2 *sensor_attr = - to_sensor_dev_attr_2(attr); - int nr = sensor_attr->nr; - int index = sensor_attr->index; - struct w83793_data *data = w83793_update_device(dev); - u32 val; - - if (TEMP_FAN_MAP == nr) { - val = data->temp_fan_map[index]; - } else if (TEMP_PWM_ENABLE == nr) { - /* +2 to transfrom into 2 and 3 to conform with sysfs intf */ - val = ((data->pwm_enable >> index) & 0x01) + 2; - } else if (TEMP_CRUISE == nr) { - val = TEMP_FROM_REG(data->temp_cruise[index] & 0x7f); - } else { /* TEMP_TOLERANCE */ - val = data->tolerance[index >> 1] >> ((index & 0x01) ? 4 : 0); - val = TEMP_FROM_REG(val & 0x0f); - } - return sprintf(buf, "%d\n", val); -} - -static ssize_t -store_sf_ctrl(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) -{ - struct sensor_device_attribute_2 *sensor_attr = - to_sensor_dev_attr_2(attr); - int nr = sensor_attr->nr; - int index = sensor_attr->index; - struct i2c_client *client = to_i2c_client(dev); - struct w83793_data *data = i2c_get_clientdata(client); - u32 val; - - mutex_lock(&data->update_lock); - if (TEMP_FAN_MAP == nr) { - val = simple_strtoul(buf, NULL, 10) & 0xff; - w83793_write_value(client, W83793_REG_TEMP_FAN_MAP(index), val); - data->temp_fan_map[index] = val; - } else if (TEMP_PWM_ENABLE == nr) { - val = simple_strtoul(buf, NULL, 10); - if (2 == val || 3 == val) { - data->pwm_enable = - w83793_read_value(client, W83793_REG_PWM_ENABLE); - if (val - 2) - data->pwm_enable |= 1 << index; - else - data->pwm_enable &= ~(1 << index); - w83793_write_value(client, W83793_REG_PWM_ENABLE, - data->pwm_enable); - } else { - mutex_unlock(&data->update_lock); - return -EINVAL; - } - } else if (TEMP_CRUISE == nr) { - data->temp_cruise[index] = - w83793_read_value(client, W83793_REG_TEMP_CRUISE(index)); - val = TEMP_TO_REG(simple_strtol(buf, NULL, 10), 0, 0x7f); - data->temp_cruise[index] &= 0x80; - data->temp_cruise[index] |= val; - - w83793_write_value(client, W83793_REG_TEMP_CRUISE(index), - data->temp_cruise[index]); - } else { /* TEMP_TOLERANCE */ - int i = index >> 1; - u8 shift = (index & 0x01) ? 4 : 0; - data->tolerance[i] = - w83793_read_value(client, W83793_REG_TEMP_TOL(i)); - - val = TEMP_TO_REG(simple_strtol(buf, NULL, 10), 0, 0x0f); - data->tolerance[i] &= ~(0x0f << shift); - data->tolerance[i] |= val << shift; - w83793_write_value(client, W83793_REG_TEMP_TOL(i), - data->tolerance[i]); - } - - mutex_unlock(&data->update_lock); - return count; -} - -static ssize_t -show_sf2_pwm(struct device *dev, struct device_attribute *attr, char *buf) -{ - struct sensor_device_attribute_2 *sensor_attr = - to_sensor_dev_attr_2(attr); - int nr = sensor_attr->nr; - int index = sensor_attr->index; - struct w83793_data *data = w83793_update_device(dev); - - return sprintf(buf, "%d\n", (data->sf2_pwm[index][nr] & 0x3f) << 2); -} - -static ssize_t -store_sf2_pwm(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct w83793_data *data = i2c_get_clientdata(client); - struct sensor_device_attribute_2 *sensor_attr = - to_sensor_dev_attr_2(attr); - int nr = sensor_attr->nr; - int index = sensor_attr->index; - u8 val = SENSORS_LIMIT(simple_strtoul(buf, NULL, 10), 0, 0xff) >> 2; - - mutex_lock(&data->update_lock); - data->sf2_pwm[index][nr] = - w83793_read_value(client, W83793_REG_SF2_PWM(index, nr)) & 0xc0; - data->sf2_pwm[index][nr] |= val; - w83793_write_value(client, W83793_REG_SF2_PWM(index, nr), - data->sf2_pwm[index][nr]); - mutex_unlock(&data->update_lock); - return count; -} - -static ssize_t -show_sf2_temp(struct device *dev, struct device_attribute *attr, char *buf) -{ - struct sensor_device_attribute_2 *sensor_attr = - to_sensor_dev_attr_2(attr); - int nr = sensor_attr->nr; - int index = sensor_attr->index; - struct w83793_data *data = w83793_update_device(dev); - - return sprintf(buf, "%ld\n", - TEMP_FROM_REG(data->sf2_temp[index][nr] & 0x7f)); -} - -static ssize_t -store_sf2_temp(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct w83793_data *data = i2c_get_clientdata(client); - struct sensor_device_attribute_2 *sensor_attr = - to_sensor_dev_attr_2(attr); - int nr = sensor_attr->nr; - int index = sensor_attr->index; - u8 val = TEMP_TO_REG(simple_strtol(buf, NULL, 10), 0, 0x7f); - - mutex_lock(&data->update_lock); - data->sf2_temp[index][nr] = - w83793_read_value(client, W83793_REG_SF2_TEMP(index, nr)) & 0x80; - data->sf2_temp[index][nr] |= val; - w83793_write_value(client, W83793_REG_SF2_TEMP(index, nr), - data->sf2_temp[index][nr]); - mutex_unlock(&data->update_lock); - return count; -} - -/* only Vcore A/B and Vtt have additional 2 bits precision */ -static ssize_t -show_in(struct device *dev, struct device_attribute *attr, char *buf) -{ - struct sensor_device_attribute_2 *sensor_attr = - to_sensor_dev_attr_2(attr); - int nr = sensor_attr->nr; - int index = sensor_attr->index; - struct w83793_data *data = w83793_update_device(dev); - u16 val = data->in[index][nr]; - - if (index < 3) { - val <<= 2; - val += (data->in_low_bits[nr] >> (index * 2)) & 0x3; - } - return sprintf(buf, "%d\n", val * scale_in[index]); -} - -static ssize_t -store_in(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) -{ - struct sensor_device_attribute_2 *sensor_attr = - to_sensor_dev_attr_2(attr); - int nr = sensor_attr->nr; - int index = sensor_attr->index; - struct i2c_client *client = to_i2c_client(dev); - struct w83793_data *data = i2c_get_clientdata(client); - u32 val; - - val = - (simple_strtoul(buf, NULL, 10) + - scale_in[index] / 2) / scale_in[index]; - mutex_lock(&data->update_lock); - if (index > 2) { - val = SENSORS_LIMIT(val, 0, 255); - } else { - val = SENSORS_LIMIT(val, 0, 0x3FF); - data->in_low_bits[nr] = - w83793_read_value(client, W83793_REG_IN_LOW_BITS[nr]); - data->in_low_bits[nr] &= ~(0x03 << (2 * index)); - data->in_low_bits[nr] |= (val & 0x03) << (2 * index); - w83793_write_value(client, W83793_REG_IN_LOW_BITS[nr], - data->in_low_bits[nr]); - val >>= 2; - } - data->in[index][nr] = val; - w83793_write_value(client, W83793_REG_IN[index][nr], - data->in[index][nr]); - mutex_unlock(&data->update_lock); - return count; -} - -#define NOT_USED -1 - -#define SENSOR_ATTR_IN(index) \ - SENSOR_ATTR_2(in##index##_input, S_IRUGO, show_in, NULL, \ - IN_READ, index), \ - SENSOR_ATTR_2(in##index##_max, S_IRUGO | S_IWUSR, show_in, \ - store_in, IN_MAX, index), \ - SENSOR_ATTR_2(in##index##_min, S_IRUGO | S_IWUSR, show_in, \ - store_in, IN_LOW, index), \ - SENSOR_ATTR_2(in##index##_alarm, S_IRUGO, show_alarm_beep, \ - NULL, ALARM_STATUS, index + ((index > 2) ? 1 : 0)), \ - SENSOR_ATTR_2(in##index##_beep, S_IWUSR | S_IRUGO, \ - show_alarm_beep, store_beep, BEEP_ENABLE, \ - index + ((index > 2) ? 1 : 0)) - -#define SENSOR_ATTR_FAN(index) \ - SENSOR_ATTR_2(fan##index##_alarm, S_IRUGO, show_alarm_beep, \ - NULL, ALARM_STATUS, index + 17), \ - SENSOR_ATTR_2(fan##index##_beep, S_IWUSR | S_IRUGO, \ - show_alarm_beep, store_beep, BEEP_ENABLE, index + 17), \ - SENSOR_ATTR_2(fan##index##_input, S_IRUGO, show_fan, \ - NULL, FAN_INPUT, index - 1), \ - SENSOR_ATTR_2(fan##index##_min, S_IWUSR | S_IRUGO, \ - show_fan, store_fan_min, FAN_MIN, index - 1) - -#define SENSOR_ATTR_PWM(index) \ - SENSOR_ATTR_2(pwm##index, S_IWUSR | S_IRUGO, show_pwm, \ - store_pwm, PWM_DUTY, index - 1), \ - SENSOR_ATTR_2(pwm##index##_nonstop, S_IWUSR | S_IRUGO, \ - show_pwm, store_pwm, PWM_NONSTOP, index - 1), \ - SENSOR_ATTR_2(pwm##index##_start, S_IWUSR | S_IRUGO, \ - show_pwm, store_pwm, PWM_START, index - 1), \ - SENSOR_ATTR_2(pwm##index##_stop_time, S_IWUSR | S_IRUGO, \ - show_pwm, store_pwm, PWM_STOP_TIME, index - 1) - -#define SENSOR_ATTR_TEMP(index) \ - SENSOR_ATTR_2(temp##index##_type, S_IRUGO | S_IWUSR, \ - show_temp_mode, store_temp_mode, NOT_USED, index - 1), \ - SENSOR_ATTR_2(temp##index##_input, S_IRUGO, show_temp, \ - NULL, TEMP_READ, index - 1), \ - SENSOR_ATTR_2(temp##index##_max, S_IRUGO | S_IWUSR, show_temp, \ - store_temp, TEMP_CRIT, index - 1), \ - SENSOR_ATTR_2(temp##index##_max_hyst, S_IRUGO | S_IWUSR, \ - show_temp, store_temp, TEMP_CRIT_HYST, index - 1), \ - SENSOR_ATTR_2(temp##index##_warn, S_IRUGO | S_IWUSR, show_temp, \ - store_temp, TEMP_WARN, index - 1), \ - SENSOR_ATTR_2(temp##index##_warn_hyst, S_IRUGO | S_IWUSR, \ - show_temp, store_temp, TEMP_WARN_HYST, index - 1), \ - SENSOR_ATTR_2(temp##index##_alarm, S_IRUGO, \ - show_alarm_beep, NULL, ALARM_STATUS, index + 11), \ - SENSOR_ATTR_2(temp##index##_beep, S_IWUSR | S_IRUGO, \ - show_alarm_beep, store_beep, BEEP_ENABLE, index + 11), \ - SENSOR_ATTR_2(temp##index##_auto_channels_pwm, \ - S_IRUGO | S_IWUSR, show_sf_ctrl, store_sf_ctrl, \ - TEMP_FAN_MAP, index - 1), \ - SENSOR_ATTR_2(temp##index##_pwm_enable, S_IWUSR | S_IRUGO, \ - show_sf_ctrl, store_sf_ctrl, TEMP_PWM_ENABLE, \ - index - 1), \ - SENSOR_ATTR_2(thermal_cruise##index, S_IRUGO | S_IWUSR, \ - show_sf_ctrl, store_sf_ctrl, TEMP_CRUISE, index - 1), \ - SENSOR_ATTR_2(tolerance##index, S_IRUGO | S_IWUSR, show_sf_ctrl,\ - store_sf_ctrl, TEMP_TOLERANCE, index - 1), \ - SENSOR_ATTR_2(temp##index##_auto_point1_pwm, S_IRUGO | S_IWUSR, \ - show_sf2_pwm, store_sf2_pwm, 0, index - 1), \ - SENSOR_ATTR_2(temp##index##_auto_point2_pwm, S_IRUGO | S_IWUSR, \ - show_sf2_pwm, store_sf2_pwm, 1, index - 1), \ - SENSOR_ATTR_2(temp##index##_auto_point3_pwm, S_IRUGO | S_IWUSR, \ - show_sf2_pwm, store_sf2_pwm, 2, index - 1), \ - SENSOR_ATTR_2(temp##index##_auto_point4_pwm, S_IRUGO | S_IWUSR, \ - show_sf2_pwm, store_sf2_pwm, 3, index - 1), \ - SENSOR_ATTR_2(temp##index##_auto_point5_pwm, S_IRUGO | S_IWUSR, \ - show_sf2_pwm, store_sf2_pwm, 4, index - 1), \ - SENSOR_ATTR_2(temp##index##_auto_point6_pwm, S_IRUGO | S_IWUSR, \ - show_sf2_pwm, store_sf2_pwm, 5, index - 1), \ - SENSOR_ATTR_2(temp##index##_auto_point7_pwm, S_IRUGO | S_IWUSR, \ - show_sf2_pwm, store_sf2_pwm, 6, index - 1), \ - SENSOR_ATTR_2(temp##index##_auto_point1_temp, S_IRUGO | S_IWUSR,\ - show_sf2_temp, store_sf2_temp, 0, index - 1), \ - SENSOR_ATTR_2(temp##index##_auto_point2_temp, S_IRUGO | S_IWUSR,\ - show_sf2_temp, store_sf2_temp, 1, index - 1), \ - SENSOR_ATTR_2(temp##index##_auto_point3_temp, S_IRUGO | S_IWUSR,\ - show_sf2_temp, store_sf2_temp, 2, index - 1), \ - SENSOR_ATTR_2(temp##index##_auto_point4_temp, S_IRUGO | S_IWUSR,\ - show_sf2_temp, store_sf2_temp, 3, index - 1), \ - SENSOR_ATTR_2(temp##index##_auto_point5_temp, S_IRUGO | S_IWUSR,\ - show_sf2_temp, store_sf2_temp, 4, index - 1), \ - SENSOR_ATTR_2(temp##index##_auto_point6_temp, S_IRUGO | S_IWUSR,\ - show_sf2_temp, store_sf2_temp, 5, index - 1), \ - SENSOR_ATTR_2(temp##index##_auto_point7_temp, S_IRUGO | S_IWUSR,\ - show_sf2_temp, store_sf2_temp, 6, index - 1) - -static struct sensor_device_attribute_2 w83793_sensor_attr_2[] = { - SENSOR_ATTR_IN(0), - SENSOR_ATTR_IN(1), - SENSOR_ATTR_IN(2), - SENSOR_ATTR_IN(3), - SENSOR_ATTR_IN(4), - SENSOR_ATTR_IN(5), - SENSOR_ATTR_IN(6), - SENSOR_ATTR_IN(7), - SENSOR_ATTR_IN(8), - SENSOR_ATTR_IN(9), - SENSOR_ATTR_TEMP(1), - SENSOR_ATTR_TEMP(2), - SENSOR_ATTR_TEMP(3), - SENSOR_ATTR_TEMP(4), - SENSOR_ATTR_TEMP(5), - SENSOR_ATTR_TEMP(6), - SENSOR_ATTR_FAN(1), - SENSOR_ATTR_FAN(2), - SENSOR_ATTR_FAN(3), - SENSOR_ATTR_FAN(4), - SENSOR_ATTR_FAN(5), - SENSOR_ATTR_PWM(1), - SENSOR_ATTR_PWM(2), - SENSOR_ATTR_PWM(3), -}; - -/* Fan6-Fan12 */ -static struct sensor_device_attribute_2 w83793_left_fan[] = { - SENSOR_ATTR_FAN(6), - SENSOR_ATTR_FAN(7), - SENSOR_ATTR_FAN(8), - SENSOR_ATTR_FAN(9), - SENSOR_ATTR_FAN(10), - SENSOR_ATTR_FAN(11), - SENSOR_ATTR_FAN(12), -}; - -/* Pwm4-Pwm8 */ -static struct sensor_device_attribute_2 w83793_left_pwm[] = { - SENSOR_ATTR_PWM(4), - SENSOR_ATTR_PWM(5), - SENSOR_ATTR_PWM(6), - SENSOR_ATTR_PWM(7), - SENSOR_ATTR_PWM(8), -}; - -static struct sensor_device_attribute_2 sda_single_files[] = { - SENSOR_ATTR_2(cpu0_vid, S_IRUGO, show_vid, NULL, NOT_USED, 0), - SENSOR_ATTR_2(cpu1_vid, S_IRUGO, show_vid, NULL, NOT_USED, 1), - SENSOR_ATTR_2(vrm, S_IWUSR | S_IRUGO, show_vrm, store_vrm, - NOT_USED, NOT_USED), - SENSOR_ATTR_2(chassis, S_IWUSR | S_IRUGO, show_alarm_beep, - store_chassis_clear, ALARM_STATUS, 30), - SENSOR_ATTR_2(beep_enable, S_IWUSR | S_IRUGO, show_beep_enable, - store_beep_enable, NOT_USED, NOT_USED), - SENSOR_ATTR_2(pwm_default, S_IWUSR | S_IRUGO, show_sf_setup, - store_sf_setup, SETUP_PWM_DEFAULT, NOT_USED), - SENSOR_ATTR_2(pwm_uptime, S_IWUSR | S_IRUGO, show_sf_setup, - store_sf_setup, SETUP_PWM_UPTIME, NOT_USED), - SENSOR_ATTR_2(pwm_downtime, S_IWUSR | S_IRUGO, show_sf_setup, - store_sf_setup, SETUP_PWM_DOWNTIME, NOT_USED), - SENSOR_ATTR_2(temp_critical, S_IWUSR | S_IRUGO, show_sf_setup, - store_sf_setup, SETUP_TEMP_CRITICAL, NOT_USED), -}; - -static void w83793_init_client(struct i2c_client *client) -{ - if (reset) { - w83793_write_value(client, W83793_REG_CONFIG, 0x80); - } - - /* Start monitoring */ - w83793_write_value(client, W83793_REG_CONFIG, - w83793_read_value(client, W83793_REG_CONFIG) | 0x01); - -} - -static int w83793_attach_adapter(struct i2c_adapter *adapter) -{ - if (!(adapter->class & I2C_CLASS_HWMON)) - return 0; - return i2c_probe(adapter, &addr_data, w83793_detect); -} - -static int w83793_detach_client(struct i2c_client *client) -{ - struct w83793_data *data = i2c_get_clientdata(client); - struct device *dev = &client->dev; - int err, i; - - /* main client */ - if (data) { - hwmon_device_unregister(data->class_dev); - - for (i = 0; i < ARRAY_SIZE(w83793_sensor_attr_2); i++) - device_remove_file(dev, - &w83793_sensor_attr_2[i].dev_attr); - - for (i = 0; i < ARRAY_SIZE(sda_single_files); i++) - device_remove_file(dev, &sda_single_files[i].dev_attr); - - for (i = 0; i < ARRAY_SIZE(w83793_left_fan); i++) - device_remove_file(dev, &w83793_left_fan[i].dev_attr); - - for (i = 0; i < ARRAY_SIZE(w83793_left_pwm); i++) - device_remove_file(dev, &w83793_left_pwm[i].dev_attr); - } - - if ((err = i2c_detach_client(client))) - return err; - - /* main client */ - if (data) - kfree(data); - /* subclient */ - else - kfree(client); - - return 0; -} - -static int -w83793_create_subclient(struct i2c_adapter *adapter, - struct i2c_client *client, int addr, - struct i2c_client **sub_cli) -{ - int err = 0; - struct i2c_client *sub_client; - - (*sub_cli) = sub_client = - kzalloc(sizeof(struct i2c_client), GFP_KERNEL); - if (!(sub_client)) { - return -ENOMEM; - } - sub_client->addr = 0x48 + addr; - i2c_set_clientdata(sub_client, NULL); - sub_client->adapter = adapter; - sub_client->driver = &w83793_driver; - strlcpy(sub_client->name, "w83793 subclient", I2C_NAME_SIZE); - if ((err = i2c_attach_client(sub_client))) { - dev_err(&client->dev, "subclient registration " - "at address 0x%x failed\n", sub_client->addr); - kfree(sub_client); - } - return err; -} - -static int -w83793_detect_subclients(struct i2c_adapter *adapter, int address, - int kind, struct i2c_client *client) -{ - int i, id, err; - u8 tmp; - struct w83793_data *data = i2c_get_clientdata(client); - - id = i2c_adapter_id(adapter); - if (force_subclients[0] == id && force_subclients[1] == address) { - for (i = 2; i <= 3; i++) { - if (force_subclients[i] < 0x48 - || force_subclients[i] > 0x4f) { - dev_err(&client->dev, - "invalid subclient " - "address %d; must be 0x48-0x4f\n", - force_subclients[i]); - err = -EINVAL; - goto ERROR_SC_0; - } - } - w83793_write_value(client, W83793_REG_I2C_SUBADDR, - (force_subclients[2] & 0x07) | - ((force_subclients[3] & 0x07) << 4)); - } - - tmp = w83793_read_value(client, W83793_REG_I2C_SUBADDR); - if (!(tmp & 0x08)) { - err = - w83793_create_subclient(adapter, client, tmp & 0x7, - &data->lm75[0]); - if (err < 0) - goto ERROR_SC_0; - } - if (!(tmp & 0x80)) { - if ((data->lm75[0] != NULL) - && ((tmp & 0x7) == ((tmp >> 4) & 0x7))) { - dev_err(&client->dev, - "duplicate addresses 0x%x, " - "use force_subclients\n", data->lm75[0]->addr); - err = -ENODEV; - goto ERROR_SC_1; - } - err = w83793_create_subclient(adapter, client, - (tmp >> 4) & 0x7, &data->lm75[1]); - if (err < 0) - goto ERROR_SC_1; - } - - return 0; - - /* Undo inits in case of errors */ - -ERROR_SC_1: - if (data->lm75[0] != NULL) { - i2c_detach_client(data->lm75[0]); - kfree(data->lm75[0]); - } -ERROR_SC_0: - return err; -} - -static int w83793_detect(struct i2c_adapter *adapter, int address, int kind) -{ - int i; - u8 tmp, val; - struct i2c_client *client; - struct device *dev; - struct w83793_data *data; - int files_fan = ARRAY_SIZE(w83793_left_fan) / 7; - int files_pwm = ARRAY_SIZE(w83793_left_pwm) / 5; - int err = 0; - - if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { - goto exit; - } - - /* OK. For now, we presume we have a valid client. We now create the - client structure, even though we cannot fill it completely yet. - But it allows us to access w83793_{read,write}_value. */ - - if (!(data = kzalloc(sizeof(struct w83793_data), GFP_KERNEL))) { - err = -ENOMEM; - goto exit; - } - - client = &data->client; - dev = &client->dev; - i2c_set_clientdata(client, data); - client->addr = address; - client->adapter = adapter; - client->driver = &w83793_driver; - - data->bank = i2c_smbus_read_byte_data(client, W83793_REG_BANKSEL); - - /* Now, we do the remaining detection. */ - if (kind < 0) { - tmp = data->bank & 0x80 ? 0x5c : 0xa3; - /* Check Winbond vendor ID */ - if (tmp != i2c_smbus_read_byte_data(client, - W83793_REG_VENDORID)) { - pr_debug("w83793: Detection failed at check " - "vendor id\n"); - err = -ENODEV; - goto free_mem; - } - - /* If Winbond chip, address of chip and W83793_REG_I2C_ADDR - should match */ - if ((data->bank & 0x07) == 0 - && i2c_smbus_read_byte_data(client, W83793_REG_I2C_ADDR) != - (address << 1)) { - pr_debug("w83793: Detection failed at check " - "i2c addr\n"); - err = -ENODEV; - goto free_mem; - } - - } - - /* We have either had a force parameter, or we have already detected the - Winbond. Determine the chip type now */ - - if (kind <= 0) { - if (0x7b == w83793_read_value(client, W83793_REG_CHIPID)) { - kind = w83793; - } else { - if (kind == 0) - dev_warn(&adapter->dev, "w83793: Ignoring " - "'force' parameter for unknown chip " - "at address 0x%02x\n", address); - err = -ENODEV; - goto free_mem; - } - } - - /* Fill in the remaining client fields and put into the global list */ - strlcpy(client->name, "w83793", I2C_NAME_SIZE); - - mutex_init(&data->update_lock); - - /* Tell the I2C layer a new client has arrived */ - if ((err = i2c_attach_client(client))) - goto free_mem; - - if ((err = w83793_detect_subclients(adapter, address, kind, client))) - goto detach_client; - - /* Initialize the chip */ - w83793_init_client(client); - - data->vrm = vid_which_vrm(); - /* - Only fan 1-5 has their own input pins, - Pwm 1-3 has their own pins - */ - data->has_fan = 0x1f; - data->has_pwm = 0x07; - tmp = w83793_read_value(client, W83793_REG_MFC); - val = w83793_read_value(client, W83793_REG_FANIN_CTRL); - - /* check the function of pins 49-56 */ - if (!(tmp & 0x80)) { - data->has_pwm |= 0x18; /* pwm 4,5 */ - if (val & 0x01) { /* fan 6 */ - data->has_fan |= 0x20; - data->has_pwm |= 0x20; - } - if (val & 0x02) { /* fan 7 */ - data->has_fan |= 0x40; - data->has_pwm |= 0x40; - } - if (!(tmp & 0x40) && (val & 0x04)) { /* fan 8 */ - data->has_fan |= 0x80; - data->has_pwm |= 0x80; - } - } - - if (0x08 == (tmp & 0x0c)) { - if (val & 0x08) /* fan 9 */ - data->has_fan |= 0x100; - if (val & 0x10) /* fan 10 */ - data->has_fan |= 0x200; - } - - if (0x20 == (tmp & 0x30)) { - if (val & 0x20) /* fan 11 */ - data->has_fan |= 0x400; - if (val & 0x40) /* fan 12 */ - data->has_fan |= 0x800; - } - - if ((tmp & 0x01) && (val & 0x04)) { /* fan 8, second location */ - data->has_fan |= 0x80; - data->has_pwm |= 0x80; - } - - /* Register sysfs hooks */ - for (i = 0; i < ARRAY_SIZE(w83793_sensor_attr_2); i++) { - err = device_create_file(dev, - &w83793_sensor_attr_2[i].dev_attr); - if (err) - goto exit_remove; - } - - for (i = 0; i < ARRAY_SIZE(sda_single_files); i++) { - err = device_create_file(dev, &sda_single_files[i].dev_attr); - if (err) - goto exit_remove; - - } - - for (i = 5; i < 12; i++) { - int j; - if (!(data->has_fan & (1 << i))) - continue; - for (j = 0; j < files_fan; j++) { - err = device_create_file(dev, - &w83793_left_fan[(i - 5) * files_fan - + j].dev_attr); - if (err) - goto exit_remove; - } - } - - for (i = 3; i < 8; i++) { - int j; - if (!(data->has_pwm & (1 << i))) - continue; - for (j = 0; j < files_pwm; j++) { - err = device_create_file(dev, - &w83793_left_pwm[(i - 3) * files_pwm - + j].dev_attr); - if (err) - goto exit_remove; - } - } - - data->class_dev = hwmon_device_register(dev); - if (IS_ERR(data->class_dev)) { - err = PTR_ERR(data->class_dev); - goto exit_remove; - } - - return 0; - - /* Unregister sysfs hooks */ - -exit_remove: - for (i = 0; i < ARRAY_SIZE(w83793_sensor_attr_2); i++) - device_remove_file(dev, &w83793_sensor_attr_2[i].dev_attr); - - for (i = 0; i < ARRAY_SIZE(sda_single_files); i++) - device_remove_file(dev, &sda_single_files[i].dev_attr); - - for (i = 0; i < ARRAY_SIZE(w83793_left_fan); i++) - device_remove_file(dev, &w83793_left_fan[i].dev_attr); - - for (i = 0; i < ARRAY_SIZE(w83793_left_pwm); i++) - device_remove_file(dev, &w83793_left_pwm[i].dev_attr); - - if (data->lm75[0] != NULL) { - i2c_detach_client(data->lm75[0]); - kfree(data->lm75[0]); - } - if (data->lm75[1] != NULL) { - i2c_detach_client(data->lm75[1]); - kfree(data->lm75[1]); - } -detach_client: - i2c_detach_client(client); -free_mem: - kfree(data); -exit: - return err; -} - -static void w83793_update_nonvolatile(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct w83793_data *data = i2c_get_clientdata(client); - int i, j; - /* - They are somewhat "stable" registers, and to update them everytime - takes so much time, it's just not worthy. Update them in a long - interval to avoid exception. - */ - if (!(time_after(jiffies, data->last_nonvolatile + HZ * 300) - || !data->valid)) - return; - /* update voltage limits */ - for (i = 1; i < 3; i++) { - for (j = 0; j < ARRAY_SIZE(data->in); j++) { - data->in[j][i] = - w83793_read_value(client, W83793_REG_IN[j][i]); - } - data->in_low_bits[i] = - w83793_read_value(client, W83793_REG_IN_LOW_BITS[i]); - } - - for (i = 0; i < ARRAY_SIZE(data->fan_min); i++) { - /* Update the Fan measured value and limits */ - if (!(data->has_fan & (1 << i))) { - continue; - } - data->fan_min[i] = - w83793_read_value(client, W83793_REG_FAN_MIN(i)) << 8; - data->fan_min[i] |= - w83793_read_value(client, W83793_REG_FAN_MIN(i) + 1); - } - - for (i = 0; i < ARRAY_SIZE(data->temp_fan_map); i++) { - data->temp_fan_map[i] = - w83793_read_value(client, W83793_REG_TEMP_FAN_MAP(i)); - for (j = 1; j < 5; j++) { - data->temp[i][j] = - w83793_read_value(client, W83793_REG_TEMP[i][j]); - } - data->temp_cruise[i] = - w83793_read_value(client, W83793_REG_TEMP_CRUISE(i)); - for (j = 0; j < 7; j++) { - data->sf2_pwm[i][j] = - w83793_read_value(client, W83793_REG_SF2_PWM(i, j)); - data->sf2_temp[i][j] = - w83793_read_value(client, - W83793_REG_SF2_TEMP(i, j)); - } - } - - for (i = 0; i < ARRAY_SIZE(data->temp_mode); i++) - data->temp_mode[i] = - w83793_read_value(client, W83793_REG_TEMP_MODE[i]); - - for (i = 0; i < ARRAY_SIZE(data->tolerance); i++) { - data->tolerance[i] = - w83793_read_value(client, W83793_REG_TEMP_TOL(i)); - } - - for (i = 0; i < ARRAY_SIZE(data->pwm); i++) { - if (!(data->has_pwm & (1 << i))) - continue; - data->pwm[i][PWM_NONSTOP] = - w83793_read_value(client, W83793_REG_PWM(i, PWM_NONSTOP)); - data->pwm[i][PWM_START] = - w83793_read_value(client, W83793_REG_PWM(i, PWM_START)); - data->pwm_stop_time[i] = - w83793_read_value(client, W83793_REG_PWM_STOP_TIME(i)); - } - - data->pwm_default = w83793_read_value(client, W83793_REG_PWM_DEFAULT); - data->pwm_enable = w83793_read_value(client, W83793_REG_PWM_ENABLE); - data->pwm_uptime = w83793_read_value(client, W83793_REG_PWM_UPTIME); - data->pwm_downtime = w83793_read_value(client, W83793_REG_PWM_DOWNTIME); - data->temp_critical = - w83793_read_value(client, W83793_REG_TEMP_CRITICAL); - data->beep_enable = w83793_read_value(client, W83793_REG_OVT_BEEP); - - for (i = 0; i < ARRAY_SIZE(data->beeps); i++) { - data->beeps[i] = w83793_read_value(client, W83793_REG_BEEP(i)); - } - - data->last_nonvolatile = jiffies; -} - -static struct w83793_data *w83793_update_device(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct w83793_data *data = i2c_get_clientdata(client); - int i; - - mutex_lock(&data->update_lock); - - if (!(time_after(jiffies, data->last_updated + HZ * 2) - || !data->valid)) - goto END; - - /* Update the voltages measured value and limits */ - for (i = 0; i < ARRAY_SIZE(data->in); i++) - data->in[i][IN_READ] = - w83793_read_value(client, W83793_REG_IN[i][IN_READ]); - - data->in_low_bits[IN_READ] = - w83793_read_value(client, W83793_REG_IN_LOW_BITS[IN_READ]); - - for (i = 0; i < ARRAY_SIZE(data->fan); i++) { - if (!(data->has_fan & (1 << i))) { - continue; - } - data->fan[i] = - w83793_read_value(client, W83793_REG_FAN(i)) << 8; - data->fan[i] |= - w83793_read_value(client, W83793_REG_FAN(i) + 1); - } - - for (i = 0; i < ARRAY_SIZE(data->temp); i++) - data->temp[i][TEMP_READ] = - w83793_read_value(client, W83793_REG_TEMP[i][TEMP_READ]); - - data->temp_low_bits = - w83793_read_value(client, W83793_REG_TEMP_LOW_BITS); - - for (i = 0; i < ARRAY_SIZE(data->pwm); i++) { - if (data->has_pwm & (1 << i)) - data->pwm[i][PWM_DUTY] = - w83793_read_value(client, - W83793_REG_PWM(i, PWM_DUTY)); - } - - for (i = 0; i < ARRAY_SIZE(data->alarms); i++) - data->alarms[i] = - w83793_read_value(client, W83793_REG_ALARM(i)); - data->vid[0] = w83793_read_value(client, W83793_REG_VID_INA); - data->vid[1] = w83793_read_value(client, W83793_REG_VID_INB); - w83793_update_nonvolatile(dev); - data->last_updated = jiffies; - data->valid = 1; - -END: - mutex_unlock(&data->update_lock); - return data; -} - -/* Ignore the possibility that somebody change bank outside the driver - Must be called with data->update_lock held, except during initialization */ -static u8 w83793_read_value(struct i2c_client *client, u16 reg) -{ - struct w83793_data *data = i2c_get_clientdata(client); - u8 res = 0xff; - u8 new_bank = reg >> 8; - - new_bank |= data->bank & 0xfc; - if (data->bank != new_bank) { - if (i2c_smbus_write_byte_data - (client, W83793_REG_BANKSEL, new_bank) >= 0) - data->bank = new_bank; - else { - dev_err(&client->dev, - "set bank to %d failed, fall back " - "to bank %d, read reg 0x%x error\n", - new_bank, data->bank, reg); - res = 0x0; /* read 0x0 from the chip */ - goto END; - } - } - res = i2c_smbus_read_byte_data(client, reg & 0xff); -END: - return res; -} - -/* Must be called with data->update_lock held, except during initialization */ -static int w83793_write_value(struct i2c_client *client, u16 reg, u8 value) -{ - struct w83793_data *data = i2c_get_clientdata(client); - int res; - u8 new_bank = reg >> 8; - - new_bank |= data->bank & 0xfc; - if (data->bank != new_bank) { - if ((res = i2c_smbus_write_byte_data - (client, W83793_REG_BANKSEL, new_bank)) >= 0) - data->bank = new_bank; - else { - dev_err(&client->dev, - "set bank to %d failed, fall back " - "to bank %d, write reg 0x%x error\n", - new_bank, data->bank, reg); - goto END; - } - } - - res = i2c_smbus_write_byte_data(client, reg & 0xff, value); -END: - return res; -} - -static int __init sensors_w83793_init(void) -{ - return i2c_add_driver(&w83793_driver); -} - -static void __exit sensors_w83793_exit(void) -{ - i2c_del_driver(&w83793_driver); -} - -MODULE_AUTHOR("Yuan Mu"); -MODULE_DESCRIPTION("w83793 driver"); -MODULE_LICENSE("GPL"); - -module_init(sensors_w83793_init); -module_exit(sensors_w83793_exit); diff --git a/trunk/drivers/i2c/busses/i2c-ali1563.c b/trunk/drivers/i2c/busses/i2c-ali1563.c index 8e1e3f8e40a4..33fbb47100a3 100644 --- a/trunk/drivers/i2c/busses/i2c-ali1563.c +++ b/trunk/drivers/i2c/busses/i2c-ali1563.c @@ -2,7 +2,7 @@ * i2c-ali1563.c - i2c driver for the ALi 1563 Southbridge * * Copyright (C) 2004 Patrick Mochel - * 2005 Rudolf Marek + * 2005 Rudolf Marek * * The 1563 southbridge is deceptively similar to the 1533, with a * few notable exceptions. One of those happens to be the fact they diff --git a/trunk/drivers/i2c/chips/tps65010.c b/trunk/drivers/i2c/chips/tps65010.c index 4ee56def61f2..60bef94cd25f 100644 --- a/trunk/drivers/i2c/chips/tps65010.c +++ b/trunk/drivers/i2c/chips/tps65010.c @@ -82,7 +82,7 @@ struct tps65010 { struct i2c_client client; struct mutex lock; int irq; - struct delayed_work work; + struct work_struct work; struct dentry *file; unsigned charging:1; unsigned por:1; @@ -328,7 +328,7 @@ static void tps65010_interrupt(struct tps65010 *tps) { u8 tmp = 0, mask, poll; - /* IRQs won't trigger for certain events, but we can get + /* IRQs won't trigger irqs for certain events, but we can get * others by polling (normally, with external power applied). */ poll = 0; @@ -411,11 +411,10 @@ static void tps65010_interrupt(struct tps65010 *tps) } /* handle IRQs and polling using keventd for now */ -static void tps65010_work(struct work_struct *work) +static void tps65010_work(void *_tps) { - struct tps65010 *tps; + struct tps65010 *tps = _tps; - tps = container_of(work, struct tps65010, work.work); mutex_lock(&tps->lock); tps65010_interrupt(tps); @@ -453,7 +452,7 @@ static irqreturn_t tps65010_irq(int irq, void *_tps) disable_irq_nosync(irq); set_bit(FLAG_IRQ_ENABLE, &tps->flags); - (void) schedule_work(&tps->work.work); + (void) schedule_work(&tps->work); return IRQ_HANDLED; } @@ -466,15 +465,13 @@ static int __exit tps65010_detach_client(struct i2c_client *client) struct tps65010 *tps; tps = container_of(client, struct tps65010, client); - free_irq(tps->irq, tps); #ifdef CONFIG_ARM if (machine_is_omap_h2()) omap_free_gpio(58); if (machine_is_omap_osk()) omap_free_gpio(OMAP_MPUIO(1)); #endif - cancel_delayed_work(&tps->work); - flush_scheduled_work(); + free_irq(tps->irq, tps); debugfs_remove(tps->file); if (i2c_detach_client(client) == 0) kfree(tps); @@ -508,7 +505,7 @@ tps65010_probe(struct i2c_adapter *bus, int address, int kind) return 0; mutex_init(&tps->lock); - INIT_DELAYED_WORK(&tps->work, tps65010_work); + INIT_WORK(&tps->work, tps65010_work, tps); tps->irq = -1; tps->client.addr = address; tps->client.adapter = bus; @@ -623,7 +620,7 @@ tps65010_probe(struct i2c_adapter *bus, int address, int kind) (void) i2c_smbus_write_byte_data(&tps->client, TPS_MASK3, 0x0f | i2c_smbus_read_byte_data(&tps->client, TPS_MASK3)); - tps65010_work(&tps->work.work); + tps65010_work(tps); tps->file = debugfs_create_file(DRIVER_NAME, S_IRUGO, NULL, tps, DEBUG_FOPS); @@ -675,7 +672,7 @@ int tps65010_set_vbus_draw(unsigned mA) && test_and_set_bit( FLAG_VBUS_CHANGED, &the_tps->flags)) { /* gadget drivers call this in_irq() */ - (void) schedule_work(&the_tps->work.work); + (void) schedule_work(&the_tps->work); } local_irq_restore(flags); diff --git a/trunk/drivers/ide/ide-floppy.c b/trunk/drivers/ide/ide-floppy.c index d33717c8afd4..e3a267622bb6 100644 --- a/trunk/drivers/ide/ide-floppy.c +++ b/trunk/drivers/ide/ide-floppy.c @@ -2147,7 +2147,7 @@ static int ide_floppy_probe(ide_drive_t *drive) printk("ide-floppy: passing drive %s to ide-scsi emulation.\n", drive->name); goto failed; } - if ((floppy = kzalloc(sizeof (idefloppy_floppy_t), GFP_KERNEL)) == NULL) { + if ((floppy = (idefloppy_floppy_t *) kzalloc (sizeof (idefloppy_floppy_t), GFP_KERNEL)) == NULL) { printk (KERN_ERR "ide-floppy: %s: Can't allocate a floppy structure\n", drive->name); goto failed; } diff --git a/trunk/drivers/ide/ide-tape.c b/trunk/drivers/ide/ide-tape.c index b3bcd1d7315e..e2f4bb549063 100644 --- a/trunk/drivers/ide/ide-tape.c +++ b/trunk/drivers/ide/ide-tape.c @@ -2573,11 +2573,11 @@ static idetape_stage_t *__idetape_kmalloc_stage (idetape_tape_t *tape, int full, int pages = tape->pages_per_stage; char *b_data = NULL; - if ((stage = kmalloc(sizeof (idetape_stage_t),GFP_KERNEL)) == NULL) + if ((stage = (idetape_stage_t *) kmalloc (sizeof (idetape_stage_t),GFP_KERNEL)) == NULL) return NULL; stage->next = NULL; - bh = stage->bh = kmalloc(sizeof(struct idetape_bh), GFP_KERNEL); + bh = stage->bh = (struct idetape_bh *)kmalloc(sizeof(struct idetape_bh), GFP_KERNEL); if (bh == NULL) goto abort; bh->b_reqnext = NULL; @@ -2607,7 +2607,7 @@ static idetape_stage_t *__idetape_kmalloc_stage (idetape_tape_t *tape, int full, continue; } prev_bh = bh; - if ((bh = kmalloc(sizeof(struct idetape_bh), GFP_KERNEL)) == NULL) { + if ((bh = (struct idetape_bh *)kmalloc(sizeof(struct idetape_bh), GFP_KERNEL)) == NULL) { free_page((unsigned long) b_data); goto abort; } @@ -4860,7 +4860,7 @@ static int ide_tape_probe(ide_drive_t *drive) printk(KERN_WARNING "ide-tape: Use drive %s with ide-scsi emulation and osst.\n", drive->name); printk(KERN_WARNING "ide-tape: OnStream support will be removed soon from ide-tape!\n"); } - tape = kzalloc(sizeof (idetape_tape_t), GFP_KERNEL); + tape = (idetape_tape_t *) kzalloc (sizeof (idetape_tape_t), GFP_KERNEL); if (tape == NULL) { printk(KERN_ERR "ide-tape: %s: Can't allocate a tape structure\n", drive->name); goto failed; diff --git a/trunk/drivers/ide/pci/hpt366.c b/trunk/drivers/ide/pci/hpt366.c index 08119da06d54..e993a51f250e 100644 --- a/trunk/drivers/ide/pci/hpt366.c +++ b/trunk/drivers/ide/pci/hpt366.c @@ -4,7 +4,6 @@ * Copyright (C) 1999-2003 Andre Hedrick * Portions Copyright (C) 2001 Sun Microsystems, Inc. * Portions Copyright (C) 2003 Red Hat Inc - * Portions Copyright (C) 2005-2006 MontaVista Software, Inc. * * Thanks to HighPoint Technologies for their assistance, and hardware. * Special Thanks to Jon Burchmore in SanDiego for the deep pockets, his @@ -12,11 +11,9 @@ * development and support. * * - * HighPoint has its own drivers (open source except for the RAID part) - * available from http://www.highpoint-tech.com/BIOS%20+%20Driver/. - * This may be useful to anyone wanting to work on this driver, however do not - * trust them too much since the code tends to become less and less meaningful - * as the time passes... :-/ + * Highpoint have their own driver (source except for the raid part) + * available from http://www.highpoint-tech.com/hpt3xx-opensource-v131.tgz + * This may be useful to anyone wanting to work on the mainstream hpt IDE. * * Note that final HPT370 support was done by force extraction of GPL. * @@ -55,29 +52,6 @@ * keeping me sane. * Alan Cox * - * - fix the clock turnaround code: it was writing to the wrong ports when - * called for the secondary channel, caching the current clock mode per- - * channel caused the cached register value to get out of sync with the - * actual one, the channels weren't serialized, the turnaround shouldn't - * be done on 66 MHz PCI bus - * - avoid calibrating PLL twice as the second time results in a wrong PCI - * frequency and thus in the wrong timings for the secondary channel - * - disable UltraATA/133 for HPT372 by default (50 MHz DPLL clock do not - * allow for this speed anyway) - * - add support for HPT302N and HPT371N clocking (the same as for HPT372N) - * - HPT371/N are single channel chips, so avoid touching the primary channel - * which exists only virtually (there's no pins for it) - * - fix/remove bad/unused timing tables and use one set of tables for the whole - * HPT37x chip family; save space by introducing the separate transfer mode - * table in which the mode lookup is done - * - use f_CNT value saved by the HighPoint BIOS as reading it directly gives - * the wrong PCI frequency since DPLL has already been calibrated by BIOS - * - fix the hotswap code: it caused RESET- to glitch when tristating the bus, - * and for HPT36x the obsolete HDIO_TRISTATE_HWIF handler was called instead - * - pass to init_chipset() handlers a copy of the IDE PCI device structure as - * they tamper with its fields - * - * */ @@ -102,8 +76,8 @@ /* various tuning parameters */ #define HPT_RESET_STATE_ENGINE -#undef HPT_DELAY_INTERRUPT -#define HPT_SERIALIZE_IO 0 +#undef HPT_DELAY_INTERRUPT +#undef HPT_SERIALIZE_IO static const char *quirk_drives[] = { "QUANTUM FIREBALLlct08 08", @@ -167,175 +141,305 @@ static const char *bad_ata33[] = { NULL }; -static u8 xfer_speeds[] = { - XFER_UDMA_6, - XFER_UDMA_5, - XFER_UDMA_4, - XFER_UDMA_3, - XFER_UDMA_2, - XFER_UDMA_1, - XFER_UDMA_0, - - XFER_MW_DMA_2, - XFER_MW_DMA_1, - XFER_MW_DMA_0, - - XFER_PIO_4, - XFER_PIO_3, - XFER_PIO_2, - XFER_PIO_1, - XFER_PIO_0 +struct chipset_bus_clock_list_entry { + u8 xfer_speed; + unsigned int chipset_settings; }; -/* Key for bus clock timings - * 36x 37x - * bits bits - * 0:3 0:3 data_high_time. Inactive time of DIOW_/DIOR_ for PIO and MW DMA. - * cycles = value + 1 - * 4:7 4:8 data_low_time. Active time of DIOW_/DIOR_ for PIO and MW DMA. - * cycles = value + 1 - * 8:11 9:12 cmd_high_time. Inactive time of DIOW_/DIOR_ during task file - * register access. - * 12:15 13:17 cmd_low_time. Active time of DIOW_/DIOR_ during task file - * register access. - * 16:18 18:20 udma_cycle_time. Clock cycles for UDMA xfer. - * - 21 CLK frequency: 0=ATA clock, 1=dual ATA clock. - * 19:21 22:24 pre_high_time. Time to initialize the 1st cycle for PIO and - * MW DMA xfer. - * 22:24 25:27 cmd_pre_high_time. Time to initialize the 1st PIO cycle for - * task file register access. - * 28 28 UDMA enable. - * 29 29 DMA enable. - * 30 30 PIO MST enable. If set, the chip is in bus master mode during - * PIO xfer. - * 31 31 FIFO enable. +/* key for bus clock timings + * bit + * 0:3 data_high_time. inactive time of DIOW_/DIOR_ for PIO and MW + * DMA. cycles = value + 1 + * 4:8 data_low_time. active time of DIOW_/DIOR_ for PIO and MW + * DMA. cycles = value + 1 + * 9:12 cmd_high_time. inactive time of DIOW_/DIOR_ during task file + * register access. + * 13:17 cmd_low_time. active time of DIOW_/DIOR_ during task file + * register access. + * 18:21 udma_cycle_time. clock freq and clock cycles for UDMA xfer. + * during task file register access. + * 22:24 pre_high_time. time to initialize 1st cycle for PIO and MW DMA + * xfer. + * 25:27 cmd_pre_high_time. time to initialize 1st PIO cycle for task + * register access. + * 28 UDMA enable + * 29 DMA enable + * 30 PIO_MST enable. if set, the chip is in bus master mode during + * PIO. + * 31 FIFO enable. */ +static struct chipset_bus_clock_list_entry forty_base_hpt366[] = { + { XFER_UDMA_4, 0x900fd943 }, + { XFER_UDMA_3, 0x900ad943 }, + { XFER_UDMA_2, 0x900bd943 }, + { XFER_UDMA_1, 0x9008d943 }, + { XFER_UDMA_0, 0x9008d943 }, + + { XFER_MW_DMA_2, 0xa008d943 }, + { XFER_MW_DMA_1, 0xa010d955 }, + { XFER_MW_DMA_0, 0xa010d9fc }, + + { XFER_PIO_4, 0xc008d963 }, + { XFER_PIO_3, 0xc010d974 }, + { XFER_PIO_2, 0xc010d997 }, + { XFER_PIO_1, 0xc010d9c7 }, + { XFER_PIO_0, 0xc018d9d9 }, + { 0, 0x0120d9d9 } +}; + +static struct chipset_bus_clock_list_entry thirty_three_base_hpt366[] = { + { XFER_UDMA_4, 0x90c9a731 }, + { XFER_UDMA_3, 0x90cfa731 }, + { XFER_UDMA_2, 0x90caa731 }, + { XFER_UDMA_1, 0x90cba731 }, + { XFER_UDMA_0, 0x90c8a731 }, + + { XFER_MW_DMA_2, 0xa0c8a731 }, + { XFER_MW_DMA_1, 0xa0c8a732 }, /* 0xa0c8a733 */ + { XFER_MW_DMA_0, 0xa0c8a797 }, + + { XFER_PIO_4, 0xc0c8a731 }, + { XFER_PIO_3, 0xc0c8a742 }, + { XFER_PIO_2, 0xc0d0a753 }, + { XFER_PIO_1, 0xc0d0a7a3 }, /* 0xc0d0a793 */ + { XFER_PIO_0, 0xc0d0a7aa }, /* 0xc0d0a7a7 */ + { 0, 0x0120a7a7 } +}; + +static struct chipset_bus_clock_list_entry twenty_five_base_hpt366[] = { + { XFER_UDMA_4, 0x90c98521 }, + { XFER_UDMA_3, 0x90cf8521 }, + { XFER_UDMA_2, 0x90cf8521 }, + { XFER_UDMA_1, 0x90cb8521 }, + { XFER_UDMA_0, 0x90cb8521 }, + + { XFER_MW_DMA_2, 0xa0ca8521 }, + { XFER_MW_DMA_1, 0xa0ca8532 }, + { XFER_MW_DMA_0, 0xa0ca8575 }, + + { XFER_PIO_4, 0xc0ca8521 }, + { XFER_PIO_3, 0xc0ca8532 }, + { XFER_PIO_2, 0xc0ca8542 }, + { XFER_PIO_1, 0xc0d08572 }, + { XFER_PIO_0, 0xc0d08585 }, + { 0, 0x01208585 } +}; + +/* from highpoint documentation. these are old values */ +static struct chipset_bus_clock_list_entry thirty_three_base_hpt370[] = { +/* { XFER_UDMA_5, 0x1A85F442, 0x16454e31 }, */ + { XFER_UDMA_5, 0x16454e31 }, + { XFER_UDMA_4, 0x16454e31 }, + { XFER_UDMA_3, 0x166d4e31 }, + { XFER_UDMA_2, 0x16494e31 }, + { XFER_UDMA_1, 0x164d4e31 }, + { XFER_UDMA_0, 0x16514e31 }, + + { XFER_MW_DMA_2, 0x26514e21 }, + { XFER_MW_DMA_1, 0x26514e33 }, + { XFER_MW_DMA_0, 0x26514e97 }, + + { XFER_PIO_4, 0x06514e21 }, + { XFER_PIO_3, 0x06514e22 }, + { XFER_PIO_2, 0x06514e33 }, + { XFER_PIO_1, 0x06914e43 }, + { XFER_PIO_0, 0x06914e57 }, + { 0, 0x06514e57 } +}; + +static struct chipset_bus_clock_list_entry sixty_six_base_hpt370[] = { + { XFER_UDMA_5, 0x14846231 }, + { XFER_UDMA_4, 0x14886231 }, + { XFER_UDMA_3, 0x148c6231 }, + { XFER_UDMA_2, 0x148c6231 }, + { XFER_UDMA_1, 0x14906231 }, + { XFER_UDMA_0, 0x14986231 }, + + { XFER_MW_DMA_2, 0x26514e21 }, + { XFER_MW_DMA_1, 0x26514e33 }, + { XFER_MW_DMA_0, 0x26514e97 }, + + { XFER_PIO_4, 0x06514e21 }, + { XFER_PIO_3, 0x06514e22 }, + { XFER_PIO_2, 0x06514e33 }, + { XFER_PIO_1, 0x06914e43 }, + { XFER_PIO_0, 0x06914e57 }, + { 0, 0x06514e57 } +}; + +/* these are the current (4 sep 2001) timings from highpoint */ +static struct chipset_bus_clock_list_entry thirty_three_base_hpt370a[] = { + { XFER_UDMA_5, 0x12446231 }, + { XFER_UDMA_4, 0x12446231 }, + { XFER_UDMA_3, 0x126c6231 }, + { XFER_UDMA_2, 0x12486231 }, + { XFER_UDMA_1, 0x124c6233 }, + { XFER_UDMA_0, 0x12506297 }, + + { XFER_MW_DMA_2, 0x22406c31 }, + { XFER_MW_DMA_1, 0x22406c33 }, + { XFER_MW_DMA_0, 0x22406c97 }, + + { XFER_PIO_4, 0x06414e31 }, + { XFER_PIO_3, 0x06414e42 }, + { XFER_PIO_2, 0x06414e53 }, + { XFER_PIO_1, 0x06814e93 }, + { XFER_PIO_0, 0x06814ea7 }, + { 0, 0x06814ea7 } +}; + +/* 2x 33MHz timings */ +static struct chipset_bus_clock_list_entry sixty_six_base_hpt370a[] = { + { XFER_UDMA_5, 0x1488e673 }, + { XFER_UDMA_4, 0x1488e673 }, + { XFER_UDMA_3, 0x1498e673 }, + { XFER_UDMA_2, 0x1490e673 }, + { XFER_UDMA_1, 0x1498e677 }, + { XFER_UDMA_0, 0x14a0e73f }, + + { XFER_MW_DMA_2, 0x2480fa73 }, + { XFER_MW_DMA_1, 0x2480fa77 }, + { XFER_MW_DMA_0, 0x2480fb3f }, + + { XFER_PIO_4, 0x0c82be73 }, + { XFER_PIO_3, 0x0c82be95 }, + { XFER_PIO_2, 0x0c82beb7 }, + { XFER_PIO_1, 0x0d02bf37 }, + { XFER_PIO_0, 0x0d02bf5f }, + { 0, 0x0d02bf5f } +}; -static u32 forty_base_hpt36x[] = { - /* XFER_UDMA_6 */ 0x900fd943, - /* XFER_UDMA_5 */ 0x900fd943, - /* XFER_UDMA_4 */ 0x900fd943, - /* XFER_UDMA_3 */ 0x900ad943, - /* XFER_UDMA_2 */ 0x900bd943, - /* XFER_UDMA_1 */ 0x9008d943, - /* XFER_UDMA_0 */ 0x9008d943, - - /* XFER_MW_DMA_2 */ 0xa008d943, - /* XFER_MW_DMA_1 */ 0xa010d955, - /* XFER_MW_DMA_0 */ 0xa010d9fc, - - /* XFER_PIO_4 */ 0xc008d963, - /* XFER_PIO_3 */ 0xc010d974, - /* XFER_PIO_2 */ 0xc010d997, - /* XFER_PIO_1 */ 0xc010d9c7, - /* XFER_PIO_0 */ 0xc018d9d9 +static struct chipset_bus_clock_list_entry fifty_base_hpt370a[] = { + { XFER_UDMA_5, 0x12848242 }, + { XFER_UDMA_4, 0x12ac8242 }, + { XFER_UDMA_3, 0x128c8242 }, + { XFER_UDMA_2, 0x120c8242 }, + { XFER_UDMA_1, 0x12148254 }, + { XFER_UDMA_0, 0x121882ea }, + + { XFER_MW_DMA_2, 0x22808242 }, + { XFER_MW_DMA_1, 0x22808254 }, + { XFER_MW_DMA_0, 0x228082ea }, + + { XFER_PIO_4, 0x0a81f442 }, + { XFER_PIO_3, 0x0a81f443 }, + { XFER_PIO_2, 0x0a81f454 }, + { XFER_PIO_1, 0x0ac1f465 }, + { XFER_PIO_0, 0x0ac1f48a }, + { 0, 0x0ac1f48a } }; -static u32 thirty_three_base_hpt36x[] = { - /* XFER_UDMA_6 */ 0x90c9a731, - /* XFER_UDMA_5 */ 0x90c9a731, - /* XFER_UDMA_4 */ 0x90c9a731, - /* XFER_UDMA_3 */ 0x90cfa731, - /* XFER_UDMA_2 */ 0x90caa731, - /* XFER_UDMA_1 */ 0x90cba731, - /* XFER_UDMA_0 */ 0x90c8a731, - - /* XFER_MW_DMA_2 */ 0xa0c8a731, - /* XFER_MW_DMA_1 */ 0xa0c8a732, /* 0xa0c8a733 */ - /* XFER_MW_DMA_0 */ 0xa0c8a797, - - /* XFER_PIO_4 */ 0xc0c8a731, - /* XFER_PIO_3 */ 0xc0c8a742, - /* XFER_PIO_2 */ 0xc0d0a753, - /* XFER_PIO_1 */ 0xc0d0a7a3, /* 0xc0d0a793 */ - /* XFER_PIO_0 */ 0xc0d0a7aa /* 0xc0d0a7a7 */ +static struct chipset_bus_clock_list_entry thirty_three_base_hpt372[] = { + { XFER_UDMA_6, 0x1c81dc62 }, + { XFER_UDMA_5, 0x1c6ddc62 }, + { XFER_UDMA_4, 0x1c8ddc62 }, + { XFER_UDMA_3, 0x1c8edc62 }, /* checkme */ + { XFER_UDMA_2, 0x1c91dc62 }, + { XFER_UDMA_1, 0x1c9adc62 }, /* checkme */ + { XFER_UDMA_0, 0x1c82dc62 }, /* checkme */ + + { XFER_MW_DMA_2, 0x2c829262 }, + { XFER_MW_DMA_1, 0x2c829266 }, /* checkme */ + { XFER_MW_DMA_0, 0x2c82922e }, /* checkme */ + + { XFER_PIO_4, 0x0c829c62 }, + { XFER_PIO_3, 0x0c829c84 }, + { XFER_PIO_2, 0x0c829ca6 }, + { XFER_PIO_1, 0x0d029d26 }, + { XFER_PIO_0, 0x0d029d5e }, + { 0, 0x0d029d5e } }; -static u32 twenty_five_base_hpt36x[] = { - /* XFER_UDMA_6 */ 0x90c98521, - /* XFER_UDMA_5 */ 0x90c98521, - /* XFER_UDMA_4 */ 0x90c98521, - /* XFER_UDMA_3 */ 0x90cf8521, - /* XFER_UDMA_2 */ 0x90cf8521, - /* XFER_UDMA_1 */ 0x90cb8521, - /* XFER_UDMA_0 */ 0x90cb8521, - - /* XFER_MW_DMA_2 */ 0xa0ca8521, - /* XFER_MW_DMA_1 */ 0xa0ca8532, - /* XFER_MW_DMA_0 */ 0xa0ca8575, - - /* XFER_PIO_4 */ 0xc0ca8521, - /* XFER_PIO_3 */ 0xc0ca8532, - /* XFER_PIO_2 */ 0xc0ca8542, - /* XFER_PIO_1 */ 0xc0d08572, - /* XFER_PIO_0 */ 0xc0d08585 +static struct chipset_bus_clock_list_entry fifty_base_hpt372[] = { + { XFER_UDMA_5, 0x12848242 }, + { XFER_UDMA_4, 0x12ac8242 }, + { XFER_UDMA_3, 0x128c8242 }, + { XFER_UDMA_2, 0x120c8242 }, + { XFER_UDMA_1, 0x12148254 }, + { XFER_UDMA_0, 0x121882ea }, + + { XFER_MW_DMA_2, 0x22808242 }, + { XFER_MW_DMA_1, 0x22808254 }, + { XFER_MW_DMA_0, 0x228082ea }, + + { XFER_PIO_4, 0x0a81f442 }, + { XFER_PIO_3, 0x0a81f443 }, + { XFER_PIO_2, 0x0a81f454 }, + { XFER_PIO_1, 0x0ac1f465 }, + { XFER_PIO_0, 0x0ac1f48a }, + { 0, 0x0a81f443 } }; -static u32 thirty_three_base_hpt37x[] = { - /* XFER_UDMA_6 */ 0x12446231, /* 0x12646231 ?? */ - /* XFER_UDMA_5 */ 0x12446231, - /* XFER_UDMA_4 */ 0x12446231, - /* XFER_UDMA_3 */ 0x126c6231, - /* XFER_UDMA_2 */ 0x12486231, - /* XFER_UDMA_1 */ 0x124c6233, - /* XFER_UDMA_0 */ 0x12506297, - - /* XFER_MW_DMA_2 */ 0x22406c31, - /* XFER_MW_DMA_1 */ 0x22406c33, - /* XFER_MW_DMA_0 */ 0x22406c97, - - /* XFER_PIO_4 */ 0x06414e31, - /* XFER_PIO_3 */ 0x06414e42, - /* XFER_PIO_2 */ 0x06414e53, - /* XFER_PIO_1 */ 0x06814e93, - /* XFER_PIO_0 */ 0x06814ea7 +static struct chipset_bus_clock_list_entry sixty_six_base_hpt372[] = { + { XFER_UDMA_6, 0x1c869c62 }, + { XFER_UDMA_5, 0x1cae9c62 }, + { XFER_UDMA_4, 0x1c8a9c62 }, + { XFER_UDMA_3, 0x1c8e9c62 }, + { XFER_UDMA_2, 0x1c929c62 }, + { XFER_UDMA_1, 0x1c9a9c62 }, + { XFER_UDMA_0, 0x1c829c62 }, + + { XFER_MW_DMA_2, 0x2c829c62 }, + { XFER_MW_DMA_1, 0x2c829c66 }, + { XFER_MW_DMA_0, 0x2c829d2e }, + + { XFER_PIO_4, 0x0c829c62 }, + { XFER_PIO_3, 0x0c829c84 }, + { XFER_PIO_2, 0x0c829ca6 }, + { XFER_PIO_1, 0x0d029d26 }, + { XFER_PIO_0, 0x0d029d5e }, + { 0, 0x0d029d26 } }; -static u32 fifty_base_hpt37x[] = { - /* XFER_UDMA_6 */ 0x12848242, - /* XFER_UDMA_5 */ 0x12848242, - /* XFER_UDMA_4 */ 0x12ac8242, - /* XFER_UDMA_3 */ 0x128c8242, - /* XFER_UDMA_2 */ 0x120c8242, - /* XFER_UDMA_1 */ 0x12148254, - /* XFER_UDMA_0 */ 0x121882ea, - - /* XFER_MW_DMA_2 */ 0x22808242, - /* XFER_MW_DMA_1 */ 0x22808254, - /* XFER_MW_DMA_0 */ 0x228082ea, - - /* XFER_PIO_4 */ 0x0a81f442, - /* XFER_PIO_3 */ 0x0a81f443, - /* XFER_PIO_2 */ 0x0a81f454, - /* XFER_PIO_1 */ 0x0ac1f465, - /* XFER_PIO_0 */ 0x0ac1f48a +static struct chipset_bus_clock_list_entry thirty_three_base_hpt374[] = { + { XFER_UDMA_6, 0x12808242 }, + { XFER_UDMA_5, 0x12848242 }, + { XFER_UDMA_4, 0x12ac8242 }, + { XFER_UDMA_3, 0x128c8242 }, + { XFER_UDMA_2, 0x120c8242 }, + { XFER_UDMA_1, 0x12148254 }, + { XFER_UDMA_0, 0x121882ea }, + + { XFER_MW_DMA_2, 0x22808242 }, + { XFER_MW_DMA_1, 0x22808254 }, + { XFER_MW_DMA_0, 0x228082ea }, + + { XFER_PIO_4, 0x0a81f442 }, + { XFER_PIO_3, 0x0a81f443 }, + { XFER_PIO_2, 0x0a81f454 }, + { XFER_PIO_1, 0x0ac1f465 }, + { XFER_PIO_0, 0x0ac1f48a }, + { 0, 0x06814e93 } }; -static u32 sixty_six_base_hpt37x[] = { - /* XFER_UDMA_6 */ 0x1c869c62, - /* XFER_UDMA_5 */ 0x1cae9c62, /* 0x1c8a9c62 */ - /* XFER_UDMA_4 */ 0x1c8a9c62, - /* XFER_UDMA_3 */ 0x1c8e9c62, - /* XFER_UDMA_2 */ 0x1c929c62, - /* XFER_UDMA_1 */ 0x1c9a9c62, - /* XFER_UDMA_0 */ 0x1c829c62, - - /* XFER_MW_DMA_2 */ 0x2c829c62, - /* XFER_MW_DMA_1 */ 0x2c829c66, - /* XFER_MW_DMA_0 */ 0x2c829d2e, - - /* XFER_PIO_4 */ 0x0c829c62, - /* XFER_PIO_3 */ 0x0c829c84, - /* XFER_PIO_2 */ 0x0c829ca6, - /* XFER_PIO_1 */ 0x0d029d26, - /* XFER_PIO_0 */ 0x0d029d5e +/* FIXME: 50MHz timings for HPT374 */ + +#if 0 +static struct chipset_bus_clock_list_entry sixty_six_base_hpt374[] = { + { XFER_UDMA_6, 0x12406231 }, /* checkme */ + { XFER_UDMA_5, 0x12446231 }, /* 0x14846231 */ + { XFER_UDMA_4, 0x16814ea7 }, /* 0x14886231 */ + { XFER_UDMA_3, 0x16814ea7 }, /* 0x148c6231 */ + { XFER_UDMA_2, 0x16814ea7 }, /* 0x148c6231 */ + { XFER_UDMA_1, 0x16814ea7 }, /* 0x14906231 */ + { XFER_UDMA_0, 0x16814ea7 }, /* 0x14986231 */ + { XFER_MW_DMA_2, 0x16814ea7 }, /* 0x26514e21 */ + { XFER_MW_DMA_1, 0x16814ea7 }, /* 0x26514e97 */ + { XFER_MW_DMA_0, 0x16814ea7 }, /* 0x26514e97 */ + { XFER_PIO_4, 0x06814ea7 }, /* 0x06514e21 */ + { XFER_PIO_3, 0x06814ea7 }, /* 0x06514e22 */ + { XFER_PIO_2, 0x06814ea7 }, /* 0x06514e33 */ + { XFER_PIO_1, 0x06814ea7 }, /* 0x06914e43 */ + { XFER_PIO_0, 0x06814ea7 }, /* 0x06914e57 */ + { 0, 0x06814ea7 } }; +#endif #define HPT366_DEBUG_DRIVE_INFO 0 #define HPT374_ALLOW_ATA133_6 0 #define HPT371_ALLOW_ATA133_6 0 #define HPT302_ALLOW_ATA133_6 0 -#define HPT372_ALLOW_ATA133_6 0 +#define HPT372_ALLOW_ATA133_6 1 #define HPT370_ALLOW_ATA100_5 1 #define HPT366_ALLOW_ATA66_4 1 #define HPT366_ALLOW_ATA66_3 1 @@ -357,10 +461,9 @@ struct hpt_info int revision; /* Chipset revision */ int flags; /* Chipset properties */ #define PLL_MODE 1 -#define IS_3xxN 2 -#define PCI_66MHZ 4 +#define IS_372N 2 /* Speed table */ - u32 *speed; + struct chipset_bus_clock_list_entry *speed; }; /* @@ -497,20 +600,12 @@ static int check_in_drive_lists (ide_drive_t *drive, const char **list) return 0; } -static u32 pci_bus_clock_list(u8 speed, u32 *chipset_table) +static unsigned int pci_bus_clock_list (u8 speed, struct chipset_bus_clock_list_entry * chipset_table) { - int i; - - /* - * Lookup the transfer mode table to get the index into - * the timing table. - * - * NOTE: For XFER_PIO_SLOW, PIO mode 0 timings will be used. - */ - for (i = 0; i < ARRAY_SIZE(xfer_speeds) - 1; i++) - if (xfer_speeds[i] == speed) - break; - return chipset_table[i]; + for ( ; chipset_table->xfer_speed ; chipset_table++) + if (chipset_table->xfer_speed == speed) + return chipset_table->chipset_settings; + return chipset_table->chipset_settings; } static int hpt36x_tune_chipset(ide_drive_t *drive, u8 xferspeed) @@ -861,127 +956,156 @@ static int hpt374_ide_dma_end (ide_drive_t *drive) } /** - * hpt3xxn_set_clock - perform clock switching dance - * @hwif: hwif to switch - * @mode: clocking mode (0x21 for write, 0x23 otherwise) + * hpt372n_set_clock - perform clock switching dance + * @drive: Drive to switch + * @mode: Switching mode (0x21 for write, 0x23 otherwise) * - * Switch the DPLL clock on the HPT3xxN devices. This is a right mess. - * NOTE: avoid touching the disabled primary channel on HPT371N -- it - * doesn't physically exist anyway... + * Switch the DPLL clock on the HPT372N devices. This is a + * right mess. */ - -static void hpt3xxn_set_clock(ide_hwif_t *hwif, u8 mode) + +static void hpt372n_set_clock(ide_drive_t *drive, int mode) { - u8 mcr1, scr2 = hwif->INB(hwif->dma_master + 0x7b); - - if ((scr2 & 0x7f) == mode) - return; - - /* MISC. control register 1 has the channel enable bit... */ - mcr1 = hwif->INB(hwif->dma_master + 0x70); - + ide_hwif_t *hwif = HWIF(drive); + + /* FIXME: should we check for DMA active and BUG() */ /* Tristate the bus */ - if (mcr1 & 0x04) - hwif->OUTB(0x80, hwif->dma_master + 0x73); - hwif->OUTB(0x80, hwif->dma_master + 0x77); - + outb(0x80, hwif->dma_base+0x73); + outb(0x80, hwif->dma_base+0x77); + /* Switch clock and reset channels */ - hwif->OUTB(mode, hwif->dma_master + 0x7b); - hwif->OUTB(0xc0, hwif->dma_master + 0x79); - + outb(mode, hwif->dma_base+0x7B); + outb(0xC0, hwif->dma_base+0x79); + /* Reset state machines */ - if (mcr1 & 0x04) - hwif->OUTB(0x37, hwif->dma_master + 0x70); - hwif->OUTB(0x37, hwif->dma_master + 0x74); - + outb(0x37, hwif->dma_base+0x70); + outb(0x37, hwif->dma_base+0x74); + /* Complete reset */ - hwif->OUTB(0x00, hwif->dma_master + 0x79); - + outb(0x00, hwif->dma_base+0x79); + /* Reconnect channels to bus */ - if (mcr1 & 0x04) - hwif->OUTB(0x00, hwif->dma_master + 0x73); - hwif->OUTB(0x00, hwif->dma_master + 0x77); + outb(0x00, hwif->dma_base+0x73); + outb(0x00, hwif->dma_base+0x77); } /** - * hpt3xxn_rw_disk - prepare for I/O + * hpt372n_rw_disk - prepare for I/O * @drive: drive for command * @rq: block request structure * - * This is called when a disk I/O is issued to HPT3xxN. + * This is called when a disk I/O is issued to the 372N. * We need it because of the clock switching. */ -static void hpt3xxn_rw_disk(ide_drive_t *drive, struct request *rq) +static void hpt372n_rw_disk(ide_drive_t *drive, struct request *rq) +{ + ide_hwif_t *hwif = drive->hwif; + int wantclock; + + wantclock = rq_data_dir(rq) ? 0x23 : 0x21; + + if (hwif->config_data != wantclock) { + hpt372n_set_clock(drive, wantclock); + hwif->config_data = wantclock; + } +} + +/* + * Since SUN Cobalt is attempting to do this operation, I should disclose + * this has been a long time ago Thu Jul 27 16:40:57 2000 was the patch date + * HOTSWAP ATA Infrastructure. + */ + +static void hpt3xx_reset (ide_drive_t *drive) +{ +} + +static int hpt3xx_tristate (ide_drive_t * drive, int state) { ide_hwif_t *hwif = HWIF(drive); - u8 wantclock = rq_data_dir(rq) ? 0x23 : 0x21; + struct pci_dev *dev = hwif->pci_dev; + u8 reg59h = 0, reset = (hwif->channel) ? 0x80 : 0x40; + u8 regXXh = 0, state_reg= (hwif->channel) ? 0x57 : 0x53; + + pci_read_config_byte(dev, 0x59, ®59h); + pci_read_config_byte(dev, state_reg, ®XXh); - hpt3xxn_set_clock(hwif, wantclock); + if (state) { + (void) ide_do_reset(drive); + pci_write_config_byte(dev, state_reg, regXXh|0x80); + pci_write_config_byte(dev, 0x59, reg59h|reset); + } else { + pci_write_config_byte(dev, 0x59, reg59h & ~(reset)); + pci_write_config_byte(dev, state_reg, regXXh & ~(0x80)); + (void) ide_do_reset(drive); + } + return 0; } /* - * Set/get power state for a drive. + * set/get power state for a drive. + * turning the power off does the following things: + * 1) soft-reset the drive + * 2) tri-states the ide bus * - * When we turn the power back on, we need to re-initialize things. + * when we turn things back on, we need to re-initialize things. */ #define TRISTATE_BIT 0x8000 - -static int hpt3xx_busproc(ide_drive_t *drive, int state) +static int hpt370_busproc(ide_drive_t * drive, int state) { ide_hwif_t *hwif = drive->hwif; struct pci_dev *dev = hwif->pci_dev; - u8 tristate, resetmask, bus_reg = 0; - u16 tri_reg = 0; + u8 tristate = 0, resetmask = 0, bus_reg = 0; + u16 tri_reg; hwif->bus_state = state; if (hwif->channel) { /* secondary channel */ - tristate = 0x56; - resetmask = 0x80; + tristate = 0x56; + resetmask = 0x80; } else { /* primary channel */ - tristate = 0x52; + tristate = 0x52; resetmask = 0x40; } - /* Grab the status. */ + /* grab status */ pci_read_config_word(dev, tristate, &tri_reg); pci_read_config_byte(dev, 0x59, &bus_reg); - /* - * Set the state. We don't set it if we don't need to do so. - * Make sure that the drive knows that it has failed if it's off. - */ + /* set the state. we don't set it if we don't need to do so. + * make sure that the drive knows that it has failed if it's off */ switch (state) { case BUSSTATE_ON: - if (!(bus_reg & resetmask)) + hwif->drives[0].failures = 0; + hwif->drives[1].failures = 0; + if ((bus_reg & resetmask) == 0) return 0; - hwif->drives[0].failures = hwif->drives[1].failures = 0; - - pci_write_config_byte(dev, 0x59, bus_reg & ~resetmask); - pci_write_config_word(dev, tristate, tri_reg & ~TRISTATE_BIT); - return 0; + tri_reg &= ~TRISTATE_BIT; + bus_reg &= ~resetmask; + break; case BUSSTATE_OFF: - if ((bus_reg & resetmask) && !(tri_reg & TRISTATE_BIT)) + hwif->drives[0].failures = hwif->drives[0].max_failures + 1; + hwif->drives[1].failures = hwif->drives[1].max_failures + 1; + if ((tri_reg & TRISTATE_BIT) == 0 && (bus_reg & resetmask)) return 0; tri_reg &= ~TRISTATE_BIT; + bus_reg |= resetmask; break; case BUSSTATE_TRISTATE: - if ((bus_reg & resetmask) && (tri_reg & TRISTATE_BIT)) + hwif->drives[0].failures = hwif->drives[0].max_failures + 1; + hwif->drives[1].failures = hwif->drives[1].max_failures + 1; + if ((tri_reg & TRISTATE_BIT) && (bus_reg & resetmask)) return 0; tri_reg |= TRISTATE_BIT; + bus_reg |= resetmask; break; - default: - return -EINVAL; } - - hwif->drives[0].failures = hwif->drives[0].max_failures + 1; - hwif->drives[1].failures = hwif->drives[1].max_failures + 1; - + pci_write_config_byte(dev, 0x59, bus_reg); pci_write_config_word(dev, tristate, tri_reg); - pci_write_config_byte(dev, 0x59, bus_reg | resetmask); + return 0; } @@ -995,14 +1119,14 @@ static void __devinit hpt366_clocking(ide_hwif_t *hwif) /* detect bus speed by looking at control reg timing: */ switch((reg1 >> 8) & 7) { case 5: - info->speed = forty_base_hpt36x; + info->speed = forty_base_hpt366; break; case 9: - info->speed = twenty_five_base_hpt36x; + info->speed = twenty_five_base_hpt366; break; case 7: default: - info->speed = thirty_three_base_hpt36x; + info->speed = thirty_three_base_hpt366; break; } } @@ -1012,9 +1136,9 @@ static void __devinit hpt37x_clocking(ide_hwif_t *hwif) struct hpt_info *info = ide_get_hwifdata(hwif); struct pci_dev *dev = hwif->pci_dev; int adjust, i; - u16 freq = 0; - u32 pll, temp = 0; - u8 reg5bh = 0, mcr1 = 0; + u16 freq; + u32 pll; + u8 reg5bh; /* * default to pci clock. make sure MA15/16 are set to output @@ -1027,40 +1151,27 @@ static void __devinit hpt37x_clocking(ide_hwif_t *hwif) pci_write_config_byte(dev, 0x5b, 0x23); /* - * We'll have to read f_CNT value in order to determine - * the PCI clock frequency according to the following ratio: - * - * f_CNT = Fpci * 192 / Fdpll - * - * First try reading the register in which the HighPoint BIOS - * saves f_CNT value before reprogramming the DPLL from its - * default setting (which differs for the various chips). - * NOTE: This register is only accessible via I/O space. + * set up the PLL. we need to adjust it so that it's stable. + * freq = Tpll * 192 / Tpci * - * In case the signature check fails, we'll have to resort to - * reading the f_CNT register itself in hopes that nobody has - * touched the DPLL yet... + * Todo. For non x86 should probably check the dword is + * set to 0xABCDExxx indicating the BIOS saved f_CNT */ - temp = inl(pci_resource_start(dev, 4) + 0x90); - if ((temp & 0xFFFFF000) != 0xABCDE000) { - printk(KERN_WARNING "HPT37X: no clock data saved by BIOS\n"); - - /* Calculate the average value of f_CNT */ - for (temp = i = 0; i < 128; i++) { - pci_read_config_word(dev, 0x78, &freq); - temp += freq & 0x1ff; - mdelay(1); - } - freq = temp / 128; - } else - freq = temp & 0x1ff; - + pci_read_config_word(dev, 0x78, &freq); + freq &= 0x1FF; + /* - * HPT3xxN chips use different PCI clock information. - * Currently we always set up the PLL for them. + * The 372N uses different PCI clock information and has + * some other complications + * On PCI33 timing we must clock switch + * On PCI66 timing we must NOT use the PCI clock + * + * Currently we always set up the PLL for the 372N */ - - if (info->flags & IS_3xxN) { + + if(info->flags & IS_372N) + { + printk(KERN_INFO "hpt: HPT372N detected, using 372N timing.\n"); if(freq < 0x55) pll = F_LOW_PCI_33; else if(freq < 0x70) @@ -1069,8 +1180,10 @@ static void __devinit hpt37x_clocking(ide_hwif_t *hwif) pll = F_LOW_PCI_50; else pll = F_LOW_PCI_66; - - printk(KERN_INFO "HPT3xxN detected, FREQ: %d, PLL: %d\n", freq, pll); + + printk(KERN_INFO "FREQ: %d PLL: %d\n", freq, pll); + + /* We always use the pll not the PCI clock on 372N */ } else { @@ -1084,22 +1197,41 @@ static void __devinit hpt37x_clocking(ide_hwif_t *hwif) pll = F_LOW_PCI_66; if (pll == F_LOW_PCI_33) { - info->speed = thirty_three_base_hpt37x; + if (info->revision >= 8) + info->speed = thirty_three_base_hpt374; + else if (info->revision >= 5) + info->speed = thirty_three_base_hpt372; + else if (info->revision >= 4) + info->speed = thirty_three_base_hpt370a; + else + info->speed = thirty_three_base_hpt370; printk(KERN_DEBUG "HPT37X: using 33MHz PCI clock\n"); } else if (pll == F_LOW_PCI_40) { /* Unsupported */ } else if (pll == F_LOW_PCI_50) { - info->speed = fifty_base_hpt37x; + if (info->revision >= 8) + info->speed = fifty_base_hpt370a; + else if (info->revision >= 5) + info->speed = fifty_base_hpt372; + else if (info->revision >= 4) + info->speed = fifty_base_hpt370a; + else + info->speed = fifty_base_hpt370a; printk(KERN_DEBUG "HPT37X: using 50MHz PCI clock\n"); } else { - info->speed = sixty_six_base_hpt37x; + if (info->revision >= 8) { + printk(KERN_ERR "HPT37x: 66MHz timings are not supported.\n"); + } + else if (info->revision >= 5) + info->speed = sixty_six_base_hpt372; + else if (info->revision >= 4) + info->speed = sixty_six_base_hpt370a; + else + info->speed = sixty_six_base_hpt370; printk(KERN_DEBUG "HPT37X: using 66MHz PCI clock\n"); } } - - if (pll == F_LOW_PCI_66) - info->flags |= PCI_66MHZ; - + /* * only try the pll if we don't have a table for the clock * speed that we're running at. NOTE: the internal PLL will @@ -1116,8 +1248,11 @@ static void __devinit hpt37x_clocking(ide_hwif_t *hwif) info->flags |= PLL_MODE; /* - * Adjust the PLL based upon the PCI clock, enable it, and - * wait for stabilization... + * FIXME: make this work correctly, esp with 372N as per + * reference driver code. + * + * adjust PLL based upon PCI clock, enable it, and wait for + * stabilization. */ adjust = 0; freq = (pll < F_LOW_PCI_50) ? 2 : 4; @@ -1140,12 +1275,22 @@ static void __devinit hpt37x_clocking(ide_hwif_t *hwif) pci_write_config_dword(dev, 0x5c, pll & ~0x100); pci_write_config_byte(dev, 0x5b, 0x21); - - info->speed = fifty_base_hpt37x; + if (info->revision >= 8) + info->speed = fifty_base_hpt370a; + else if (info->revision >= 5) + info->speed = fifty_base_hpt372; + else if (info->revision >= 4) + info->speed = fifty_base_hpt370a; + else + info->speed = fifty_base_hpt370a; printk("HPT37X: using 50MHz internal PLL\n"); goto init_hpt37X_done; } } + if (!pci_get_drvdata(dev)) { + printk("No Clock Stabilization!!!\n"); + return; + } pll_recal: if (adjust & 1) pll -= (adjust >> 1); @@ -1155,16 +1300,11 @@ static void __devinit hpt37x_clocking(ide_hwif_t *hwif) init_hpt37X_done: if (!info->speed) - printk(KERN_ERR "HPT37x%s: unknown bus timing [%d %d].\n", - (info->flags & IS_3xxN) ? "N" : "", pll, freq); - /* - * Reset the state engines. - * NOTE: avoid accidentally enabling the primary channel on HPT371N. - */ - pci_read_config_byte(dev, 0x50, &mcr1); - if (mcr1 & 0x04) - pci_write_config_byte(dev, 0x50, 0x37); - pci_write_config_byte(dev, 0x54, 0x37); + printk(KERN_ERR "HPT37X%s: unknown bus timing [%d %d].\n", + (info->flags & IS_372N)?"N":"", pll, freq); + /* reset state engine */ + pci_write_config_byte(dev, 0x50, 0x37); + pci_write_config_byte(dev, 0x54, 0x37); udelay(100); } @@ -1227,7 +1367,6 @@ static void __devinit init_hwif_hpt366(ide_hwif_t *hwif) struct pci_dev *dev = hwif->pci_dev; struct hpt_info *info = ide_get_hwifdata(hwif); u8 ata66 = 0, regmask = (hwif->channel) ? 0x01 : 0x02; - int serialize = HPT_SERIALIZE_IO; hwif->tuneproc = &hpt3xx_tune_drive; hwif->speedproc = &hpt3xx_tune_chipset; @@ -1235,20 +1374,8 @@ static void __devinit init_hwif_hpt366(ide_hwif_t *hwif) hwif->intrproc = &hpt3xx_intrproc; hwif->maskproc = &hpt3xx_maskproc; - /* - * HPT3xxN chips have some complications: - * - * - on 33 MHz PCI we must clock switch - * - on 66 MHz PCI we must NOT use the PCI clock - */ - if ((info->flags & (IS_3xxN | PCI_66MHZ)) == IS_3xxN) { - /* - * Clock is shared between the channels, - * so we'll have to serialize them... :-( - */ - serialize = 1; - hwif->rw_disk = &hpt3xxn_rw_disk; - } + if(info->flags & IS_372N) + hwif->rw_disk = &hpt372n_rw_disk; /* * The HPT37x uses the CBLID pins as outputs for MA15/MA16 @@ -1291,15 +1418,29 @@ static void __devinit init_hwif_hpt366(ide_hwif_t *hwif) PCI_FUNC(hwif->pci_dev->devfn)); #endif /* DEBUG */ - /* Serialize access to this device */ - if (serialize && hwif->mate) +#ifdef HPT_SERIALIZE_IO + /* serialize access to this device */ + if (hwif->mate) hwif->serialized = hwif->mate->serialized = 1; +#endif - /* - * Set up ioctl for power status. - * NOTE: power affects both drives on each channel. - */ - hwif->busproc = &hpt3xx_busproc; + if (info->revision >= 3) { + u8 reg5ah = 0; + pci_write_config_byte(dev, 0x5a, reg5ah & ~0x10); + /* + * set up ioctl for power status. + * note: power affects both + * drives on each channel + */ + hwif->resetproc = &hpt3xx_reset; + hwif->busproc = &hpt370_busproc; + } else if (info->revision >= 2) { + hwif->resetproc = &hpt3xx_reset; + hwif->busproc = &hpt3xx_tristate; + } else { + hwif->resetproc = &hpt3xx_reset; + hwif->busproc = &hpt3xx_tristate; + } if (!hwif->dma_base) { hwif->drives[0].autotune = 1; @@ -1349,7 +1490,7 @@ static void __devinit init_dma_hpt366(ide_hwif_t *hwif, unsigned long dmabase) return; if(info->speed == NULL) { - printk(KERN_WARNING "hpt366: no known IDE timings, disabling DMA.\n"); + printk(KERN_WARNING "hpt: no known IDE timings, disabling DMA.\n"); return; } @@ -1378,10 +1519,9 @@ static void __devinit init_dma_hpt366(ide_hwif_t *hwif, unsigned long dmabase) static void __devinit init_iops_hpt366(ide_hwif_t *hwif) { - struct hpt_info *info = kzalloc(sizeof(struct hpt_info), GFP_KERNEL); - struct pci_dev *dev = hwif->pci_dev; - u16 did = dev->device; - u8 rid = 0; + struct hpt_info *info = kzalloc(sizeof(struct hpt_info), GFP_KERNEL); + unsigned long dmabase = pci_resource_start(hwif->pci_dev, 4); + u8 did, rid; if(info == NULL) { printk(KERN_WARNING "hpt366: out of memory.\n"); @@ -1389,22 +1529,15 @@ static void __devinit init_iops_hpt366(ide_hwif_t *hwif) } ide_set_hwifdata(hwif, info); - /* Avoid doing the same thing twice. */ - if (hwif->channel && hwif->mate) { - memcpy(info, ide_get_hwifdata(hwif->mate), sizeof(struct hpt_info)); - return; - } + if(dmabase) { + did = inb(dmabase + 0x22); + rid = inb(dmabase + 0x28); - pci_read_config_byte(dev, PCI_CLASS_REVISION, &rid); - - if (( did == PCI_DEVICE_ID_TTI_HPT366 && rid == 6) || - ((did == PCI_DEVICE_ID_TTI_HPT372 || - did == PCI_DEVICE_ID_TTI_HPT302 || - did == PCI_DEVICE_ID_TTI_HPT371) && rid > 1) || - did == PCI_DEVICE_ID_TTI_HPT372N) - info->flags |= IS_3xxN; + if((did == 4 && rid == 6) || (did == 5 && rid > 1)) + info->flags |= IS_372N; + } - info->revision = hpt_revision(dev); + info->revision = hpt_revision(hwif->pci_dev); if (info->revision >= 3) hpt37x_clocking(hwif); @@ -1441,23 +1574,6 @@ static int __devinit init_setup_hpt37x(struct pci_dev *dev, ide_pci_device_t *d) return ide_setup_pci_device(dev, d); } -static int __devinit init_setup_hpt371(struct pci_dev *dev, ide_pci_device_t *d) -{ - u8 mcr1 = 0; - - /* - * HPT371 chips physically have only one channel, the secondary one, - * but the primary channel registers do exist! Go figure... - * So, we manually disable the non-existing channel here - * (if the BIOS hasn't done this already). - */ - pci_read_config_byte(dev, 0x50, &mcr1); - if (mcr1 & 0x04) - pci_write_config_byte(dev, 0x50, (mcr1 & ~0x04)); - - return ide_setup_pci_device(dev, d); -} - static int __devinit init_setup_hpt366(struct pci_dev *dev, ide_pci_device_t *d) { struct pci_dev *findev = NULL; @@ -1545,14 +1661,13 @@ static ide_pci_device_t hpt366_chipsets[] __devinitdata = { .bootable = OFF_BOARD, },{ /* 3 */ .name = "HPT371", - .init_setup = init_setup_hpt371, + .init_setup = init_setup_hpt37x, .init_chipset = init_chipset_hpt366, .init_iops = init_iops_hpt366, .init_hwif = init_hwif_hpt366, .init_dma = init_dma_hpt366, .channels = 2, .autodma = AUTODMA, - .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, .bootable = OFF_BOARD, },{ /* 4 */ .name = "HPT374", @@ -1584,16 +1699,13 @@ static ide_pci_device_t hpt366_chipsets[] __devinitdata = { * * Called when the PCI registration layer (or the IDE initialization) * finds a device matching our IDE device tables. - * - * NOTE: since we'll have to modify some fields of the ide_pci_device_t - * structure depending on the chip's revision, we'd better pass a local - * copy down the call chain... */ + static int __devinit hpt366_init_one(struct pci_dev *dev, const struct pci_device_id *id) { - ide_pci_device_t d = hpt366_chipsets[id->driver_data]; + ide_pci_device_t *d = &hpt366_chipsets[id->driver_data]; - return d.init_setup(dev, &d); + return d->init_setup(dev, d); } static struct pci_device_id hpt366_pci_tbl[] = { diff --git a/trunk/drivers/input/keyboard/hilkbd.c b/trunk/drivers/input/keyboard/hilkbd.c index 35461eab2faf..54bc569db4b0 100644 --- a/trunk/drivers/input/keyboard/hilkbd.c +++ b/trunk/drivers/input/keyboard/hilkbd.c @@ -23,12 +23,7 @@ #include #include #include -#include #include -#include -#ifdef CONFIG_HP300 -#include -#endif MODULE_AUTHOR("Philip Blundell, Matthew Wilcox, Helge Deller"); diff --git a/trunk/drivers/isdn/act2000/act2000_isa.c b/trunk/drivers/isdn/act2000/act2000_isa.c index 09ea50dd3459..3cac23739344 100644 --- a/trunk/drivers/isdn/act2000/act2000_isa.c +++ b/trunk/drivers/isdn/act2000/act2000_isa.c @@ -408,7 +408,7 @@ act2000_isa_download(act2000_card * card, act2000_ddef __user * cb) p = cblock.buffer; if (!access_ok(VERIFY_READ, p, length)) return -EFAULT; - buf = kmalloc(1024, GFP_KERNEL); + buf = (u_char *) kmalloc(1024, GFP_KERNEL); if (!buf) return -ENOMEM; timeout = 0; diff --git a/trunk/drivers/isdn/capi/capidrv.c b/trunk/drivers/isdn/capi/capidrv.c index c4d438c17dab..097bfa7bc323 100644 --- a/trunk/drivers/isdn/capi/capidrv.c +++ b/trunk/drivers/isdn/capi/capidrv.c @@ -2013,7 +2013,7 @@ static int capidrv_addcontr(u16 contr, struct capi_profile *profp) strcpy(card->name, id); card->contrnr = contr; card->nbchan = profp->nbchannel; - card->bchans = kmalloc(sizeof(capidrv_bchan) * card->nbchan, GFP_ATOMIC); + card->bchans = (capidrv_bchan *) kmalloc(sizeof(capidrv_bchan) * card->nbchan, GFP_ATOMIC); if (!card->bchans) { printk(KERN_WARNING "capidrv: (%s) Could not allocate bchan-structs.\n", id); diff --git a/trunk/drivers/isdn/divert/divert_procfs.c b/trunk/drivers/isdn/divert/divert_procfs.c index 06967da7c4a8..399b316111f7 100644 --- a/trunk/drivers/isdn/divert/divert_procfs.c +++ b/trunk/drivers/isdn/divert/divert_procfs.c @@ -45,7 +45,7 @@ put_info_buffer(char *cp) return; if (!*cp) return; - if (!(ib = kmalloc(sizeof(struct divert_info) + strlen(cp), GFP_ATOMIC))) + if (!(ib = (struct divert_info *) kmalloc(sizeof(struct divert_info) + strlen(cp), GFP_ATOMIC))) return; /* no memory */ strcpy(ib->info_start, cp); /* set output string */ ib->next = NULL; diff --git a/trunk/drivers/isdn/divert/isdn_divert.c b/trunk/drivers/isdn/divert/isdn_divert.c index 7d97d54588d9..03319ea5aa0c 100644 --- a/trunk/drivers/isdn/divert/isdn_divert.c +++ b/trunk/drivers/isdn/divert/isdn_divert.c @@ -153,7 +153,7 @@ int cf_command(int drvid, int mode, *ielenp = p - ielenp - 1; /* set total IE length */ /* allocate mem for information struct */ - if (!(cs = kmalloc(sizeof(struct call_struc), GFP_ATOMIC))) + if (!(cs = (struct call_struc *) kmalloc(sizeof(struct call_struc), GFP_ATOMIC))) return(-ENOMEM); /* no memory */ init_timer(&cs->timer); cs->info[0] = '\0'; @@ -276,7 +276,7 @@ int insertrule(int idx, divert_rule *newrule) { struct deflect_struc *ds,*ds1=NULL; unsigned long flags; - if (!(ds = kmalloc(sizeof(struct deflect_struc), + if (!(ds = (struct deflect_struc *) kmalloc(sizeof(struct deflect_struc), GFP_KERNEL))) return(-ENOMEM); /* no memory */ @@ -451,7 +451,7 @@ static int isdn_divert_icall(isdn_ctrl *ic) if (dv->rule.action == DEFLECT_PROCEED) if ((!if_used) || ((!extern_wait_max) && (!dv->rule.waittime))) return(0); /* no external deflection needed */ - if (!(cs = kmalloc(sizeof(struct call_struc), GFP_ATOMIC))) + if (!(cs = (struct call_struc *) kmalloc(sizeof(struct call_struc), GFP_ATOMIC))) return(0); /* no memory */ init_timer(&cs->timer); cs->info[0] = '\0'; diff --git a/trunk/drivers/isdn/gigaset/bas-gigaset.c b/trunk/drivers/isdn/gigaset/bas-gigaset.c index b5e7f9c7d74e..63b629b1cdb2 100644 --- a/trunk/drivers/isdn/gigaset/bas-gigaset.c +++ b/trunk/drivers/isdn/gigaset/bas-gigaset.c @@ -1853,24 +1853,20 @@ static int gigaset_write_cmd(struct cardstate *cs, { struct cmdbuf_t *cb; unsigned long flags; - int rc; + int status; gigaset_dbg_buffer(atomic_read(&cs->mstate) != MS_LOCKED ? DEBUG_TRANSCMD : DEBUG_LOCKCMD, "CMD Transmit", len, buf); - if (len <= 0) { - /* nothing to do */ - rc = 0; - goto notqueued; - } + if (len <= 0) + return 0; /* nothing to do */ if (len > IF_WRITEBUF) len = IF_WRITEBUF; if (!(cb = kmalloc(sizeof(struct cmdbuf_t) + len, GFP_ATOMIC))) { dev_err(cs->dev, "%s: out of memory\n", __func__); - rc = -ENOMEM; - goto notqueued; + return -ENOMEM; } memcpy(cb->buf, buf, len); @@ -1895,21 +1891,11 @@ static int gigaset_write_cmd(struct cardstate *cs, if (unlikely(!cs->connected)) { spin_unlock_irqrestore(&cs->lock, flags); gig_dbg(DEBUG_USBREQ, "%s: not connected", __func__); - /* flush command queue */ - spin_lock_irqsave(&cs->cmdlock, flags); - while (cs->cmdbuf != NULL) - complete_cb(cs); - spin_unlock_irqrestore(&cs->cmdlock, flags); return -ENODEV; } - rc = start_cbsend(cs); + status = start_cbsend(cs); spin_unlock_irqrestore(&cs->lock, flags); - return rc < 0 ? rc : len; - -notqueued: /* request handled without queuing */ - if (wake_tasklet) - tasklet_schedule(wake_tasklet); - return rc; + return status < 0 ? status : len; } /* gigaset_write_room @@ -1978,15 +1964,20 @@ static int gigaset_freebcshw(struct bc_state *bcs) /* kill URBs and tasklets before freeing - better safe than sorry */ atomic_set(&ubc->running, 0); - gig_dbg(DEBUG_INIT, "%s: killing iso URBs", __func__); - for (i = 0; i < BAS_OUTURBS; ++i) { - usb_kill_urb(ubc->isoouturbs[i].urb); - usb_free_urb(ubc->isoouturbs[i].urb); - } - for (i = 0; i < BAS_INURBS; ++i) { - usb_kill_urb(ubc->isoinurbs[i]); - usb_free_urb(ubc->isoinurbs[i]); - } + for (i = 0; i < BAS_OUTURBS; ++i) + if (ubc->isoouturbs[i].urb) { + gig_dbg(DEBUG_INIT, "%s: killing iso out URB %d", + __func__, i); + usb_kill_urb(ubc->isoouturbs[i].urb); + usb_free_urb(ubc->isoouturbs[i].urb); + } + for (i = 0; i < BAS_INURBS; ++i) + if (ubc->isoinurbs[i]) { + gig_dbg(DEBUG_INIT, "%s: killing iso in URB %d", + __func__, i); + usb_kill_urb(ubc->isoinurbs[i]); + usb_free_urb(ubc->isoinurbs[i]); + } tasklet_kill(&ubc->sent_tasklet); tasklet_kill(&ubc->rcvd_tasklet); kfree(ubc->isooutbuf); @@ -2108,32 +2099,55 @@ static void freeurbs(struct cardstate *cs) struct bas_bc_state *ubc; int i, j; - gig_dbg(DEBUG_INIT, "%s: killing URBs", __func__); for (j = 0; j < 2; ++j) { ubc = cs->bcs[j].hw.bas; - for (i = 0; i < BAS_OUTURBS; ++i) { - usb_kill_urb(ubc->isoouturbs[i].urb); - usb_free_urb(ubc->isoouturbs[i].urb); - ubc->isoouturbs[i].urb = NULL; - } - for (i = 0; i < BAS_INURBS; ++i) { - usb_kill_urb(ubc->isoinurbs[i]); - usb_free_urb(ubc->isoinurbs[i]); - ubc->isoinurbs[i] = NULL; - } + for (i = 0; i < BAS_OUTURBS; ++i) + if (ubc->isoouturbs[i].urb) { + usb_kill_urb(ubc->isoouturbs[i].urb); + gig_dbg(DEBUG_INIT, + "%s: isoc output URB %d/%d unlinked", + __func__, j, i); + usb_free_urb(ubc->isoouturbs[i].urb); + ubc->isoouturbs[i].urb = NULL; + } + for (i = 0; i < BAS_INURBS; ++i) + if (ubc->isoinurbs[i]) { + usb_kill_urb(ubc->isoinurbs[i]); + gig_dbg(DEBUG_INIT, + "%s: isoc input URB %d/%d unlinked", + __func__, j, i); + usb_free_urb(ubc->isoinurbs[i]); + ubc->isoinurbs[i] = NULL; + } + } + if (ucs->urb_int_in) { + usb_kill_urb(ucs->urb_int_in); + gig_dbg(DEBUG_INIT, "%s: interrupt input URB unlinked", + __func__); + usb_free_urb(ucs->urb_int_in); + ucs->urb_int_in = NULL; + } + if (ucs->urb_cmd_out) { + usb_kill_urb(ucs->urb_cmd_out); + gig_dbg(DEBUG_INIT, "%s: command output URB unlinked", + __func__); + usb_free_urb(ucs->urb_cmd_out); + ucs->urb_cmd_out = NULL; + } + if (ucs->urb_cmd_in) { + usb_kill_urb(ucs->urb_cmd_in); + gig_dbg(DEBUG_INIT, "%s: command input URB unlinked", + __func__); + usb_free_urb(ucs->urb_cmd_in); + ucs->urb_cmd_in = NULL; + } + if (ucs->urb_ctrl) { + usb_kill_urb(ucs->urb_ctrl); + gig_dbg(DEBUG_INIT, "%s: control output URB unlinked", + __func__); + usb_free_urb(ucs->urb_ctrl); + ucs->urb_ctrl = NULL; } - usb_kill_urb(ucs->urb_int_in); - usb_free_urb(ucs->urb_int_in); - ucs->urb_int_in = NULL; - usb_kill_urb(ucs->urb_cmd_out); - usb_free_urb(ucs->urb_cmd_out); - ucs->urb_cmd_out = NULL; - usb_kill_urb(ucs->urb_cmd_in); - usb_free_urb(ucs->urb_cmd_in); - ucs->urb_cmd_in = NULL; - usb_kill_urb(ucs->urb_ctrl); - usb_free_urb(ucs->urb_ctrl); - ucs->urb_ctrl = NULL; } /* gigaset_probe diff --git a/trunk/drivers/isdn/hysdn/hysdn_procconf.c b/trunk/drivers/isdn/hysdn/hysdn_procconf.c index 94a935089119..8e2b03889f3c 100644 --- a/trunk/drivers/isdn/hysdn/hysdn_procconf.c +++ b/trunk/drivers/isdn/hysdn/hysdn_procconf.c @@ -275,7 +275,7 @@ hysdn_conf_open(struct inode *ino, struct file *filep) } else if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) { /* read access -> output card info data */ - if (!(tmp = kmalloc(INFO_OUT_LEN * 2 + 2, GFP_KERNEL))) { + if (!(tmp = (char *) kmalloc(INFO_OUT_LEN * 2 + 2, GFP_KERNEL))) { unlock_kernel(); return (-EFAULT); /* out of memory */ } diff --git a/trunk/drivers/isdn/hysdn/hysdn_proclog.c b/trunk/drivers/isdn/hysdn/hysdn_proclog.c index 375d956884d7..f241f5e551cb 100644 --- a/trunk/drivers/isdn/hysdn/hysdn_proclog.c +++ b/trunk/drivers/isdn/hysdn/hysdn_proclog.c @@ -111,7 +111,7 @@ put_log_buffer(hysdn_card * card, char *cp) if (pd->if_used <= 0) return; /* no open file for read */ - if (!(ib = kmalloc(sizeof(struct log_data) + strlen(cp), GFP_ATOMIC))) + if (!(ib = (struct log_data *) kmalloc(sizeof(struct log_data) + strlen(cp), GFP_ATOMIC))) return; /* no memory */ strcpy(ib->log_start, cp); /* set output string */ ib->next = NULL; diff --git a/trunk/drivers/isdn/i4l/isdn_audio.c b/trunk/drivers/isdn/i4l/isdn_audio.c index fb350c567c6b..2cc56d6a9fae 100644 --- a/trunk/drivers/isdn/i4l/isdn_audio.c +++ b/trunk/drivers/isdn/i4l/isdn_audio.c @@ -328,7 +328,7 @@ adpcm_state * isdn_audio_adpcm_init(adpcm_state * s, int nbits) { if (!s) - s = kmalloc(sizeof(adpcm_state), GFP_ATOMIC); + s = (adpcm_state *) kmalloc(sizeof(adpcm_state), GFP_ATOMIC); if (s) { s->a = 0; s->d = 5; @@ -343,7 +343,7 @@ dtmf_state * isdn_audio_dtmf_init(dtmf_state * s) { if (!s) - s = kmalloc(sizeof(dtmf_state), GFP_ATOMIC); + s = (dtmf_state *) kmalloc(sizeof(dtmf_state), GFP_ATOMIC); if (s) { s->idx = 0; s->last = ' '; @@ -621,7 +621,7 @@ silence_state * isdn_audio_silence_init(silence_state * s) { if (!s) - s = kmalloc(sizeof(silence_state), GFP_ATOMIC); + s = (silence_state *) kmalloc(sizeof(silence_state), GFP_ATOMIC); if (s) { s->idx = 0; s->state = 0; diff --git a/trunk/drivers/isdn/i4l/isdn_net.c b/trunk/drivers/isdn/i4l/isdn_net.c index 838b3734e2b6..c36c817578cb 100644 --- a/trunk/drivers/isdn/i4l/isdn_net.c +++ b/trunk/drivers/isdn/i4l/isdn_net.c @@ -2948,7 +2948,7 @@ isdn_net_addphone(isdn_net_ioctl_phone * phone) isdn_net_phone *n; if (p) { - if (!(n = kmalloc(sizeof(isdn_net_phone), GFP_KERNEL))) + if (!(n = (isdn_net_phone *) kmalloc(sizeof(isdn_net_phone), GFP_KERNEL))) return -ENOMEM; strcpy(n->num, phone->phone); n->next = p->local->phone[phone->outgoing & 1]; diff --git a/trunk/drivers/isdn/i4l/isdn_ppp.c b/trunk/drivers/isdn/i4l/isdn_ppp.c index 1726131b20be..43811795b46b 100644 --- a/trunk/drivers/isdn/i4l/isdn_ppp.c +++ b/trunk/drivers/isdn/i4l/isdn_ppp.c @@ -717,7 +717,7 @@ isdn_ppp_fill_rq(unsigned char *buf, int len, int proto, int slot) printk(KERN_DEBUG "ippp: device not activated.\n"); return 0; } - nbuf = kmalloc(len + 4, GFP_ATOMIC); + nbuf = (unsigned char *) kmalloc(len + 4, GFP_ATOMIC); if (!nbuf) { printk(KERN_WARNING "ippp: Can't alloc buf\n"); return 0; diff --git a/trunk/drivers/isdn/pcbit/layer2.c b/trunk/drivers/isdn/pcbit/layer2.c index eafcce5e656a..6ff85574e941 100644 --- a/trunk/drivers/isdn/pcbit/layer2.c +++ b/trunk/drivers/isdn/pcbit/layer2.c @@ -100,7 +100,7 @@ pcbit_l2_write(struct pcbit_dev *dev, ulong msg, ushort refnum, dev_kfree_skb(skb); return -1; } - if ((frame = kmalloc(sizeof(struct frame_buf), + if ((frame = (struct frame_buf *) kmalloc(sizeof(struct frame_buf), GFP_ATOMIC)) == NULL) { printk(KERN_WARNING "pcbit_2_write: kmalloc failed\n"); dev_kfree_skb(skb); diff --git a/trunk/drivers/kvm/Kconfig b/trunk/drivers/kvm/Kconfig index 703cc88d1ef9..36412e90f09b 100644 --- a/trunk/drivers/kvm/Kconfig +++ b/trunk/drivers/kvm/Kconfig @@ -1,8 +1,6 @@ # # KVM configuration # -menu "Virtualization" - config KVM tristate "Kernel-based Virtual Machine (KVM) support" depends on X86 && EXPERIMENTAL @@ -33,5 +31,3 @@ config KVM_AMD ---help--- Provides support for KVM on AMD processors equipped with the AMD-V (SVM) extensions. - -endmenu diff --git a/trunk/drivers/kvm/kvm.h b/trunk/drivers/kvm/kvm.h index 930e04ce1af6..5785d0870ab6 100644 --- a/trunk/drivers/kvm/kvm.h +++ b/trunk/drivers/kvm/kvm.h @@ -140,7 +140,7 @@ enum { VCPU_REGS_RBP = 5, VCPU_REGS_RSI = 6, VCPU_REGS_RDI = 7, -#ifdef CONFIG_X86_64 +#ifdef __x86_64__ VCPU_REGS_R8 = 8, VCPU_REGS_R9 = 9, VCPU_REGS_R10 = 10, @@ -375,7 +375,7 @@ void set_cr4(struct kvm_vcpu *vcpu, unsigned long cr0); void set_cr8(struct kvm_vcpu *vcpu, unsigned long cr0); void lmsw(struct kvm_vcpu *vcpu, unsigned long msw); -#ifdef CONFIG_X86_64 +#ifdef __x86_64__ void set_efer(struct kvm_vcpu *vcpu, u64 efer); #endif @@ -485,7 +485,7 @@ static inline unsigned long read_tr_base(void) return segment_base(tr); } -#ifdef CONFIG_X86_64 +#ifdef __x86_64__ static inline unsigned long read_msr(unsigned long msr) { u64 value; @@ -533,7 +533,7 @@ static inline u32 get_rdx_init_val(void) #define TSS_REDIRECTION_SIZE (256 / 8) #define RMODE_TSS_SIZE (TSS_BASE_SIZE + TSS_REDIRECTION_SIZE + TSS_IOPB_SIZE + 1) -#ifdef CONFIG_X86_64 +#ifdef __x86_64__ /* * When emulating 32-bit mode, cr3 is only 32 bits even on x86_64. Therefore diff --git a/trunk/drivers/kvm/kvm_main.c b/trunk/drivers/kvm/kvm_main.c index fd1bb870545c..b6b8a41b5ec8 100644 --- a/trunk/drivers/kvm/kvm_main.c +++ b/trunk/drivers/kvm/kvm_main.c @@ -72,7 +72,18 @@ static struct dentry *debugfs_dir; #define CR8_RESEVED_BITS (~0x0fULL) #define EFER_RESERVED_BITS 0xfffffffffffff2fe -#ifdef CONFIG_X86_64 +struct vmx_msr_entry *find_msr_entry(struct kvm_vcpu *vcpu, u32 msr) +{ + int i; + + for (i = 0; i < vcpu->nmsrs; ++i) + if (vcpu->guest_msrs[i].index == msr) + return &vcpu->guest_msrs[i]; + return 0; +} +EXPORT_SYMBOL_GPL(find_msr_entry); + +#ifdef __x86_64__ // LDT or TSS descriptor in the GDT. 16 bytes. struct segment_descriptor_64 { struct segment_descriptor s; @@ -104,7 +115,7 @@ unsigned long segment_base(u16 selector) } d = (struct segment_descriptor *)(table_base + (selector & ~7)); v = d->base_low | ((ul)d->base_mid << 16) | ((ul)d->base_high << 24); -#ifdef CONFIG_X86_64 +#ifdef __x86_64__ if (d->system == 0 && (d->type == 2 || d->type == 9 || d->type == 11)) v |= ((ul)((struct segment_descriptor_64 *)d)->base_higher) << 32; @@ -205,6 +216,7 @@ static struct kvm_vcpu *vcpu_load(struct kvm *kvm, int vcpu_slot) static void vcpu_put(struct kvm_vcpu *vcpu) { kvm_arch_ops->vcpu_put(vcpu); + put_cpu(); mutex_unlock(&vcpu->mutex); } @@ -339,7 +351,7 @@ void set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0) } if (!is_paging(vcpu) && (cr0 & CR0_PG_MASK)) { -#ifdef CONFIG_X86_64 +#ifdef __x86_64__ if ((vcpu->shadow_efer & EFER_LME)) { int cs_db, cs_l; @@ -1108,10 +1120,12 @@ static int get_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 *pdata) return kvm_arch_ops->get_msr(vcpu, msr_index, pdata); } -#ifdef CONFIG_X86_64 +#ifdef __x86_64__ void set_efer(struct kvm_vcpu *vcpu, u64 efer) { + struct vmx_msr_entry *msr; + if (efer & EFER_RESERVED_BITS) { printk(KERN_DEBUG "set_efer: 0x%llx #GP, reserved bits\n", efer); @@ -1126,12 +1140,16 @@ void set_efer(struct kvm_vcpu *vcpu, u64 efer) return; } - kvm_arch_ops->set_efer(vcpu, efer); - efer &= ~EFER_LMA; efer |= vcpu->shadow_efer & EFER_LMA; vcpu->shadow_efer = efer; + + msr = find_msr_entry(vcpu, MSR_EFER); + + if (!(efer & EFER_LMA)) + efer &= ~EFER_LME; + msr->data = efer; } EXPORT_SYMBOL_GPL(set_efer); @@ -1225,7 +1243,7 @@ static int kvm_dev_ioctl_get_regs(struct kvm *kvm, struct kvm_regs *regs) regs->rdi = vcpu->regs[VCPU_REGS_RDI]; regs->rsp = vcpu->regs[VCPU_REGS_RSP]; regs->rbp = vcpu->regs[VCPU_REGS_RBP]; -#ifdef CONFIG_X86_64 +#ifdef __x86_64__ regs->r8 = vcpu->regs[VCPU_REGS_R8]; regs->r9 = vcpu->regs[VCPU_REGS_R9]; regs->r10 = vcpu->regs[VCPU_REGS_R10]; @@ -1269,7 +1287,7 @@ static int kvm_dev_ioctl_set_regs(struct kvm *kvm, struct kvm_regs *regs) vcpu->regs[VCPU_REGS_RDI] = regs->rdi; vcpu->regs[VCPU_REGS_RSP] = regs->rsp; vcpu->regs[VCPU_REGS_RBP] = regs->rbp; -#ifdef CONFIG_X86_64 +#ifdef __x86_64__ vcpu->regs[VCPU_REGS_R8] = regs->r8; vcpu->regs[VCPU_REGS_R9] = regs->r9; vcpu->regs[VCPU_REGS_R10] = regs->r10; @@ -1383,7 +1401,7 @@ static int kvm_dev_ioctl_set_sregs(struct kvm *kvm, struct kvm_sregs *sregs) vcpu->cr8 = sregs->cr8; mmu_reset_needed |= vcpu->shadow_efer != sregs->efer; -#ifdef CONFIG_X86_64 +#ifdef __x86_64__ kvm_arch_ops->set_efer(vcpu, sregs->efer); #endif vcpu->apic_base = sregs->apic_base; @@ -1416,7 +1434,7 @@ static int kvm_dev_ioctl_set_sregs(struct kvm *kvm, struct kvm_sregs *sregs) static u32 msrs_to_save[] = { MSR_IA32_SYSENTER_CS, MSR_IA32_SYSENTER_ESP, MSR_IA32_SYSENTER_EIP, MSR_K6_STAR, -#ifdef CONFIG_X86_64 +#ifdef __x86_64__ MSR_CSTAR, MSR_KERNEL_GS_BASE, MSR_SYSCALL_MASK, MSR_LSTAR, #endif MSR_IA32_TIME_STAMP_COUNTER, diff --git a/trunk/drivers/kvm/kvm_svm.h b/trunk/drivers/kvm/kvm_svm.h index 74cc862f4935..7d7f2aa10960 100644 --- a/trunk/drivers/kvm/kvm_svm.h +++ b/trunk/drivers/kvm/kvm_svm.h @@ -9,7 +9,7 @@ #include "kvm.h" static const u32 host_save_msrs[] = { -#ifdef CONFIG_X86_64 +#ifdef __x86_64__ MSR_STAR, MSR_LSTAR, MSR_CSTAR, MSR_SYSCALL_MASK, MSR_KERNEL_GS_BASE, MSR_FS_BASE, MSR_GS_BASE, #endif diff --git a/trunk/drivers/kvm/kvm_vmx.h b/trunk/drivers/kvm/kvm_vmx.h index d139f73fb6e1..87e12d2bfa16 100644 --- a/trunk/drivers/kvm/kvm_vmx.h +++ b/trunk/drivers/kvm/kvm_vmx.h @@ -1,7 +1,7 @@ #ifndef __KVM_VMX_H #define __KVM_VMX_H -#ifdef CONFIG_X86_64 +#ifdef __x86_64__ /* * avoid save/load MSR_SYSCALL_MASK and MSR_LSTAR by std vt * mechanism (cpu bug AA24) diff --git a/trunk/drivers/kvm/mmu.c b/trunk/drivers/kvm/mmu.c index 3d367cbfe1f9..4e29d9b7211c 100644 --- a/trunk/drivers/kvm/mmu.c +++ b/trunk/drivers/kvm/mmu.c @@ -61,9 +61,22 @@ #define PT32_PTE_COPY_MASK \ - (PT_PRESENT_MASK | PT_ACCESSED_MASK | PT_DIRTY_MASK | PT_GLOBAL_MASK) + (PT_PRESENT_MASK | PT_PWT_MASK | PT_PCD_MASK | \ + PT_ACCESSED_MASK | PT_DIRTY_MASK | PT_PAT_MASK | \ + PT_GLOBAL_MASK ) + +#define PT32_NON_PTE_COPY_MASK \ + (PT_PRESENT_MASK | PT_PWT_MASK | PT_PCD_MASK | \ + PT_ACCESSED_MASK | PT_DIRTY_MASK) + + +#define PT64_PTE_COPY_MASK \ + (PT64_NX_MASK | PT32_PTE_COPY_MASK) + +#define PT64_NON_PTE_COPY_MASK \ + (PT64_NX_MASK | PT32_NON_PTE_COPY_MASK) + -#define PT64_PTE_COPY_MASK (PT64_NX_MASK | PT32_PTE_COPY_MASK) #define PT_FIRST_AVAIL_BITS_SHIFT 9 #define PT64_SECOND_AVAIL_BITS_SHIFT 52 diff --git a/trunk/drivers/kvm/paging_tmpl.h b/trunk/drivers/kvm/paging_tmpl.h index a9771b4c5bb8..765c2e1a048e 100644 --- a/trunk/drivers/kvm/paging_tmpl.h +++ b/trunk/drivers/kvm/paging_tmpl.h @@ -32,6 +32,7 @@ #define SHADOW_PT_INDEX(addr, level) PT64_INDEX(addr, level) #define PT_LEVEL_MASK(level) PT64_LEVEL_MASK(level) #define PT_PTE_COPY_MASK PT64_PTE_COPY_MASK + #define PT_NON_PTE_COPY_MASK PT64_NON_PTE_COPY_MASK #elif PTTYPE == 32 #define pt_element_t u32 #define guest_walker guest_walker32 @@ -42,6 +43,7 @@ #define SHADOW_PT_INDEX(addr, level) PT64_INDEX(addr, level) #define PT_LEVEL_MASK(level) PT32_LEVEL_MASK(level) #define PT_PTE_COPY_MASK PT32_PTE_COPY_MASK + #define PT_NON_PTE_COPY_MASK PT32_NON_PTE_COPY_MASK #else #error Invalid PTTYPE value #endif @@ -103,7 +105,9 @@ static void FNAME(set_pde)(struct kvm_vcpu *vcpu, u64 guest_pde, if (PTTYPE == 32 && is_cpuid_PSE36()) gaddr |= (guest_pde & PT32_DIR_PSE36_MASK) << (32 - PT32_DIR_PSE36_SHIFT); - *shadow_pte = guest_pde & PT_PTE_COPY_MASK; + *shadow_pte = (guest_pde & (PT_NON_PTE_COPY_MASK | PT_GLOBAL_MASK)) | + ((guest_pde & PT_DIR_PAT_MASK) >> + (PT_DIR_PAT_SHIFT - PT_PAT_SHIFT)); set_pte_common(vcpu, shadow_pte, gaddr, guest_pde & PT_DIRTY_MASK, access_bits); } @@ -158,7 +162,6 @@ static u64 *FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr, u32 index = SHADOW_PT_INDEX(addr, level); u64 *shadow_ent = ((u64 *)__va(shadow_addr)) + index; pt_element_t *guest_ent; - u64 shadow_pte; if (is_present_pte(*shadow_ent) || is_io_pte(*shadow_ent)) { if (level == PT_PAGE_TABLE_LEVEL) @@ -201,11 +204,14 @@ static u64 *FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr, shadow_addr = kvm_mmu_alloc_page(vcpu, shadow_ent); if (!VALID_PAGE(shadow_addr)) return ERR_PTR(-ENOMEM); - shadow_pte = shadow_addr | PT_PRESENT_MASK; - if (vcpu->mmu.root_level > 3 || level != 3) - shadow_pte |= PT_ACCESSED_MASK - | PT_WRITABLE_MASK | PT_USER_MASK; - *shadow_ent = shadow_pte; + if (!kvm_arch_ops->is_long_mode(vcpu) && level == 3) + *shadow_ent = shadow_addr | + (*guest_ent & (PT_PRESENT_MASK | PT_PWT_MASK | PT_PCD_MASK)); + else { + *shadow_ent = shadow_addr | + (*guest_ent & PT_NON_PTE_COPY_MASK); + *shadow_ent |= (PT_WRITABLE_MASK | PT_USER_MASK); + } prev_shadow_ent = shadow_ent; } } diff --git a/trunk/drivers/kvm/svm.c b/trunk/drivers/kvm/svm.c index 0e6bc8c649ce..a33a89c68138 100644 --- a/trunk/drivers/kvm/svm.c +++ b/trunk/drivers/kvm/svm.c @@ -287,7 +287,7 @@ static void svm_hardware_enable(void *garbage) struct svm_cpu_data *svm_data; uint64_t efer; -#ifdef CONFIG_X86_64 +#ifdef __x86_64__ struct desc_ptr gdt_descr; #else struct Xgt_desc_struct gdt_descr; @@ -377,7 +377,6 @@ static __init int svm_hardware_setup(void) void *msrpm_va; int r; - kvm_emulator_want_group7_invlpg(); iopm_pages = alloc_pages(GFP_KERNEL, IOPM_ALLOC_ORDER); @@ -398,7 +397,7 @@ static __init int svm_hardware_setup(void) memset(msrpm_va, 0xff, PAGE_SIZE * (1 << MSRPM_ALLOC_ORDER)); msrpm_base = page_to_pfn(msrpm_pages) << PAGE_SHIFT; -#ifdef CONFIG_X86_64 +#ifdef __x86_64__ set_msr_interception(msrpm_va, MSR_GS_BASE, 1, 1); set_msr_interception(msrpm_va, MSR_FS_BASE, 1, 1); set_msr_interception(msrpm_va, MSR_KERNEL_GS_BASE, 1, 1); @@ -705,7 +704,7 @@ static void svm_set_gdt(struct kvm_vcpu *vcpu, struct descriptor_table *dt) static void svm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0) { -#ifdef CONFIG_X86_64 +#ifdef __x86_64__ if (vcpu->shadow_efer & KVM_EFER_LME) { if (!is_paging(vcpu) && (cr0 & CR0_PG_MASK)) { vcpu->shadow_efer |= KVM_EFER_LMA; @@ -1098,7 +1097,7 @@ static int svm_get_msr(struct kvm_vcpu *vcpu, unsigned ecx, u64 *data) case MSR_IA32_APICBASE: *data = vcpu->apic_base; break; -#ifdef CONFIG_X86_64 +#ifdef __x86_64__ case MSR_STAR: *data = vcpu->svm->vmcb->save.star; break; @@ -1150,7 +1149,7 @@ static int rdmsr_interception(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) static int svm_set_msr(struct kvm_vcpu *vcpu, unsigned ecx, u64 data) { switch (ecx) { -#ifdef CONFIG_X86_64 +#ifdef __x86_64__ case MSR_EFER: set_efer(vcpu, data); break; @@ -1173,7 +1172,7 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, unsigned ecx, u64 data) case MSR_IA32_APICBASE: vcpu->apic_base = data; break; -#ifdef CONFIG_X86_64_ +#ifdef __x86_64___ case MSR_STAR: vcpu->svm->vmcb->save.star = data; break; @@ -1346,18 +1345,53 @@ static void kvm_reput_irq(struct kvm_vcpu *vcpu) static void save_db_regs(unsigned long *db_regs) { - asm volatile ("mov %%dr0, %0" : "=r"(db_regs[0])); - asm volatile ("mov %%dr1, %0" : "=r"(db_regs[1])); - asm volatile ("mov %%dr2, %0" : "=r"(db_regs[2])); - asm volatile ("mov %%dr3, %0" : "=r"(db_regs[3])); +#ifdef __x86_64__ + asm ("mov %%dr0, %%rax \n\t" + "mov %%rax, %[dr0] \n\t" + "mov %%dr1, %%rax \n\t" + "mov %%rax, %[dr1] \n\t" + "mov %%dr2, %%rax \n\t" + "mov %%rax, %[dr2] \n\t" + "mov %%dr3, %%rax \n\t" + "mov %%rax, %[dr3] \n\t" + : [dr0] "=m"(db_regs[0]), + [dr1] "=m"(db_regs[1]), + [dr2] "=m"(db_regs[2]), + [dr3] "=m"(db_regs[3]) + : : "rax"); +#else + asm ("mov %%dr0, %%eax \n\t" + "mov %%eax, %[dr0] \n\t" + "mov %%dr1, %%eax \n\t" + "mov %%eax, %[dr1] \n\t" + "mov %%dr2, %%eax \n\t" + "mov %%eax, %[dr2] \n\t" + "mov %%dr3, %%eax \n\t" + "mov %%eax, %[dr3] \n\t" + : [dr0] "=m"(db_regs[0]), + [dr1] "=m"(db_regs[1]), + [dr2] "=m"(db_regs[2]), + [dr3] "=m"(db_regs[3]) + : : "eax"); +#endif } static void load_db_regs(unsigned long *db_regs) { - asm volatile ("mov %0, %%dr0" : : "r"(db_regs[0])); - asm volatile ("mov %0, %%dr1" : : "r"(db_regs[1])); - asm volatile ("mov %0, %%dr2" : : "r"(db_regs[2])); - asm volatile ("mov %0, %%dr3" : : "r"(db_regs[3])); + asm volatile ("mov %[dr0], %%dr0 \n\t" + "mov %[dr1], %%dr1 \n\t" + "mov %[dr2], %%dr2 \n\t" + "mov %[dr3], %%dr3 \n\t" + : + : [dr0] "r"(db_regs[0]), + [dr1] "r"(db_regs[1]), + [dr2] "r"(db_regs[2]), + [dr3] "r"(db_regs[3]) +#ifdef __x86_64__ + : "rax"); +#else + : "eax"); +#endif } static int svm_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) @@ -1388,7 +1422,7 @@ static int svm_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) load_db_regs(vcpu->svm->db_regs); } asm volatile ( -#ifdef CONFIG_X86_64 +#ifdef __x86_64__ "push %%rbx; push %%rcx; push %%rdx;" "push %%rsi; push %%rdi; push %%rbp;" "push %%r8; push %%r9; push %%r10; push %%r11;" @@ -1398,7 +1432,7 @@ static int svm_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) "push %%esi; push %%edi; push %%ebp;" #endif -#ifdef CONFIG_X86_64 +#ifdef __x86_64__ "mov %c[rbx](%[vcpu]), %%rbx \n\t" "mov %c[rcx](%[vcpu]), %%rcx \n\t" "mov %c[rdx](%[vcpu]), %%rdx \n\t" @@ -1422,7 +1456,7 @@ static int svm_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) "mov %c[rbp](%[vcpu]), %%ebp \n\t" #endif -#ifdef CONFIG_X86_64 +#ifdef __x86_64__ /* Enter guest mode */ "push %%rax \n\t" "mov %c[svm](%[vcpu]), %%rax \n\t" @@ -1443,7 +1477,7 @@ static int svm_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) #endif /* Save guest registers, load host registers */ -#ifdef CONFIG_X86_64 +#ifdef __x86_64__ "mov %%rbx, %c[rbx](%[vcpu]) \n\t" "mov %%rcx, %c[rcx](%[vcpu]) \n\t" "mov %%rdx, %c[rdx](%[vcpu]) \n\t" @@ -1484,7 +1518,7 @@ static int svm_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) [rsi]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_RSI])), [rdi]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_RDI])), [rbp]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_RBP])) -#ifdef CONFIG_X86_64 +#ifdef __x86_64__ ,[r8 ]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_R8 ])), [r9 ]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_R9 ])), [r10]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_R10])), @@ -1629,7 +1663,9 @@ static struct kvm_arch_ops svm_arch_ops = { static int __init svm_init(void) { - return kvm_init_arch(&svm_arch_ops, THIS_MODULE); + kvm_emulator_want_group7_invlpg(); + kvm_init_arch(&svm_arch_ops, THIS_MODULE); + return 0; } static void __exit svm_exit(void) diff --git a/trunk/drivers/kvm/vmx.c b/trunk/drivers/kvm/vmx.c index f0f0b1a781f8..bda7a7ae2167 100644 --- a/trunk/drivers/kvm/vmx.c +++ b/trunk/drivers/kvm/vmx.c @@ -22,7 +22,6 @@ #include #include #include -#include #include "segment_descriptor.h" @@ -34,7 +33,7 @@ MODULE_LICENSE("GPL"); static DEFINE_PER_CPU(struct vmcs *, vmxarea); static DEFINE_PER_CPU(struct vmcs *, current_vmcs); -#ifdef CONFIG_X86_64 +#ifdef __x86_64__ #define HOST_IS_64 1 #else #define HOST_IS_64 0 @@ -71,13 +70,15 @@ static struct kvm_vmx_segment_field { }; static const u32 vmx_msr_index[] = { -#ifdef CONFIG_X86_64 +#ifdef __x86_64__ MSR_SYSCALL_MASK, MSR_LSTAR, MSR_CSTAR, MSR_KERNEL_GS_BASE, #endif MSR_EFER, MSR_K6_STAR, }; #define NR_VMX_MSR (sizeof(vmx_msr_index) / sizeof(*vmx_msr_index)) +struct vmx_msr_entry *find_msr_entry(struct kvm_vcpu *vcpu, u32 msr); + static inline int is_page_fault(u32 intr_info) { return (intr_info & (INTR_INFO_INTR_TYPE_MASK | INTR_INFO_VECTOR_MASK | @@ -91,16 +92,6 @@ static inline int is_external_interrupt(u32 intr_info) == (INTR_TYPE_EXT_INTR | INTR_INFO_VALID_MASK); } -static struct vmx_msr_entry *find_msr_entry(struct kvm_vcpu *vcpu, u32 msr) -{ - int i; - - for (i = 0; i < vcpu->nmsrs; ++i) - if (vcpu->guest_msrs[i].index == msr) - return &vcpu->guest_msrs[i]; - return 0; -} - static void vmcs_clear(struct vmcs *vmcs) { u64 phys_addr = __pa(vmcs); @@ -146,7 +137,7 @@ static u32 vmcs_read32(unsigned long field) static u64 vmcs_read64(unsigned long field) { -#ifdef CONFIG_X86_64 +#ifdef __x86_64__ return vmcs_readl(field); #else return vmcs_readl(field) | ((u64)vmcs_readl(field+1) << 32); @@ -176,7 +167,7 @@ static void vmcs_write32(unsigned long field, u32 value) static void vmcs_write64(unsigned long field, u64 value) { -#ifdef CONFIG_X86_64 +#ifdef __x86_64__ vmcs_writel(field, value); #else vmcs_writel(field, value); @@ -305,7 +296,7 @@ static void guest_write_tsc(u64 guest_tsc) static void reload_tss(void) { -#ifndef CONFIG_X86_64 +#ifndef __x86_64__ /* * VT restores TR but not its size. Useless. @@ -336,7 +327,7 @@ static int vmx_get_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 *pdata) } switch (msr_index) { -#ifdef CONFIG_X86_64 +#ifdef __x86_64__ case MSR_FS_BASE: data = vmcs_readl(GUEST_FS_BASE); break; @@ -399,7 +390,7 @@ static int vmx_set_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 data) { struct vmx_msr_entry *msr; switch (msr_index) { -#ifdef CONFIG_X86_64 +#ifdef __x86_64__ case MSR_FS_BASE: vmcs_writel(GUEST_FS_BASE, data); break; @@ -534,7 +525,7 @@ static __init void hardware_enable(void *garbage) u64 old; rdmsrl(MSR_IA32_FEATURE_CONTROL, old); - if ((old & 5) != 5) + if ((old & 5) == 0) /* enable and lock */ wrmsrl(MSR_IA32_FEATURE_CONTROL, old | 5); write_cr4(read_cr4() | CR4_VMXE); /* FIXME: not cpu hotplug safe */ @@ -734,7 +725,7 @@ static void enter_rmode(struct kvm_vcpu *vcpu) fix_rmode_seg(VCPU_SREG_FS, &vcpu->rmode.fs); } -#ifdef CONFIG_X86_64 +#ifdef __x86_64__ static void enter_lmode(struct kvm_vcpu *vcpu) { @@ -776,7 +767,7 @@ static void vmx_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0) if (!vcpu->rmode.active && !(cr0 & CR0_PE_MASK)) enter_rmode(vcpu); -#ifdef CONFIG_X86_64 +#ifdef __x86_64__ if (vcpu->shadow_efer & EFER_LME) { if (!is_paging(vcpu) && (cr0 & CR0_PG_MASK)) enter_lmode(vcpu); @@ -817,7 +808,7 @@ static void vmx_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4) vcpu->cr4 = cr4; } -#ifdef CONFIG_X86_64 +#ifdef __x86_64__ static void vmx_set_efer(struct kvm_vcpu *vcpu, u64 efer) { @@ -892,8 +883,6 @@ static void vmx_set_segment(struct kvm_vcpu *vcpu, ar |= (var->db & 1) << 14; ar |= (var->g & 1) << 15; } - if (ar == 0) /* a 0 value means unusable */ - ar = AR_UNUSABLE_MASK; vmcs_write32(sf->ar_bytes, ar); } @@ -1106,7 +1095,7 @@ static int vmx_vcpu_setup(struct kvm_vcpu *vcpu) vmcs_write16(HOST_FS_SELECTOR, read_fs()); /* 22.2.4 */ vmcs_write16(HOST_GS_SELECTOR, read_gs()); /* 22.2.4 */ vmcs_write16(HOST_SS_SELECTOR, __KERNEL_DS); /* 22.2.4 */ -#ifdef CONFIG_X86_64 +#ifdef __x86_64__ rdmsrl(MSR_FS_BASE, a); vmcs_writel(HOST_FS_BASE, a); /* 22.2.4 */ rdmsrl(MSR_GS_BASE, a); @@ -1175,10 +1164,8 @@ static int vmx_vcpu_setup(struct kvm_vcpu *vcpu) VM_ENTRY_CONTROLS, 0); vmcs_write32(VM_ENTRY_INTR_INFO_FIELD, 0); /* 22.2.1 */ -#ifdef CONFIG_X86_64 vmcs_writel(VIRTUAL_APIC_PAGE_ADDR, 0); vmcs_writel(TPR_THRESHOLD, 0); -#endif vmcs_writel(CR0_GUEST_HOST_MASK, KVM_GUEST_CR0_MASK); vmcs_writel(CR4_GUEST_HOST_MASK, KVM_GUEST_CR4_MASK); @@ -1186,7 +1173,7 @@ static int vmx_vcpu_setup(struct kvm_vcpu *vcpu) vcpu->cr0 = 0x60000010; vmx_set_cr0(vcpu, vcpu->cr0); // enter rmode vmx_set_cr4(vcpu, 0); -#ifdef CONFIG_X86_64 +#ifdef __x86_64__ vmx_set_efer(vcpu, 0); #endif @@ -1702,7 +1689,7 @@ static int vmx_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) vmcs_write16(HOST_GS_SELECTOR, 0); } -#ifdef CONFIG_X86_64 +#ifdef __x86_64__ vmcs_writel(HOST_FS_BASE, read_msr(MSR_FS_BASE)); vmcs_writel(HOST_GS_BASE, read_msr(MSR_GS_BASE)); #else @@ -1726,7 +1713,7 @@ static int vmx_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) asm ( /* Store host registers */ "pushf \n\t" -#ifdef CONFIG_X86_64 +#ifdef __x86_64__ "push %%rax; push %%rbx; push %%rdx;" "push %%rsi; push %%rdi; push %%rbp;" "push %%r8; push %%r9; push %%r10; push %%r11;" @@ -1740,7 +1727,7 @@ static int vmx_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) /* Check if vmlaunch of vmresume is needed */ "cmp $0, %1 \n\t" /* Load guest registers. Don't clobber flags. */ -#ifdef CONFIG_X86_64 +#ifdef __x86_64__ "mov %c[cr2](%3), %%rax \n\t" "mov %%rax, %%cr2 \n\t" "mov %c[rax](%3), %%rax \n\t" @@ -1777,7 +1764,7 @@ static int vmx_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) ".globl kvm_vmx_return \n\t" "kvm_vmx_return: " /* Save guest registers, load host registers, keep flags */ -#ifdef CONFIG_X86_64 +#ifdef __x86_64__ "xchg %3, 0(%%rsp) \n\t" "mov %%rax, %c[rax](%3) \n\t" "mov %%rbx, %c[rbx](%3) \n\t" @@ -1829,7 +1816,7 @@ static int vmx_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) [rsi]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_RSI])), [rdi]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_RDI])), [rbp]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_RBP])), -#ifdef CONFIG_X86_64 +#ifdef __x86_64__ [r8 ]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_R8 ])), [r9 ]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_R9 ])), [r10]"i"(offsetof(struct kvm_vcpu, regs[VCPU_REGS_R10])), @@ -1850,7 +1837,7 @@ static int vmx_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) fx_save(vcpu->guest_fx_image); fx_restore(vcpu->host_fx_image); -#ifndef CONFIG_X86_64 +#ifndef __x86_64__ asm ("mov %0, %%ds; mov %0, %%es" : : "r"(__USER_DS)); #endif @@ -1868,7 +1855,7 @@ static int vmx_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) */ local_irq_disable(); load_gs(gs_sel); -#ifdef CONFIG_X86_64 +#ifdef __x86_64__ wrmsrl(MSR_GS_BASE, vmcs_readl(HOST_GS_BASE)); #endif local_irq_enable(); @@ -1978,7 +1965,7 @@ static struct kvm_arch_ops vmx_arch_ops = { .set_cr0_no_modeswitch = vmx_set_cr0_no_modeswitch, .set_cr3 = vmx_set_cr3, .set_cr4 = vmx_set_cr4, -#ifdef CONFIG_X86_64 +#ifdef __x86_64__ .set_efer = vmx_set_efer, #endif .get_idt = vmx_get_idt, @@ -2002,7 +1989,8 @@ static struct kvm_arch_ops vmx_arch_ops = { static int __init vmx_init(void) { - return kvm_init_arch(&vmx_arch_ops, THIS_MODULE); + kvm_init_arch(&vmx_arch_ops, THIS_MODULE); + return 0; } static void __exit vmx_exit(void) diff --git a/trunk/drivers/kvm/x86_emulate.c b/trunk/drivers/kvm/x86_emulate.c index 1bff3e925fda..7e838bf0592d 100644 --- a/trunk/drivers/kvm/x86_emulate.c +++ b/trunk/drivers/kvm/x86_emulate.c @@ -238,7 +238,7 @@ struct operand { * any modified flags. */ -#if defined(CONFIG_X86_64) +#if defined(__x86_64__) #define _LO32 "k" /* force 32-bit operand */ #define _STK "%%rsp" /* stack pointer */ #elif defined(__i386__) @@ -385,7 +385,7 @@ struct operand { } while (0) /* Emulate an instruction with quadword operands (x86/64 only). */ -#if defined(CONFIG_X86_64) +#if defined(__x86_64__) #define __emulate_2op_8byte(_op, _src, _dst, _eflags, _qx, _qy) \ do { \ __asm__ __volatile__ ( \ @@ -495,7 +495,7 @@ x86_emulate_memop(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops) case X86EMUL_MODE_PROT32: op_bytes = ad_bytes = 4; break; -#ifdef CONFIG_X86_64 +#ifdef __x86_64__ case X86EMUL_MODE_PROT64: op_bytes = 4; ad_bytes = 8; @@ -1341,7 +1341,7 @@ x86_emulate_memop(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops) } break; } -#elif defined(CONFIG_X86_64) +#elif defined(__x86_64__) { unsigned long old, new; if ((rc = ops->read_emulated(cr2, &old, 8, ctxt)) != 0) diff --git a/trunk/drivers/kvm/x86_emulate.h b/trunk/drivers/kvm/x86_emulate.h index 5d41bd55125e..658b58de30fc 100644 --- a/trunk/drivers/kvm/x86_emulate.h +++ b/trunk/drivers/kvm/x86_emulate.h @@ -162,7 +162,7 @@ struct x86_emulate_ctxt { /* Host execution mode. */ #if defined(__i386__) #define X86EMUL_MODE_HOST X86EMUL_MODE_PROT32 -#elif defined(CONFIG_X86_64) +#elif defined(__x86_64__) #define X86EMUL_MODE_HOST X86EMUL_MODE_PROT64 #endif diff --git a/trunk/drivers/macintosh/adb.c b/trunk/drivers/macintosh/adb.c index 7cec6de5e2b0..d43ea81d6df9 100644 --- a/trunk/drivers/macintosh/adb.c +++ b/trunk/drivers/macintosh/adb.c @@ -828,7 +828,7 @@ static ssize_t adb_write(struct file *file, const char __user *buf, if (!access_ok(VERIFY_READ, buf, count)) return -EFAULT; - req = kmalloc(sizeof(struct adb_request), + req = (struct adb_request *) kmalloc(sizeof(struct adb_request), GFP_KERNEL); if (req == NULL) return -ENOMEM; diff --git a/trunk/drivers/macintosh/apm_emu.c b/trunk/drivers/macintosh/apm_emu.c index 4300c628f8af..8862a83b8d84 100644 --- a/trunk/drivers/macintosh/apm_emu.c +++ b/trunk/drivers/macintosh/apm_emu.c @@ -321,7 +321,7 @@ static int do_open(struct inode * inode, struct file * filp) { struct apm_user * as; - as = kmalloc(sizeof(*as), GFP_KERNEL); + as = (struct apm_user *)kmalloc(sizeof(*as), GFP_KERNEL); if (as == NULL) { printk(KERN_ERR "apm: cannot allocate struct of size %d bytes\n", sizeof(*as)); diff --git a/trunk/drivers/macintosh/smu.c b/trunk/drivers/macintosh/smu.c index 6f30459b9385..6dde27ab79a8 100644 --- a/trunk/drivers/macintosh/smu.c +++ b/trunk/drivers/macintosh/smu.c @@ -945,7 +945,7 @@ static struct smu_sdbp_header *smu_create_sdb_partition(int id) */ tlen = sizeof(struct property) + len + 18; - prop = kzalloc(tlen, GFP_KERNEL); + prop = kcalloc(tlen, 1, GFP_KERNEL); if (prop == NULL) return NULL; hdr = (struct smu_sdbp_header *)(prop + 1); diff --git a/trunk/drivers/macintosh/via-pmu68k.c b/trunk/drivers/macintosh/via-pmu68k.c index 93e6ef9233f9..d9986f3a3fbf 100644 --- a/trunk/drivers/macintosh/via-pmu68k.c +++ b/trunk/drivers/macintosh/via-pmu68k.c @@ -847,7 +847,7 @@ pbook_pci_save(void) n_pbook_pci_saves = npci; if (npci == 0) return; - ps = kmalloc(npci * sizeof(*ps), GFP_KERNEL); + ps = (struct pci_save *) kmalloc(npci * sizeof(*ps), GFP_KERNEL); pbook_pci_saves = ps; if (ps == NULL) return; diff --git a/trunk/drivers/md/faulty.c b/trunk/drivers/md/faulty.c index 4ebd0f2a75ec..a7a5ab554338 100644 --- a/trunk/drivers/md/faulty.c +++ b/trunk/drivers/md/faulty.c @@ -173,7 +173,7 @@ static int make_request(request_queue_t *q, struct bio *bio) conf_t *conf = (conf_t*)mddev->private; int failit = 0; - if (bio_data_dir(bio) == WRITE) { + if (bio->bi_rw & 1) { /* write request */ if (atomic_read(&conf->counters[WriteAll])) { /* special case - don't decrement, don't generic_make_request, diff --git a/trunk/drivers/md/raid1.c b/trunk/drivers/md/raid1.c index b30f74be3982..b3c5e12f081d 100644 --- a/trunk/drivers/md/raid1.c +++ b/trunk/drivers/md/raid1.c @@ -1736,7 +1736,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i /* take from bio_init */ bio->bi_next = NULL; bio->bi_flags |= 1 << BIO_UPTODATE; - bio->bi_rw = READ; + bio->bi_rw = 0; bio->bi_vcnt = 0; bio->bi_idx = 0; bio->bi_phys_segments = 0; diff --git a/trunk/drivers/md/raid10.c b/trunk/drivers/md/raid10.c index f0141910bb8d..7492d6033ac6 100644 --- a/trunk/drivers/md/raid10.c +++ b/trunk/drivers/md/raid10.c @@ -1785,7 +1785,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i biolist = bio; bio->bi_private = r10_bio; bio->bi_end_io = end_sync_read; - bio->bi_rw = READ; + bio->bi_rw = 0; bio->bi_sector = r10_bio->devs[j].addr + conf->mirrors[d].rdev->data_offset; 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 biolist = bio; bio->bi_private = r10_bio; bio->bi_end_io = end_sync_write; - bio->bi_rw = WRITE; + bio->bi_rw = 1; bio->bi_sector = r10_bio->devs[k].addr + conf->mirrors[i].rdev->data_offset; 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 biolist = bio; bio->bi_private = r10_bio; bio->bi_end_io = end_sync_read; - bio->bi_rw = READ; + bio->bi_rw = 0; bio->bi_sector = r10_bio->devs[i].addr + conf->mirrors[d].rdev->data_offset; bio->bi_bdev = conf->mirrors[d].rdev->bdev; diff --git a/trunk/drivers/md/raid5.c b/trunk/drivers/md/raid5.c index be008f034ada..377f8bc9b78b 100644 --- a/trunk/drivers/md/raid5.c +++ b/trunk/drivers/md/raid5.c @@ -1827,16 +1827,16 @@ static void handle_stripe5(struct stripe_head *sh) struct bio *bi; mdk_rdev_t *rdev; if (test_and_clear_bit(R5_Wantwrite, &sh->dev[i].flags)) - rw = WRITE; + rw = 1; else if (test_and_clear_bit(R5_Wantread, &sh->dev[i].flags)) - rw = READ; + rw = 0; else continue; bi = &sh->dev[i].req; bi->bi_rw = rw; - if (rw == WRITE) + if (rw) bi->bi_end_io = raid5_end_write_request; else bi->bi_end_io = raid5_end_read_request; @@ -1872,7 +1872,7 @@ static void handle_stripe5(struct stripe_head *sh) atomic_add(STRIPE_SECTORS, &rdev->corrected_errors); generic_make_request(bi); } else { - if (rw == WRITE) + if (rw == 1) set_bit(STRIPE_DEGRADED, &sh->state); PRINTK("skip op %ld on disc %d for sector %llu\n", 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) struct bio *bi; mdk_rdev_t *rdev; if (test_and_clear_bit(R5_Wantwrite, &sh->dev[i].flags)) - rw = WRITE; + rw = 1; else if (test_and_clear_bit(R5_Wantread, &sh->dev[i].flags)) - rw = READ; + rw = 0; else continue; bi = &sh->dev[i].req; bi->bi_rw = rw; - if (rw == WRITE) + if (rw) bi->bi_end_io = raid5_end_write_request; else bi->bi_end_io = raid5_end_read_request; @@ -2415,7 +2415,7 @@ static void handle_stripe6(struct stripe_head *sh, struct page *tmp_page) atomic_add(STRIPE_SECTORS, &rdev->corrected_errors); generic_make_request(bi); } else { - if (rw == WRITE) + if (rw == 1) set_bit(STRIPE_DEGRADED, &sh->state); PRINTK("skip op %ld on disc %d for sector %llu\n", 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_ unsigned int chunk_sectors = mddev->chunk_size >> 9; unsigned int bio_sectors = bio->bi_size >> 9; - if (bio_data_dir(bio) == WRITE) + if (bio_data_dir(bio)) return biovec->bv_len; /* always allow writes to be mergeable */ 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) disk_stat_inc(mddev->gendisk, ios[rw]); disk_stat_add(mddev->gendisk, sectors[rw], bio_sectors(bi)); - if (rw == READ && + if (bio_data_dir(bi) == READ && mddev->reshape_position == MaxSector && chunk_aligned_read(q,bi)) return 0; diff --git a/trunk/drivers/media/dvb/bt8xx/dst_ca.c b/trunk/drivers/media/dvb/bt8xx/dst_ca.c index 50bc32a8bd55..240ad084fa78 100644 --- a/trunk/drivers/media/dvb/bt8xx/dst_ca.c +++ b/trunk/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, struct ca_msg *hw_buffer; int result = 0; - if ((hw_buffer = kmalloc(sizeof (struct ca_msg), GFP_KERNEL)) == NULL) { + if ((hw_buffer = (struct ca_msg *) kmalloc(sizeof (struct ca_msg), GFP_KERNEL)) == NULL) { dprintk(verbose, DST_CA_ERROR, 1, " Memory allocation failure"); return -ENOMEM; } diff --git a/trunk/drivers/media/dvb/bt8xx/dvb-bt8xx.c b/trunk/drivers/media/dvb/bt8xx/dvb-bt8xx.c index 3e35931af35d..80a85cb4975f 100644 --- a/trunk/drivers/media/dvb/bt8xx/dvb-bt8xx.c +++ b/trunk/drivers/media/dvb/bt8xx/dvb-bt8xx.c @@ -657,7 +657,7 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type) case BTTV_BOARD_TWINHAN_DST: /* DST is not a frontend driver !!! */ - state = kmalloc(sizeof (struct dst_state), GFP_KERNEL); + state = (struct dst_state *) kmalloc(sizeof (struct dst_state), GFP_KERNEL); if (!state) { printk("dvb_bt8xx: No memory\n"); break; diff --git a/trunk/drivers/media/dvb/ttusb-dec/ttusbdecfe.c b/trunk/drivers/media/dvb/ttusb-dec/ttusbdecfe.c index a6fb1d6a7b5d..42f39a89bc4d 100644 --- a/trunk/drivers/media/dvb/ttusb-dec/ttusbdecfe.c +++ b/trunk/drivers/media/dvb/ttusb-dec/ttusbdecfe.c @@ -195,7 +195,7 @@ struct dvb_frontend* ttusbdecfe_dvbt_attach(const struct ttusbdecfe_config* conf struct ttusbdecfe_state* state = NULL; /* allocate memory for the internal state */ - state = kmalloc(sizeof(struct ttusbdecfe_state), GFP_KERNEL); + state = (struct ttusbdecfe_state*) kmalloc(sizeof(struct ttusbdecfe_state), GFP_KERNEL); if (state == NULL) return NULL; @@ -215,7 +215,7 @@ struct dvb_frontend* ttusbdecfe_dvbs_attach(const struct ttusbdecfe_config* conf struct ttusbdecfe_state* state = NULL; /* allocate memory for the internal state */ - state = kmalloc(sizeof(struct ttusbdecfe_state), GFP_KERNEL); + state = (struct ttusbdecfe_state*) kmalloc(sizeof(struct ttusbdecfe_state), GFP_KERNEL); if (state == NULL) return NULL; diff --git a/trunk/drivers/media/video/dabusb.c b/trunk/drivers/media/video/dabusb.c index 917021fc2993..b1012e92ee04 100644 --- a/trunk/drivers/media/video/dabusb.c +++ b/trunk/drivers/media/video/dabusb.c @@ -218,7 +218,7 @@ static int dabusb_alloc_buffers (pdabusb_t s) pipesize, packets, transfer_buffer_length); while (buffers < (s->total_buffer_size << 10)) { - b = kzalloc(sizeof (buff_t), GFP_KERNEL); + b = (pbuff_t) kzalloc (sizeof (buff_t), GFP_KERNEL); if (!b) { err("kzalloc(sizeof(buff_t))==NULL"); goto err; @@ -659,7 +659,7 @@ static int dabusb_ioctl (struct inode *inode, struct file *file, unsigned int cm switch (cmd) { case IOCTL_DAB_BULK: - pbulk = kmalloc(sizeof (bulk_transfer_t), GFP_KERNEL); + pbulk = (pbulk_transfer_t) kmalloc (sizeof (bulk_transfer_t), GFP_KERNEL); if (!pbulk) { ret = -ENOMEM; diff --git a/trunk/drivers/media/video/planb.c b/trunk/drivers/media/video/planb.c index 86d2884e16c6..368d6e219fa4 100644 --- a/trunk/drivers/media/video/planb.c +++ b/trunk/drivers/media/video/planb.c @@ -138,7 +138,7 @@ static int grabbuf_alloc(struct planb *pb) + MAX_LNUM #endif /* PLANB_GSCANLINE */ ); - if ((pb->rawbuf = kmalloc(npage + if ((pb->rawbuf = (unsigned char**) kmalloc (npage * sizeof(unsigned long), GFP_KERNEL)) == 0) return -ENOMEM; for (i = 0; i < npage; i++) { diff --git a/trunk/drivers/media/video/usbvideo/usbvideo.c b/trunk/drivers/media/video/usbvideo/usbvideo.c index b560c9d7c516..d8b88024bc2f 100644 --- a/trunk/drivers/media/video/usbvideo/usbvideo.c +++ b/trunk/drivers/media/video/usbvideo/usbvideo.c @@ -690,7 +690,7 @@ int usbvideo_register( } base_size = num_cams * sizeof(struct uvd) + sizeof(struct usbvideo); - cams = kzalloc(base_size, GFP_KERNEL); + cams = (struct usbvideo *) kzalloc(base_size, GFP_KERNEL); if (cams == NULL) { err("Failed to allocate %d. bytes for usbvideo struct", base_size); return -ENOMEM; diff --git a/trunk/drivers/media/video/videocodec.c b/trunk/drivers/media/video/videocodec.c index 290e64135650..2ae3fb250630 100644 --- a/trunk/drivers/media/video/videocodec.c +++ b/trunk/drivers/media/video/videocodec.c @@ -346,7 +346,7 @@ videocodec_build_table (void) size); kfree(videocodec_buf); - videocodec_buf = kmalloc(size, GFP_KERNEL); + videocodec_buf = (char *) kmalloc(size, GFP_KERNEL); i = 0; i += scnprintf(videocodec_buf + i, size - 1, diff --git a/trunk/drivers/message/i2o/core.h b/trunk/drivers/message/i2o/core.h index cbe384fb848c..dc388a3ff5e0 100644 --- a/trunk/drivers/message/i2o/core.h +++ b/trunk/drivers/message/i2o/core.h @@ -18,7 +18,7 @@ extern struct i2o_driver i2o_exec_driver; extern int i2o_exec_lct_get(struct i2o_controller *); extern int __init i2o_exec_init(void); -extern void i2o_exec_exit(void); +extern void __exit i2o_exec_exit(void); /* driver */ extern struct bus_type i2o_bus_type; @@ -26,7 +26,7 @@ extern struct bus_type i2o_bus_type; extern int i2o_driver_dispatch(struct i2o_controller *, u32); extern int __init i2o_driver_init(void); -extern void i2o_driver_exit(void); +extern void __exit i2o_driver_exit(void); /* PCI */ extern int __init i2o_pci_init(void); diff --git a/trunk/drivers/message/i2o/driver.c b/trunk/drivers/message/i2o/driver.c index d3235f213c89..9104b65ff70f 100644 --- a/trunk/drivers/message/i2o/driver.c +++ b/trunk/drivers/message/i2o/driver.c @@ -362,7 +362,7 @@ int __init i2o_driver_init(void) * * Unregisters the I2O bus and frees driver array. */ -void i2o_driver_exit(void) +void __exit i2o_driver_exit(void) { bus_unregister(&i2o_bus_type); kfree(i2o_drivers); diff --git a/trunk/drivers/message/i2o/exec-osm.c b/trunk/drivers/message/i2o/exec-osm.c index a539d3b61e76..902753b2c661 100644 --- a/trunk/drivers/message/i2o/exec-osm.c +++ b/trunk/drivers/message/i2o/exec-osm.c @@ -595,7 +595,7 @@ int __init i2o_exec_init(void) * * Unregisters the Exec OSM from the I2O core. */ -void i2o_exec_exit(void) +void __exit i2o_exec_exit(void) { i2o_driver_unregister(&i2o_exec_driver); }; diff --git a/trunk/drivers/message/i2o/i2o_config.c b/trunk/drivers/message/i2o/i2o_config.c index e33d446e7493..1de30d711671 100644 --- a/trunk/drivers/message/i2o/i2o_config.c +++ b/trunk/drivers/message/i2o/i2o_config.c @@ -186,7 +186,7 @@ static int i2o_cfg_parms(unsigned long arg, unsigned int type) if (!dev) return -ENXIO; - ops = kmalloc(kcmd.oplen, GFP_KERNEL); + ops = (u8 *) kmalloc(kcmd.oplen, GFP_KERNEL); if (!ops) return -ENOMEM; @@ -199,7 +199,7 @@ static int i2o_cfg_parms(unsigned long arg, unsigned int type) * It's possible to have a _very_ large table * and that the user asks for all of it at once... */ - res = kmalloc(65536, GFP_KERNEL); + res = (u8 *) kmalloc(65536, GFP_KERNEL); if (!res) { kfree(ops); return -ENOMEM; diff --git a/trunk/drivers/mtd/devices/mtd_dataflash.c b/trunk/drivers/mtd/devices/mtd_dataflash.c index 0a7e86859bf1..5db716045927 100644 --- a/trunk/drivers/mtd/devices/mtd_dataflash.c +++ b/trunk/drivers/mtd/devices/mtd_dataflash.c @@ -459,7 +459,7 @@ add_dataflash(struct spi_device *spi, char *name, struct mtd_info *device; struct flash_platform_data *pdata = spi->dev.platform_data; - priv = kzalloc(sizeof *priv, GFP_KERNEL); + priv = (struct dataflash *) kzalloc(sizeof *priv, GFP_KERNEL); if (!priv) return -ENOMEM; diff --git a/trunk/drivers/mtd/rfd_ftl.c b/trunk/drivers/mtd/rfd_ftl.c index 0f3baa5d9c2a..fa4362fb4dd8 100644 --- a/trunk/drivers/mtd/rfd_ftl.c +++ b/trunk/drivers/mtd/rfd_ftl.c @@ -768,7 +768,7 @@ static void rfd_ftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) if (mtd->type != MTD_NORFLASH) return; - part = kzalloc(sizeof(struct partition), GFP_KERNEL); + part = kcalloc(1, sizeof(struct partition), GFP_KERNEL); if (!part) return; diff --git a/trunk/drivers/net/appletalk/ipddp.c b/trunk/drivers/net/appletalk/ipddp.c index f22e46dfd770..b98592a8bac8 100644 --- a/trunk/drivers/net/appletalk/ipddp.c +++ b/trunk/drivers/net/appletalk/ipddp.c @@ -186,7 +186,7 @@ static int ipddp_xmit(struct sk_buff *skb, struct net_device *dev) */ static int ipddp_create(struct ipddp_route *new_rt) { - struct ipddp_route *rt = kmalloc(sizeof(*rt), GFP_KERNEL); + struct ipddp_route *rt =(struct ipddp_route*) kmalloc(sizeof(*rt), GFP_KERNEL); if (rt == NULL) return -ENOMEM; diff --git a/trunk/drivers/net/bsd_comp.c b/trunk/drivers/net/bsd_comp.c index 7845eaf6f29f..bae1de1e7802 100644 --- a/trunk/drivers/net/bsd_comp.c +++ b/trunk/drivers/net/bsd_comp.c @@ -395,7 +395,7 @@ static void *bsd_alloc (unsigned char *options, int opt_len, int decomp) * Allocate the main control structure for this instance. */ maxmaxcode = MAXCODE(bits); - db = kmalloc(sizeof (struct bsd_db), + db = (struct bsd_db *) kmalloc (sizeof (struct bsd_db), GFP_KERNEL); if (!db) { diff --git a/trunk/drivers/net/irda/donauboe.c b/trunk/drivers/net/irda/donauboe.c index 11af0ae7510e..16620bd97fbf 100644 --- a/trunk/drivers/net/irda/donauboe.c +++ b/trunk/drivers/net/irda/donauboe.c @@ -1603,7 +1603,7 @@ toshoboe_open (struct pci_dev *pci_dev, const struct pci_device_id *pdid) irda_qos_bits_to_value (&self->qos); /* Allocate twice the size to guarantee alignment */ - self->ringbuf = kmalloc(OBOE_RING_LEN << 1, GFP_KERNEL); + self->ringbuf = (void *) kmalloc (OBOE_RING_LEN << 1, GFP_KERNEL); if (!self->ringbuf) { printk (KERN_ERR DRIVER_NAME ": can't allocate DMA buffers\n"); diff --git a/trunk/drivers/net/irda/irda-usb.c b/trunk/drivers/net/irda/irda-usb.c index 3ca1082ec776..6e95645e7245 100644 --- a/trunk/drivers/net/irda/irda-usb.c +++ b/trunk/drivers/net/irda/irda-usb.c @@ -1747,7 +1747,7 @@ static int irda_usb_probe(struct usb_interface *intf, /* Don't change this buffer size and allocation without doing * some heavy and complete testing. Don't ask why :-( * Jean II */ - self->speed_buff = kmalloc(IRDA_USB_SPEED_MTU, GFP_KERNEL); + self->speed_buff = (char *) kmalloc(IRDA_USB_SPEED_MTU, GFP_KERNEL); if (self->speed_buff == NULL) goto err_out_3; diff --git a/trunk/drivers/net/irda/irport.c b/trunk/drivers/net/irda/irport.c index 3098960dc2a1..654a68b490ae 100644 --- a/trunk/drivers/net/irda/irport.c +++ b/trunk/drivers/net/irda/irport.c @@ -164,7 +164,7 @@ irport_open(int i, unsigned int iobase, unsigned int irq) /* Allocate memory if needed */ if (self->tx_buff.truesize > 0) { - self->tx_buff.head = kmalloc(self->tx_buff.truesize, + self->tx_buff.head = (__u8 *) kmalloc(self->tx_buff.truesize, GFP_KERNEL); if (self->tx_buff.head == NULL) { IRDA_ERROR("%s(), can't allocate memory for " diff --git a/trunk/drivers/net/lp486e.c b/trunk/drivers/net/lp486e.c index 177c502f7385..b833016f1825 100644 --- a/trunk/drivers/net/lp486e.c +++ b/trunk/drivers/net/lp486e.c @@ -884,7 +884,7 @@ static int i596_start_xmit (struct sk_buff *skb, struct net_device *dev) { dev->trans_start = jiffies; - tx_cmd = kmalloc((sizeof (struct tx_cmd) + sizeof (struct i596_tbd)), GFP_ATOMIC); + tx_cmd = (struct tx_cmd *) kmalloc ((sizeof (struct tx_cmd) + sizeof (struct i596_tbd)), GFP_ATOMIC); if (tx_cmd == NULL) { printk(KERN_WARNING "%s: i596_xmit Memory squeeze, dropping packet.\n", dev->name); lp->stats.tx_dropped++; @@ -1266,7 +1266,7 @@ static void set_multicast_list(struct net_device *dev) { if (dev->mc_count > 0) { struct dev_mc_list *dmi; char *cp; - cmd = kmalloc(sizeof(struct i596_cmd)+2+dev->mc_count*6, GFP_ATOMIC); + cmd = (struct i596_cmd *)kmalloc(sizeof(struct i596_cmd)+2+dev->mc_count*6, GFP_ATOMIC); if (cmd == NULL) { printk (KERN_ERR "%s: set_multicast Memory squeeze.\n", dev->name); return; diff --git a/trunk/drivers/net/phy/phy_device.c b/trunk/drivers/net/phy/phy_device.c index a4d7529ef415..b01fc70a57db 100644 --- a/trunk/drivers/net/phy/phy_device.c +++ b/trunk/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) struct phy_device *dev; /* We allocate the device, and initialize the * default values */ - dev = kzalloc(sizeof(*dev), GFP_KERNEL); + dev = kcalloc(1, sizeof(*dev), GFP_KERNEL); if (NULL == dev) return (struct phy_device*) PTR_ERR((void*)-ENOMEM); diff --git a/trunk/drivers/net/ppp_deflate.c b/trunk/drivers/net/ppp_deflate.c index 72c8d6628f58..f54c55242f4a 100644 --- a/trunk/drivers/net/ppp_deflate.c +++ b/trunk/drivers/net/ppp_deflate.c @@ -121,7 +121,7 @@ static void *z_comp_alloc(unsigned char *options, int opt_len) if (w_size < DEFLATE_MIN_SIZE || w_size > DEFLATE_MAX_SIZE) return NULL; - state = kmalloc(sizeof(*state), + state = (struct ppp_deflate_state *) kmalloc(sizeof(*state), GFP_KERNEL); if (state == NULL) return NULL; @@ -341,7 +341,7 @@ static void *z_decomp_alloc(unsigned char *options, int opt_len) if (w_size < DEFLATE_MIN_SIZE || w_size > DEFLATE_MAX_SIZE) return NULL; - state = kmalloc(sizeof(*state), GFP_KERNEL); + state = (struct ppp_deflate_state *) kmalloc(sizeof(*state), GFP_KERNEL); if (state == NULL) return NULL; diff --git a/trunk/drivers/net/ppp_mppe.c b/trunk/drivers/net/ppp_mppe.c index d5bdd2574659..f3655fd772f5 100644 --- a/trunk/drivers/net/ppp_mppe.c +++ b/trunk/drivers/net/ppp_mppe.c @@ -200,7 +200,7 @@ static void *mppe_alloc(unsigned char *options, int optlen) || options[0] != CI_MPPE || options[1] != CILEN_MPPE) goto out; - state = kmalloc(sizeof(*state), GFP_KERNEL); + state = (struct ppp_mppe_state *) kmalloc(sizeof(*state), GFP_KERNEL); if (state == NULL) goto out; diff --git a/trunk/drivers/net/skge.c b/trunk/drivers/net/skge.c index 8a39376f87dc..b60f0451f6cd 100644 --- a/trunk/drivers/net/skge.c +++ b/trunk/drivers/net/skge.c @@ -749,7 +749,7 @@ static int skge_ring_alloc(struct skge_ring *ring, void *vaddr, u32 base) struct skge_element *e; int i; - ring->start = kcalloc(ring->count, sizeof(*e), GFP_KERNEL); + ring->start = kcalloc(sizeof(*e), ring->count, GFP_KERNEL); if (!ring->start) return -ENOMEM; diff --git a/trunk/drivers/net/slip.c b/trunk/drivers/net/slip.c index a0806d262fc6..39c2152a07f4 100644 --- a/trunk/drivers/net/slip.c +++ b/trunk/drivers/net/slip.c @@ -229,10 +229,10 @@ static int sl_realloc_bufs(struct slip *sl, int mtu) if (len < 576 * 2) len = 576 * 2; - xbuff = kmalloc(len + 4, GFP_ATOMIC); - rbuff = kmalloc(len + 4, GFP_ATOMIC); + xbuff = (unsigned char *) kmalloc (len + 4, GFP_ATOMIC); + rbuff = (unsigned char *) kmalloc (len + 4, GFP_ATOMIC); #ifdef SL_INCLUDE_CSLIP - cbuff = kmalloc(len + 4, GFP_ATOMIC); + cbuff = (unsigned char *) kmalloc (len + 4, GFP_ATOMIC); #endif diff --git a/trunk/drivers/net/wan/hostess_sv11.c b/trunk/drivers/net/wan/hostess_sv11.c index a02c5fb40567..a4f735723c41 100644 --- a/trunk/drivers/net/wan/hostess_sv11.c +++ b/trunk/drivers/net/wan/hostess_sv11.c @@ -231,7 +231,7 @@ static struct sv11_device *sv11_init(int iobase, int irq) return NULL; } - sv = kmalloc(sizeof(struct sv11_device), GFP_KERNEL); + sv=(struct sv11_device *)kmalloc(sizeof(struct sv11_device), GFP_KERNEL); if(!sv) goto fail3; diff --git a/trunk/drivers/net/wan/pc300_drv.c b/trunk/drivers/net/wan/pc300_drv.c index 62184dee377c..36d1c3ff7078 100644 --- a/trunk/drivers/net/wan/pc300_drv.c +++ b/trunk/drivers/net/wan/pc300_drv.c @@ -3455,7 +3455,7 @@ cpc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) if ((err = pci_enable_device(pdev)) < 0) return err; - card = kmalloc(sizeof(pc300_t), GFP_KERNEL); + card = (pc300_t *) kmalloc(sizeof(pc300_t), GFP_KERNEL); if (card == NULL) { printk("PC300 found at RAM 0x%016llx, " "but could not allocate card structure.\n", diff --git a/trunk/drivers/net/wan/pc300_tty.c b/trunk/drivers/net/wan/pc300_tty.c index 5873c346e7e9..b2a23aed4428 100644 --- a/trunk/drivers/net/wan/pc300_tty.c +++ b/trunk/drivers/net/wan/pc300_tty.c @@ -784,7 +784,7 @@ void cpc_tty_receive(pc300dev_t *pc300dev) continue; } - new = kmalloc(rx_len + sizeof(st_cpc_rx_buf), GFP_ATOMIC); + new = (st_cpc_rx_buf *)kmalloc(rx_len + sizeof(st_cpc_rx_buf), GFP_ATOMIC); if (new == 0) { cpc_tty_rx_disc_frame(pc300chan); continue; diff --git a/trunk/drivers/net/wan/x25_asy.c b/trunk/drivers/net/wan/x25_asy.c index 1c9edd97accd..9c3ccc669143 100644 --- a/trunk/drivers/net/wan/x25_asy.c +++ b/trunk/drivers/net/wan/x25_asy.c @@ -123,8 +123,8 @@ static int x25_asy_change_mtu(struct net_device *dev, int newmtu) unsigned char *xbuff, *rbuff; int len = 2* newmtu; - xbuff = kmalloc(len + 4, GFP_ATOMIC); - rbuff = kmalloc(len + 4, GFP_ATOMIC); + xbuff = (unsigned char *) kmalloc (len + 4, GFP_ATOMIC); + rbuff = (unsigned char *) kmalloc (len + 4, GFP_ATOMIC); if (xbuff == NULL || rbuff == NULL) { @@ -465,11 +465,11 @@ static int x25_asy_open(struct net_device *dev) len = dev->mtu * 2; - sl->rbuff = kmalloc(len + 4, GFP_KERNEL); + sl->rbuff = (unsigned char *) kmalloc(len + 4, GFP_KERNEL); if (sl->rbuff == NULL) { goto norbuff; } - sl->xbuff = kmalloc(len + 4, GFP_KERNEL); + sl->xbuff = (unsigned char *) kmalloc(len + 4, GFP_KERNEL); if (sl->xbuff == NULL) { goto noxbuff; } diff --git a/trunk/drivers/net/wireless/hostap/hostap_ap.c b/trunk/drivers/net/wireless/hostap/hostap_ap.c index efb8cf3bd8ad..974a8e5bec8b 100644 --- a/trunk/drivers/net/wireless/hostap/hostap_ap.c +++ b/trunk/drivers/net/wireless/hostap/hostap_ap.c @@ -1253,7 +1253,7 @@ static char * ap_auth_make_challenge(struct ap_data *ap) return NULL; } - tmpbuf = kmalloc(WLAN_AUTH_CHALLENGE_LEN, GFP_ATOMIC); + tmpbuf = (char *) kmalloc(WLAN_AUTH_CHALLENGE_LEN, GFP_ATOMIC); if (tmpbuf == NULL) { PDEBUG(DEBUG_AP, "AP: kmalloc failed for challenge\n"); return NULL; diff --git a/trunk/drivers/net/wireless/hostap/hostap_download.c b/trunk/drivers/net/wireless/hostap/hostap_download.c index c7678e67697d..24fc387bba67 100644 --- a/trunk/drivers/net/wireless/hostap/hostap_download.c +++ b/trunk/drivers/net/wireless/hostap/hostap_download.c @@ -201,7 +201,7 @@ static u8 * prism2_read_pda(struct net_device *dev) 0x7f0002 /* Intel PRO/Wireless 2011B (PCI) */, }; - buf = kmalloc(PRISM2_PDA_SIZE, GFP_KERNEL); + buf = (u8 *) kmalloc(PRISM2_PDA_SIZE, GFP_KERNEL); if (buf == NULL) return NULL; diff --git a/trunk/drivers/net/wireless/hostap/hostap_hw.c b/trunk/drivers/net/wireless/hostap/hostap_hw.c index 3079378fb8cd..a394a23b9a20 100644 --- a/trunk/drivers/net/wireless/hostap/hostap_hw.c +++ b/trunk/drivers/net/wireless/hostap/hostap_hw.c @@ -2252,7 +2252,7 @@ static int hostap_tx_compl_read(local_info_t *local, int error, if (txdesc->sw_support) { len = le16_to_cpu(txdesc->data_len); if (len < PRISM2_DATA_MAXLEN) { - *payload = kmalloc(len, GFP_ATOMIC); + *payload = (char *) kmalloc(len, GFP_ATOMIC); if (*payload == NULL || hfa384x_from_bap(dev, BAP0, *payload, len)) { PDEBUG(DEBUG_EXTRA, "%s: could not read TX " diff --git a/trunk/drivers/net/wireless/hostap/hostap_ioctl.c b/trunk/drivers/net/wireless/hostap/hostap_ioctl.c index cb08bc5db2bd..3b7b8063ff1c 100644 --- a/trunk/drivers/net/wireless/hostap/hostap_ioctl.c +++ b/trunk/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) p->length > PRISM2_HOSTAPD_MAX_BUF_SIZE || !p->pointer) return -EINVAL; - param = kmalloc(p->length, GFP_KERNEL); + param = (struct prism2_hostapd_param *) kmalloc(p->length, GFP_KERNEL); if (param == NULL) return -ENOMEM; diff --git a/trunk/drivers/net/wireless/hostap/hostap_main.c b/trunk/drivers/net/wireless/hostap/hostap_main.c index 04c19cefa1da..0796be9d9e77 100644 --- a/trunk/drivers/net/wireless/hostap/hostap_main.c +++ b/trunk/drivers/net/wireless/hostap/hostap_main.c @@ -250,7 +250,7 @@ u16 hostap_tx_callback_register(local_info_t *local, unsigned long flags; struct hostap_tx_callback_info *entry; - entry = kmalloc(sizeof(*entry), + entry = (struct hostap_tx_callback_info *) kmalloc(sizeof(*entry), GFP_ATOMIC); if (entry == NULL) return 0; diff --git a/trunk/drivers/net/wireless/ipw2100.c b/trunk/drivers/net/wireless/ipw2100.c index 0e94fbbf7a94..dd9ba4aad7bb 100644 --- a/trunk/drivers/net/wireless/ipw2100.c +++ b/trunk/drivers/net/wireless/ipw2100.c @@ -2246,7 +2246,7 @@ static int ipw2100_snapshot_alloc(struct ipw2100_priv *priv) if (priv->snapshot[0]) return 1; for (i = 0; i < 0x30; i++) { - priv->snapshot[i] = kmalloc(0x1000, GFP_ATOMIC); + priv->snapshot[i] = (u8 *) kmalloc(0x1000, GFP_ATOMIC); if (!priv->snapshot[i]) { IPW_DEBUG_INFO("%s: Error allocating snapshot " "buffer %d\n", priv->net_dev->name, i); diff --git a/trunk/drivers/net/wireless/prism54/isl_ioctl.c b/trunk/drivers/net/wireless/prism54/isl_ioctl.c index 838d510213c6..96606ed10076 100644 --- a/trunk/drivers/net/wireless/prism54/isl_ioctl.c +++ b/trunk/drivers/net/wireless/prism54/isl_ioctl.c @@ -2775,7 +2775,7 @@ prism54_hostapd(struct net_device *ndev, struct iw_point *p) p->length > PRISM2_HOSTAPD_MAX_BUF_SIZE || !p->pointer) return -EINVAL; - param = kmalloc(p->length, GFP_KERNEL); + param = (struct prism2_hostapd_param *) kmalloc(p->length, GFP_KERNEL); if (param == NULL) return -ENOMEM; diff --git a/trunk/drivers/net/wireless/wavelan_cs.c b/trunk/drivers/net/wireless/wavelan_cs.c index 5eb81638e846..233d906c08f0 100644 --- a/trunk/drivers/net/wireless/wavelan_cs.c +++ b/trunk/drivers/net/wireless/wavelan_cs.c @@ -603,7 +603,7 @@ static wavepoint_history *wl_new_wavepoint(unsigned short nwid, unsigned char se if(lp->wavepoint_table.num_wavepoints==MAX_WAVEPOINTS) return NULL; - new_wavepoint = kmalloc(sizeof(wavepoint_history),GFP_ATOMIC); + new_wavepoint=(wavepoint_history *) kmalloc(sizeof(wavepoint_history),GFP_ATOMIC); if(new_wavepoint==NULL) return NULL; diff --git a/trunk/drivers/net/wireless/zd1211rw/zd_chip.c b/trunk/drivers/net/wireless/zd1211rw/zd_chip.c index 78ea72fb8f0c..77e11ddad836 100644 --- a/trunk/drivers/net/wireless/zd1211rw/zd_chip.c +++ b/trunk/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 /* Allocate a single memory block for values and addresses. */ count16 = 2*count; - a16 = kmalloc(count16 * (sizeof(zd_addr_t) + sizeof(u16)), + a16 = (zd_addr_t *)kmalloc(count16 * (sizeof(zd_addr_t) + sizeof(u16)), GFP_NOFS); if (!a16) { dev_dbg_f(zd_chip_dev(chip), diff --git a/trunk/drivers/parisc/iosapic.c b/trunk/drivers/parisc/iosapic.c index 6fb3f7979f21..12bab64a62a1 100644 --- a/trunk/drivers/parisc/iosapic.c +++ b/trunk/drivers/parisc/iosapic.c @@ -874,7 +874,7 @@ void *iosapic_register(unsigned long hpa) return NULL; } - isi = kzalloc(sizeof(struct iosapic_info), GFP_KERNEL); + isi = (struct iosapic_info *)kzalloc(sizeof(struct iosapic_info), GFP_KERNEL); if (!isi) { BUG(); return NULL; diff --git a/trunk/drivers/pci/hotplug/cpqphp_nvram.c b/trunk/drivers/pci/hotplug/cpqphp_nvram.c index ae5e974c45a7..298a6cfd8406 100644 --- a/trunk/drivers/pci/hotplug/cpqphp_nvram.c +++ b/trunk/drivers/pci/hotplug/cpqphp_nvram.c @@ -520,7 +520,7 @@ int compaq_nvram_load (void __iomem *rom_start, struct controller *ctrl) return 2; while (nummem--) { - mem_node = kmalloc(sizeof(struct pci_resource), GFP_KERNEL); + mem_node = (struct pci_resource*) kmalloc(sizeof(struct pci_resource), GFP_KERNEL); if (!mem_node) break; @@ -548,7 +548,7 @@ int compaq_nvram_load (void __iomem *rom_start, struct controller *ctrl) } while (numpmem--) { - p_mem_node = kmalloc(sizeof(struct pci_resource), GFP_KERNEL); + p_mem_node = (struct pci_resource*) kmalloc(sizeof(struct pci_resource), GFP_KERNEL); if (!p_mem_node) break; @@ -576,7 +576,7 @@ int compaq_nvram_load (void __iomem *rom_start, struct controller *ctrl) } while (numio--) { - io_node = kmalloc(sizeof(struct pci_resource), GFP_KERNEL); + io_node = (struct pci_resource*) kmalloc(sizeof(struct pci_resource), GFP_KERNEL); if (!io_node) break; @@ -604,7 +604,7 @@ int compaq_nvram_load (void __iomem *rom_start, struct controller *ctrl) } while (numbus--) { - bus_node = kmalloc(sizeof(struct pci_resource), GFP_KERNEL); + bus_node = (struct pci_resource*) kmalloc(sizeof(struct pci_resource), GFP_KERNEL); if (!bus_node) break; diff --git a/trunk/drivers/pci/hotplug/pciehp_hpc.c b/trunk/drivers/pci/hotplug/pciehp_hpc.c index 25d3aadfddbf..6d3f580f2666 100644 --- a/trunk/drivers/pci/hotplug/pciehp_hpc.c +++ b/trunk/drivers/pci/hotplug/pciehp_hpc.c @@ -1320,7 +1320,7 @@ int pcie_init(struct controller * ctrl, struct pcie_device *dev) DBG_ENTER_ROUTINE spin_lock_init(&list_lock); - php_ctlr = kmalloc(sizeof(struct php_ctlr_state_s), GFP_KERNEL); + php_ctlr = (struct php_ctlr_state_s *) kmalloc(sizeof(struct php_ctlr_state_s), GFP_KERNEL); if (!php_ctlr) { /* allocate controller state data */ err("%s: HPC controller memory allocation error!\n", __FUNCTION__); diff --git a/trunk/drivers/pci/pcie/aer/aerdrv.c b/trunk/drivers/pci/pcie/aer/aerdrv.c index 6f5fabbd14e5..55866b6b26fa 100644 --- a/trunk/drivers/pci/pcie/aer/aerdrv.c +++ b/trunk/drivers/pci/pcie/aer/aerdrv.c @@ -148,7 +148,7 @@ static struct aer_rpc* aer_alloc_rpc(struct pcie_device *dev) { struct aer_rpc *rpc; - if (!(rpc = kmalloc(sizeof(struct aer_rpc), + if (!(rpc = (struct aer_rpc *)kmalloc(sizeof(struct aer_rpc), GFP_KERNEL))) return NULL; diff --git a/trunk/drivers/pcmcia/at91_cf.c b/trunk/drivers/pcmcia/at91_cf.c index 3334f22a86c0..52d4a38b3667 100644 --- a/trunk/drivers/pcmcia/at91_cf.c +++ b/trunk/drivers/pcmcia/at91_cf.c @@ -230,7 +230,7 @@ static int __init at91_cf_probe(struct platform_device *pdev) if (!io) return -ENODEV; - cf = kzalloc(sizeof *cf, GFP_KERNEL); + cf = kcalloc(1, sizeof *cf, GFP_KERNEL); if (!cf) return -ENOMEM; diff --git a/trunk/drivers/pcmcia/omap_cf.c b/trunk/drivers/pcmcia/omap_cf.c index e65a6b8188f6..06bf7f48836e 100644 --- a/trunk/drivers/pcmcia/omap_cf.c +++ b/trunk/drivers/pcmcia/omap_cf.c @@ -220,7 +220,7 @@ static int __devinit omap_cf_probe(struct device *dev) if (irq < 0) return -EINVAL; - cf = kzalloc(sizeof *cf, GFP_KERNEL); + cf = kcalloc(1, sizeof *cf, GFP_KERNEL); if (!cf) return -ENOMEM; init_timer(&cf->timer); diff --git a/trunk/drivers/pnp/isapnp/core.c b/trunk/drivers/pnp/isapnp/core.c index a0b158704ca1..3ac5b123215a 100644 --- a/trunk/drivers/pnp/isapnp/core.c +++ b/trunk/drivers/pnp/isapnp/core.c @@ -395,7 +395,7 @@ static void isapnp_parse_id(struct pnp_dev * dev, unsigned short vendor, unsigne struct pnp_id * id; if (!dev) return; - id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL); + id = kcalloc(1, sizeof(struct pnp_id), GFP_KERNEL); if (!id) return; 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 struct pnp_dev *dev; isapnp_peek(tmp, size); - dev = kzalloc(sizeof(struct pnp_dev), GFP_KERNEL); + dev = kcalloc(1, sizeof(struct pnp_dev), GFP_KERNEL); if (!dev) return NULL; dev->number = number; @@ -450,7 +450,7 @@ static void __init isapnp_parse_irq_resource(struct pnp_option *option, unsigned long bits; isapnp_peek(tmp, size); - irq = kzalloc(sizeof(struct pnp_irq), GFP_KERNEL); + irq = kcalloc(1, sizeof(struct pnp_irq), GFP_KERNEL); if (!irq) return; bits = (tmp[1] << 8) | tmp[0]; @@ -474,7 +474,7 @@ static void __init isapnp_parse_dma_resource(struct pnp_option *option, struct pnp_dma *dma; isapnp_peek(tmp, size); - dma = kzalloc(sizeof(struct pnp_dma), GFP_KERNEL); + dma = kcalloc(1, sizeof(struct pnp_dma), GFP_KERNEL); if (!dma) return; dma->map = tmp[0]; @@ -494,7 +494,7 @@ static void __init isapnp_parse_port_resource(struct pnp_option *option, struct pnp_port *port; isapnp_peek(tmp, size); - port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL); + port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL); if (!port) return; port->min = (tmp[2] << 8) | tmp[1]; @@ -517,7 +517,7 @@ static void __init isapnp_parse_fixed_port_resource(struct pnp_option *option, struct pnp_port *port; isapnp_peek(tmp, size); - port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL); + port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL); if (!port) return; port->min = port->max = (tmp[1] << 8) | tmp[0]; @@ -539,7 +539,7 @@ static void __init isapnp_parse_mem_resource(struct pnp_option *option, struct pnp_mem *mem; isapnp_peek(tmp, size); - mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); + mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); if (!mem) return; mem->min = ((tmp[2] << 8) | tmp[1]) << 8; @@ -562,7 +562,7 @@ static void __init isapnp_parse_mem32_resource(struct pnp_option *option, struct pnp_mem *mem; isapnp_peek(tmp, size); - mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); + mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); if (!mem) return; 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, struct pnp_mem *mem; isapnp_peek(tmp, size); - mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); + mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); if (!mem) return; 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) static void isapnp_parse_card_id(struct pnp_card * card, unsigned short vendor, unsigned short device) { - struct pnp_id * id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL); + struct pnp_id * id = kcalloc(1, sizeof(struct pnp_id), GFP_KERNEL); if (!id) return; sprintf(id->id, "%c%c%c%x%x%x%x", @@ -865,7 +865,7 @@ static int __init isapnp_build_device_list(void) header[4], header[5], header[6], header[7], header[8]); printk(KERN_DEBUG "checksum = 0x%x\n", checksum); #endif - if ((card = kzalloc(sizeof(struct pnp_card), GFP_KERNEL)) == NULL) + if ((card = kcalloc(1, sizeof(struct pnp_card), GFP_KERNEL)) == NULL) continue; card->number = csn; diff --git a/trunk/drivers/pnp/pnpacpi/core.c b/trunk/drivers/pnp/pnpacpi/core.c index 62eda5d59024..6cf34a63c790 100644 --- a/trunk/drivers/pnp/pnpacpi/core.c +++ b/trunk/drivers/pnp/pnpacpi/core.c @@ -139,7 +139,7 @@ static int __init pnpacpi_add_device(struct acpi_device *device) return 0; pnp_dbg("ACPI device : hid %s", acpi_device_hid(device)); - dev = kzalloc(sizeof(struct pnp_dev), GFP_KERNEL); + dev = kcalloc(1, sizeof(struct pnp_dev), GFP_KERNEL); if (!dev) { pnp_err("Out of memory"); return -ENOMEM; @@ -169,7 +169,7 @@ static int __init pnpacpi_add_device(struct acpi_device *device) dev->number = num; /* set the initial values for the PnP device */ - dev_id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL); + dev_id = kcalloc(1, sizeof(struct pnp_id), GFP_KERNEL); if (!dev_id) goto err; pnpidacpi_to_pnpid(acpi_device_hid(device), dev_id->id); @@ -201,7 +201,7 @@ static int __init pnpacpi_add_device(struct acpi_device *device) for (i = 0; i < cid_list->count; i++) { if (!ispnpidacpi(cid_list->id[i].value)) continue; - dev_id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL); + dev_id = kcalloc(1, sizeof(struct pnp_id), GFP_KERNEL); if (!dev_id) continue; diff --git a/trunk/drivers/pnp/pnpacpi/rsparser.c b/trunk/drivers/pnp/pnpacpi/rsparser.c index 7a535542fe92..379048fdf05d 100644 --- a/trunk/drivers/pnp/pnpacpi/rsparser.c +++ b/trunk/drivers/pnp/pnpacpi/rsparser.c @@ -298,7 +298,7 @@ static void pnpacpi_parse_dma_option(struct pnp_option *option, struct acpi_reso if (p->channel_count == 0) return; - dma = kzalloc(sizeof(struct pnp_dma), GFP_KERNEL); + dma = kcalloc(1, sizeof(struct pnp_dma), GFP_KERNEL); if (!dma) return; @@ -354,7 +354,7 @@ static void pnpacpi_parse_irq_option(struct pnp_option *option, if (p->interrupt_count == 0) return; - irq = kzalloc(sizeof(struct pnp_irq), GFP_KERNEL); + irq = kcalloc(1, sizeof(struct pnp_irq), GFP_KERNEL); if (!irq) return; @@ -375,7 +375,7 @@ static void pnpacpi_parse_ext_irq_option(struct pnp_option *option, if (p->interrupt_count == 0) return; - irq = kzalloc(sizeof(struct pnp_irq), GFP_KERNEL); + irq = kcalloc(1, sizeof(struct pnp_irq), GFP_KERNEL); if (!irq) return; @@ -396,7 +396,7 @@ pnpacpi_parse_port_option(struct pnp_option *option, if (io->address_length == 0) return; - port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL); + port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL); if (!port) return; port->min = io->minimum; @@ -417,7 +417,7 @@ pnpacpi_parse_fixed_port_option(struct pnp_option *option, if (io->address_length == 0) return; - port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL); + port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL); if (!port) return; port->min = port->max = io->address; @@ -436,7 +436,7 @@ pnpacpi_parse_mem24_option(struct pnp_option *option, if (p->address_length == 0) return; - mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); + mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); if (!mem) return; mem->min = p->minimum; @@ -459,7 +459,7 @@ pnpacpi_parse_mem32_option(struct pnp_option *option, if (p->address_length == 0) return; - mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); + mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); if (!mem) return; mem->min = p->minimum; @@ -482,7 +482,7 @@ pnpacpi_parse_fixed_mem32_option(struct pnp_option *option, if (p->address_length == 0) return; - mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); + mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); if (!mem) return; mem->min = mem->max = p->address; @@ -514,7 +514,7 @@ pnpacpi_parse_address_option(struct pnp_option *option, struct acpi_resource *r) return; if (p->resource_type == ACPI_MEMORY_RANGE) { - mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); + mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); if (!mem) return; mem->min = mem->max = p->minimum; @@ -524,7 +524,7 @@ pnpacpi_parse_address_option(struct pnp_option *option, struct acpi_resource *r) ACPI_READ_WRITE_MEMORY) ? IORESOURCE_MEM_WRITEABLE : 0; pnp_register_mem_resource(option, mem); } else if (p->resource_type == ACPI_IO_RANGE) { - port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL); + port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL); if (!port) return; port->min = port->max = p->minimum; @@ -721,7 +721,7 @@ int pnpacpi_build_resource_template(acpi_handle handle, if (!res_cnt) return -EINVAL; buffer->length = sizeof(struct acpi_resource) * (res_cnt + 1) + 1; - buffer->pointer = kzalloc(buffer->length - 1, GFP_KERNEL); + buffer->pointer = kcalloc(1, buffer->length - 1, GFP_KERNEL); if (!buffer->pointer) return -ENOMEM; pnp_dbg("Res cnt %d", res_cnt); diff --git a/trunk/drivers/pnp/pnpbios/core.c b/trunk/drivers/pnp/pnpbios/core.c index 95738dbd5d45..33adeba1a31f 100644 --- a/trunk/drivers/pnp/pnpbios/core.c +++ b/trunk/drivers/pnp/pnpbios/core.c @@ -109,10 +109,10 @@ static int pnp_dock_event(int dock, struct pnp_docking_station_info *info) if (!current->fs->root) { return -EAGAIN; } - if (!(envp = kcalloc(20, sizeof (char *), GFP_KERNEL))) { + if (!(envp = (char **) kcalloc (20, sizeof (char *), GFP_KERNEL))) { return -ENOMEM; } - if (!(buf = kzalloc(256, GFP_KERNEL))) { + if (!(buf = kcalloc (1, 256, GFP_KERNEL))) { kfree (envp); return -ENOMEM; } @@ -220,7 +220,7 @@ static int pnpbios_get_resources(struct pnp_dev * dev, struct pnp_resource_table if(!pnpbios_is_dynamic(dev)) return -EPERM; - node = kzalloc(node_info.max_node_size, GFP_KERNEL); + node = kcalloc(1, node_info.max_node_size, GFP_KERNEL); if (!node) return -1; 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 if (!pnpbios_is_dynamic(dev)) return -EPERM; - node = kzalloc(node_info.max_node_size, GFP_KERNEL); + node = kcalloc(1, node_info.max_node_size, GFP_KERNEL); if (!node) return -1; if (pnp_bios_get_dev_node(&nodenum, (char )PNPMODE_DYNAMIC, node)) { @@ -294,7 +294,7 @@ static int pnpbios_disable_resources(struct pnp_dev *dev) if(dev->flags & PNPBIOS_NO_DISABLE || !pnpbios_is_dynamic(dev)) return -EPERM; - node = kzalloc(node_info.max_node_size, GFP_KERNEL); + node = kcalloc(1, node_info.max_node_size, GFP_KERNEL); if (!node) return -ENOMEM; @@ -336,7 +336,7 @@ static int insert_device(struct pnp_dev *dev, struct pnp_bios_node * node) } /* set the initial values for the PnP device */ - dev_id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL); + dev_id = kcalloc(1, sizeof(struct pnp_id), GFP_KERNEL); if (!dev_id) return -1; pnpid32_to_pnpid(node->eisa_id,id); @@ -374,7 +374,7 @@ static void __init build_devlist(void) struct pnp_bios_node *node; struct pnp_dev *dev; - node = kzalloc(node_info.max_node_size, GFP_KERNEL); + node = kcalloc(1, node_info.max_node_size, GFP_KERNEL); if (!node) return; @@ -391,7 +391,7 @@ static void __init build_devlist(void) break; } nodes_got++; - dev = kzalloc(sizeof (struct pnp_dev), GFP_KERNEL); + dev = kcalloc(1, sizeof (struct pnp_dev), GFP_KERNEL); if (!dev) break; if(insert_device(dev,node)<0) diff --git a/trunk/drivers/pnp/pnpbios/proc.c b/trunk/drivers/pnp/pnpbios/proc.c index 8027073f7919..5a3dfc97f5e9 100644 --- a/trunk/drivers/pnp/pnpbios/proc.c +++ b/trunk/drivers/pnp/pnpbios/proc.c @@ -87,7 +87,7 @@ static int proc_read_escd(char *buf, char **start, off_t pos, return -EFBIG; } - tmpbuf = kzalloc(escd.escd_size, GFP_KERNEL); + tmpbuf = kcalloc(1, escd.escd_size, GFP_KERNEL); if (!tmpbuf) return -ENOMEM; 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, if (pos >= 0xff) return 0; - node = kzalloc(node_info.max_node_size, GFP_KERNEL); + node = kcalloc(1, node_info.max_node_size, GFP_KERNEL); if (!node) return -ENOMEM; for (nodenum=pos; nodenum<0xff; ) { @@ -168,7 +168,7 @@ static int proc_read_node(char *buf, char **start, off_t pos, u8 nodenum = (long)data; int len; - node = kzalloc(node_info.max_node_size, GFP_KERNEL); + node = kcalloc(1, node_info.max_node_size, GFP_KERNEL); if (!node) return -ENOMEM; if (pnp_bios_get_dev_node(&nodenum, boot, node)) { kfree(node); @@ -188,7 +188,7 @@ static int proc_write_node(struct file *file, const char __user *buf, u8 nodenum = (long)data; int ret = count; - node = kzalloc(node_info.max_node_size, GFP_KERNEL); + node = kcalloc(1, node_info.max_node_size, GFP_KERNEL); if (!node) return -ENOMEM; if (pnp_bios_get_dev_node(&nodenum, boot, node)) { diff --git a/trunk/drivers/pnp/pnpbios/rsparser.c b/trunk/drivers/pnp/pnpbios/rsparser.c index 95b79685a9d1..ef508a4de557 100644 --- a/trunk/drivers/pnp/pnpbios/rsparser.c +++ b/trunk/drivers/pnp/pnpbios/rsparser.c @@ -248,7 +248,7 @@ static void pnpbios_parse_mem_option(unsigned char *p, int size, struct pnp_option *option) { struct pnp_mem * mem; - mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); + mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); if (!mem) return; mem->min = ((p[5] << 8) | p[4]) << 8; @@ -264,7 +264,7 @@ static void pnpbios_parse_mem32_option(unsigned char *p, int size, struct pnp_option *option) { struct pnp_mem * mem; - mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); + mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); if (!mem) return; mem->min = (p[7] << 24) | (p[6] << 16) | (p[5] << 8) | p[4]; @@ -280,7 +280,7 @@ static void pnpbios_parse_fixed_mem32_option(unsigned char *p, int size, struct pnp_option *option) { struct pnp_mem * mem; - mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); + mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL); if (!mem) return; 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) struct pnp_irq * irq; unsigned long bits; - irq = kzalloc(sizeof(struct pnp_irq), GFP_KERNEL); + irq = kcalloc(1, sizeof(struct pnp_irq), GFP_KERNEL); if (!irq) return; bits = (p[2] << 8) | p[1]; @@ -314,7 +314,7 @@ static void pnpbios_parse_dma_option(unsigned char *p, int size, struct pnp_option *option) { struct pnp_dma * dma; - dma = kzalloc(sizeof(struct pnp_dma), GFP_KERNEL); + dma = kcalloc(1, sizeof(struct pnp_dma), GFP_KERNEL); if (!dma) return; dma->map = p[1]; @@ -327,7 +327,7 @@ static void pnpbios_parse_port_option(unsigned char *p, int size, struct pnp_option *option) { struct pnp_port * port; - port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL); + port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL); if (!port) return; port->min = (p[3] << 8) | p[2]; @@ -343,7 +343,7 @@ static void pnpbios_parse_fixed_port_option(unsigned char *p, int size, struct pnp_option *option) { struct pnp_port * port; - port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL); + port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL); if (!port) return; 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 case SMALL_TAG_COMPATDEVID: /* compatible ID */ if (len != 4) goto len_err; - dev_id = kzalloc(sizeof (struct pnp_id), GFP_KERNEL); + dev_id = kcalloc(1, sizeof (struct pnp_id), GFP_KERNEL); if (!dev_id) return NULL; memset(dev_id, 0, sizeof(struct pnp_id)); diff --git a/trunk/drivers/rtc/rtc-at91rm9200.c b/trunk/drivers/rtc/rtc-at91rm9200.c index 4f654c901c64..5c8addcaf1fb 100644 --- a/trunk/drivers/rtc/rtc-at91rm9200.c +++ b/trunk/drivers/rtc/rtc-at91rm9200.c @@ -137,9 +137,6 @@ static int at91_rtc_readalarm(struct device *dev, struct rtc_wkalrm *alrm) tm->tm_yday = rtc_year_days(tm->tm_mday, tm->tm_mon, tm->tm_year); tm->tm_year = at91_alarm_year - 1900; - alrm->enabled = (at91_sys_read(AT91_RTC_IMR) & AT91_RTC_ALARM) - ? 1 : 0; - pr_debug("%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __FUNCTION__, 1900 + tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); @@ -226,6 +223,8 @@ static int at91_rtc_proc(struct device *dev, struct seq_file *seq) { unsigned long imr = at91_sys_read(AT91_RTC_IMR); + seq_printf(seq, "alarm_IRQ\t: %s\n", + (imr & AT91_RTC_ALARM) ? "yes" : "no"); seq_printf(seq, "update_IRQ\t: %s\n", (imr & AT91_RTC_ACKUPD) ? "yes" : "no"); seq_printf(seq, "periodic_IRQ\t: %s\n", diff --git a/trunk/drivers/rtc/rtc-dev.c b/trunk/drivers/rtc/rtc-dev.c index 94d3df62a5fa..828b329e08e0 100644 --- a/trunk/drivers/rtc/rtc-dev.c +++ b/trunk/drivers/rtc/rtc-dev.c @@ -435,7 +435,7 @@ static int rtc_dev_add_device(struct class_device *class_dev, goto err_cdev_del; } - dev_dbg(class_dev->dev, "rtc intf: dev (%d:%d)\n", + dev_info(class_dev->dev, "rtc intf: dev (%d:%d)\n", MAJOR(rtc->rtc_dev->devt), MINOR(rtc->rtc_dev->devt)); diff --git a/trunk/drivers/rtc/rtc-omap.c b/trunk/drivers/rtc/rtc-omap.c index d59880d44fba..eac5fb1fc02f 100644 --- a/trunk/drivers/rtc/rtc-omap.c +++ b/trunk/drivers/rtc/rtc-omap.c @@ -279,8 +279,9 @@ static int omap_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm) local_irq_enable(); bcd2tm(&alm->time); - alm->enabled = !!(rtc_read(OMAP_RTC_INTERRUPTS_REG) + alm->pending = !!(rtc_read(OMAP_RTC_INTERRUPTS_REG) & OMAP_RTC_INTERRUPTS_IT_ALARM); + alm->enabled = alm->pending && device_may_wakeup(dev); return 0; } diff --git a/trunk/drivers/rtc/rtc-proc.c b/trunk/drivers/rtc/rtc-proc.c index c272afd62173..d51d8f20e634 100644 --- a/trunk/drivers/rtc/rtc-proc.c +++ b/trunk/drivers/rtc/rtc-proc.c @@ -65,7 +65,7 @@ static int rtc_proc_show(struct seq_file *seq, void *offset) seq_printf(seq, "%02d\n", alrm.time.tm_mday); else seq_printf(seq, "**\n"); - seq_printf(seq, "alarm_IRQ\t: %s\n", + seq_printf(seq, "alrm_wakeup\t: %s\n", alrm.enabled ? "yes" : "no"); seq_printf(seq, "alrm_pending\t: %s\n", alrm.pending ? "yes" : "no"); @@ -120,7 +120,7 @@ static int rtc_proc_add_device(struct class_device *class_dev, ent->owner = rtc->owner; ent->data = class_dev; - dev_dbg(class_dev->dev, "rtc intf: proc\n"); + dev_info(class_dev->dev, "rtc intf: proc\n"); } else rtc_dev = NULL; diff --git a/trunk/drivers/rtc/rtc-s3c.c b/trunk/drivers/rtc/rtc-s3c.c index f406a2b55aea..e301dea57bb3 100644 --- a/trunk/drivers/rtc/rtc-s3c.c +++ b/trunk/drivers/rtc/rtc-s3c.c @@ -191,8 +191,6 @@ static int s3c_rtc_getalarm(struct device *dev, struct rtc_wkalrm *alrm) alm_en = readb(base + S3C2410_RTCALM); - alrm->enabled = (alm_en & S3C2410_RTCALM_ALMEN) ? 1 : 0; - pr_debug("read alarm %02x %02x.%02x.%02x %02x/%02x/%02x\n", alm_en, alm_tm->tm_year, alm_tm->tm_mon, alm_tm->tm_mday, @@ -333,8 +331,12 @@ static int s3c_rtc_ioctl(struct device *dev, static int s3c_rtc_proc(struct device *dev, struct seq_file *seq) { + unsigned int rtcalm = readb(s3c_rtc_base + S3C2410_RTCALM); unsigned int ticnt = readb(s3c_rtc_base + S3C2410_TICNT); + seq_printf(seq, "alarm_IRQ\t: %s\n", + (rtcalm & S3C2410_RTCALM_ALMEN) ? "yes" : "no" ); + seq_printf(seq, "periodic_IRQ\t: %s\n", (ticnt & S3C2410_TICNT_ENABLE) ? "yes" : "no" ); diff --git a/trunk/drivers/rtc/rtc-sa1100.c b/trunk/drivers/rtc/rtc-sa1100.c index 9c8ead43a59c..bd4d7d174ef4 100644 --- a/trunk/drivers/rtc/rtc-sa1100.c +++ b/trunk/drivers/rtc/rtc-sa1100.c @@ -289,7 +289,9 @@ static int sa1100_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) static int sa1100_rtc_proc(struct device *dev, struct seq_file *seq) { - seq_printf(seq, "trim/divider\t: 0x%08x\n", (u32) RTTR); + seq_printf(seq, "trim/divider\t: 0x%08lx\n", RTTR); + seq_printf(seq, "alarm_IRQ\t: %s\n", + (RTSR & RTSR_ALE) ? "yes" : "no" ); seq_printf(seq, "update_IRQ\t: %s\n", (RTSR & RTSR_HZE) ? "yes" : "no"); seq_printf(seq, "periodic_IRQ\t: %s\n", diff --git a/trunk/drivers/rtc/rtc-sysfs.c b/trunk/drivers/rtc/rtc-sysfs.c index 9418a59fb368..625637b84d33 100644 --- a/trunk/drivers/rtc/rtc-sysfs.c +++ b/trunk/drivers/rtc/rtc-sysfs.c @@ -83,7 +83,7 @@ static int __devinit rtc_sysfs_add_device(struct class_device *class_dev, { int err; - dev_dbg(class_dev->dev, "rtc intf: sysfs\n"); + dev_info(class_dev->dev, "rtc intf: sysfs\n"); err = sysfs_create_group(&class_dev->kobj, &rtc_attr_group); if (err) diff --git a/trunk/drivers/s390/char/con3215.c b/trunk/drivers/s390/char/con3215.c index 25b5d7a66417..c9321b920e90 100644 --- a/trunk/drivers/s390/char/con3215.c +++ b/trunk/drivers/s390/char/con3215.c @@ -688,7 +688,7 @@ raw3215_probe (struct ccw_device *cdev) raw->cdev = cdev; raw->inbuf = (char *) raw + sizeof(struct raw3215_info); memset(raw, 0, sizeof(struct raw3215_info)); - raw->buffer = kmalloc(RAW3215_BUFFER_SIZE, + raw->buffer = (char *) kmalloc(RAW3215_BUFFER_SIZE, GFP_KERNEL|GFP_DMA); if (raw->buffer == NULL) { spin_lock(&raw3215_device_lock); diff --git a/trunk/drivers/s390/char/keyboard.c b/trunk/drivers/s390/char/keyboard.c index 3e86fd1756e5..e3491a5f5219 100644 --- a/trunk/drivers/s390/char/keyboard.c +++ b/trunk/drivers/s390/char/keyboard.c @@ -377,7 +377,7 @@ do_kdsk_ioctl(struct kbd_data *kbd, struct kbentry __user *user_kbe, if (!(key_map = kbd->key_maps[tmp.kb_table])) { int j; - key_map = kmalloc(sizeof(plain_map), + key_map = (ushort *) kmalloc(sizeof(plain_map), GFP_KERNEL); if (!key_map) return -ENOMEM; diff --git a/trunk/drivers/s390/char/sclp_cpi.c b/trunk/drivers/s390/char/sclp_cpi.c index f7c10d954ec6..732dfbdb85c4 100644 --- a/trunk/drivers/s390/char/sclp_cpi.c +++ b/trunk/drivers/s390/char/sclp_cpi.c @@ -127,7 +127,7 @@ cpi_prepare_req(void) struct cpi_sccb *sccb; struct cpi_evbuf *evb; - req = kmalloc(sizeof(struct sclp_req), GFP_KERNEL); + req = (struct sclp_req *) kmalloc(sizeof(struct sclp_req), GFP_KERNEL); if (req == NULL) return ERR_PTR(-ENOMEM); sccb = (struct cpi_sccb *) __get_free_page(GFP_KERNEL | GFP_DMA); diff --git a/trunk/drivers/s390/crypto/zcrypt_cex2a.c b/trunk/drivers/s390/crypto/zcrypt_cex2a.c index 5bb13a9d0898..a62b00083d0c 100644 --- a/trunk/drivers/s390/crypto/zcrypt_cex2a.c +++ b/trunk/drivers/s390/crypto/zcrypt_cex2a.c @@ -295,7 +295,7 @@ static long zcrypt_cex2a_modexpo(struct zcrypt_device *zdev, struct completion work; int rc; - ap_msg.message = kmalloc(CEX2A_MAX_MESSAGE_SIZE, GFP_KERNEL); + ap_msg.message = (void *) kmalloc(CEX2A_MAX_MESSAGE_SIZE, GFP_KERNEL); if (!ap_msg.message) return -ENOMEM; ap_msg.psmid = (((unsigned long long) current->pid) << 32) + @@ -337,7 +337,7 @@ static long zcrypt_cex2a_modexpo_crt(struct zcrypt_device *zdev, struct completion work; int rc; - ap_msg.message = kmalloc(CEX2A_MAX_MESSAGE_SIZE, GFP_KERNEL); + ap_msg.message = (void *) kmalloc(CEX2A_MAX_MESSAGE_SIZE, GFP_KERNEL); if (!ap_msg.message) return -ENOMEM; ap_msg.psmid = (((unsigned long long) current->pid) << 32) + diff --git a/trunk/drivers/s390/crypto/zcrypt_pcica.c b/trunk/drivers/s390/crypto/zcrypt_pcica.c index 32e37014345c..b6a4ecdc8025 100644 --- a/trunk/drivers/s390/crypto/zcrypt_pcica.c +++ b/trunk/drivers/s390/crypto/zcrypt_pcica.c @@ -279,7 +279,7 @@ static long zcrypt_pcica_modexpo(struct zcrypt_device *zdev, struct completion work; int rc; - ap_msg.message = kmalloc(PCICA_MAX_MESSAGE_SIZE, GFP_KERNEL); + ap_msg.message = (void *) kmalloc(PCICA_MAX_MESSAGE_SIZE, GFP_KERNEL); if (!ap_msg.message) return -ENOMEM; ap_msg.psmid = (((unsigned long long) current->pid) << 32) + @@ -321,7 +321,7 @@ static long zcrypt_pcica_modexpo_crt(struct zcrypt_device *zdev, struct completion work; int rc; - ap_msg.message = kmalloc(PCICA_MAX_MESSAGE_SIZE, GFP_KERNEL); + ap_msg.message = (void *) kmalloc(PCICA_MAX_MESSAGE_SIZE, GFP_KERNEL); if (!ap_msg.message) return -ENOMEM; ap_msg.psmid = (((unsigned long long) current->pid) << 32) + diff --git a/trunk/drivers/s390/crypto/zcrypt_pcixcc.c b/trunk/drivers/s390/crypto/zcrypt_pcixcc.c index b7153c1e15cd..2da8b9381407 100644 --- a/trunk/drivers/s390/crypto/zcrypt_pcixcc.c +++ b/trunk/drivers/s390/crypto/zcrypt_pcixcc.c @@ -717,7 +717,7 @@ long zcrypt_pcixcc_send_cprb(struct zcrypt_device *zdev, struct ica_xcRB *xcRB) }; int rc; - ap_msg.message = kmalloc(PCIXCC_MAX_XCRB_MESSAGE_SIZE, GFP_KERNEL); + ap_msg.message = (void *) kmalloc(PCIXCC_MAX_XCRB_MESSAGE_SIZE, GFP_KERNEL); if (!ap_msg.message) return -ENOMEM; ap_msg.psmid = (((unsigned long long) current->pid) << 32) + diff --git a/trunk/drivers/s390/net/ctcmain.c b/trunk/drivers/s390/net/ctcmain.c index 03cc263fe0da..3257c22dd79c 100644 --- a/trunk/drivers/s390/net/ctcmain.c +++ b/trunk/drivers/s390/net/ctcmain.c @@ -1646,7 +1646,7 @@ add_channel(struct ccw_device *cdev, enum channel_types type) return -1; } memset(ch, 0, sizeof (struct channel)); - if ((ch->ccw = kmalloc(8*sizeof(struct ccw1), + if ((ch->ccw = (struct ccw1 *) kmalloc(8*sizeof(struct ccw1), GFP_KERNEL | GFP_DMA)) == NULL) { kfree(ch); 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) return -1; } fsm_newstate(ch->fsm, CH_STATE_IDLE); - if ((ch->irb = kmalloc(sizeof (struct irb), + if ((ch->irb = (struct irb *) kmalloc(sizeof (struct irb), GFP_KERNEL)) == NULL) { ctc_pr_warn("ctc: Out of memory in add_channel\n"); kfree_fsm(ch->fsm); @@ -2535,7 +2535,7 @@ ctc_print_statistics(struct ctc_priv *priv) DBF_TEXT(trace, 4, __FUNCTION__); if (!priv) return; - sbuf = kmalloc(2048, GFP_KERNEL); + sbuf = (char *)kmalloc(2048, GFP_KERNEL); if (sbuf == NULL) return; p = sbuf; diff --git a/trunk/drivers/s390/net/iucv.c b/trunk/drivers/s390/net/iucv.c index 229aeb5fc399..1476ce2b437c 100644 --- a/trunk/drivers/s390/net/iucv.c +++ b/trunk/drivers/s390/net/iucv.c @@ -772,7 +772,7 @@ iucv_register_program (__u8 pgmname[16], } /* Allocate handler entry */ - new_handler = kmalloc(sizeof(handler), GFP_ATOMIC); + new_handler = (handler *)kmalloc(sizeof(handler), GFP_ATOMIC); if (new_handler == NULL) { printk(KERN_WARNING "%s: storage allocation for new handler " "failed.\n", __FUNCTION__); diff --git a/trunk/drivers/s390/scsi/zfcp_aux.c b/trunk/drivers/s390/scsi/zfcp_aux.c index 85093b71f9fa..5d39b2df0cc4 100644 --- a/trunk/drivers/s390/scsi/zfcp_aux.c +++ b/trunk/drivers/s390/scsi/zfcp_aux.c @@ -237,7 +237,7 @@ zfcp_device_setup(char *devstr) return 0; len = strlen(devstr) + 1; - str = kmalloc(len, GFP_KERNEL); + str = (char *) kmalloc(len, GFP_KERNEL); if (!str) goto err_out; memcpy(str, devstr, len); diff --git a/trunk/drivers/sbus/char/vfc_dev.c b/trunk/drivers/sbus/char/vfc_dev.c index 386e7de0b7e3..2722af5d3404 100644 --- a/trunk/drivers/sbus/char/vfc_dev.c +++ b/trunk/drivers/sbus/char/vfc_dev.c @@ -659,7 +659,7 @@ static int vfc_probe(void) if (!cards) return -ENODEV; - vfc_dev_lst = kmalloc(sizeof(struct vfc_dev *) * + vfc_dev_lst = (struct vfc_dev **)kmalloc(sizeof(struct vfc_dev *) * (cards+1), GFP_KERNEL); if (vfc_dev_lst == NULL) diff --git a/trunk/drivers/scsi/aacraid/aachba.c b/trunk/drivers/scsi/aacraid/aachba.c index 426cd6f49f5d..ac108f9e2674 100644 --- a/trunk/drivers/scsi/aacraid/aachba.c +++ b/trunk/drivers/scsi/aacraid/aachba.c @@ -288,7 +288,7 @@ int aac_get_containers(struct aac_dev *dev) if (maximum_num_containers < MAXIMUM_NUM_CONTAINERS) maximum_num_containers = MAXIMUM_NUM_CONTAINERS; - fsa_dev_ptr = kmalloc( + fsa_dev_ptr = (struct fsa_dev_info *) kmalloc( sizeof(*fsa_dev_ptr) * maximum_num_containers, GFP_KERNEL); if (!fsa_dev_ptr) { aac_fib_free(fibptr); diff --git a/trunk/drivers/scsi/aacraid/comminit.c b/trunk/drivers/scsi/aacraid/comminit.c index 6d305b2f854e..d5cf8b91a0e7 100644 --- a/trunk/drivers/scsi/aacraid/comminit.c +++ b/trunk/drivers/scsi/aacraid/comminit.c @@ -386,7 +386,7 @@ struct aac_dev *aac_init_adapter(struct aac_dev *dev) * Ok now init the communication subsystem */ - dev->queues = kmalloc(sizeof(struct aac_queue_block), GFP_KERNEL); + dev->queues = (struct aac_queue_block *) kmalloc(sizeof(struct aac_queue_block), GFP_KERNEL); if (dev->queues == NULL) { printk(KERN_ERR "Error could not allocate comm region.\n"); return NULL; diff --git a/trunk/drivers/scsi/aha1542.c b/trunk/drivers/scsi/aha1542.c index 1d239f6c0103..d7a61a6bdaae 100644 --- a/trunk/drivers/scsi/aha1542.c +++ b/trunk/drivers/scsi/aha1542.c @@ -699,7 +699,7 @@ static int aha1542_queuecommand(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *)) #endif int i; ccb[mbo].op = 2; /* SCSI Initiator Command w/scatter-gather */ - SCpnt->host_scribble = kmalloc(512, GFP_KERNEL | GFP_DMA); + SCpnt->host_scribble = (unsigned char *) kmalloc(512, GFP_KERNEL | GFP_DMA); sgpnt = (struct scatterlist *) SCpnt->request_buffer; cptr = (struct chain *) SCpnt->host_scribble; if (cptr == NULL) { diff --git a/trunk/drivers/scsi/aic7xxx_old.c b/trunk/drivers/scsi/aic7xxx_old.c index 7d1fec620948..46eed10b25d9 100644 --- a/trunk/drivers/scsi/aic7xxx_old.c +++ b/trunk/drivers/scsi/aic7xxx_old.c @@ -2565,7 +2565,7 @@ aic7xxx_allocate_scb(struct aic7xxx_host *p) } } scb_count = min( (i-1), p->scb_data->maxscbs - p->scb_data->numscbs); - scb_ap = kmalloc(sizeof (struct aic7xxx_scb) * scb_count + scb_ap = (struct aic7xxx_scb *)kmalloc(sizeof (struct aic7xxx_scb) * scb_count + sizeof(struct aic7xxx_scb_dma), GFP_ATOMIC); if (scb_ap == NULL) return(0); diff --git a/trunk/drivers/scsi/dc395x.c b/trunk/drivers/scsi/dc395x.c index a965ed3548d5..e95b367d09ed 100644 --- a/trunk/drivers/scsi/dc395x.c +++ b/trunk/drivers/scsi/dc395x.c @@ -4319,7 +4319,7 @@ static int __devinit adapter_sg_tables_alloc(struct AdapterCtlBlk *acb) dprintkdbg(DBG_1, "Allocate %i pages for SG tables\n", pages); while (pages--) { - ptr = kmalloc(PAGE_SIZE, GFP_KERNEL); + ptr = (struct SGentry *)kmalloc(PAGE_SIZE, GFP_KERNEL); if (!ptr) { adapter_sg_tables_free(acb); return 1; diff --git a/trunk/drivers/scsi/dpt_i2o.c b/trunk/drivers/scsi/dpt_i2o.c index 365db537a28d..60b1b434eba7 100644 --- a/trunk/drivers/scsi/dpt_i2o.c +++ b/trunk/drivers/scsi/dpt_i2o.c @@ -297,7 +297,7 @@ static void adpt_inquiry(adpt_hba* pHba) s32 rcode; memset(msg, 0, sizeof(msg)); - buf = kmalloc(80,GFP_KERNEL|ADDR32); + buf = (u8*)kmalloc(80,GFP_KERNEL|ADDR32); if(!buf){ printk(KERN_ERR"%s: Could not allocate buffer\n",pHba->name); return; @@ -1311,7 +1311,7 @@ static s32 adpt_i2o_reset_hba(adpt_hba* pHba) schedule_timeout_uninterruptible(1); } while (m == EMPTY_QUEUE); - status = kmalloc(4, GFP_KERNEL|ADDR32); + status = (u8*)kmalloc(4, GFP_KERNEL|ADDR32); if(status == NULL) { adpt_send_nop(pHba, m); printk(KERN_ERR"IOP reset failed - no free memory.\n"); @@ -1444,7 +1444,7 @@ static int adpt_i2o_parse_lct(adpt_hba* pHba) } continue; } - d = kmalloc(sizeof(struct i2o_device), GFP_KERNEL); + d = (struct i2o_device *)kmalloc(sizeof(struct i2o_device), GFP_KERNEL); if(d==NULL) { 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) pDev = pDev->next_lun; } if(!pDev ) { // Something new add it - d = kmalloc(sizeof(struct i2o_device), GFP_KERNEL); + d = (struct i2o_device *)kmalloc(sizeof(struct i2o_device), GFP_KERNEL); if(d==NULL) { 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) kfree(pHba->reply_pool); - pHba->reply_pool = kmalloc(pHba->reply_fifo_size * REPLY_FRAME_SIZE * 4, GFP_KERNEL|ADDR32); + pHba->reply_pool = (u32*)kmalloc(pHba->reply_fifo_size * REPLY_FRAME_SIZE * 4, GFP_KERNEL|ADDR32); if(!pHba->reply_pool){ printk(KERN_ERR"%s: Could not allocate reply pool\n",pHba->name); return -1; diff --git a/trunk/drivers/scsi/initio.c b/trunk/drivers/scsi/initio.c index d561663fb4e4..f160357e37a6 100644 --- a/trunk/drivers/scsi/initio.c +++ b/trunk/drivers/scsi/initio.c @@ -2828,7 +2828,7 @@ static int i91u_detect(struct scsi_host_template * tpnt) for (; tul_num_scb >= MAX_TARGETS + 3; tul_num_scb--) { i = tul_num_ch * tul_num_scb * sizeof(SCB); - if ((tul_scb = kmalloc(i, GFP_ATOMIC | GFP_DMA)) != NULL) + if ((tul_scb = (SCB *) kmalloc(i, GFP_ATOMIC | GFP_DMA)) != NULL) break; } if (tul_scb == NULL) { diff --git a/trunk/drivers/scsi/osst.c b/trunk/drivers/scsi/osst.c index 7d2311067903..824fe080d1dc 100644 --- a/trunk/drivers/scsi/osst.c +++ b/trunk/drivers/scsi/osst.c @@ -5777,7 +5777,7 @@ static int osst_probe(struct device *dev) dev_num = i; /* allocate a struct osst_tape for this device */ - tpnt = kmalloc(sizeof(struct osst_tape), GFP_ATOMIC); + tpnt = (struct osst_tape *)kmalloc(sizeof(struct osst_tape), GFP_ATOMIC); if (tpnt == NULL) { write_unlock(&os_scsi_tapes_lock); printk(KERN_ERR "osst :E: Can't allocate device descriptor, device not attached.\n"); diff --git a/trunk/drivers/scsi/pluto.c b/trunk/drivers/scsi/pluto.c index 3b2e1a53e6e2..aa60a5f1fbc3 100644 --- a/trunk/drivers/scsi/pluto.c +++ b/trunk/drivers/scsi/pluto.c @@ -117,7 +117,7 @@ int __init pluto_detect(struct scsi_host_template *tpnt) #endif return 0; } - fcs = kmalloc(sizeof (struct ctrl_inquiry) * fcscount, GFP_DMA); + fcs = (struct ctrl_inquiry *) kmalloc (sizeof (struct ctrl_inquiry) * fcscount, GFP_DMA); if (!fcs) { printk ("PLUTO: Not enough memory to probe\n"); return 0; diff --git a/trunk/drivers/scsi/sr_ioctl.c b/trunk/drivers/scsi/sr_ioctl.c index 0578ba42718b..d1268cb46837 100644 --- a/trunk/drivers/scsi/sr_ioctl.c +++ b/trunk/drivers/scsi/sr_ioctl.c @@ -546,7 +546,7 @@ int sr_is_xa(Scsi_CD *cd) if (!xa_test) return 0; - raw_sector = kmalloc(2048, GFP_KERNEL | SR_GFP_DMA(cd)); + raw_sector = (unsigned char *) kmalloc(2048, GFP_KERNEL | SR_GFP_DMA(cd)); if (!raw_sector) return -ENOMEM; if (0 == sr_read_sector(cd, cd->ms_offset + 16, diff --git a/trunk/drivers/scsi/sr_vendor.c b/trunk/drivers/scsi/sr_vendor.c index 4eb3da996b36..a3e9d0f2eb5b 100644 --- a/trunk/drivers/scsi/sr_vendor.c +++ b/trunk/drivers/scsi/sr_vendor.c @@ -117,7 +117,7 @@ int sr_set_blocklength(Scsi_CD *cd, int blocklength) density = (blocklength > 2048) ? 0x81 : 0x83; #endif - buffer = kmalloc(512, GFP_KERNEL | GFP_DMA); + buffer = (unsigned char *) kmalloc(512, GFP_KERNEL | GFP_DMA); if (!buffer) return -ENOMEM; @@ -164,7 +164,7 @@ int sr_cd_check(struct cdrom_device_info *cdi) if (cd->cdi.mask & CDC_MULTI_SESSION) return 0; - buffer = kmalloc(512, GFP_KERNEL | GFP_DMA); + buffer = (unsigned char *) kmalloc(512, GFP_KERNEL | GFP_DMA); if (!buffer) return -ENOMEM; diff --git a/trunk/drivers/scsi/sym53c8xx_2/sym_hipd.c b/trunk/drivers/scsi/sym53c8xx_2/sym_hipd.c index 21cd4c7f5289..940fa1e6f994 100644 --- a/trunk/drivers/scsi/sym53c8xx_2/sym_hipd.c +++ b/trunk/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 /* * Allocate the array of lists of CCBs hashed by DSA. */ - np->ccbh = kcalloc(CCB_HASH_SIZE, sizeof(struct sym_ccb **), GFP_KERNEL); + np->ccbh = kcalloc(sizeof(struct sym_ccb **), CCB_HASH_SIZE, GFP_KERNEL); if (!np->ccbh) goto attach_failed; diff --git a/trunk/drivers/usb/gadget/at91_udc.c b/trunk/drivers/usb/gadget/at91_udc.c index 3e0abbb49fe1..72f3db99ff94 100644 --- a/trunk/drivers/usb/gadget/at91_udc.c +++ b/trunk/drivers/usb/gadget/at91_udc.c @@ -598,7 +598,7 @@ at91_ep_alloc_request(struct usb_ep *_ep, unsigned int gfp_flags) { struct at91_request *req; - req = kzalloc(sizeof (struct at91_request), gfp_flags); + req = kcalloc(1, sizeof (struct at91_request), gfp_flags); if (!req) return NULL; diff --git a/trunk/drivers/usb/gadget/serial.c b/trunk/drivers/usb/gadget/serial.c index 2d12bf9f19d6..5516c59ed5ec 100644 --- a/trunk/drivers/usb/gadget/serial.c +++ b/trunk/drivers/usb/gadget/serial.c @@ -2195,7 +2195,7 @@ static struct gs_buf *gs_buf_alloc(unsigned int size, gfp_t kmalloc_flags) if (size == 0) return NULL; - gb = kmalloc(sizeof(struct gs_buf), kmalloc_flags); + gb = (struct gs_buf *)kmalloc(sizeof(struct gs_buf), kmalloc_flags); if (gb == NULL) return NULL; diff --git a/trunk/drivers/usb/host/hc_crisv10.c b/trunk/drivers/usb/host/hc_crisv10.c index 282d82efc0b0..9325e46a68c0 100644 --- a/trunk/drivers/usb/host/hc_crisv10.c +++ b/trunk/drivers/usb/host/hc_crisv10.c @@ -365,7 +365,7 @@ static inline struct urb *urb_list_first(int epid) /* Adds an urb_entry last in the list for this epid. */ static inline void urb_list_add(struct urb *urb, int epid) { - urb_entry_t *urb_entry = kmalloc(sizeof(urb_entry_t), KMALLOC_FLAG); + urb_entry_t *urb_entry = (urb_entry_t *)kmalloc(sizeof(urb_entry_t), KMALLOC_FLAG); assert(urb_entry); urb_entry->urb = urb; diff --git a/trunk/drivers/usb/misc/auerswald.c b/trunk/drivers/usb/misc/auerswald.c index 6c7f3efb1d40..c703f73e1655 100644 --- a/trunk/drivers/usb/misc/auerswald.c +++ b/trunk/drivers/usb/misc/auerswald.c @@ -766,7 +766,7 @@ static int auerbuf_setup (pauerbufctl_t bcp, unsigned int numElements, unsigned bep->bufp = kmalloc (bufsize, GFP_KERNEL); if (!bep->bufp) goto bl_fail; - bep->dr = kmalloc(sizeof (struct usb_ctrlrequest), GFP_KERNEL); + bep->dr = (struct usb_ctrlrequest *) kmalloc (sizeof (struct usb_ctrlrequest), GFP_KERNEL); if (!bep->dr) goto bl_fail; bep->urbp = usb_alloc_urb (0, GFP_KERNEL); @@ -1969,7 +1969,7 @@ static int auerswald_probe (struct usb_interface *intf, info("device is a %s", cp->dev_desc); /* get the maximum allowed control transfer length */ - pbuf = kmalloc(2, GFP_KERNEL); /* use an allocated buffer because of urb target */ + pbuf = (__le16 *) kmalloc (2, GFP_KERNEL); /* use an allocated buffer because of urb target */ if (!pbuf) { err( "out of memory"); goto pfail; diff --git a/trunk/drivers/usb/misc/uss720.c b/trunk/drivers/usb/misc/uss720.c index 70250252ae2a..7e8a0acd52ee 100644 --- a/trunk/drivers/usb/misc/uss720.c +++ b/trunk/drivers/usb/misc/uss720.c @@ -705,7 +705,7 @@ static int uss720_probe(struct usb_interface *intf, /* * Allocate parport interface */ - if (!(priv = kzalloc(sizeof(struct parport_uss720_private), GFP_KERNEL))) { + if (!(priv = kcalloc(sizeof(struct parport_uss720_private), 1, GFP_KERNEL))) { usb_put_dev(usbdev); return -ENOMEM; } diff --git a/trunk/drivers/usb/net/rndis_host.c b/trunk/drivers/usb/net/rndis_host.c index ea5f44de3de2..99f26b3e502f 100644 --- a/trunk/drivers/usb/net/rndis_host.c +++ b/trunk/drivers/usb/net/rndis_host.c @@ -469,7 +469,7 @@ static void rndis_unbind(struct usbnet *dev, struct usb_interface *intf) struct rndis_halt *halt; /* try to clear any rndis state/activity (no i/o from stack!) */ - halt = kzalloc(sizeof *halt, GFP_KERNEL); + halt = kcalloc(1, sizeof *halt, GFP_KERNEL); if (halt) { halt->msg_type = RNDIS_MSG_HALT; halt->msg_len = ccpu2(sizeof *halt); diff --git a/trunk/drivers/usb/serial/cypress_m8.c b/trunk/drivers/usb/serial/cypress_m8.c index 45cdf9bc43b2..a1fdb85b8c0a 100644 --- a/trunk/drivers/usb/serial/cypress_m8.c +++ b/trunk/drivers/usb/serial/cypress_m8.c @@ -1493,7 +1493,7 @@ static struct cypress_buf *cypress_buf_alloc(unsigned int size) if (size == 0) return NULL; - cb = kmalloc(sizeof(struct cypress_buf), GFP_KERNEL); + cb = (struct cypress_buf *)kmalloc(sizeof(struct cypress_buf), GFP_KERNEL); if (cb == NULL) return NULL; diff --git a/trunk/drivers/usb/serial/digi_acceleport.c b/trunk/drivers/usb/serial/digi_acceleport.c index efd9ce3f931f..9d9ea874639c 100644 --- a/trunk/drivers/usb/serial/digi_acceleport.c +++ b/trunk/drivers/usb/serial/digi_acceleport.c @@ -1681,7 +1681,7 @@ dbg( "digi_startup: TOP" ); for( i=0; itype->num_ports+1; i++ ) { /* allocate port private structure */ - priv = kmalloc( sizeof(struct digi_port), + priv = (struct digi_port *)kmalloc( sizeof(struct digi_port), GFP_KERNEL ); if( priv == (struct digi_port *)0 ) { while( --i >= 0 ) @@ -1714,7 +1714,7 @@ dbg( "digi_startup: TOP" ); } /* allocate serial private structure */ - serial_priv = kmalloc( sizeof(struct digi_serial), + serial_priv = (struct digi_serial *)kmalloc( sizeof(struct digi_serial), GFP_KERNEL ); if( serial_priv == (struct digi_serial *)0 ) { for( i=0; itype->num_ports+1; i++ ) diff --git a/trunk/drivers/usb/serial/io_ti.c b/trunk/drivers/usb/serial/io_ti.c index 980285c0233a..2da2684e0809 100644 --- a/trunk/drivers/usb/serial/io_ti.c +++ b/trunk/drivers/usb/serial/io_ti.c @@ -2811,7 +2811,7 @@ static struct edge_buf *edge_buf_alloc(unsigned int size) if (size == 0) return NULL; - eb = kmalloc(sizeof(struct edge_buf), GFP_KERNEL); + eb = (struct edge_buf *)kmalloc(sizeof(struct edge_buf), GFP_KERNEL); if (eb == NULL) return NULL; diff --git a/trunk/drivers/usb/serial/ipaq.c b/trunk/drivers/usb/serial/ipaq.c index 42f757a5b876..d72cf8bc7f76 100644 --- a/trunk/drivers/usb/serial/ipaq.c +++ b/trunk/drivers/usb/serial/ipaq.c @@ -595,7 +595,7 @@ static int ipaq_open(struct usb_serial_port *port, struct file *filp) bytes_in = 0; bytes_out = 0; - priv = kmalloc(sizeof(struct ipaq_private), GFP_KERNEL); + priv = (struct ipaq_private *)kmalloc(sizeof(struct ipaq_private), GFP_KERNEL); if (priv == NULL) { err("%s - Out of memory", __FUNCTION__); return -ENOMEM; diff --git a/trunk/drivers/usb/serial/kobil_sct.c b/trunk/drivers/usb/serial/kobil_sct.c index 62bea0c923bd..e284d6c0fd35 100644 --- a/trunk/drivers/usb/serial/kobil_sct.c +++ b/trunk/drivers/usb/serial/kobil_sct.c @@ -269,7 +269,7 @@ static int kobil_open (struct usb_serial_port *port, struct file *filp) } // allocate memory for write_urb transfer buffer - port->write_urb->transfer_buffer = kmalloc(write_urb_transfer_buffer_length, GFP_KERNEL); + port->write_urb->transfer_buffer = (unsigned char *) kmalloc(write_urb_transfer_buffer_length, GFP_KERNEL); if (! port->write_urb->transfer_buffer) { kfree(transfer_buffer); usb_free_urb(port->write_urb); @@ -696,7 +696,7 @@ static int kobil_ioctl(struct usb_serial_port *port, struct file *file, return 0; case TCFLSH: // 0x540B - transfer_buffer = kmalloc(transfer_buffer_length, GFP_KERNEL); + transfer_buffer = (unsigned char *) kmalloc(transfer_buffer_length, GFP_KERNEL); if (! transfer_buffer) { return -ENOBUFS; } diff --git a/trunk/drivers/usb/serial/pl2303.c b/trunk/drivers/usb/serial/pl2303.c index 5dc2ac9afa90..d124d780e42e 100644 --- a/trunk/drivers/usb/serial/pl2303.c +++ b/trunk/drivers/usb/serial/pl2303.c @@ -159,7 +159,7 @@ static struct pl2303_buf *pl2303_buf_alloc(unsigned int size) if (size == 0) return NULL; - pb = kmalloc(sizeof(struct pl2303_buf), GFP_KERNEL); + pb = (struct pl2303_buf *)kmalloc(sizeof(struct pl2303_buf), GFP_KERNEL); if (pb == NULL) return NULL; diff --git a/trunk/drivers/usb/serial/ti_usb_3410_5052.c b/trunk/drivers/usb/serial/ti_usb_3410_5052.c index 83189005c6fb..f42eb9ea6405 100644 --- a/trunk/drivers/usb/serial/ti_usb_3410_5052.c +++ b/trunk/drivers/usb/serial/ti_usb_3410_5052.c @@ -1710,7 +1710,7 @@ static struct circ_buf *ti_buf_alloc(void) { struct circ_buf *cb; - cb = kmalloc(sizeof(struct circ_buf), GFP_KERNEL); + cb = (struct circ_buf *)kmalloc(sizeof(struct circ_buf), GFP_KERNEL); if (cb == NULL) return NULL; diff --git a/trunk/drivers/usb/serial/whiteheat.c b/trunk/drivers/usb/serial/whiteheat.c index 5483d8564c1b..dc45e58e2b8c 100644 --- a/trunk/drivers/usb/serial/whiteheat.c +++ b/trunk/drivers/usb/serial/whiteheat.c @@ -416,7 +416,7 @@ static int whiteheat_attach (struct usb_serial *serial) for (i = 0; i < serial->num_ports; i++) { port = serial->port[i]; - info = kmalloc(sizeof(struct whiteheat_private), GFP_KERNEL); + info = (struct whiteheat_private *)kmalloc(sizeof(struct whiteheat_private), GFP_KERNEL); if (info == NULL) { err("%s: Out of memory for port structures\n", serial->type->description); goto no_private; @@ -487,7 +487,7 @@ static int whiteheat_attach (struct usb_serial *serial) usb_set_serial_port_data(port, info); } - command_info = kmalloc(sizeof(struct whiteheat_command_private), GFP_KERNEL); + command_info = (struct whiteheat_command_private *)kmalloc(sizeof(struct whiteheat_command_private), GFP_KERNEL); if (command_info == NULL) { err("%s: Out of memory for port structures\n", serial->type->description); goto no_command_private; diff --git a/trunk/drivers/usb/storage/sddr09.c b/trunk/drivers/usb/storage/sddr09.c index e3528eca29a5..fb8bacaae27c 100644 --- a/trunk/drivers/usb/storage/sddr09.c +++ b/trunk/drivers/usb/storage/sddr09.c @@ -646,7 +646,7 @@ sddr09_read_sg_test_only(struct us_data *us) { return result; } - buf = kmalloc(bulklen, GFP_NOIO); + buf = (unsigned char *) kmalloc(bulklen, GFP_NOIO); if (!buf) return -ENOMEM; diff --git a/trunk/drivers/video/amba-clcd.c b/trunk/drivers/video/amba-clcd.c index 6c9dc2e69c82..6761b68c35e9 100644 --- a/trunk/drivers/video/amba-clcd.c +++ b/trunk/drivers/video/amba-clcd.c @@ -447,7 +447,7 @@ static int clcdfb_probe(struct amba_device *dev, void *id) goto out; } - fb = kmalloc(sizeof(struct clcd_fb), GFP_KERNEL); + fb = (struct clcd_fb *) kmalloc(sizeof(struct clcd_fb), GFP_KERNEL); if (!fb) { printk(KERN_INFO "CLCD: could not allocate new clcd_fb struct\n"); ret = -ENOMEM; diff --git a/trunk/drivers/video/amifb.c b/trunk/drivers/video/amifb.c index 1a849b870bcc..88a47845c4f7 100644 --- a/trunk/drivers/video/amifb.c +++ b/trunk/drivers/video/amifb.c @@ -2906,6 +2906,14 @@ static int ami_decode_var(struct fb_var_screeninfo *var, par->crsr.spot_x = par->crsr.spot_y = 0; par->crsr.height = par->crsr.width = 0; +#if 0 /* fbmon not done. uncomment for 2.5.x -brad */ + if (!fbmon_valid_timings(pixclock[clk_shift], htotal, vtotal, + &fb_info)) { + DPRINTK("mode doesn't fit for monitor\n"); + return -EINVAL; + } +#endif + return 0; } diff --git a/trunk/drivers/video/aty/atyfb_base.c b/trunk/drivers/video/aty/atyfb_base.c index 09684d7a7ce9..176f9b85cdbe 100644 --- a/trunk/drivers/video/aty/atyfb_base.c +++ b/trunk/drivers/video/aty/atyfb_base.c @@ -1488,6 +1488,10 @@ static int atyfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) else info->var.accel_flags = 0; +#if 0 /* fbmon is not done. uncomment for 2.5.x -brad */ + if (!fbmon_valid_timings(pixclock, htotal, vtotal, info)) + return -EINVAL; +#endif aty_crtc_to_var(&crtc, var); var->pixclock = par->pll_ops->pll_to_var(info, &pll); return 0; diff --git a/trunk/drivers/video/matrox/i2c-matroxfb.c b/trunk/drivers/video/matrox/i2c-matroxfb.c index fe28848e7b52..797b42305b0f 100644 --- a/trunk/drivers/video/matrox/i2c-matroxfb.c +++ b/trunk/drivers/video/matrox/i2c-matroxfb.c @@ -146,7 +146,7 @@ static void* i2c_matroxfb_probe(struct matrox_fb_info* minfo) { unsigned long flags; struct matroxfb_dh_maven_info* m2info; - m2info = kmalloc(sizeof(*m2info), GFP_KERNEL); + m2info = (struct matroxfb_dh_maven_info*)kmalloc(sizeof(*m2info), GFP_KERNEL); if (!m2info) return NULL; diff --git a/trunk/drivers/video/matrox/matroxfb_base.c b/trunk/drivers/video/matrox/matroxfb_base.c index cb2aa402ddfd..e9b4115fcad0 100644 --- a/trunk/drivers/video/matrox/matroxfb_base.c +++ b/trunk/drivers/video/matrox/matroxfb_base.c @@ -2028,7 +2028,7 @@ static int matroxfb_probe(struct pci_dev* pdev, const struct pci_device_id* dumm } #ifdef CONFIG_FB_MATROX_MULTIHEAD - minfo = kmalloc(sizeof(*minfo), GFP_KERNEL); + minfo = (struct matrox_fb_info*)kmalloc(sizeof(*minfo), GFP_KERNEL); if (!minfo) return -1; #else diff --git a/trunk/drivers/video/matrox/matroxfb_crtc2.c b/trunk/drivers/video/matrox/matroxfb_crtc2.c index 2c9801090fae..27eb4bb4f89f 100644 --- a/trunk/drivers/video/matrox/matroxfb_crtc2.c +++ b/trunk/drivers/video/matrox/matroxfb_crtc2.c @@ -694,7 +694,7 @@ static void* matroxfb_crtc2_probe(struct matrox_fb_info* minfo) { /* hardware is CRTC2 incapable... */ if (!ACCESS_FBINFO(devflags.crtc2)) return NULL; - m2info = kmalloc(sizeof(*m2info), GFP_KERNEL); + m2info = (struct matroxfb_dh_fb_info*)kmalloc(sizeof(*m2info), GFP_KERNEL); if (!m2info) { printk(KERN_ERR "matroxfb_crtc2: Not enough memory for CRTC2 control structs\n"); return NULL; diff --git a/trunk/drivers/video/sstfb.c b/trunk/drivers/video/sstfb.c index 59cd1e750f30..711cb11d6eb3 100644 --- a/trunk/drivers/video/sstfb.c +++ b/trunk/drivers/video/sstfb.c @@ -21,11 +21,6 @@ * Remove never finished and bogus 24/32bit support * Clean up macro abuse * Minor tidying for format. - * 12/2006 Helge Deller - * add /sys/class/graphics/fbX/vgapass sysfs-interface - * add module option "mode_option" to set initial screen mode - * use fbdev default videomode database - * remove debug functions from ioctl */ /* @@ -70,10 +65,19 @@ * * sstfb specific ioctls: * toggle vga (0x46db) : toggle vga_pass_through + * fill fb (0x46dc) : fills fb + * test disp (0x46de) : draws a test image */ #undef SST_DEBUG +/* + Default video mode . + 0 800x600@60 took from glide + 1 640x480@75 took from glide + 2 1024x768@76 std fb.mode + 3 640x480@60 glide default */ +#define DEFAULT_MODE 3 /* * Includes @@ -88,24 +92,20 @@ #include #include #include +#include #include #include