aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTony Luck <tony.luck@intel.com>2005-06-21 19:21:20 -0400
committerTony Luck <tony.luck@intel.com>2005-06-21 19:21:20 -0400
commit29516d75a0b09e0a0328dd55c98a342515c9615a (patch)
tree4b03326311958ad6de82653a1caf289ad8c38538
parent4ea78729b8dbfc400fe165a57b90a394a7275a54 (diff)
parent4a4f8fdba6f5a34ca90f426021e17491a30202da (diff)
Auto merge with /home/aegl/GIT/linus
-rw-r--r--Documentation/DocBook/kernel-api.tmpl1
-rw-r--r--Documentation/driver-model/device.txt8
-rw-r--r--Documentation/driver-model/driver.txt51
-rw-r--r--Documentation/filesystems/sysfs.txt2
-rw-r--r--arch/arm/Kconfig13
-rw-r--r--arch/arm/Makefile1
-rw-r--r--arch/arm/common/amba.c2
-rw-r--r--arch/arm/common/dmabounce.c18
-rw-r--r--arch/arm/common/sharpsl_param.c2
-rw-r--r--arch/arm/configs/enp2611_defconfig8
-rw-r--r--arch/arm/configs/ixdp2400_defconfig8
-rw-r--r--arch/arm/configs/ixdp2401_defconfig8
-rw-r--r--arch/arm/configs/ixdp2800_defconfig8
-rw-r--r--arch/arm/configs/ixdp2801_defconfig8
-rw-r--r--arch/arm/kernel/Makefile2
-rw-r--r--arch/arm/kernel/arch.c46
-rw-r--r--arch/arm/kernel/ecard.c12
-rw-r--r--arch/arm/kernel/smp.c3
-rw-r--r--arch/arm/lib/ashldi3.c47
-rw-r--r--arch/arm/lib/ashrdi3.c48
-rw-r--r--arch/arm/lib/gcclib.h27
-rw-r--r--arch/arm/lib/longlong.h68
-rw-r--r--arch/arm/lib/lshrdi3.c47
-rw-r--r--arch/arm/lib/muldi3.c31
-rw-r--r--arch/arm/lib/ucmpdi2.c30
-rw-r--r--arch/arm/lib/udivdi3.c372
-rw-r--r--arch/arm/mach-aaec2000/Kconfig11
-rw-r--r--arch/arm/mach-aaec2000/Makefile9
-rw-r--r--arch/arm/mach-aaec2000/aaed2000.c48
-rw-r--r--arch/arm/mach-aaec2000/core.c157
-rw-r--r--arch/arm/mach-aaec2000/core.h16
-rw-r--r--arch/arm/mach-integrator/core.c1
-rw-r--r--arch/arm/mach-ixp2000/core.c34
-rw-r--r--arch/arm/mach-versatile/Makefile1
-rw-r--r--arch/arm/mach-versatile/core.c14
-rw-r--r--arch/arm/mach-versatile/pci.c360
-rw-r--r--arch/arm/mm/Kconfig2
-rw-r--r--arch/arm/mm/copypage-v6.c6
-rw-r--r--arch/arm/mm/fault-armv.c31
-rw-r--r--arch/arm/mm/flush.c44
-rw-r--r--arch/arm/mm/ioremap.c47
-rw-r--r--arch/arm26/kernel/ecard.c10
-rw-r--r--arch/i386/kernel/cpuid.c22
-rw-r--r--arch/i386/kernel/msr.c22
-rw-r--r--arch/ia64/sn/kernel/tiocx.c25
-rw-r--r--arch/parisc/kernel/drivers.c2
-rw-r--r--arch/ppc/kernel/pci.c2
-rw-r--r--arch/ppc/syslib/ocp.c2
-rw-r--r--arch/ppc/syslib/of_device.c2
-rw-r--r--arch/ppc64/kernel/iommu.c3
-rw-r--r--arch/ppc64/kernel/of_device.c2
-rw-r--r--arch/ppc64/kernel/pSeries_smp.c9
-rw-r--r--arch/ppc64/kernel/pci.c2
-rw-r--r--arch/ppc64/kernel/rtasd.c4
-rw-r--r--arch/ppc64/kernel/vio.c4
-rw-r--r--drivers/acpi/scan.c4
-rw-r--r--drivers/base/Makefile4
-rw-r--r--drivers/base/base.h2
-rw-r--r--drivers/base/bus.c299
-rw-r--r--drivers/base/class.c194
-rw-r--r--drivers/base/class_simple.c199
-rw-r--r--drivers/base/core.c62
-rw-r--r--drivers/base/dd.c248
-rw-r--r--drivers/base/dmapool.c2
-rw-r--r--drivers/base/driver.c39
-rw-r--r--drivers/base/node.c20
-rw-r--r--drivers/base/power/resume.c8
-rw-r--r--drivers/base/power/suspend.c16
-rw-r--r--drivers/base/power/sysfs.c4
-rw-r--r--drivers/base/sys.c4
-rw-r--r--drivers/block/aoe/aoechr.c10
-rw-r--r--drivers/block/as-iosched.c4
-rw-r--r--drivers/block/cfq-iosched.c4
-rw-r--r--drivers/block/deadline-iosched.c4
-rw-r--r--drivers/block/genhd.c2
-rw-r--r--drivers/block/ll_rw_blk.c4
-rw-r--r--drivers/block/paride/pg.c14
-rw-r--r--drivers/block/paride/pt.c20
-rw-r--r--drivers/block/ub.c2
-rw-r--r--drivers/char/dsp56k.c14
-rw-r--r--drivers/char/ftape/zftape/zftape-init.c30
-rw-r--r--drivers/char/hvcs.c14
-rw-r--r--drivers/char/ip2main.c24
-rw-r--r--drivers/char/ipmi/ipmi_devintf.c14
-rw-r--r--drivers/char/istallion.c10
-rw-r--r--drivers/char/lp.c12
-rw-r--r--drivers/char/mbcs.c4
-rw-r--r--drivers/char/mem.c7
-rw-r--r--drivers/char/misc.c16
-rw-r--r--drivers/char/mwave/mwavedd.c2
-rw-r--r--drivers/char/ppdev.c12
-rw-r--r--drivers/char/raw.c18
-rw-r--r--drivers/char/snsc.c7
-rw-r--r--drivers/char/stallion.c10
-rw-r--r--drivers/char/tipar.c14
-rw-r--r--drivers/char/tpm/tpm.c6
-rw-r--r--drivers/char/tty_io.c16
-rw-r--r--drivers/char/vc_screen.c16
-rw-r--r--drivers/char/viotape.c16
-rw-r--r--drivers/char/watchdog/ixp2000_wdt.c7
-rw-r--r--drivers/cpufreq/cpufreq.c4
-rw-r--r--drivers/dio/dio-sysfs.c10
-rw-r--r--drivers/eisa/eisa-bus.c4
-rw-r--r--drivers/fc4/fc.c6
-rw-r--r--drivers/firmware/edd.c2
-rw-r--r--drivers/firmware/efivars.c4
-rw-r--r--drivers/i2c/chips/adm1021.c6
-rw-r--r--drivers/i2c/chips/adm1025.c28
-rw-r--r--drivers/i2c/chips/adm1026.c572
-rw-r--r--drivers/i2c/chips/adm1031.c44
-rw-r--r--drivers/i2c/chips/asb100.c46
-rw-r--r--drivers/i2c/chips/ds1621.c6
-rw-r--r--drivers/i2c/chips/fscher.c8
-rw-r--r--drivers/i2c/chips/fscpos.c16
-rw-r--r--drivers/i2c/chips/gl518sm.c12
-rw-r--r--drivers/i2c/chips/gl520sm.c8
-rw-r--r--drivers/i2c/chips/it87.c50
-rw-r--r--drivers/i2c/chips/lm63.c24
-rw-r--r--drivers/i2c/chips/lm75.c4
-rw-r--r--drivers/i2c/chips/lm77.c14
-rw-r--r--drivers/i2c/chips/lm78.c36
-rw-r--r--drivers/i2c/chips/lm80.c20
-rw-r--r--drivers/i2c/chips/lm83.c6
-rw-r--r--drivers/i2c/chips/lm85.c72
-rw-r--r--drivers/i2c/chips/lm87.c46
-rw-r--r--drivers/i2c/chips/lm90.c12
-rw-r--r--drivers/i2c/chips/lm92.c14
-rw-r--r--drivers/i2c/chips/max1619.c6
-rw-r--r--drivers/i2c/chips/pc87360.c68
-rw-r--r--drivers/i2c/chips/pcf8574.c6
-rw-r--r--drivers/i2c/chips/pcf8591.c10
-rw-r--r--drivers/i2c/chips/sis5595.c34
-rw-r--r--drivers/i2c/chips/smsc47b397.c4
-rw-r--r--drivers/i2c/chips/smsc47m1.c20
-rw-r--r--drivers/i2c/chips/via686a.c32
-rw-r--r--drivers/i2c/chips/w83627hf.c56
-rw-r--r--drivers/i2c/chips/w83781d.c52
-rw-r--r--drivers/i2c/chips/w83l785ts.c4
-rw-r--r--drivers/i2c/i2c-core.c4
-rw-r--r--drivers/ieee1394/dv1394.c6
-rw-r--r--drivers/ieee1394/ieee1394_core.c8
-rw-r--r--drivers/ieee1394/ieee1394_core.h3
-rw-r--r--drivers/ieee1394/nodemgr.c27
-rw-r--r--drivers/ieee1394/raw1394.c10
-rw-r--r--drivers/ieee1394/sbp2.c2
-rw-r--r--drivers/ieee1394/video1394.c4
-rw-r--r--drivers/infiniband/core/sysfs.c122
-rw-r--r--drivers/input/evdev.c9
-rw-r--r--drivers/input/gameport/gameport.c4
-rw-r--r--drivers/input/input.c10
-rw-r--r--drivers/input/joydev.c8
-rw-r--r--drivers/input/keyboard/atkbd.c4
-rw-r--r--drivers/input/mouse/psmouse.h4
-rw-r--r--drivers/input/mousedev.c16
-rw-r--r--drivers/input/serio/serio.c16
-rw-r--r--drivers/input/tsdev.c9
-rw-r--r--drivers/isdn/capi/capi.c14
-rw-r--r--drivers/macintosh/adb.c9
-rw-r--r--drivers/macintosh/therm_adt746x.c11
-rw-r--r--drivers/macintosh/therm_pm72.c4
-rw-r--r--drivers/macintosh/therm_windtunnel.c4
-rw-r--r--drivers/mca/mca-bus.c4
-rw-r--r--drivers/media/dvb/dvb-core/dvbdev.c13
-rw-r--r--drivers/message/fusion/mptscsih.c2
-rw-r--r--drivers/message/fusion/mptscsih.h2
-rw-r--r--drivers/mmc/mmc_sysfs.c2
-rw-r--r--drivers/net/ppp_generic.c14
-rw-r--r--drivers/net/wan/cosa.c12
-rw-r--r--drivers/pci/hotplug/cpqphp_sysfs.c4
-rw-r--r--drivers/pci/hotplug/pci_hotplug_core.c4
-rw-r--r--drivers/pci/hotplug/rpadlpar_sysfs.c2
-rw-r--r--drivers/pci/hotplug/shpchp_sysfs.c4
-rw-r--r--drivers/pci/pci-driver.c26
-rw-r--r--drivers/pci/pci-sysfs.c21
-rw-r--r--drivers/pci/pcie/portdrv_core.c139
-rw-r--r--drivers/pcmcia/ds.c4
-rw-r--r--drivers/pnp/card.c4
-rw-r--r--drivers/pnp/driver.c12
-rw-r--r--drivers/pnp/interface.c8
-rw-r--r--drivers/s390/block/dasd_devmap.c10
-rw-r--r--drivers/s390/block/dcssblk.c24
-rw-r--r--drivers/s390/char/raw3270.c6
-rw-r--r--drivers/s390/char/tape_class.c10
-rw-r--r--drivers/s390/char/tape_core.c10
-rw-r--r--drivers/s390/char/vmlogrdr.c22
-rw-r--r--drivers/s390/cio/ccwgroup.c6
-rw-r--r--drivers/s390/cio/chsc.c6
-rw-r--r--drivers/s390/cio/cmf.c12
-rw-r--r--drivers/s390/cio/device.c14
-rw-r--r--drivers/s390/net/claw.c40
-rw-r--r--drivers/s390/net/ctcmain.c18
-rw-r--r--drivers/s390/net/lcs.c10
-rw-r--r--drivers/s390/net/netiucv.c44
-rw-r--r--drivers/s390/net/qeth_sys.c126
-rw-r--r--drivers/s390/scsi/zfcp_scsi.c2
-rw-r--r--drivers/s390/scsi/zfcp_sysfs_adapter.c10
-rw-r--r--drivers/s390/scsi/zfcp_sysfs_port.c10
-rw-r--r--drivers/s390/scsi/zfcp_sysfs_unit.c6
-rw-r--r--drivers/scsi/53c700.c2
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_osm.c8
-rw-r--r--drivers/scsi/arm/eesox.c4
-rw-r--r--drivers/scsi/arm/powertec.c4
-rw-r--r--drivers/scsi/ipr.c2
-rw-r--r--drivers/scsi/megaraid/megaraid_mbox.c4
-rw-r--r--drivers/scsi/osst.c10
-rw-r--r--drivers/scsi/scsi_sysfs.c42
-rw-r--r--drivers/scsi/scsi_transport_spi.c16
-rw-r--r--drivers/scsi/sg.c14
-rw-r--r--drivers/scsi/st.c28
-rw-r--r--drivers/sh/superhyway/superhyway-sysfs.c2
-rw-r--r--drivers/usb/core/devices.c2
-rw-r--r--drivers/usb/core/file.c13
-rw-r--r--drivers/usb/core/hcd.c61
-rw-r--r--drivers/usb/core/sysfs.c26
-rw-r--r--drivers/usb/core/usb.c53
-rw-r--r--drivers/usb/gadget/dummy_hcd.c4
-rw-r--r--drivers/usb/gadget/file_storage.c8
-rw-r--r--drivers/usb/gadget/net2280.c6
-rw-r--r--drivers/usb/gadget/pxa2xx_udc.c2
-rw-r--r--drivers/usb/host/ehci-dbg.c10
-rw-r--r--drivers/usb/host/ohci-dbg.c10
-rw-r--r--drivers/usb/input/aiptek.c78
-rw-r--r--drivers/usb/misc/cytherm.c20
-rw-r--r--drivers/usb/misc/phidgetkit.c14
-rw-r--r--drivers/usb/misc/phidgetservo.c4
-rw-r--r--drivers/usb/misc/usbled.c4
-rw-r--r--drivers/usb/serial/ftdi_sio.c6
-rw-r--r--drivers/usb/storage/scsiglue.c4
-rw-r--r--drivers/video/fbmem.c10
-rw-r--r--drivers/video/gbefb.c4
-rw-r--r--drivers/video/w100fb.c12
-rw-r--r--drivers/w1/w1.c16
-rw-r--r--drivers/w1/w1_family.h4
-rw-r--r--drivers/w1/w1_smem.c8
-rw-r--r--drivers/w1/w1_therm.c8
-rw-r--r--drivers/zorro/zorro-sysfs.c4
-rw-r--r--fs/Kconfig50
-rw-r--r--fs/coda/psdev.c18
-rw-r--r--fs/debugfs/file.c67
-rw-r--r--fs/jfs/acl.c6
-rw-r--r--fs/jfs/file.c9
-rw-r--r--fs/jfs/inode.c11
-rw-r--r--fs/jfs/jfs_debug.c10
-rw-r--r--fs/jfs/jfs_debug.h15
-rw-r--r--fs/jfs/jfs_dmap.c9
-rw-r--r--fs/jfs/jfs_dtree.c3
-rw-r--r--fs/jfs/jfs_extent.c7
-rw-r--r--fs/jfs/jfs_imap.c6
-rw-r--r--fs/jfs/jfs_inode.c1
-rw-r--r--fs/jfs/jfs_inode.h19
-rw-r--r--fs/jfs/jfs_logmgr.c14
-rw-r--r--fs/jfs/jfs_logmgr.h2
-rw-r--r--fs/jfs/jfs_metapage.c6
-rw-r--r--fs/jfs/jfs_metapage.h6
-rw-r--r--fs/jfs/jfs_superblock.h11
-rw-r--r--fs/jfs/jfs_txnmgr.c40
-rw-r--r--fs/jfs/jfs_txnmgr.h52
-rw-r--r--fs/jfs/namei.c28
-rw-r--r--fs/jfs/super.c37
-rw-r--r--fs/jfs/symlink.c3
-rw-r--r--fs/jfs/xattr.c6
-rw-r--r--fs/libfs.c100
-rw-r--r--fs/sysfs/bin.c4
-rw-r--r--fs/sysfs/dir.c26
-rw-r--r--fs/sysfs/file.c6
-rw-r--r--fs/sysfs/inode.c102
-rw-r--r--fs/sysfs/mount.c4
-rw-r--r--fs/sysfs/symlink.c8
-rw-r--r--fs/sysfs/sysfs.h4
-rw-r--r--include/asm-arm/arch-aaec2000/aaec2000.h151
-rw-r--r--include/asm-arm/arch-aaec2000/debug-macro.S36
-rw-r--r--include/asm-arm/arch-aaec2000/dma.h17
-rw-r--r--include/asm-arm/arch-aaec2000/entry-macro.S33
-rw-r--r--include/asm-arm/arch-aaec2000/hardware.h49
-rw-r--r--include/asm-arm/arch-aaec2000/io.h19
-rw-r--r--include/asm-arm/arch-aaec2000/irqs.h46
-rw-r--r--include/asm-arm/arch-aaec2000/memory.h73
-rw-r--r--include/asm-arm/arch-aaec2000/param.h15
-rw-r--r--include/asm-arm/arch-aaec2000/system.h24
-rw-r--r--include/asm-arm/arch-aaec2000/timex.h18
-rw-r--r--include/asm-arm/arch-aaec2000/uncompress.h47
-rw-r--r--include/asm-arm/arch-aaec2000/vmalloc.h16
-rw-r--r--include/asm-arm/arch-ixp2000/ixp2000-regs.h1
-rw-r--r--include/asm-arm/arch-versatile/hardware.h27
-rw-r--r--include/asm-arm/arch-versatile/io.h2
-rw-r--r--include/asm-arm/arch-versatile/platform.h17
-rw-r--r--include/asm-arm/cacheflush.h3
-rw-r--r--include/asm-arm/io.h27
-rw-r--r--include/asm-ppc/ocp.h2
-rw-r--r--include/linux/atalk.h26
-rw-r--r--include/linux/device.h64
-rw-r--r--include/linux/fs.h46
-rw-r--r--include/linux/i2c-sysfs.h36
-rw-r--r--include/linux/input.h2
-rw-r--r--include/linux/klist.h55
-rw-r--r--include/linux/kobject.h8
-rw-r--r--include/linux/netfilter_ipv4.h6
-rw-r--r--include/linux/netfilter_ipv4/ip_conntrack_core.h3
-rw-r--r--include/linux/netfilter_ipv4/ip_nat.h3
-rw-r--r--include/linux/netfilter_ipv4/listhelp.h1
-rw-r--r--include/linux/netfilter_ipv4/lockhelp.h129
-rw-r--r--include/linux/netlink.h3
-rw-r--r--include/linux/node.h1
-rw-r--r--include/linux/pfkeyv2.h1
-rw-r--r--include/linux/skbuff.h13
-rw-r--r--include/linux/sysfs.h15
-rw-r--r--include/linux/usb.h5
-rw-r--r--include/linux/xfrm.h1
-rw-r--r--include/net/ax25.h2
-rw-r--r--include/net/ip6_fib.h9
-rw-r--r--include/net/ip6_route.h9
-rw-r--r--include/net/ip_fib.h14
-rw-r--r--include/net/sctp/command.h8
-rw-r--r--include/net/sctp/constants.h7
-rw-r--r--include/net/sctp/sctp.h17
-rw-r--r--include/net/sctp/sm.h8
-rw-r--r--include/net/sctp/structs.h41
-rw-r--r--include/net/sctp/user.h3
-rw-r--r--include/net/xfrm.h4
-rw-r--r--kernel/params.c4
-rw-r--r--lib/Makefile7
-rw-r--r--lib/klist.c265
-rw-r--r--lib/kobject.c2
-rw-r--r--lib/kobject_uevent.c6
-rw-r--r--net/appletalk/aarp.c2
-rw-r--r--net/appletalk/ddp.c2
-rw-r--r--net/bridge/br_forward.c3
-rw-r--r--net/bridge/br_input.c4
-rw-r--r--net/bridge/br_netfilter.c38
-rw-r--r--net/core/netfilter.c138
-rw-r--r--net/core/skbuff.c6
-rw-r--r--net/ipv4/Kconfig26
-rw-r--r--net/ipv4/Makefile4
-rw-r--r--net/ipv4/af_inet.c12
-rw-r--r--net/ipv4/ah4.c2
-rw-r--r--net/ipv4/esp4.c2
-rw-r--r--net/ipv4/fib_frontend.c55
-rw-r--r--net/ipv4/fib_trie.c2454
-rw-r--r--net/ipv4/ip_input.c5
-rw-r--r--net/ipv4/ip_output.c11
-rw-r--r--net/ipv4/ipcomp.c11
-rw-r--r--net/ipv4/ipmr.c1
-rw-r--r--net/ipv4/ipvs/ip_vs_xmit.c1
-rw-r--r--net/ipv4/netfilter/arp_tables.c1
-rw-r--r--net/ipv4/netfilter/ip_conntrack_amanda.c7
-rw-r--r--net/ipv4/netfilter/ip_conntrack_core.c107
-rw-r--r--net/ipv4/netfilter/ip_conntrack_ftp.c7
-rw-r--r--net/ipv4/netfilter/ip_conntrack_irc.c7
-rw-r--r--net/ipv4/netfilter/ip_conntrack_proto_sctp.c23
-rw-r--r--net/ipv4/netfilter/ip_conntrack_proto_tcp.c27
-rw-r--r--net/ipv4/netfilter/ip_conntrack_proto_udp.c1
-rw-r--r--net/ipv4/netfilter/ip_conntrack_standalone.c22
-rw-r--r--net/ipv4/netfilter/ip_nat_core.c32
-rw-r--r--net/ipv4/netfilter/ip_nat_helper.c13
-rw-r--r--net/ipv4/netfilter/ip_nat_rule.c4
-rw-r--r--net/ipv4/netfilter/ip_nat_standalone.c5
-rw-r--r--net/ipv4/netfilter/ip_tables.c1
-rw-r--r--net/ipv4/netfilter/ipt_CLUSTERIP.c49
-rw-r--r--net/ipv4/netfilter/ipt_MASQUERADE.c10
-rw-r--r--net/ipv4/netfilter/ipt_REJECT.c13
-rw-r--r--net/ipv4/netfilter/ipt_ULOG.c15
-rw-r--r--net/ipv4/netfilter/ipt_hashlimit.c17
-rw-r--r--net/ipv4/netfilter/ipt_helper.c4
-rw-r--r--net/ipv4/xfrm4_output.c8
-rw-r--r--net/ipv4/xfrm4_state.c9
-rw-r--r--net/ipv4/xfrm4_tunnel.c2
-rw-r--r--net/ipv6/addrconf.c14
-rw-r--r--net/ipv6/ah6.c2
-rw-r--r--net/ipv6/anycast.c4
-rw-r--r--net/ipv6/esp6.c2
-rw-r--r--net/ipv6/ip6_fib.c19
-rw-r--r--net/ipv6/ip6_output.c3
-rw-r--r--net/ipv6/ipcomp6.c9
-rw-r--r--net/ipv6/ipv6_sockglue.c5
-rw-r--r--net/ipv6/mcast.c68
-rw-r--r--net/ipv6/ndisc.c4
-rw-r--r--net/ipv6/netfilter/ip6_tables.c1
-rw-r--r--net/ipv6/netfilter/ip6t_LOG.c54
-rw-r--r--net/ipv6/netfilter/ip6table_raw.c6
-rw-r--r--net/ipv6/route.c78
-rw-r--r--net/ipv6/xfrm6_tunnel.c2
-rw-r--r--net/key/af_key.c16
-rw-r--r--net/sctp/associola.c151
-rw-r--r--net/sctp/endpointola.c1
-rw-r--r--net/sctp/input.c2
-rw-r--r--net/sctp/outqueue.c11
-rw-r--r--net/sctp/sm_make_chunk.c20
-rw-r--r--net/sctp/sm_sideeffect.c105
-rw-r--r--net/sctp/sm_statefuns.c148
-rw-r--r--net/sctp/sm_statetable.c6
-rw-r--r--net/sctp/socket.c405
-rw-r--r--net/sctp/transport.c4
-rw-r--r--net/xfrm/xfrm_policy.c1
-rw-r--r--net/xfrm/xfrm_state.c37
-rw-r--r--net/xfrm/xfrm_user.c9
-rw-r--r--security/seclvl.c4
-rw-r--r--sound/core/sound.c6
-rw-r--r--sound/oss/soundcard.c19
-rw-r--r--sound/sound_core.c10
399 files changed, 8472 insertions, 4117 deletions
diff --git a/Documentation/DocBook/kernel-api.tmpl b/Documentation/DocBook/kernel-api.tmpl
index 757cef8f8491..bb6a0106be11 100644
--- a/Documentation/DocBook/kernel-api.tmpl
+++ b/Documentation/DocBook/kernel-api.tmpl
@@ -338,7 +338,6 @@ X!Earch/i386/kernel/mca.c
338X!Iinclude/linux/device.h 338X!Iinclude/linux/device.h
339--> 339-->
340!Edrivers/base/driver.c 340!Edrivers/base/driver.c
341!Edrivers/base/class_simple.c
342!Edrivers/base/core.c 341!Edrivers/base/core.c
343!Edrivers/base/firmware_class.c 342!Edrivers/base/firmware_class.c
344!Edrivers/base/transport_class.c 343!Edrivers/base/transport_class.c
diff --git a/Documentation/driver-model/device.txt b/Documentation/driver-model/device.txt
index 58cc5dc8fd3e..a05ec50f8004 100644
--- a/Documentation/driver-model/device.txt
+++ b/Documentation/driver-model/device.txt
@@ -76,6 +76,14 @@ driver_data: Driver-specific data.
76 76
77platform_data: Platform data specific to the device. 77platform_data: Platform data specific to the device.
78 78
79 Example: for devices on custom boards, as typical of embedded
80 and SOC based hardware, Linux often uses platform_data to point
81 to board-specific structures describing devices and how they
82 are wired. That can include what ports are available, chip
83 variants, which GPIO pins act in what additional roles, and so
84 on. This shrinks the "Board Support Packages" (BSPs) and
85 minimizes board-specific #ifdefs in drivers.
86
79current_state: Current power state of the device. 87current_state: Current power state of the device.
80 88
81saved_state: Pointer to saved state of the device. This is usable by 89saved_state: Pointer to saved state of the device. This is usable by
diff --git a/Documentation/driver-model/driver.txt b/Documentation/driver-model/driver.txt
index 6031a68dd3f5..fabaca1ab1b0 100644
--- a/Documentation/driver-model/driver.txt
+++ b/Documentation/driver-model/driver.txt
@@ -5,21 +5,17 @@ struct device_driver {
5 char * name; 5 char * name;
6 struct bus_type * bus; 6 struct bus_type * bus;
7 7
8 rwlock_t lock; 8 struct completion unloaded;
9 atomic_t refcount; 9 struct kobject kobj;
10
11 list_t bus_list;
12 list_t devices; 10 list_t devices;
13 11
14 struct driver_dir_entry dir; 12 struct module *owner;
15 13
16 int (*probe) (struct device * dev); 14 int (*probe) (struct device * dev);
17 int (*remove) (struct device * dev); 15 int (*remove) (struct device * dev);
18 16
19 int (*suspend) (struct device * dev, pm_message_t state, u32 level); 17 int (*suspend) (struct device * dev, pm_message_t state, u32 level);
20 int (*resume) (struct device * dev, u32 level); 18 int (*resume) (struct device * dev, u32 level);
21
22 void (*release) (struct device_driver * drv);
23}; 19};
24 20
25 21
@@ -51,7 +47,6 @@ being converted completely to the new model.
51static struct device_driver eepro100_driver = { 47static struct device_driver eepro100_driver = {
52 .name = "eepro100", 48 .name = "eepro100",
53 .bus = &pci_bus_type, 49 .bus = &pci_bus_type,
54 .devclass = &ethernet_devclass, /* when it's implemented */
55 50
56 .probe = eepro100_probe, 51 .probe = eepro100_probe,
57 .remove = eepro100_remove, 52 .remove = eepro100_remove,
@@ -85,7 +80,6 @@ static struct pci_driver eepro100_driver = {
85 .driver = { 80 .driver = {
86 .name = "eepro100", 81 .name = "eepro100",
87 .bus = &pci_bus_type, 82 .bus = &pci_bus_type,
88 .devclass = &ethernet_devclass, /* when it's implemented */
89 .probe = eepro100_probe, 83 .probe = eepro100_probe,
90 .remove = eepro100_remove, 84 .remove = eepro100_remove,
91 .suspend = eepro100_suspend, 85 .suspend = eepro100_suspend,
@@ -166,27 +160,32 @@ Callbacks
166 160
167 int (*probe) (struct device * dev); 161 int (*probe) (struct device * dev);
168 162
169probe is called to verify the existence of a certain type of 163The probe() entry is called in task context, with the bus's rwsem locked
170hardware. This is called during the driver binding process, after the 164and the driver partially bound to the device. Drivers commonly use
171bus has verified that the device ID of a device matches one of the 165container_of() to convert "dev" to a bus-specific type, both in probe()
172device IDs supported by the driver. 166and other routines. That type often provides device resource data, such
173 167as pci_dev.resource[] or platform_device.resources, which is used in
174This callback only verifies that there actually is supported hardware 168addition to dev->platform_data to initialize the driver.
175present. It may allocate a driver-specific structure, but it should 169
176not do any initialization of the hardware itself. The device-specific 170This callback holds the driver-specific logic to bind the driver to a
177structure may be stored in the device's driver_data field. 171given device. That includes verifying that the device is present, that
178 172it's a version the driver can handle, that driver data structures can
179 int (*init) (struct device * dev); 173be allocated and initialized, and that any hardware can be initialized.
180 174Drivers often store a pointer to their state with dev_set_drvdata().
181init is called during the binding stage. It is called after probe has 175When the driver has successfully bound itself to that device, then probe()
182successfully returned and the device has been registered with its 176returns zero and the driver model code will finish its part of binding
183class. It is responsible for initializing the hardware. 177the driver to that device.
178
179A driver's probe() may return a negative errno value to indicate that
180the driver did not bind to this device, in which case it should have
181released all reasources it allocated.
184 182
185 int (*remove) (struct device * dev); 183 int (*remove) (struct device * dev);
186 184
187remove is called to dissociate a driver with a device. This may be 185remove is called to unbind a driver from a device. This may be
188called if a device is physically removed from the system, if the 186called if a device is physically removed from the system, if the
189driver module is being unloaded, or during a reboot sequence. 187driver module is being unloaded, during a reboot sequence, or
188in other cases.
190 189
191It is up to the driver to determine if the device is present or 190It is up to the driver to determine if the device is present or
192not. It should free any resources allocated specifically for the 191not. It should free any resources allocated specifically for the
diff --git a/Documentation/filesystems/sysfs.txt b/Documentation/filesystems/sysfs.txt
index 60f6c2c4d477..dc276598a65a 100644
--- a/Documentation/filesystems/sysfs.txt
+++ b/Documentation/filesystems/sysfs.txt
@@ -214,7 +214,7 @@ Other notes:
214 214
215A very simple (and naive) implementation of a device attribute is: 215A very simple (and naive) implementation of a device attribute is:
216 216
217static ssize_t show_name(struct device * dev, char * buf) 217static ssize_t show_name(struct device *dev, struct device_attribute *attr, char *buf)
218{ 218{
219 return sprintf(buf,"%s\n",dev->name); 219 return sprintf(buf,"%s\n",dev->name);
220} 220}
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 475950c8a831..ee8a9ad7bbd9 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -67,10 +67,6 @@ config GENERIC_BUST_SPINLOCK
67config GENERIC_ISA_DMA 67config GENERIC_ISA_DMA
68 bool 68 bool
69 69
70config GENERIC_IOMAP
71 bool
72 default y
73
74config FIQ 70config FIQ
75 bool 71 bool
76 72
@@ -202,6 +198,11 @@ config ARCH_H720X
202 help 198 help
203 This enables support for systems based on the Hynix HMS720x 199 This enables support for systems based on the Hynix HMS720x
204 200
201config ARCH_AAEC2000
202 bool "Agilent AAEC-2000 based"
203 help
204 This enables support for systems based on the Agilent AAEC-2000
205
205endchoice 206endchoice
206 207
207source "arch/arm/mach-clps711x/Kconfig" 208source "arch/arm/mach-clps711x/Kconfig"
@@ -234,6 +235,8 @@ source "arch/arm/mach-h720x/Kconfig"
234 235
235source "arch/arm/mach-versatile/Kconfig" 236source "arch/arm/mach-versatile/Kconfig"
236 237
238source "arch/arm/mach-aaec2000/Kconfig"
239
237# Definitions to make life easier 240# Definitions to make life easier
238config ARCH_ACORN 241config ARCH_ACORN
239 bool 242 bool
@@ -277,7 +280,7 @@ config ISA_DMA_API
277 default y 280 default y
278 281
279config PCI 282config PCI
280 bool "PCI support" if ARCH_INTEGRATOR_AP 283 bool "PCI support" if ARCH_INTEGRATOR_AP || ARCH_VERSATILE_PB
281 help 284 help
282 Find out whether you have a PCI motherboard. PCI is the name of a 285 Find out whether you have a PCI motherboard. PCI is the name of a
283 bus system, i.e. the way the CPU talks to the other stuff inside 286 bus system, i.e. the way the CPU talks to the other stuff inside
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 2277e3d179cc..8330495e2448 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -97,6 +97,7 @@ textaddr-$(CONFIG_ARCH_FORTUNET) := 0xc0008000
97 machine-$(CONFIG_ARCH_VERSATILE) := versatile 97 machine-$(CONFIG_ARCH_VERSATILE) := versatile
98 machine-$(CONFIG_ARCH_IMX) := imx 98 machine-$(CONFIG_ARCH_IMX) := imx
99 machine-$(CONFIG_ARCH_H720X) := h720x 99 machine-$(CONFIG_ARCH_H720X) := h720x
100 machine-$(CONFIG_ARCH_AAEC2000) := aaec2000
100 101
101ifeq ($(CONFIG_ARCH_EBSA110),y) 102ifeq ($(CONFIG_ARCH_EBSA110),y)
102# This is what happens if you forget the IOCS16 line. 103# This is what happens if you forget the IOCS16 line.
diff --git a/arch/arm/common/amba.c b/arch/arm/common/amba.c
index a0507f8c33fe..c6beb751f2a9 100644
--- a/arch/arm/common/amba.c
+++ b/arch/arm/common/amba.c
@@ -169,7 +169,7 @@ static void amba_device_release(struct device *dev)
169} 169}
170 170
171#define amba_attr(name,fmt,arg...) \ 171#define amba_attr(name,fmt,arg...) \
172static ssize_t show_##name(struct device *_dev, char *buf) \ 172static ssize_t show_##name(struct device *_dev, struct device_attribute *attr, char *buf) \
173{ \ 173{ \
174 struct amba_device *dev = to_amba_device(_dev); \ 174 struct amba_device *dev = to_amba_device(_dev); \
175 return sprintf(buf, fmt, arg); \ 175 return sprintf(buf, fmt, arg); \
diff --git a/arch/arm/common/dmabounce.c b/arch/arm/common/dmabounce.c
index 5797b1b100a1..9d63a01214eb 100644
--- a/arch/arm/common/dmabounce.c
+++ b/arch/arm/common/dmabounce.c
@@ -30,6 +30,8 @@
30#include <linux/dmapool.h> 30#include <linux/dmapool.h>
31#include <linux/list.h> 31#include <linux/list.h>
32 32
33#include <asm/cacheflush.h>
34
33#undef DEBUG 35#undef DEBUG
34 36
35#undef STATS 37#undef STATS
@@ -302,12 +304,24 @@ unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
302 304
303 DO_STATS ( device_info->bounce_count++ ); 305 DO_STATS ( device_info->bounce_count++ );
304 306
305 if ((dir == DMA_FROM_DEVICE) || 307 if (dir == DMA_FROM_DEVICE || dir == DMA_BIDIRECTIONAL) {
306 (dir == DMA_BIDIRECTIONAL)) { 308 unsigned long ptr;
309
307 dev_dbg(dev, 310 dev_dbg(dev,
308 "%s: copy back safe %p to unsafe %p size %d\n", 311 "%s: copy back safe %p to unsafe %p size %d\n",
309 __func__, buf->safe, buf->ptr, size); 312 __func__, buf->safe, buf->ptr, size);
310 memcpy(buf->ptr, buf->safe, size); 313 memcpy(buf->ptr, buf->safe, size);
314
315 /*
316 * DMA buffers must have the same cache properties
317 * as if they were really used for DMA - which means
318 * data must be written back to RAM. Note that
319 * we don't use dmac_flush_range() here for the
320 * bidirectional case because we know the cache
321 * lines will be coherent with the data written.
322 */
323 ptr = (unsigned long)buf->ptr;
324 dmac_clean_range(ptr, ptr + size);
311 } 325 }
312 free_safe_buffer(device_info, buf); 326 free_safe_buffer(device_info, buf);
313 } 327 }
diff --git a/arch/arm/common/sharpsl_param.c b/arch/arm/common/sharpsl_param.c
index c2c557a224c2..c94864c5b1af 100644
--- a/arch/arm/common/sharpsl_param.c
+++ b/arch/arm/common/sharpsl_param.c
@@ -22,7 +22,7 @@
22 * them early in the boot process, then pass them to the appropriate drivers. 22 * them early in the boot process, then pass them to the appropriate drivers.
23 * Not all devices use all paramaters but the format is common to all. 23 * Not all devices use all paramaters but the format is common to all.
24 */ 24 */
25#ifdef ARCH_SA1100 25#ifdef CONFIG_ARCH_SA1100
26#define PARAM_BASE 0xe8ffc000 26#define PARAM_BASE 0xe8ffc000
27#else 27#else
28#define PARAM_BASE 0xa0000a00 28#define PARAM_BASE 0xa0000a00
diff --git a/arch/arm/configs/enp2611_defconfig b/arch/arm/configs/enp2611_defconfig
index e8f9fccffe84..06fae4b62774 100644
--- a/arch/arm/configs/enp2611_defconfig
+++ b/arch/arm/configs/enp2611_defconfig
@@ -50,7 +50,13 @@ CONFIG_BASE_SMALL=0
50# 50#
51# Loadable module support 51# Loadable module support
52# 52#
53# CONFIG_MODULES is not set 53CONFIG_MODULES=y
54CONFIG_MODULE_UNLOAD=y
55# CONFIG_MODULE_FORCE_UNLOAD is not set
56CONFIG_OBSOLETE_MODPARM=y
57# CONFIG_MODVERSIONS is not set
58# CONFIG_MODULE_SRCVERSION_ALL is not set
59CONFIG_KMOD=y
54 60
55# 61#
56# System Type 62# System Type
diff --git a/arch/arm/configs/ixdp2400_defconfig b/arch/arm/configs/ixdp2400_defconfig
index 4fd663ecbe39..810a450a55d2 100644
--- a/arch/arm/configs/ixdp2400_defconfig
+++ b/arch/arm/configs/ixdp2400_defconfig
@@ -50,7 +50,13 @@ CONFIG_BASE_SMALL=0
50# 50#
51# Loadable module support 51# Loadable module support
52# 52#
53# CONFIG_MODULES is not set 53CONFIG_MODULES=y
54CONFIG_MODULE_UNLOAD=y
55# CONFIG_MODULE_FORCE_UNLOAD is not set
56CONFIG_OBSOLETE_MODPARM=y
57# CONFIG_MODVERSIONS is not set
58# CONFIG_MODULE_SRCVERSION_ALL is not set
59CONFIG_KMOD=y
54 60
55# 61#
56# System Type 62# System Type
diff --git a/arch/arm/configs/ixdp2401_defconfig b/arch/arm/configs/ixdp2401_defconfig
index 6f51c98084a3..72e1b940e975 100644
--- a/arch/arm/configs/ixdp2401_defconfig
+++ b/arch/arm/configs/ixdp2401_defconfig
@@ -50,7 +50,13 @@ CONFIG_BASE_SMALL=0
50# 50#
51# Loadable module support 51# Loadable module support
52# 52#
53# CONFIG_MODULES is not set 53CONFIG_MODULES=y
54CONFIG_MODULE_UNLOAD=y
55# CONFIG_MODULE_FORCE_UNLOAD is not set
56CONFIG_OBSOLETE_MODPARM=y
57# CONFIG_MODVERSIONS is not set
58# CONFIG_MODULE_SRCVERSION_ALL is not set
59CONFIG_KMOD=y
54 60
55# 61#
56# System Type 62# System Type
diff --git a/arch/arm/configs/ixdp2800_defconfig b/arch/arm/configs/ixdp2800_defconfig
index 7be3521f91fc..1592e45f0278 100644
--- a/arch/arm/configs/ixdp2800_defconfig
+++ b/arch/arm/configs/ixdp2800_defconfig
@@ -50,7 +50,13 @@ CONFIG_BASE_SMALL=0
50# 50#
51# Loadable module support 51# Loadable module support
52# 52#
53# CONFIG_MODULES is not set 53CONFIG_MODULES=y
54CONFIG_MODULE_UNLOAD=y
55# CONFIG_MODULE_FORCE_UNLOAD is not set
56CONFIG_OBSOLETE_MODPARM=y
57# CONFIG_MODVERSIONS is not set
58# CONFIG_MODULE_SRCVERSION_ALL is not set
59CONFIG_KMOD=y
54 60
55# 61#
56# System Type 62# System Type
diff --git a/arch/arm/configs/ixdp2801_defconfig b/arch/arm/configs/ixdp2801_defconfig
index cd84a20f30f1..f1afe3d09ec6 100644
--- a/arch/arm/configs/ixdp2801_defconfig
+++ b/arch/arm/configs/ixdp2801_defconfig
@@ -50,7 +50,13 @@ CONFIG_BASE_SMALL=0
50# 50#
51# Loadable module support 51# Loadable module support
52# 52#
53# CONFIG_MODULES is not set 53CONFIG_MODULES=y
54CONFIG_MODULE_UNLOAD=y
55# CONFIG_MODULE_FORCE_UNLOAD is not set
56CONFIG_OBSOLETE_MODPARM=y
57# CONFIG_MODVERSIONS is not set
58# CONFIG_MODULE_SRCVERSION_ALL is not set
59CONFIG_KMOD=y
54 60
55# 61#
56# System Type 62# System Type
diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile
index 4a2af55e134b..3e1b0327e4d7 100644
--- a/arch/arm/kernel/Makefile
+++ b/arch/arm/kernel/Makefile
@@ -6,7 +6,7 @@ AFLAGS_head.o := -DTEXTADDR=$(TEXTADDR) -DDATAADDR=$(DATAADDR)
6 6
7# Object file lists. 7# Object file lists.
8 8
9obj-y := arch.o compat.o dma.o entry-armv.o entry-common.o irq.o \ 9obj-y := compat.o dma.o entry-armv.o entry-common.o irq.o \
10 process.o ptrace.o semaphore.o setup.o signal.o sys_arm.o \ 10 process.o ptrace.o semaphore.o setup.o signal.o sys_arm.o \
11 time.o traps.o 11 time.o traps.o
12 12
diff --git a/arch/arm/kernel/arch.c b/arch/arm/kernel/arch.c
deleted file mode 100644
index 4e02fbeb10a6..000000000000
--- a/arch/arm/kernel/arch.c
+++ /dev/null
@@ -1,46 +0,0 @@
1/*
2 * linux/arch/arm/kernel/arch.c
3 *
4 * Architecture specific fixups.
5 */
6#include <linux/config.h>
7#include <linux/init.h>
8#include <linux/types.h>
9
10#include <asm/elf.h>
11#include <asm/page.h>
12#include <asm/setup.h>
13#include <asm/mach/arch.h>
14
15unsigned int vram_size;
16
17#ifdef CONFIG_ARCH_ACORN
18
19unsigned int memc_ctrl_reg;
20unsigned int number_mfm_drives;
21
22static int __init parse_tag_acorn(const struct tag *tag)
23{
24 memc_ctrl_reg = tag->u.acorn.memc_control_reg;
25 number_mfm_drives = tag->u.acorn.adfsdrives;
26
27 switch (tag->u.acorn.vram_pages) {
28 case 512:
29 vram_size += PAGE_SIZE * 256;
30 case 256:
31 vram_size += PAGE_SIZE * 256;
32 default:
33 break;
34 }
35#if 0
36 if (vram_size) {
37 desc->video_start = 0x02000000;
38 desc->video_end = 0x02000000 + vram_size;
39 }
40#endif
41 return 0;
42}
43
44__tagtable(ATAG_ACORN, parse_tag_acorn);
45
46#endif
diff --git a/arch/arm/kernel/ecard.c b/arch/arm/kernel/ecard.c
index 3dc15b131f53..6540db691338 100644
--- a/arch/arm/kernel/ecard.c
+++ b/arch/arm/kernel/ecard.c
@@ -866,19 +866,19 @@ static struct expansion_card *__init ecard_alloc_card(int type, int slot)
866 return ec; 866 return ec;
867} 867}
868 868
869static ssize_t ecard_show_irq(struct device *dev, char *buf) 869static ssize_t ecard_show_irq(struct device *dev, struct device_attribute *attr, char *buf)
870{ 870{
871 struct expansion_card *ec = ECARD_DEV(dev); 871 struct expansion_card *ec = ECARD_DEV(dev);
872 return sprintf(buf, "%u\n", ec->irq); 872 return sprintf(buf, "%u\n", ec->irq);
873} 873}
874 874
875static ssize_t ecard_show_dma(struct device *dev, char *buf) 875static ssize_t ecard_show_dma(struct device *dev, struct device_attribute *attr, char *buf)
876{ 876{
877 struct expansion_card *ec = ECARD_DEV(dev); 877 struct expansion_card *ec = ECARD_DEV(dev);
878 return sprintf(buf, "%u\n", ec->dma); 878 return sprintf(buf, "%u\n", ec->dma);
879} 879}
880 880
881static ssize_t ecard_show_resources(struct device *dev, char *buf) 881static ssize_t ecard_show_resources(struct device *dev, struct device_attribute *attr, char *buf)
882{ 882{
883 struct expansion_card *ec = ECARD_DEV(dev); 883 struct expansion_card *ec = ECARD_DEV(dev);
884 char *str = buf; 884 char *str = buf;
@@ -893,19 +893,19 @@ static ssize_t ecard_show_resources(struct device *dev, char *buf)
893 return str - buf; 893 return str - buf;
894} 894}
895 895
896static ssize_t ecard_show_vendor(struct device *dev, char *buf) 896static ssize_t ecard_show_vendor(struct device *dev, struct device_attribute *attr, char *buf)
897{ 897{
898 struct expansion_card *ec = ECARD_DEV(dev); 898 struct expansion_card *ec = ECARD_DEV(dev);
899 return sprintf(buf, "%u\n", ec->cid.manufacturer); 899 return sprintf(buf, "%u\n", ec->cid.manufacturer);
900} 900}
901 901
902static ssize_t ecard_show_device(struct device *dev, char *buf) 902static ssize_t ecard_show_device(struct device *dev, struct device_attribute *attr, char *buf)
903{ 903{
904 struct expansion_card *ec = ECARD_DEV(dev); 904 struct expansion_card *ec = ECARD_DEV(dev);
905 return sprintf(buf, "%u\n", ec->cid.product); 905 return sprintf(buf, "%u\n", ec->cid.product);
906} 906}
907 907
908static ssize_t ecard_show_type(struct device *dev, char *buf) 908static ssize_t ecard_show_type(struct device *dev, struct device_attribute *attr, char *buf)
909{ 909{
910 struct expansion_card *ec = ECARD_DEV(dev); 910 struct expansion_card *ec = ECARD_DEV(dev);
911 return sprintf(buf, "%s\n", ec->type == ECARD_EASI ? "EASI" : "IOC"); 911 return sprintf(buf, "%s\n", ec->type == ECARD_EASI ? "EASI" : "IOC");
diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index 45ed036336e0..34892758f098 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -145,7 +145,8 @@ int __init __cpu_up(unsigned int cpu)
145 pgd_free(pgd); 145 pgd_free(pgd);
146 146
147 if (ret) { 147 if (ret) {
148 printk(KERN_CRIT "cpu_up: processor %d failed to boot\n", cpu); 148 printk(KERN_CRIT "CPU%u: processor failed to boot\n", cpu);
149
149 /* 150 /*
150 * FIXME: We need to clean up the new idle thread. --rmk 151 * FIXME: We need to clean up the new idle thread. --rmk
151 */ 152 */
diff --git a/arch/arm/lib/ashldi3.c b/arch/arm/lib/ashldi3.c
index 130f5a839669..b62875cfd8f8 100644
--- a/arch/arm/lib/ashldi3.c
+++ b/arch/arm/lib/ashldi3.c
@@ -31,31 +31,26 @@ Boston, MA 02111-1307, USA. */
31 31
32#include "gcclib.h" 32#include "gcclib.h"
33 33
34DItype 34s64 __ashldi3(s64 u, int b)
35__ashldi3 (DItype u, word_type b)
36{ 35{
37 DIunion w; 36 DIunion w;
38 word_type bm; 37 int bm;
39 DIunion uu; 38 DIunion uu;
40 39
41 if (b == 0) 40 if (b == 0)
42 return u; 41 return u;
43 42
44 uu.ll = u; 43 uu.ll = u;
45 44
46 bm = (sizeof (SItype) * BITS_PER_UNIT) - b; 45 bm = (sizeof(s32) * BITS_PER_UNIT) - b;
47 if (bm <= 0) 46 if (bm <= 0) {
48 { 47 w.s.low = 0;
49 w.s.low = 0; 48 w.s.high = (u32) uu.s.low << -bm;
50 w.s.high = (USItype)uu.s.low << -bm; 49 } else {
51 } 50 u32 carries = (u32) uu.s.low >> bm;
52 else 51 w.s.low = (u32) uu.s.low << b;
53 { 52 w.s.high = ((u32) uu.s.high << b) | carries;
54 USItype carries = (USItype)uu.s.low >> bm; 53 }
55 w.s.low = (USItype)uu.s.low << b; 54
56 w.s.high = ((USItype)uu.s.high << b) | carries; 55 return w.ll;
57 }
58
59 return w.ll;
60} 56}
61
diff --git a/arch/arm/lib/ashrdi3.c b/arch/arm/lib/ashrdi3.c
index 71625d218f8d..9a8600a7543f 100644
--- a/arch/arm/lib/ashrdi3.c
+++ b/arch/arm/lib/ashrdi3.c
@@ -31,31 +31,27 @@ Boston, MA 02111-1307, USA. */
31 31
32#include "gcclib.h" 32#include "gcclib.h"
33 33
34DItype 34s64 __ashrdi3(s64 u, int b)
35__ashrdi3 (DItype u, word_type b)
36{ 35{
37 DIunion w; 36 DIunion w;
38 word_type bm; 37 int bm;
39 DIunion uu; 38 DIunion uu;
40 39
41 if (b == 0) 40 if (b == 0)
42 return u; 41 return u;
43 42
44 uu.ll = u; 43 uu.ll = u;
45 44
46 bm = (sizeof (SItype) * BITS_PER_UNIT) - b; 45 bm = (sizeof(s32) * BITS_PER_UNIT) - b;
47 if (bm <= 0) 46 if (bm <= 0) {
48 { 47 /* w.s.high = 1..1 or 0..0 */
49 /* w.s.high = 1..1 or 0..0 */ 48 w.s.high = uu.s.high >> (sizeof(s32) * BITS_PER_UNIT - 1);
50 w.s.high = uu.s.high >> (sizeof (SItype) * BITS_PER_UNIT - 1); 49 w.s.low = uu.s.high >> -bm;
51 w.s.low = uu.s.high >> -bm; 50 } else {
52 } 51 u32 carries = (u32) uu.s.high << bm;
53 else 52 w.s.high = uu.s.high >> b;
54 { 53 w.s.low = ((u32) uu.s.low >> b) | carries;
55 USItype carries = (USItype)uu.s.high << bm; 54 }
56 w.s.high = uu.s.high >> b; 55
57 w.s.low = ((USItype)uu.s.low >> b) | carries; 56 return w.ll;
58 }
59
60 return w.ll;
61} 57}
diff --git a/arch/arm/lib/gcclib.h b/arch/arm/lib/gcclib.h
index 65314a3d9e27..8b6dcc656de7 100644
--- a/arch/arm/lib/gcclib.h
+++ b/arch/arm/lib/gcclib.h
@@ -1,25 +1,22 @@
1/* gcclib.h -- definitions for various functions 'borrowed' from gcc-2.95.3 */ 1/* gcclib.h -- definitions for various functions 'borrowed' from gcc-2.95.3 */
2/* I Molton 29/07/01 */ 2/* I Molton 29/07/01 */
3 3
4#define BITS_PER_UNIT 8 4#include <linux/types.h>
5#define SI_TYPE_SIZE (sizeof (SItype) * BITS_PER_UNIT)
6 5
7typedef unsigned int UQItype __attribute__ ((mode (QI))); 6#define BITS_PER_UNIT 8
8typedef int SItype __attribute__ ((mode (SI))); 7#define SI_TYPE_SIZE (sizeof(s32) * BITS_PER_UNIT)
9typedef unsigned int USItype __attribute__ ((mode (SI)));
10typedef int DItype __attribute__ ((mode (DI)));
11typedef int word_type __attribute__ ((mode (__word__)));
12typedef unsigned int UDItype __attribute__ ((mode (DI)));
13 8
14#ifdef __ARMEB__ 9#ifdef __ARMEB__
15 struct DIstruct {SItype high, low;}; 10struct DIstruct {
11 s32 high, low;
12};
16#else 13#else
17 struct DIstruct {SItype low, high;}; 14struct DIstruct {
15 s32 low, high;
16};
18#endif 17#endif
19 18
20typedef union 19typedef union {
21{ 20 struct DIstruct s;
22 struct DIstruct s; 21 s64 ll;
23 DItype ll;
24} DIunion; 22} DIunion;
25
diff --git a/arch/arm/lib/longlong.h b/arch/arm/lib/longlong.h
index 179eea4edc35..90ae647e4d76 100644
--- a/arch/arm/lib/longlong.h
+++ b/arch/arm/lib/longlong.h
@@ -26,18 +26,18 @@
26 26
27#define __BITS4 (SI_TYPE_SIZE / 4) 27#define __BITS4 (SI_TYPE_SIZE / 4)
28#define __ll_B (1L << (SI_TYPE_SIZE / 2)) 28#define __ll_B (1L << (SI_TYPE_SIZE / 2))
29#define __ll_lowpart(t) ((USItype) (t) % __ll_B) 29#define __ll_lowpart(t) ((u32) (t) % __ll_B)
30#define __ll_highpart(t) ((USItype) (t) / __ll_B) 30#define __ll_highpart(t) ((u32) (t) / __ll_B)
31 31
32/* Define auxiliary asm macros. 32/* Define auxiliary asm macros.
33 33
34 1) umul_ppmm(high_prod, low_prod, multipler, multiplicand) 34 1) umul_ppmm(high_prod, low_prod, multipler, multiplicand)
35 multiplies two USItype integers MULTIPLER and MULTIPLICAND, 35 multiplies two u32 integers MULTIPLER and MULTIPLICAND,
36 and generates a two-part USItype product in HIGH_PROD and 36 and generates a two-part u32 product in HIGH_PROD and
37 LOW_PROD. 37 LOW_PROD.
38 38
39 2) __umulsidi3(a,b) multiplies two USItype integers A and B, 39 2) __umulsidi3(a,b) multiplies two u32 integers A and B,
40 and returns a UDItype product. This is just a variant of umul_ppmm. 40 and returns a u64 product. This is just a variant of umul_ppmm.
41 41
42 3) udiv_qrnnd(quotient, remainder, high_numerator, low_numerator, 42 3) udiv_qrnnd(quotient, remainder, high_numerator, low_numerator,
43 denominator) divides a two-word unsigned integer, composed by the 43 denominator) divides a two-word unsigned integer, composed by the
@@ -77,23 +77,23 @@
77#define add_ssaaaa(sh, sl, ah, al, bh, bl) \ 77#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
78 __asm__ ("adds %1, %4, %5 \n\ 78 __asm__ ("adds %1, %4, %5 \n\
79 adc %0, %2, %3" \ 79 adc %0, %2, %3" \
80 : "=r" ((USItype) (sh)), \ 80 : "=r" ((u32) (sh)), \
81 "=&r" ((USItype) (sl)) \ 81 "=&r" ((u32) (sl)) \
82 : "%r" ((USItype) (ah)), \ 82 : "%r" ((u32) (ah)), \
83 "rI" ((USItype) (bh)), \ 83 "rI" ((u32) (bh)), \
84 "%r" ((USItype) (al)), \ 84 "%r" ((u32) (al)), \
85 "rI" ((USItype) (bl))) 85 "rI" ((u32) (bl)))
86#define sub_ddmmss(sh, sl, ah, al, bh, bl) \ 86#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
87 __asm__ ("subs %1, %4, %5 \n\ 87 __asm__ ("subs %1, %4, %5 \n\
88 sbc %0, %2, %3" \ 88 sbc %0, %2, %3" \
89 : "=r" ((USItype) (sh)), \ 89 : "=r" ((u32) (sh)), \
90 "=&r" ((USItype) (sl)) \ 90 "=&r" ((u32) (sl)) \
91 : "r" ((USItype) (ah)), \ 91 : "r" ((u32) (ah)), \
92 "rI" ((USItype) (bh)), \ 92 "rI" ((u32) (bh)), \
93 "r" ((USItype) (al)), \ 93 "r" ((u32) (al)), \
94 "rI" ((USItype) (bl))) 94 "rI" ((u32) (bl)))
95#define umul_ppmm(xh, xl, a, b) \ 95#define umul_ppmm(xh, xl, a, b) \
96{register USItype __t0, __t1, __t2; \ 96{register u32 __t0, __t1, __t2; \
97 __asm__ ("%@ Inlined umul_ppmm \n\ 97 __asm__ ("%@ Inlined umul_ppmm \n\
98 mov %2, %5, lsr #16 \n\ 98 mov %2, %5, lsr #16 \n\
99 mov %0, %6, lsr #16 \n\ 99 mov %0, %6, lsr #16 \n\
@@ -107,14 +107,14 @@
107 addcs %0, %0, #65536 \n\ 107 addcs %0, %0, #65536 \n\
108 adds %1, %1, %3, lsl #16 \n\ 108 adds %1, %1, %3, lsl #16 \n\
109 adc %0, %0, %3, lsr #16" \ 109 adc %0, %0, %3, lsr #16" \
110 : "=&r" ((USItype) (xh)), \ 110 : "=&r" ((u32) (xh)), \
111 "=r" ((USItype) (xl)), \ 111 "=r" ((u32) (xl)), \
112 "=&r" (__t0), "=&r" (__t1), "=r" (__t2) \ 112 "=&r" (__t0), "=&r" (__t1), "=r" (__t2) \
113 : "r" ((USItype) (a)), \ 113 : "r" ((u32) (a)), \
114 "r" ((USItype) (b)));} 114 "r" ((u32) (b)));}
115#define UMUL_TIME 20 115#define UMUL_TIME 20
116#define UDIV_TIME 100 116#define UDIV_TIME 100
117#endif /* __arm__ */ 117#endif /* __arm__ */
118 118
119#define __umulsidi3(u, v) \ 119#define __umulsidi3(u, v) \
120 ({DIunion __w; \ 120 ({DIunion __w; \
@@ -123,14 +123,14 @@
123 123
124#define __udiv_qrnnd_c(q, r, n1, n0, d) \ 124#define __udiv_qrnnd_c(q, r, n1, n0, d) \
125 do { \ 125 do { \
126 USItype __d1, __d0, __q1, __q0; \ 126 u32 __d1, __d0, __q1, __q0; \
127 USItype __r1, __r0, __m; \ 127 u32 __r1, __r0, __m; \
128 __d1 = __ll_highpart (d); \ 128 __d1 = __ll_highpart (d); \
129 __d0 = __ll_lowpart (d); \ 129 __d0 = __ll_lowpart (d); \
130 \ 130 \
131 __r1 = (n1) % __d1; \ 131 __r1 = (n1) % __d1; \
132 __q1 = (n1) / __d1; \ 132 __q1 = (n1) / __d1; \
133 __m = (USItype) __q1 * __d0; \ 133 __m = (u32) __q1 * __d0; \
134 __r1 = __r1 * __ll_B | __ll_highpart (n0); \ 134 __r1 = __r1 * __ll_B | __ll_highpart (n0); \
135 if (__r1 < __m) \ 135 if (__r1 < __m) \
136 { \ 136 { \
@@ -143,7 +143,7 @@
143 \ 143 \
144 __r0 = __r1 % __d1; \ 144 __r0 = __r1 % __d1; \
145 __q0 = __r1 / __d1; \ 145 __q0 = __r1 / __d1; \
146 __m = (USItype) __q0 * __d0; \ 146 __m = (u32) __q0 * __d0; \
147 __r0 = __r0 * __ll_B | __ll_lowpart (n0); \ 147 __r0 = __r0 * __ll_B | __ll_lowpart (n0); \
148 if (__r0 < __m) \ 148 if (__r0 < __m) \
149 { \ 149 { \
@@ -154,7 +154,7 @@
154 } \ 154 } \
155 __r0 -= __m; \ 155 __r0 -= __m; \
156 \ 156 \
157 (q) = (USItype) __q1 * __ll_B | __q0; \ 157 (q) = (u32) __q1 * __ll_B | __q0; \
158 (r) = __r0; \ 158 (r) = __r0; \
159 } while (0) 159 } while (0)
160 160
@@ -163,14 +163,14 @@
163 163
164#define count_leading_zeros(count, x) \ 164#define count_leading_zeros(count, x) \
165 do { \ 165 do { \
166 USItype __xr = (x); \ 166 u32 __xr = (x); \
167 USItype __a; \ 167 u32 __a; \
168 \ 168 \
169 if (SI_TYPE_SIZE <= 32) \ 169 if (SI_TYPE_SIZE <= 32) \
170 { \ 170 { \
171 __a = __xr < ((USItype)1<<2*__BITS4) \ 171 __a = __xr < ((u32)1<<2*__BITS4) \
172 ? (__xr < ((USItype)1<<__BITS4) ? 0 : __BITS4) \ 172 ? (__xr < ((u32)1<<__BITS4) ? 0 : __BITS4) \
173 : (__xr < ((USItype)1<<3*__BITS4) ? 2*__BITS4 : 3*__BITS4); \ 173 : (__xr < ((u32)1<<3*__BITS4) ? 2*__BITS4 : 3*__BITS4); \
174 } \ 174 } \
175 else \ 175 else \
176 { \ 176 { \
diff --git a/arch/arm/lib/lshrdi3.c b/arch/arm/lib/lshrdi3.c
index b666f1bad451..3681f49d2b6e 100644
--- a/arch/arm/lib/lshrdi3.c
+++ b/arch/arm/lib/lshrdi3.c
@@ -31,31 +31,26 @@ Boston, MA 02111-1307, USA. */
31 31
32#include "gcclib.h" 32#include "gcclib.h"
33 33
34DItype 34s64 __lshrdi3(s64 u, int b)
35__lshrdi3 (DItype u, word_type b)
36{ 35{
37 DIunion w; 36 DIunion w;
38 word_type bm; 37 int bm;
39 DIunion uu; 38 DIunion uu;
40 39
41 if (b == 0) 40 if (b == 0)
42 return u; 41 return u;
43 42
44 uu.ll = u; 43 uu.ll = u;
45 44
46 bm = (sizeof (SItype) * BITS_PER_UNIT) - b; 45 bm = (sizeof(s32) * BITS_PER_UNIT) - b;
47 if (bm <= 0) 46 if (bm <= 0) {
48 { 47 w.s.high = 0;
49 w.s.high = 0; 48 w.s.low = (u32) uu.s.high >> -bm;
50 w.s.low = (USItype)uu.s.high >> -bm; 49 } else {
51 } 50 u32 carries = (u32) uu.s.high << bm;
52 else 51 w.s.high = (u32) uu.s.high >> b;
53 { 52 w.s.low = ((u32) uu.s.low >> b) | carries;
54 USItype carries = (USItype)uu.s.high << bm; 53 }
55 w.s.high = (USItype)uu.s.high >> b; 54
56 w.s.low = ((USItype)uu.s.low >> b) | carries; 55 return w.ll;
57 }
58
59 return w.ll;
60} 56}
61
diff --git a/arch/arm/lib/muldi3.c b/arch/arm/lib/muldi3.c
index 44d611b1cfdb..0a3b93313f18 100644
--- a/arch/arm/lib/muldi3.c
+++ b/arch/arm/lib/muldi3.c
@@ -32,7 +32,7 @@ Boston, MA 02111-1307, USA. */
32#include "gcclib.h" 32#include "gcclib.h"
33 33
34#define umul_ppmm(xh, xl, a, b) \ 34#define umul_ppmm(xh, xl, a, b) \
35{register USItype __t0, __t1, __t2; \ 35{register u32 __t0, __t1, __t2; \
36 __asm__ ("%@ Inlined umul_ppmm \n\ 36 __asm__ ("%@ Inlined umul_ppmm \n\
37 mov %2, %5, lsr #16 \n\ 37 mov %2, %5, lsr #16 \n\
38 mov %0, %6, lsr #16 \n\ 38 mov %0, %6, lsr #16 \n\
@@ -46,32 +46,27 @@ Boston, MA 02111-1307, USA. */
46 addcs %0, %0, #65536 \n\ 46 addcs %0, %0, #65536 \n\
47 adds %1, %1, %3, lsl #16 \n\ 47 adds %1, %1, %3, lsl #16 \n\
48 adc %0, %0, %3, lsr #16" \ 48 adc %0, %0, %3, lsr #16" \
49 : "=&r" ((USItype) (xh)), \ 49 : "=&r" ((u32) (xh)), \
50 "=r" ((USItype) (xl)), \ 50 "=r" ((u32) (xl)), \
51 "=&r" (__t0), "=&r" (__t1), "=r" (__t2) \ 51 "=&r" (__t0), "=&r" (__t1), "=r" (__t2) \
52 : "r" ((USItype) (a)), \ 52 : "r" ((u32) (a)), \
53 "r" ((USItype) (b)));} 53 "r" ((u32) (b)));}
54
55 54
56#define __umulsidi3(u, v) \ 55#define __umulsidi3(u, v) \
57 ({DIunion __w; \ 56 ({DIunion __w; \
58 umul_ppmm (__w.s.high, __w.s.low, u, v); \ 57 umul_ppmm (__w.s.high, __w.s.low, u, v); \
59 __w.ll; }) 58 __w.ll; })
60 59
61 60s64 __muldi3(s64 u, s64 v)
62DItype
63__muldi3 (DItype u, DItype v)
64{ 61{
65 DIunion w; 62 DIunion w;
66 DIunion uu, vv; 63 DIunion uu, vv;
67 64
68 uu.ll = u, 65 uu.ll = u, vv.ll = v;
69 vv.ll = v;
70 66
71 w.ll = __umulsidi3 (uu.s.low, vv.s.low); 67 w.ll = __umulsidi3(uu.s.low, vv.s.low);
72 w.s.high += ((USItype) uu.s.low * (USItype) vv.s.high 68 w.s.high += ((u32) uu.s.low * (u32) vv.s.high
73 + (USItype) uu.s.high * (USItype) vv.s.low); 69 + (u32) uu.s.high * (u32) vv.s.low);
74 70
75 return w.ll; 71 return w.ll;
76} 72}
77
diff --git a/arch/arm/lib/ucmpdi2.c b/arch/arm/lib/ucmpdi2.c
index 6c6ae63efa02..57f3f2df3850 100644
--- a/arch/arm/lib/ucmpdi2.c
+++ b/arch/arm/lib/ucmpdi2.c
@@ -31,21 +31,19 @@ Boston, MA 02111-1307, USA. */
31 31
32#include "gcclib.h" 32#include "gcclib.h"
33 33
34word_type 34int __ucmpdi2(s64 a, s64 b)
35__ucmpdi2 (DItype a, DItype b)
36{ 35{
37 DIunion au, bu; 36 DIunion au, bu;
38 37
39 au.ll = a, bu.ll = b; 38 au.ll = a, bu.ll = b;
40 39
41 if ((USItype) au.s.high < (USItype) bu.s.high) 40 if ((u32) au.s.high < (u32) bu.s.high)
42 return 0; 41 return 0;
43 else if ((USItype) au.s.high > (USItype) bu.s.high) 42 else if ((u32) au.s.high > (u32) bu.s.high)
44 return 2; 43 return 2;
45 if ((USItype) au.s.low < (USItype) bu.s.low) 44 if ((u32) au.s.low < (u32) bu.s.low)
46 return 0; 45 return 0;
47 else if ((USItype) au.s.low > (USItype) bu.s.low) 46 else if ((u32) au.s.low > (u32) bu.s.low)
48 return 2; 47 return 2;
49 return 1; 48 return 1;
50} 49}
51
diff --git a/arch/arm/lib/udivdi3.c b/arch/arm/lib/udivdi3.c
index d25195f673f4..e343be4c6642 100644
--- a/arch/arm/lib/udivdi3.c
+++ b/arch/arm/lib/udivdi3.c
@@ -32,211 +32,191 @@ Boston, MA 02111-1307, USA. */
32#include "gcclib.h" 32#include "gcclib.h"
33#include "longlong.h" 33#include "longlong.h"
34 34
35static const UQItype __clz_tab[] = 35static const u8 __clz_tab[] = {
36{ 36 0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5,
37 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, 37 5, 5, 5, 5, 5, 5, 5, 5,
38 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, 38 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
39 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 39 6, 6, 6, 6, 6, 6, 6, 6,
40 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 40 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
41 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 41 7, 7, 7, 7, 7, 7, 7, 7,
42 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 42 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
43 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 43 7, 7, 7, 7, 7, 7, 7, 7,
44 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 44 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
45 8, 8, 8, 8, 8, 8, 8, 8,
46 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
47 8, 8, 8, 8, 8, 8, 8, 8,
48 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
49 8, 8, 8, 8, 8, 8, 8, 8,
50 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
51 8, 8, 8, 8, 8, 8, 8, 8,
45}; 52};
46 53
47UDItype 54u64 __udivmoddi4(u64 n, u64 d, u64 * rp)
48__udivmoddi4 (UDItype n, UDItype d, UDItype *rp)
49{ 55{
50 DIunion ww; 56 DIunion ww;
51 DIunion nn, dd; 57 DIunion nn, dd;
52 DIunion rr; 58 DIunion rr;
53 USItype d0, d1, n0, n1, n2; 59 u32 d0, d1, n0, n1, n2;
54 USItype q0, q1; 60 u32 q0, q1;
55 USItype b, bm; 61 u32 b, bm;
56 62
57 nn.ll = n; 63 nn.ll = n;
58 dd.ll = d; 64 dd.ll = d;
59 65
60 d0 = dd.s.low; 66 d0 = dd.s.low;
61 d1 = dd.s.high; 67 d1 = dd.s.high;
62 n0 = nn.s.low; 68 n0 = nn.s.low;
63 n1 = nn.s.high; 69 n1 = nn.s.high;
64 70
65 if (d1 == 0) 71 if (d1 == 0) {
66 { 72 if (d0 > n1) {
67 if (d0 > n1) 73 /* 0q = nn / 0D */
68 { 74
69 /* 0q = nn / 0D */ 75 count_leading_zeros(bm, d0);
70 76
71 count_leading_zeros (bm, d0); 77 if (bm != 0) {
72 78 /* Normalize, i.e. make the most significant bit of the
73 if (bm != 0) 79 denominator set. */
74 { 80
75 /* Normalize, i.e. make the most significant bit of the 81 d0 = d0 << bm;
76 denominator set. */ 82 n1 = (n1 << bm) | (n0 >> (SI_TYPE_SIZE - bm));
77 83 n0 = n0 << bm;
78 d0 = d0 << bm; 84 }
79 n1 = (n1 << bm) | (n0 >> (SI_TYPE_SIZE - bm)); 85
80 n0 = n0 << bm; 86 udiv_qrnnd(q0, n0, n1, n0, d0);
81 } 87 q1 = 0;
82 88
83 udiv_qrnnd (q0, n0, n1, n0, d0); 89 /* Remainder in n0 >> bm. */
84 q1 = 0; 90 } else {
85 91 /* qq = NN / 0d */
86 /* Remainder in n0 >> bm. */ 92
87 } 93 if (d0 == 0)
88 else 94 d0 = 1 / d0; /* Divide intentionally by zero. */
89 { 95
90 /* qq = NN / 0d */ 96 count_leading_zeros(bm, d0);
91 97
92 if (d0 == 0) 98 if (bm == 0) {
93 d0 = 1 / d0; /* Divide intentionally by zero. */ 99 /* From (n1 >= d0) /\ (the most significant bit of d0 is set),
94 100 conclude (the most significant bit of n1 is set) /\ (the
95 count_leading_zeros (bm, d0); 101 leading quotient digit q1 = 1).
96 102
97 if (bm == 0) 103 This special case is necessary, not an optimization.
98 { 104 (Shifts counts of SI_TYPE_SIZE are undefined.) */
99 /* From (n1 >= d0) /\ (the most significant bit of d0 is set), 105
100 conclude (the most significant bit of n1 is set) /\ (the 106 n1 -= d0;
101 leading quotient digit q1 = 1). 107 q1 = 1;
102 108 } else {
103 This special case is necessary, not an optimization. 109 /* Normalize. */
104 (Shifts counts of SI_TYPE_SIZE are undefined.) */ 110
105 111 b = SI_TYPE_SIZE - bm;
106 n1 -= d0; 112
107 q1 = 1; 113 d0 = d0 << bm;
108 } 114 n2 = n1 >> b;
109 else 115 n1 = (n1 << bm) | (n0 >> b);
110 { 116 n0 = n0 << bm;
111 /* Normalize. */ 117
112 118 udiv_qrnnd(q1, n1, n2, n1, d0);
113 b = SI_TYPE_SIZE - bm; 119 }
114 120
115 d0 = d0 << bm; 121 /* n1 != d0... */
116 n2 = n1 >> b; 122
117 n1 = (n1 << bm) | (n0 >> b); 123 udiv_qrnnd(q0, n0, n1, n0, d0);
118 n0 = n0 << bm; 124
119 125 /* Remainder in n0 >> bm. */
120 udiv_qrnnd (q1, n1, n2, n1, d0); 126 }
121 } 127
122 128 if (rp != 0) {
123 /* n1 != d0... */ 129 rr.s.low = n0 >> bm;
124 130 rr.s.high = 0;
125 udiv_qrnnd (q0, n0, n1, n0, d0); 131 *rp = rr.ll;
126 132 }
127 /* Remainder in n0 >> bm. */ 133 } else {
128 } 134 if (d1 > n1) {
129 135 /* 00 = nn / DD */
130 if (rp != 0) 136
131 { 137 q0 = 0;
132 rr.s.low = n0 >> bm; 138 q1 = 0;
133 rr.s.high = 0; 139
134 *rp = rr.ll; 140 /* Remainder in n1n0. */
135 } 141 if (rp != 0) {
136 } 142 rr.s.low = n0;
137 else 143 rr.s.high = n1;
138 { 144 *rp = rr.ll;
139 if (d1 > n1) 145 }
140 { 146 } else {
141 /* 00 = nn / DD */ 147 /* 0q = NN / dd */
142 148
143 q0 = 0; 149 count_leading_zeros(bm, d1);
144 q1 = 0; 150 if (bm == 0) {
145 151 /* From (n1 >= d1) /\ (the most significant bit of d1 is set),
146 /* Remainder in n1n0. */ 152 conclude (the most significant bit of n1 is set) /\ (the
147 if (rp != 0) 153 quotient digit q0 = 0 or 1).
148 { 154
149 rr.s.low = n0; 155 This special case is necessary, not an optimization. */
150 rr.s.high = n1; 156
151 *rp = rr.ll; 157 /* The condition on the next line takes advantage of that
152 } 158 n1 >= d1 (true due to program flow). */
153 } 159 if (n1 > d1 || n0 >= d0) {
154 else 160 q0 = 1;
155 { 161 sub_ddmmss(n1, n0, n1, n0, d1, d0);
156 /* 0q = NN / dd */ 162 } else
157 163 q0 = 0;
158 count_leading_zeros (bm, d1); 164
159 if (bm == 0) 165 q1 = 0;
160 { 166
161 /* From (n1 >= d1) /\ (the most significant bit of d1 is set), 167 if (rp != 0) {
162 conclude (the most significant bit of n1 is set) /\ (the 168 rr.s.low = n0;
163 quotient digit q0 = 0 or 1). 169 rr.s.high = n1;
164 170 *rp = rr.ll;
165 This special case is necessary, not an optimization. */ 171 }
166 172 } else {
167 /* The condition on the next line takes advantage of that 173 u32 m1, m0;
168 n1 >= d1 (true due to program flow). */ 174 /* Normalize. */
169 if (n1 > d1 || n0 >= d0) 175
170 { 176 b = SI_TYPE_SIZE - bm;
171 q0 = 1; 177
172 sub_ddmmss (n1, n0, n1, n0, d1, d0); 178 d1 = (d1 << bm) | (d0 >> b);
173 } 179 d0 = d0 << bm;
174 else 180 n2 = n1 >> b;
175 q0 = 0; 181 n1 = (n1 << bm) | (n0 >> b);
176 182 n0 = n0 << bm;
177 q1 = 0; 183
178 184 udiv_qrnnd(q0, n1, n2, n1, d1);
179 if (rp != 0) 185 umul_ppmm(m1, m0, q0, d0);
180 { 186
181 rr.s.low = n0; 187 if (m1 > n1 || (m1 == n1 && m0 > n0)) {
182 rr.s.high = n1; 188 q0--;
183 *rp = rr.ll; 189 sub_ddmmss(m1, m0, m1, m0, d1, d0);
184 } 190 }
185 } 191
186 else 192 q1 = 0;
187 { 193
188 USItype m1, m0; 194 /* Remainder in (n1n0 - m1m0) >> bm. */
189 /* Normalize. */ 195 if (rp != 0) {
190 196 sub_ddmmss(n1, n0, n1, n0, m1, m0);
191 b = SI_TYPE_SIZE - bm; 197 rr.s.low = (n1 << b) | (n0 >> bm);
192 198 rr.s.high = n1 >> bm;
193 d1 = (d1 << bm) | (d0 >> b); 199 *rp = rr.ll;
194 d0 = d0 << bm; 200 }
195 n2 = n1 >> b; 201 }
196 n1 = (n1 << bm) | (n0 >> b); 202 }
197 n0 = n0 << bm; 203 }
198 204
199 udiv_qrnnd (q0, n1, n2, n1, d1); 205 ww.s.low = q0;
200 umul_ppmm (m1, m0, q0, d0); 206 ww.s.high = q1;
201 207 return ww.ll;
202 if (m1 > n1 || (m1 == n1 && m0 > n0))
203 {
204 q0--;
205 sub_ddmmss (m1, m0, m1, m0, d1, d0);
206 }
207
208 q1 = 0;
209
210 /* Remainder in (n1n0 - m1m0) >> bm. */
211 if (rp != 0)
212 {
213 sub_ddmmss (n1, n0, n1, n0, m1, m0);
214 rr.s.low = (n1 << b) | (n0 >> bm);
215 rr.s.high = n1 >> bm;
216 *rp = rr.ll;
217 }
218 }
219 }
220 }
221
222 ww.s.low = q0;
223 ww.s.high = q1;
224 return ww.ll;
225} 208}
226 209
227UDItype 210u64 __udivdi3(u64 n, u64 d)
228__udivdi3 (UDItype n, UDItype d)
229{ 211{
230 return __udivmoddi4 (n, d, (UDItype *) 0); 212 return __udivmoddi4(n, d, (u64 *) 0);
231} 213}
232 214
233UDItype 215u64 __umoddi3(u64 u, u64 v)
234__umoddi3 (UDItype u, UDItype v)
235{ 216{
236 UDItype w; 217 u64 w;
237 218
238 (void) __udivmoddi4 (u ,v, &w); 219 (void)__udivmoddi4(u, v, &w);
239 220
240 return w; 221 return w;
241} 222}
242
diff --git a/arch/arm/mach-aaec2000/Kconfig b/arch/arm/mach-aaec2000/Kconfig
new file mode 100644
index 000000000000..5e4bef93754c
--- /dev/null
+++ b/arch/arm/mach-aaec2000/Kconfig
@@ -0,0 +1,11 @@
1if ARCH_AAEC2000
2
3menu "Agilent AAEC-2000 Implementations"
4
5config MACH_AAED2000
6 bool "Agilent AAED-2000 Development Platform"
7 select CPU_ARM920T
8
9endmenu
10
11endif
diff --git a/arch/arm/mach-aaec2000/Makefile b/arch/arm/mach-aaec2000/Makefile
new file mode 100644
index 000000000000..20ec83896c37
--- /dev/null
+++ b/arch/arm/mach-aaec2000/Makefile
@@ -0,0 +1,9 @@
1#
2# Makefile for the linux kernel.
3#
4
5# Common support (must be linked before board specific support)
6obj-y += core.o
7
8# Specific board support
9obj-$(CONFIG_MACH_AAED2000) += aaed2000.o
diff --git a/arch/arm/mach-aaec2000/aaed2000.c b/arch/arm/mach-aaec2000/aaed2000.c
new file mode 100644
index 000000000000..5417ca3f4621
--- /dev/null
+++ b/arch/arm/mach-aaec2000/aaed2000.c
@@ -0,0 +1,48 @@
1/*
2 * linux/arch/arm/mach-aaec2000/aaed2000.c
3 *
4 * Support for the Agilent AAED-2000 Development Platform.
5 *
6 * Copyright (c) 2005 Nicolas Bellido Y Ortega
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 */
13#include <linux/module.h>
14#include <linux/kernel.h>
15#include <linux/init.h>
16#include <linux/device.h>
17#include <linux/major.h>
18#include <linux/interrupt.h>
19
20#include <asm/setup.h>
21#include <asm/memory.h>
22#include <asm/mach-types.h>
23#include <asm/hardware.h>
24#include <asm/irq.h>
25
26#include <asm/mach/arch.h>
27#include <asm/mach/map.h>
28#include <asm/mach/irq.h>
29
30#include "core.h"
31
32static void __init aaed2000_init_irq(void)
33{
34 aaec2000_init_irq();
35}
36
37static void __init aaed2000_map_io(void)
38{
39 aaec2000_map_io();
40}
41
42MACHINE_START(AAED2000, "Agilent AAED-2000 Development Platform")
43 MAINTAINER("Nicolas Bellido Y Ortega")
44 BOOT_MEM(0xf0000000, PIO_BASE, VIO_BASE)
45 MAPIO(aaed2000_map_io)
46 INITIRQ(aaed2000_init_irq)
47 .timer = &aaec2000_timer,
48MACHINE_END
diff --git a/arch/arm/mach-aaec2000/core.c b/arch/arm/mach-aaec2000/core.c
new file mode 100644
index 000000000000..fc145b3768fa
--- /dev/null
+++ b/arch/arm/mach-aaec2000/core.c
@@ -0,0 +1,157 @@
1/*
2 * linux/arch/arm/mach-aaec2000/core.c
3 *
4 * Code common to all AAEC-2000 machines
5 *
6 * Copyright (c) 2005 Nicolas Bellido Y Ortega
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12#include <linux/config.h>
13#include <linux/module.h>
14#include <linux/kernel.h>
15#include <linux/init.h>
16#include <linux/list.h>
17#include <linux/errno.h>
18#include <linux/interrupt.h>
19#include <linux/timex.h>
20#include <linux/signal.h>
21
22#include <asm/hardware.h>
23#include <asm/irq.h>
24
25#include <asm/mach/irq.h>
26#include <asm/mach/time.h>
27#include <asm/mach/map.h>
28
29/*
30 * Common I/O mapping:
31 *
32 * Static virtual address mappings are as follow:
33 *
34 * 0xf8000000-0xf8001ffff: Devices connected to APB bus
35 * 0xf8002000-0xf8003ffff: Devices connected to AHB bus
36 *
37 * Below 0xe8000000 is reserved for vm allocation.
38 *
39 * The machine specific code must provide the extra mapping beside the
40 * default mapping provided here.
41 */
42static struct map_desc standard_io_desc[] __initdata = {
43 /* virtual physical length type */
44 { VIO_APB_BASE, PIO_APB_BASE, IO_APB_LENGTH, MT_DEVICE },
45 { VIO_AHB_BASE, PIO_AHB_BASE, IO_AHB_LENGTH, MT_DEVICE }
46};
47
48void __init aaec2000_map_io(void)
49{
50 iotable_init(standard_io_desc, ARRAY_SIZE(standard_io_desc));
51}
52
53/*
54 * Interrupt handling routines
55 */
56static void aaec2000_int_ack(unsigned int irq)
57{
58 IRQ_INTSR = 1 << irq;
59}
60
61static void aaec2000_int_mask(unsigned int irq)
62{
63 IRQ_INTENC |= (1 << irq);
64}
65
66static void aaec2000_int_unmask(unsigned int irq)
67{
68 IRQ_INTENS |= (1 << irq);
69}
70
71static struct irqchip aaec2000_irq_chip = {
72 .ack = aaec2000_int_ack,
73 .mask = aaec2000_int_mask,
74 .unmask = aaec2000_int_unmask,
75};
76
77void __init aaec2000_init_irq(void)
78{
79 unsigned int i;
80
81 for (i = 0; i < NR_IRQS; i++) {
82 set_irq_handler(i, do_level_IRQ);
83 set_irq_chip(i, &aaec2000_irq_chip);
84 set_irq_flags(i, IRQF_VALID);
85 }
86
87 /* Disable all interrupts */
88 IRQ_INTENC = 0xffffffff;
89
90 /* Clear any pending interrupts */
91 IRQ_INTSR = IRQ_INTSR;
92}
93
94/*
95 * Time keeping
96 */
97/* IRQs are disabled before entering here from do_gettimeofday() */
98static unsigned long aaec2000_gettimeoffset(void)
99{
100 unsigned long ticks_to_match, elapsed, usec;
101
102 /* Get ticks before next timer match */
103 ticks_to_match = TIMER1_LOAD - TIMER1_VAL;
104
105 /* We need elapsed ticks since last match */
106 elapsed = LATCH - ticks_to_match;
107
108 /* Now, convert them to usec */
109 usec = (unsigned long)(elapsed * (tick_nsec / 1000))/LATCH;
110
111 return usec;
112}
113
114/* We enter here with IRQs enabled */
115static irqreturn_t
116aaec2000_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
117{
118 /* TODO: Check timer accuracy */
119 write_seqlock(&xtime_lock);
120
121 timer_tick(regs);
122 TIMER1_CLEAR = 1;
123
124 write_sequnlock(&xtime_lock);
125
126 return IRQ_HANDLED;
127}
128
129static struct irqaction aaec2000_timer_irq = {
130 .name = "AAEC-2000 Timer Tick",
131 .flags = SA_INTERRUPT,
132 .handler = aaec2000_timer_interrupt
133};
134
135static void __init aaec2000_timer_init(void)
136{
137 /* Disable timer 1 */
138 TIMER1_CTRL = 0;
139
140 /* We have somehow to generate a 100Hz clock.
141 * We then use the 508KHz timer in periodic mode.
142 */
143 TIMER1_LOAD = LATCH;
144 TIMER1_CLEAR = 1; /* Clear interrupt */
145
146 setup_irq(INT_TMR1_OFL, &aaec2000_timer_irq);
147
148 TIMER1_CTRL = TIMER_CTRL_ENABLE |
149 TIMER_CTRL_PERIODIC |
150 TIMER_CTRL_CLKSEL_508K;
151}
152
153struct sys_timer aaec2000_timer = {
154 .init = aaec2000_timer_init,
155 .offset = aaec2000_gettimeoffset,
156};
157
diff --git a/arch/arm/mach-aaec2000/core.h b/arch/arm/mach-aaec2000/core.h
new file mode 100644
index 000000000000..91893d848c16
--- /dev/null
+++ b/arch/arm/mach-aaec2000/core.h
@@ -0,0 +1,16 @@
1/*
2 * linux/arch/arm/mach-aaec2000/core.h
3 *
4 * Copyright (c) 2005 Nicolas Bellido Y Ortega
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 */
11
12struct sys_timer;
13
14extern struct sys_timer aaec2000_timer;
15extern void __init aaec2000_map_io(void);
16extern void __init aaec2000_init_irq(void);
diff --git a/arch/arm/mach-integrator/core.c b/arch/arm/mach-integrator/core.c
index d302f0405fd2..bd1e5e3c9d34 100644
--- a/arch/arm/mach-integrator/core.c
+++ b/arch/arm/mach-integrator/core.c
@@ -227,7 +227,6 @@ integrator_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
227 * primary CPU 227 * primary CPU
228 */ 228 */
229 if (hard_smp_processor_id() == 0) { 229 if (hard_smp_processor_id() == 0) {
230 nmi_tick();
231 timer_tick(regs); 230 timer_tick(regs);
232#ifdef CONFIG_SMP 231#ifdef CONFIG_SMP
233 smp_send_timer(); 232 smp_send_timer();
diff --git a/arch/arm/mach-ixp2000/core.c b/arch/arm/mach-ixp2000/core.c
index 4f3c3d5c781c..fc0555596d6d 100644
--- a/arch/arm/mach-ixp2000/core.c
+++ b/arch/arm/mach-ixp2000/core.c
@@ -162,12 +162,13 @@ void __init ixp2000_map_io(void)
162static unsigned ticks_per_jiffy; 162static unsigned ticks_per_jiffy;
163static unsigned ticks_per_usec; 163static unsigned ticks_per_usec;
164static unsigned next_jiffy_time; 164static unsigned next_jiffy_time;
165static volatile unsigned long *missing_jiffy_timer_csr;
165 166
166unsigned long ixp2000_gettimeoffset (void) 167unsigned long ixp2000_gettimeoffset (void)
167{ 168{
168 unsigned long offset; 169 unsigned long offset;
169 170
170 offset = next_jiffy_time - *IXP2000_T4_CSR; 171 offset = next_jiffy_time - *missing_jiffy_timer_csr;
171 172
172 return offset / ticks_per_usec; 173 return offset / ticks_per_usec;
173} 174}
@@ -179,7 +180,7 @@ static int ixp2000_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
179 /* clear timer 1 */ 180 /* clear timer 1 */
180 ixp2000_reg_write(IXP2000_T1_CLR, 1); 181 ixp2000_reg_write(IXP2000_T1_CLR, 1);
181 182
182 while ((next_jiffy_time - *IXP2000_T4_CSR) > ticks_per_jiffy) { 183 while ((next_jiffy_time - *missing_jiffy_timer_csr) > ticks_per_jiffy) {
183 timer_tick(regs); 184 timer_tick(regs);
184 next_jiffy_time -= ticks_per_jiffy; 185 next_jiffy_time -= ticks_per_jiffy;
185 } 186 }
@@ -197,20 +198,37 @@ static struct irqaction ixp2000_timer_irq = {
197 198
198void __init ixp2000_init_time(unsigned long tick_rate) 199void __init ixp2000_init_time(unsigned long tick_rate)
199{ 200{
200 ixp2000_reg_write(IXP2000_T1_CLR, 0);
201 ixp2000_reg_write(IXP2000_T4_CLR, 0);
202
203 ticks_per_jiffy = (tick_rate + HZ/2) / HZ; 201 ticks_per_jiffy = (tick_rate + HZ/2) / HZ;
204 ticks_per_usec = tick_rate / 1000000; 202 ticks_per_usec = tick_rate / 1000000;
205 203
204 /*
205 * We use timer 1 as our timer interrupt.
206 */
207 ixp2000_reg_write(IXP2000_T1_CLR, 0);
206 ixp2000_reg_write(IXP2000_T1_CLD, ticks_per_jiffy - 1); 208 ixp2000_reg_write(IXP2000_T1_CLD, ticks_per_jiffy - 1);
207 ixp2000_reg_write(IXP2000_T1_CTL, (1 << 7)); 209 ixp2000_reg_write(IXP2000_T1_CTL, (1 << 7));
208 210
209 /* 211 /*
210 * We use T4 as a monotonic counter to track missed jiffies 212 * We use a second timer as a monotonic counter for tracking
213 * missed jiffies. The IXP2000 has four timers, but if we're
214 * on an A-step IXP2800, timer 2 and 3 don't work, so on those
215 * chips we use timer 4. Timer 4 is the only timer that can
216 * be used for the watchdog, so we use timer 2 if we're on a
217 * non-buggy chip.
211 */ 218 */
212 ixp2000_reg_write(IXP2000_T4_CLD, -1); 219 if ((*IXP2000_PRODUCT_ID & 0x001ffef0) == 0x00000000) {
213 ixp2000_reg_write(IXP2000_T4_CTL, (1 << 7)); 220 printk(KERN_INFO "Enabling IXP2800 erratum #25 workaround\n");
221
222 ixp2000_reg_write(IXP2000_T4_CLR, 0);
223 ixp2000_reg_write(IXP2000_T4_CLD, -1);
224 ixp2000_reg_write(IXP2000_T4_CTL, (1 << 7));
225 missing_jiffy_timer_csr = IXP2000_T4_CSR;
226 } else {
227 ixp2000_reg_write(IXP2000_T2_CLR, 0);
228 ixp2000_reg_write(IXP2000_T2_CLD, -1);
229 ixp2000_reg_write(IXP2000_T2_CTL, (1 << 7));
230 missing_jiffy_timer_csr = IXP2000_T2_CSR;
231 }
214 next_jiffy_time = 0xffffffff; 232 next_jiffy_time = 0xffffffff;
215 233
216 /* register for interrupt */ 234 /* register for interrupt */
diff --git a/arch/arm/mach-versatile/Makefile b/arch/arm/mach-versatile/Makefile
index 5d608837757a..ba81e70ed813 100644
--- a/arch/arm/mach-versatile/Makefile
+++ b/arch/arm/mach-versatile/Makefile
@@ -5,3 +5,4 @@
5obj-y := core.o clock.o 5obj-y := core.o clock.o
6obj-$(CONFIG_ARCH_VERSATILE_PB) += versatile_pb.o 6obj-$(CONFIG_ARCH_VERSATILE_PB) += versatile_pb.o
7obj-$(CONFIG_MACH_VERSATILE_AB) += versatile_ab.o 7obj-$(CONFIG_MACH_VERSATILE_AB) += versatile_ab.o
8obj-$(CONFIG_PCI) += pci.o
diff --git a/arch/arm/mach-versatile/core.c b/arch/arm/mach-versatile/core.c
index 302c2a7b9b63..6a7cbea5e098 100644
--- a/arch/arm/mach-versatile/core.c
+++ b/arch/arm/mach-versatile/core.c
@@ -196,11 +196,15 @@ static struct map_desc versatile_io_desc[] __initdata = {
196#ifdef CONFIG_DEBUG_LL 196#ifdef CONFIG_DEBUG_LL
197 { IO_ADDRESS(VERSATILE_UART0_BASE), VERSATILE_UART0_BASE, SZ_4K, MT_DEVICE }, 197 { IO_ADDRESS(VERSATILE_UART0_BASE), VERSATILE_UART0_BASE, SZ_4K, MT_DEVICE },
198#endif 198#endif
199#ifdef FIXME 199#ifdef CONFIG_PCI
200 { PCI_MEMORY_VADDR, PHYS_PCI_MEM_BASE, SZ_16M, MT_DEVICE }, 200 { IO_ADDRESS(VERSATILE_PCI_CORE_BASE), VERSATILE_PCI_CORE_BASE, SZ_4K, MT_DEVICE },
201 { PCI_CONFIG_VADDR, PHYS_PCI_CONFIG_BASE, SZ_16M, MT_DEVICE }, 201 { VERSATILE_PCI_VIRT_BASE, VERSATILE_PCI_BASE, VERSATILE_PCI_BASE_SIZE, MT_DEVICE },
202 { PCI_V3_VADDR, PHYS_PCI_V3_BASE, SZ_512K, MT_DEVICE }, 202 { VERSATILE_PCI_CFG_VIRT_BASE, VERSATILE_PCI_CFG_BASE, VERSATILE_PCI_CFG_BASE_SIZE, MT_DEVICE },
203 { PCI_IO_VADDR, PHYS_PCI_IO_BASE, SZ_64K, MT_DEVICE }, 203#if 0
204 { VERSATILE_PCI_VIRT_MEM_BASE0, VERSATILE_PCI_MEM_BASE0, SZ_16M, MT_DEVICE },
205 { VERSATILE_PCI_VIRT_MEM_BASE1, VERSATILE_PCI_MEM_BASE1, SZ_16M, MT_DEVICE },
206 { VERSATILE_PCI_VIRT_MEM_BASE2, VERSATILE_PCI_MEM_BASE2, SZ_16M, MT_DEVICE },
207#endif
204#endif 208#endif
205}; 209};
206 210
diff --git a/arch/arm/mach-versatile/pci.c b/arch/arm/mach-versatile/pci.c
new file mode 100644
index 000000000000..d1565e851f0e
--- /dev/null
+++ b/arch/arm/mach-versatile/pci.c
@@ -0,0 +1,360 @@
1/*
2 * linux/arch/arm/mach-versatile/pci.c
3 *
4 * (C) Copyright Koninklijke Philips Electronics NV 2004. All rights reserved.
5 * You can redistribute and/or modify this software under the terms of version 2
6 * of the GNU General Public License as published by the Free Software Foundation.
7 * THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED
8 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9 * General Public License for more details.
10 * Koninklijke Philips Electronics nor its subsidiaries is obligated to provide any support for this software.
11 *
12 * ARM Versatile PCI driver.
13 *
14 * 14/04/2005 Initial version, colin.king@philips.com
15 *
16 */
17#include <linux/config.h>
18#include <linux/kernel.h>
19#include <linux/pci.h>
20#include <linux/ptrace.h>
21#include <linux/slab.h>
22#include <linux/ioport.h>
23#include <linux/interrupt.h>
24#include <linux/spinlock.h>
25#include <linux/init.h>
26
27#include <asm/hardware.h>
28#include <asm/io.h>
29#include <asm/irq.h>
30#include <asm/system.h>
31#include <asm/mach/pci.h>
32#include <asm/mach-types.h>
33
34/*
35 * these spaces are mapped using the following base registers:
36 *
37 * Usage Local Bus Memory Base/Map registers used
38 *
39 * Mem 50000000 - 5FFFFFFF LB_BASE0/LB_MAP0, non prefetch
40 * Mem 60000000 - 6FFFFFFF LB_BASE1/LB_MAP1, prefetch
41 * IO 44000000 - 4FFFFFFF LB_BASE2/LB_MAP2, IO
42 * Cfg 42000000 - 42FFFFFF PCI config
43 *
44 */
45#define SYS_PCICTL IO_ADDRESS(VERSATILE_SYS_PCICTL)
46#define PCI_IMAP0 IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0x0)
47#define PCI_IMAP1 IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0x4)
48#define PCI_IMAP2 IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0x8)
49#define PCI_SMAP0 IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0x10)
50#define PCI_SMAP1 IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0x14)
51#define PCI_SMAP2 IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0x18)
52#define PCI_SELFID IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0xc)
53
54#define DEVICE_ID_OFFSET 0x00
55#define CSR_OFFSET 0x04
56#define CLASS_ID_OFFSET 0x08
57
58#define VP_PCI_DEVICE_ID 0x030010ee
59#define VP_PCI_CLASS_ID 0x0b400000
60
61static unsigned long pci_slot_ignore = 0;
62
63static int __init versatile_pci_slot_ignore(char *str)
64{
65 int retval;
66 int slot;
67
68 while ((retval = get_option(&str,&slot))) {
69 if ((slot < 0) || (slot > 31)) {
70 printk("Illegal slot value: %d\n",slot);
71 } else {
72 pci_slot_ignore |= (1 << slot);
73 }
74 }
75 return 1;
76}
77
78__setup("pci_slot_ignore=", versatile_pci_slot_ignore);
79
80
81static unsigned long __pci_addr(struct pci_bus *bus,
82 unsigned int devfn, int offset)
83{
84 unsigned int busnr = bus->number;
85
86 /*
87 * Trap out illegal values
88 */
89 if (offset > 255)
90 BUG();
91 if (busnr > 255)
92 BUG();
93 if (devfn > 255)
94 BUG();
95
96 return (VERSATILE_PCI_CFG_VIRT_BASE | (busnr << 16) |
97 (PCI_SLOT(devfn) << 11) | (PCI_FUNC(devfn) << 8) | offset);
98}
99
100static int versatile_read_config(struct pci_bus *bus, unsigned int devfn, int where,
101 int size, u32 *val)
102{
103 unsigned long addr = __pci_addr(bus, devfn, where);
104 u32 v;
105 int slot = PCI_SLOT(devfn);
106
107 if (pci_slot_ignore & (1 << slot)) {
108 /* Ignore this slot */
109 switch (size) {
110 case 1:
111 v = 0xff;
112 break;
113 case 2:
114 v = 0xffff;
115 break;
116 default:
117 v = 0xffffffff;
118 }
119 } else {
120 switch (size) {
121 case 1:
122 addr &= ~3;
123 v = __raw_readb(addr);
124 break;
125
126 case 2:
127 v = __raw_readl(addr & ~3);
128 if (addr & 2) v >>= 16;
129 v &= 0xffff;
130 break;
131
132 default:
133 addr &= ~3;
134 v = __raw_readl(addr);
135 break;
136 }
137 }
138
139 *val = v;
140 return PCIBIOS_SUCCESSFUL;
141}
142
143static int versatile_write_config(struct pci_bus *bus, unsigned int devfn, int where,
144 int size, u32 val)
145{
146 unsigned long addr = __pci_addr(bus, devfn, where);
147 int slot = PCI_SLOT(devfn);
148
149 if (pci_slot_ignore & (1 << slot)) {
150 return PCIBIOS_SUCCESSFUL;
151 }
152
153 switch (size) {
154 case 1:
155 __raw_writeb((u8)val, addr);
156 break;
157
158 case 2:
159 __raw_writew((u16)val, addr);
160 break;
161
162 case 4:
163 __raw_writel(val, addr);
164 break;
165 }
166
167 return PCIBIOS_SUCCESSFUL;
168}
169
170static struct pci_ops pci_versatile_ops = {
171 .read = versatile_read_config,
172 .write = versatile_write_config,
173};
174
175static struct resource io_mem = {
176 .name = "PCI I/O space",
177 .start = VERSATILE_PCI_MEM_BASE0,
178 .end = VERSATILE_PCI_MEM_BASE0+VERSATILE_PCI_MEM_BASE0_SIZE-1,
179 .flags = IORESOURCE_IO,
180};
181
182static struct resource non_mem = {
183 .name = "PCI non-prefetchable",
184 .start = VERSATILE_PCI_MEM_BASE1,
185 .end = VERSATILE_PCI_MEM_BASE1+VERSATILE_PCI_MEM_BASE1_SIZE-1,
186 .flags = IORESOURCE_MEM,
187};
188
189static struct resource pre_mem = {
190 .name = "PCI prefetchable",
191 .start = VERSATILE_PCI_MEM_BASE2,
192 .end = VERSATILE_PCI_MEM_BASE2+VERSATILE_PCI_MEM_BASE2_SIZE-1,
193 .flags = IORESOURCE_MEM | IORESOURCE_PREFETCH,
194};
195
196static int __init pci_versatile_setup_resources(struct resource **resource)
197{
198 int ret = 0;
199
200 ret = request_resource(&iomem_resource, &io_mem);
201 if (ret) {
202 printk(KERN_ERR "PCI: unable to allocate I/O "
203 "memory region (%d)\n", ret);
204 goto out;
205 }
206 ret = request_resource(&iomem_resource, &non_mem);
207 if (ret) {
208 printk(KERN_ERR "PCI: unable to allocate non-prefetchable "
209 "memory region (%d)\n", ret);
210 goto release_io_mem;
211 }
212 ret = request_resource(&iomem_resource, &pre_mem);
213 if (ret) {
214 printk(KERN_ERR "PCI: unable to allocate prefetchable "
215 "memory region (%d)\n", ret);
216 goto release_non_mem;
217 }
218
219 /*
220 * bus->resource[0] is the IO resource for this bus
221 * bus->resource[1] is the mem resource for this bus
222 * bus->resource[2] is the prefetch mem resource for this bus
223 */
224 resource[0] = &io_mem;
225 resource[1] = &non_mem;
226 resource[2] = &pre_mem;
227
228 goto out;
229
230 release_non_mem:
231 release_resource(&non_mem);
232 release_io_mem:
233 release_resource(&io_mem);
234 out:
235 return ret;
236}
237
238int __init pci_versatile_setup(int nr, struct pci_sys_data *sys)
239{
240 int ret = 0;
241 int i;
242 int myslot = -1;
243 unsigned long val;
244
245 if (nr == 0) {
246 sys->mem_offset = 0;
247 ret = pci_versatile_setup_resources(sys->resource);
248 if (ret < 0) {
249 printk("pci_versatile_setup: resources... oops?\n");
250 goto out;
251 }
252 } else {
253 printk("pci_versatile_setup: resources... nr == 0??\n");
254 goto out;
255 }
256
257 __raw_writel(VERSATILE_PCI_MEM_BASE0 >> 28,PCI_IMAP0);
258 __raw_writel(VERSATILE_PCI_MEM_BASE1 >> 28,PCI_IMAP1);
259 __raw_writel(VERSATILE_PCI_MEM_BASE2 >> 28,PCI_IMAP2);
260
261 __raw_writel(1, SYS_PCICTL);
262
263 val = __raw_readl(SYS_PCICTL);
264 if (!(val & 1)) {
265 printk("Not plugged into PCI backplane!\n");
266 ret = -EIO;
267 goto out;
268 }
269
270 /*
271 * We need to discover the PCI core first to configure itself
272 * before the main PCI probing is performed
273 */
274 for (i=0; i<32; i++) {
275 if ((__raw_readl(VERSATILE_PCI_VIRT_BASE+(i<<11)+DEVICE_ID_OFFSET) == VP_PCI_DEVICE_ID) &&
276 (__raw_readl(VERSATILE_PCI_VIRT_BASE+(i<<11)+CLASS_ID_OFFSET) == VP_PCI_CLASS_ID)) {
277 myslot = i;
278
279 __raw_writel(myslot, PCI_SELFID);
280 val = __raw_readl(VERSATILE_PCI_CFG_VIRT_BASE+(myslot<<11)+CSR_OFFSET);
281 val |= (1<<2);
282 __raw_writel(val, VERSATILE_PCI_CFG_VIRT_BASE+(myslot<<11)+CSR_OFFSET);
283 break;
284 }
285 }
286
287 if (myslot == -1) {
288 printk("Cannot find PCI core!\n");
289 ret = -EIO;
290 } else {
291 printk("PCI core found (slot %d)\n",myslot);
292 /* Do not to map Versatile FPGA PCI device
293 into memory space as we are short of
294 mappable memory */
295 pci_slot_ignore |= (1 << myslot);
296 ret = 1;
297 }
298
299 out:
300 return ret;
301}
302
303
304struct pci_bus *pci_versatile_scan_bus(int nr, struct pci_sys_data *sys)
305{
306 return pci_scan_bus(sys->busnr, &pci_versatile_ops, sys);
307}
308
309/*
310 * V3_LB_BASE? - local bus address
311 * V3_LB_MAP? - pci bus address
312 */
313void __init pci_versatile_preinit(void)
314{
315}
316
317void __init pci_versatile_postinit(void)
318{
319}
320
321
322/*
323 * map the specified device/slot/pin to an IRQ. Different backplanes may need to modify this.
324 */
325static int __init versatile_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
326{
327 int irq;
328 int devslot = PCI_SLOT(dev->devfn);
329
330 /* slot, pin, irq
331 24 1 27
332 25 1 28 untested
333 26 1 29
334 27 1 30 untested
335 */
336
337 irq = 27 + ((slot + pin + 2) % 3); /* Fudged */
338
339 printk("map irq: slot %d, pin %d, devslot %d, irq: %d\n",slot,pin,devslot,irq);
340
341 return irq;
342}
343
344static struct hw_pci versatile_pci __initdata = {
345 .swizzle = NULL,
346 .map_irq = versatile_map_irq,
347 .nr_controllers = 1,
348 .setup = pci_versatile_setup,
349 .scan = pci_versatile_scan_bus,
350 .preinit = pci_versatile_preinit,
351 .postinit = pci_versatile_postinit,
352};
353
354static int __init versatile_pci_init(void)
355{
356 pci_common_init(&versatile_pci);
357 return 0;
358}
359
360subsys_initcall(versatile_pci_init);
diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
index 3fefb43c67f7..95606b4a3ba6 100644
--- a/arch/arm/mm/Kconfig
+++ b/arch/arm/mm/Kconfig
@@ -62,7 +62,7 @@ config CPU_ARM720T
62# ARM920T 62# ARM920T
63config CPU_ARM920T 63config CPU_ARM920T
64 bool "Support ARM920T processor" if !ARCH_S3C2410 64 bool "Support ARM920T processor" if !ARCH_S3C2410
65 depends on ARCH_INTEGRATOR || ARCH_S3C2410 || ARCH_IMX 65 depends on ARCH_INTEGRATOR || ARCH_S3C2410 || ARCH_IMX || ARCH_AAEC2000
66 default y if ARCH_S3C2410 66 default y if ARCH_S3C2410
67 select CPU_32v4 67 select CPU_32v4
68 select CPU_ABRT_EV4T 68 select CPU_ABRT_EV4T
diff --git a/arch/arm/mm/copypage-v6.c b/arch/arm/mm/copypage-v6.c
index a8c00236bd3d..27d041574ea7 100644
--- a/arch/arm/mm/copypage-v6.c
+++ b/arch/arm/mm/copypage-v6.c
@@ -30,8 +30,6 @@
30 30
31static DEFINE_SPINLOCK(v6_lock); 31static DEFINE_SPINLOCK(v6_lock);
32 32
33#define DCACHE_COLOUR(vaddr) ((vaddr & (SHMLBA - 1)) >> PAGE_SHIFT)
34
35/* 33/*
36 * Copy the user page. No aliasing to deal with so we can just 34 * Copy the user page. No aliasing to deal with so we can just
37 * attack the kernel's existing mapping of these pages. 35 * attack the kernel's existing mapping of these pages.
@@ -55,7 +53,7 @@ void v6_clear_user_page_nonaliasing(void *kaddr, unsigned long vaddr)
55 */ 53 */
56void v6_copy_user_page_aliasing(void *kto, const void *kfrom, unsigned long vaddr) 54void v6_copy_user_page_aliasing(void *kto, const void *kfrom, unsigned long vaddr)
57{ 55{
58 unsigned int offset = DCACHE_COLOUR(vaddr); 56 unsigned int offset = CACHE_COLOUR(vaddr);
59 unsigned long from, to; 57 unsigned long from, to;
60 58
61 /* 59 /*
@@ -95,7 +93,7 @@ void v6_copy_user_page_aliasing(void *kto, const void *kfrom, unsigned long vadd
95 */ 93 */
96void v6_clear_user_page_aliasing(void *kaddr, unsigned long vaddr) 94void v6_clear_user_page_aliasing(void *kaddr, unsigned long vaddr)
97{ 95{
98 unsigned int offset = DCACHE_COLOUR(vaddr); 96 unsigned int offset = CACHE_COLOUR(vaddr);
99 unsigned long to = to_address + (offset << PAGE_SHIFT); 97 unsigned long to = to_address + (offset << PAGE_SHIFT);
100 98
101 /* 99 /*
diff --git a/arch/arm/mm/fault-armv.c b/arch/arm/mm/fault-armv.c
index 01967ddeef53..be4ab3d73c91 100644
--- a/arch/arm/mm/fault-armv.c
+++ b/arch/arm/mm/fault-armv.c
@@ -77,9 +77,8 @@ no_pmd:
77} 77}
78 78
79static void 79static void
80make_coherent(struct vm_area_struct *vma, unsigned long addr, struct page *page, int dirty) 80make_coherent(struct address_space *mapping, struct vm_area_struct *vma, unsigned long addr, unsigned long pfn)
81{ 81{
82 struct address_space *mapping = page_mapping(page);
83 struct mm_struct *mm = vma->vm_mm; 82 struct mm_struct *mm = vma->vm_mm;
84 struct vm_area_struct *mpnt; 83 struct vm_area_struct *mpnt;
85 struct prio_tree_iter iter; 84 struct prio_tree_iter iter;
@@ -87,9 +86,6 @@ make_coherent(struct vm_area_struct *vma, unsigned long addr, struct page *page,
87 pgoff_t pgoff; 86 pgoff_t pgoff;
88 int aliases = 0; 87 int aliases = 0;
89 88
90 if (!mapping)
91 return;
92
93 pgoff = vma->vm_pgoff + ((addr - vma->vm_start) >> PAGE_SHIFT); 89 pgoff = vma->vm_pgoff + ((addr - vma->vm_start) >> PAGE_SHIFT);
94 90
95 /* 91 /*
@@ -115,9 +111,11 @@ make_coherent(struct vm_area_struct *vma, unsigned long addr, struct page *page,
115 if (aliases) 111 if (aliases)
116 adjust_pte(vma, addr); 112 adjust_pte(vma, addr);
117 else 113 else
118 flush_cache_page(vma, addr, page_to_pfn(page)); 114 flush_cache_page(vma, addr, pfn);
119} 115}
120 116
117void __flush_dcache_page(struct address_space *mapping, struct page *page);
118
121/* 119/*
122 * Take care of architecture specific things when placing a new PTE into 120 * Take care of architecture specific things when placing a new PTE into
123 * a page table, or changing an existing PTE. Basically, there are two 121 * a page table, or changing an existing PTE. Basically, there are two
@@ -134,29 +132,22 @@ make_coherent(struct vm_area_struct *vma, unsigned long addr, struct page *page,
134void update_mmu_cache(struct vm_area_struct *vma, unsigned long addr, pte_t pte) 132void update_mmu_cache(struct vm_area_struct *vma, unsigned long addr, pte_t pte)
135{ 133{
136 unsigned long pfn = pte_pfn(pte); 134 unsigned long pfn = pte_pfn(pte);
135 struct address_space *mapping;
137 struct page *page; 136 struct page *page;
138 137
139 if (!pfn_valid(pfn)) 138 if (!pfn_valid(pfn))
140 return; 139 return;
140
141 page = pfn_to_page(pfn); 141 page = pfn_to_page(pfn);
142 if (page_mapping(page)) { 142 mapping = page_mapping(page);
143 if (mapping) {
143 int dirty = test_and_clear_bit(PG_dcache_dirty, &page->flags); 144 int dirty = test_and_clear_bit(PG_dcache_dirty, &page->flags);
144 145
145 if (dirty) { 146 if (dirty)
146 /* 147 __flush_dcache_page(mapping, page);
147 * This is our first userspace mapping of this page.
148 * Ensure that the physical page is coherent with
149 * the kernel mapping.
150 *
151 * FIXME: only need to do this on VIVT and aliasing
152 * VIPT cache architectures. We can do that
153 * by choosing whether to set this bit...
154 */
155 __cpuc_flush_dcache_page(page_address(page));
156 }
157 148
158 if (cache_is_vivt()) 149 if (cache_is_vivt())
159 make_coherent(vma, addr, page, dirty); 150 make_coherent(mapping, vma, addr, pfn);
160 } 151 }
161} 152}
162 153
diff --git a/arch/arm/mm/flush.c b/arch/arm/mm/flush.c
index 4085ed983e46..191788fb18d1 100644
--- a/arch/arm/mm/flush.c
+++ b/arch/arm/mm/flush.c
@@ -37,13 +37,8 @@ static void flush_pfn_alias(unsigned long pfn, unsigned long vaddr)
37#define flush_pfn_alias(pfn,vaddr) do { } while (0) 37#define flush_pfn_alias(pfn,vaddr) do { } while (0)
38#endif 38#endif
39 39
40static void __flush_dcache_page(struct address_space *mapping, struct page *page) 40void __flush_dcache_page(struct address_space *mapping, struct page *page)
41{ 41{
42 struct mm_struct *mm = current->active_mm;
43 struct vm_area_struct *mpnt;
44 struct prio_tree_iter iter;
45 pgoff_t pgoff;
46
47 /* 42 /*
48 * Writeback any data associated with the kernel mapping of this 43 * Writeback any data associated with the kernel mapping of this
49 * page. This ensures that data in the physical page is mutually 44 * page. This ensures that data in the physical page is mutually
@@ -52,24 +47,21 @@ static void __flush_dcache_page(struct address_space *mapping, struct page *page
52 __cpuc_flush_dcache_page(page_address(page)); 47 __cpuc_flush_dcache_page(page_address(page));
53 48
54 /* 49 /*
55 * If there's no mapping pointer here, then this page isn't 50 * If this is a page cache page, and we have an aliasing VIPT cache,
56 * visible to userspace yet, so there are no cache lines 51 * we only need to do one flush - which would be at the relevant
57 * associated with any other aliases.
58 */
59 if (!mapping)
60 return;
61
62 /*
63 * This is a page cache page. If we have a VIPT cache, we
64 * only need to do one flush - which would be at the relevant
65 * userspace colour, which is congruent with page->index. 52 * userspace colour, which is congruent with page->index.
66 */ 53 */
67 if (cache_is_vipt()) { 54 if (mapping && cache_is_vipt_aliasing())
68 if (cache_is_vipt_aliasing()) 55 flush_pfn_alias(page_to_pfn(page),
69 flush_pfn_alias(page_to_pfn(page), 56 page->index << PAGE_CACHE_SHIFT);
70 page->index << PAGE_CACHE_SHIFT); 57}
71 return; 58
72 } 59static void __flush_dcache_aliases(struct address_space *mapping, struct page *page)
60{
61 struct mm_struct *mm = current->active_mm;
62 struct vm_area_struct *mpnt;
63 struct prio_tree_iter iter;
64 pgoff_t pgoff;
73 65
74 /* 66 /*
75 * There are possible user space mappings of this page: 67 * There are possible user space mappings of this page:
@@ -116,12 +108,12 @@ void flush_dcache_page(struct page *page)
116{ 108{
117 struct address_space *mapping = page_mapping(page); 109 struct address_space *mapping = page_mapping(page);
118 110
119 if (cache_is_vipt_nonaliasing())
120 return;
121
122 if (mapping && !mapping_mapped(mapping)) 111 if (mapping && !mapping_mapped(mapping))
123 set_bit(PG_dcache_dirty, &page->flags); 112 set_bit(PG_dcache_dirty, &page->flags);
124 else 113 else {
125 __flush_dcache_page(mapping, page); 114 __flush_dcache_page(mapping, page);
115 if (mapping && cache_is_vivt())
116 __flush_dcache_aliases(mapping, page);
117 }
126} 118}
127EXPORT_SYMBOL(flush_dcache_page); 119EXPORT_SYMBOL(flush_dcache_page);
diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
index 00bb8fd37a59..7110e54182b1 100644
--- a/arch/arm/mm/ioremap.c
+++ b/arch/arm/mm/ioremap.c
@@ -170,3 +170,50 @@ void __iounmap(void __iomem *addr)
170 vfree((void *) (PAGE_MASK & (unsigned long) addr)); 170 vfree((void *) (PAGE_MASK & (unsigned long) addr));
171} 171}
172EXPORT_SYMBOL(__iounmap); 172EXPORT_SYMBOL(__iounmap);
173
174#ifdef __io
175void __iomem *ioport_map(unsigned long port, unsigned int nr)
176{
177 return __io(port);
178}
179EXPORT_SYMBOL(ioport_map);
180
181void ioport_unmap(void __iomem *addr)
182{
183}
184EXPORT_SYMBOL(ioport_unmap);
185#endif
186
187#ifdef CONFIG_PCI
188#include <linux/pci.h>
189#include <linux/ioport.h>
190
191void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
192{
193 unsigned long start = pci_resource_start(dev, bar);
194 unsigned long len = pci_resource_len(dev, bar);
195 unsigned long flags = pci_resource_flags(dev, bar);
196
197 if (!len || !start)
198 return NULL;
199 if (maxlen && len > maxlen)
200 len = maxlen;
201 if (flags & IORESOURCE_IO)
202 return ioport_map(start, len);
203 if (flags & IORESOURCE_MEM) {
204 if (flags & IORESOURCE_CACHEABLE)
205 return ioremap(start, len);
206 return ioremap_nocache(start, len);
207 }
208 return NULL;
209}
210EXPORT_SYMBOL(pci_iomap);
211
212void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
213{
214 if ((unsigned long)addr >= VMALLOC_START &&
215 (unsigned long)addr < VMALLOC_END)
216 iounmap(addr);
217}
218EXPORT_SYMBOL(pci_iounmap);
219#endif
diff --git a/arch/arm26/kernel/ecard.c b/arch/arm26/kernel/ecard.c
index 824c6b571ad9..f2278aadac8a 100644
--- a/arch/arm26/kernel/ecard.c
+++ b/arch/arm26/kernel/ecard.c
@@ -562,31 +562,31 @@ static void __init ecard_init_resources(struct expansion_card *ec)
562 } 562 }
563} 563}
564 564
565static ssize_t ecard_show_irq(struct device *dev, char *buf) 565static ssize_t ecard_show_irq(struct device *dev, struct device_attribute *attr, char *buf)
566{ 566{
567 struct expansion_card *ec = ECARD_DEV(dev); 567 struct expansion_card *ec = ECARD_DEV(dev);
568 return sprintf(buf, "%u\n", ec->irq); 568 return sprintf(buf, "%u\n", ec->irq);
569} 569}
570 570
571static ssize_t ecard_show_vendor(struct device *dev, char *buf) 571static ssize_t ecard_show_vendor(struct device *dev, struct device_attribute *attr, char *buf)
572{ 572{
573 struct expansion_card *ec = ECARD_DEV(dev); 573 struct expansion_card *ec = ECARD_DEV(dev);
574 return sprintf(buf, "%u\n", ec->cid.manufacturer); 574 return sprintf(buf, "%u\n", ec->cid.manufacturer);
575} 575}
576 576
577static ssize_t ecard_show_device(struct device *dev, char *buf) 577static ssize_t ecard_show_device(struct device *dev, struct device_attribute *attr, char *buf)
578{ 578{
579 struct expansion_card *ec = ECARD_DEV(dev); 579 struct expansion_card *ec = ECARD_DEV(dev);
580 return sprintf(buf, "%u\n", ec->cid.product); 580 return sprintf(buf, "%u\n", ec->cid.product);
581} 581}
582 582
583static ssize_t ecard_show_dma(struct device *dev, char *buf) 583static ssize_t ecard_show_dma(struct device *dev, struct device_attribute *attr, char *buf)
584{ 584{
585 struct expansion_card *ec = ECARD_DEV(dev); 585 struct expansion_card *ec = ECARD_DEV(dev);
586 return sprintf(buf, "%u\n", ec->dma); 586 return sprintf(buf, "%u\n", ec->dma);
587} 587}
588 588
589static ssize_t ecard_show_resources(struct device *dev, char *buf) 589static ssize_t ecard_show_resources(struct device *dev, struct device_attribute *attr, char *buf)
590{ 590{
591 struct expansion_card *ec = ECARD_DEV(dev); 591 struct expansion_card *ec = ECARD_DEV(dev);
592 char *str = buf; 592 char *str = buf;
diff --git a/arch/i386/kernel/cpuid.c b/arch/i386/kernel/cpuid.c
index 2e2756345bb2..4647db4ad6de 100644
--- a/arch/i386/kernel/cpuid.c
+++ b/arch/i386/kernel/cpuid.c
@@ -45,7 +45,7 @@
45#include <asm/uaccess.h> 45#include <asm/uaccess.h>
46#include <asm/system.h> 46#include <asm/system.h>
47 47
48static struct class_simple *cpuid_class; 48static struct class *cpuid_class;
49 49
50#ifdef CONFIG_SMP 50#ifdef CONFIG_SMP
51 51
@@ -158,12 +158,12 @@ static struct file_operations cpuid_fops = {
158 .open = cpuid_open, 158 .open = cpuid_open,
159}; 159};
160 160
161static int cpuid_class_simple_device_add(int i) 161static int cpuid_class_device_create(int i)
162{ 162{
163 int err = 0; 163 int err = 0;
164 struct class_device *class_err; 164 struct class_device *class_err;
165 165
166 class_err = class_simple_device_add(cpuid_class, MKDEV(CPUID_MAJOR, i), NULL, "cpu%d",i); 166 class_err = class_device_create(cpuid_class, MKDEV(CPUID_MAJOR, i), NULL, "cpu%d",i);
167 if (IS_ERR(class_err)) 167 if (IS_ERR(class_err))
168 err = PTR_ERR(class_err); 168 err = PTR_ERR(class_err);
169 return err; 169 return err;
@@ -175,10 +175,10 @@ static int __devinit cpuid_class_cpu_callback(struct notifier_block *nfb, unsign
175 175
176 switch (action) { 176 switch (action) {
177 case CPU_ONLINE: 177 case CPU_ONLINE:
178 cpuid_class_simple_device_add(cpu); 178 cpuid_class_device_create(cpu);
179 break; 179 break;
180 case CPU_DEAD: 180 case CPU_DEAD:
181 class_simple_device_remove(MKDEV(CPUID_MAJOR, cpu)); 181 class_device_destroy(cpuid_class, MKDEV(CPUID_MAJOR, cpu));
182 break; 182 break;
183 } 183 }
184 return NOTIFY_OK; 184 return NOTIFY_OK;
@@ -200,13 +200,13 @@ static int __init cpuid_init(void)
200 err = -EBUSY; 200 err = -EBUSY;
201 goto out; 201 goto out;
202 } 202 }
203 cpuid_class = class_simple_create(THIS_MODULE, "cpuid"); 203 cpuid_class = class_create(THIS_MODULE, "cpuid");
204 if (IS_ERR(cpuid_class)) { 204 if (IS_ERR(cpuid_class)) {
205 err = PTR_ERR(cpuid_class); 205 err = PTR_ERR(cpuid_class);
206 goto out_chrdev; 206 goto out_chrdev;
207 } 207 }
208 for_each_online_cpu(i) { 208 for_each_online_cpu(i) {
209 err = cpuid_class_simple_device_add(i); 209 err = cpuid_class_device_create(i);
210 if (err != 0) 210 if (err != 0)
211 goto out_class; 211 goto out_class;
212 } 212 }
@@ -218,9 +218,9 @@ static int __init cpuid_init(void)
218out_class: 218out_class:
219 i = 0; 219 i = 0;
220 for_each_online_cpu(i) { 220 for_each_online_cpu(i) {
221 class_simple_device_remove(MKDEV(CPUID_MAJOR, i)); 221 class_device_destroy(cpuid_class, MKDEV(CPUID_MAJOR, i));
222 } 222 }
223 class_simple_destroy(cpuid_class); 223 class_destroy(cpuid_class);
224out_chrdev: 224out_chrdev:
225 unregister_chrdev(CPUID_MAJOR, "cpu/cpuid"); 225 unregister_chrdev(CPUID_MAJOR, "cpu/cpuid");
226out: 226out:
@@ -232,8 +232,8 @@ static void __exit cpuid_exit(void)
232 int cpu = 0; 232 int cpu = 0;
233 233
234 for_each_online_cpu(cpu) 234 for_each_online_cpu(cpu)
235 class_simple_device_remove(MKDEV(CPUID_MAJOR, cpu)); 235 class_device_destroy(cpuid_class, MKDEV(CPUID_MAJOR, cpu));
236 class_simple_destroy(cpuid_class); 236 class_destroy(cpuid_class);
237 unregister_chrdev(CPUID_MAJOR, "cpu/cpuid"); 237 unregister_chrdev(CPUID_MAJOR, "cpu/cpuid");
238 unregister_cpu_notifier(&cpuid_class_cpu_notifier); 238 unregister_cpu_notifier(&cpuid_class_cpu_notifier);
239} 239}
diff --git a/arch/i386/kernel/msr.c b/arch/i386/kernel/msr.c
index 05d9f8f363a6..b2f03c39a6fe 100644
--- a/arch/i386/kernel/msr.c
+++ b/arch/i386/kernel/msr.c
@@ -44,7 +44,7 @@
44#include <asm/uaccess.h> 44#include <asm/uaccess.h>
45#include <asm/system.h> 45#include <asm/system.h>
46 46
47static struct class_simple *msr_class; 47static struct class *msr_class;
48 48
49/* Note: "err" is handled in a funny way below. Otherwise one version 49/* Note: "err" is handled in a funny way below. Otherwise one version
50 of gcc or another breaks. */ 50 of gcc or another breaks. */
@@ -260,12 +260,12 @@ static struct file_operations msr_fops = {
260 .open = msr_open, 260 .open = msr_open,
261}; 261};
262 262
263static int msr_class_simple_device_add(int i) 263static int msr_class_device_create(int i)
264{ 264{
265 int err = 0; 265 int err = 0;
266 struct class_device *class_err; 266 struct class_device *class_err;
267 267
268 class_err = class_simple_device_add(msr_class, MKDEV(MSR_MAJOR, i), NULL, "msr%d",i); 268 class_err = class_device_create(msr_class, MKDEV(MSR_MAJOR, i), NULL, "msr%d",i);
269 if (IS_ERR(class_err)) 269 if (IS_ERR(class_err))
270 err = PTR_ERR(class_err); 270 err = PTR_ERR(class_err);
271 return err; 271 return err;
@@ -277,10 +277,10 @@ static int __devinit msr_class_cpu_callback(struct notifier_block *nfb, unsigned
277 277
278 switch (action) { 278 switch (action) {
279 case CPU_ONLINE: 279 case CPU_ONLINE:
280 msr_class_simple_device_add(cpu); 280 msr_class_device_create(cpu);
281 break; 281 break;
282 case CPU_DEAD: 282 case CPU_DEAD:
283 class_simple_device_remove(MKDEV(MSR_MAJOR, cpu)); 283 class_device_destroy(msr_class, MKDEV(MSR_MAJOR, cpu));
284 break; 284 break;
285 } 285 }
286 return NOTIFY_OK; 286 return NOTIFY_OK;
@@ -302,13 +302,13 @@ static int __init msr_init(void)
302 err = -EBUSY; 302 err = -EBUSY;
303 goto out; 303 goto out;
304 } 304 }
305 msr_class = class_simple_create(THIS_MODULE, "msr"); 305 msr_class = class_create(THIS_MODULE, "msr");
306 if (IS_ERR(msr_class)) { 306 if (IS_ERR(msr_class)) {
307 err = PTR_ERR(msr_class); 307 err = PTR_ERR(msr_class);
308 goto out_chrdev; 308 goto out_chrdev;
309 } 309 }
310 for_each_online_cpu(i) { 310 for_each_online_cpu(i) {
311 err = msr_class_simple_device_add(i); 311 err = msr_class_device_create(i);
312 if (err != 0) 312 if (err != 0)
313 goto out_class; 313 goto out_class;
314 } 314 }
@@ -320,8 +320,8 @@ static int __init msr_init(void)
320out_class: 320out_class:
321 i = 0; 321 i = 0;
322 for_each_online_cpu(i) 322 for_each_online_cpu(i)
323 class_simple_device_remove(MKDEV(MSR_MAJOR, i)); 323 class_device_destroy(msr_class, MKDEV(MSR_MAJOR, i));
324 class_simple_destroy(msr_class); 324 class_destroy(msr_class);
325out_chrdev: 325out_chrdev:
326 unregister_chrdev(MSR_MAJOR, "cpu/msr"); 326 unregister_chrdev(MSR_MAJOR, "cpu/msr");
327out: 327out:
@@ -332,8 +332,8 @@ static void __exit msr_exit(void)
332{ 332{
333 int cpu = 0; 333 int cpu = 0;
334 for_each_online_cpu(cpu) 334 for_each_online_cpu(cpu)
335 class_simple_device_remove(MKDEV(MSR_MAJOR, cpu)); 335 class_device_destroy(msr_class, MKDEV(MSR_MAJOR, cpu));
336 class_simple_destroy(msr_class); 336 class_destroy(msr_class);
337 unregister_chrdev(MSR_MAJOR, "cpu/msr"); 337 unregister_chrdev(MSR_MAJOR, "cpu/msr");
338 unregister_cpu_notifier(&msr_class_cpu_notifier); 338 unregister_cpu_notifier(&msr_class_cpu_notifier);
339} 339}
diff --git a/arch/ia64/sn/kernel/tiocx.c b/arch/ia64/sn/kernel/tiocx.c
index ab9b5f35c2a7..a087b274847e 100644
--- a/arch/ia64/sn/kernel/tiocx.c
+++ b/arch/ia64/sn/kernel/tiocx.c
@@ -432,7 +432,7 @@ static int tiocx_reload(struct cx_dev *cx_dev)
432 return cx_device_reload(cx_dev); 432 return cx_device_reload(cx_dev);
433} 433}
434 434
435static ssize_t show_cxdev_control(struct device *dev, char *buf) 435static ssize_t show_cxdev_control(struct device *dev, struct device_attribute *attr, char *buf)
436{ 436{
437 struct cx_dev *cx_dev = to_cx_dev(dev); 437 struct cx_dev *cx_dev = to_cx_dev(dev);
438 438
@@ -442,7 +442,7 @@ static ssize_t show_cxdev_control(struct device *dev, char *buf)
442 tiocx_btchar_get(cx_dev->cx_id.nasid)); 442 tiocx_btchar_get(cx_dev->cx_id.nasid));
443} 443}
444 444
445static ssize_t store_cxdev_control(struct device *dev, const char *buf, 445static ssize_t store_cxdev_control(struct device *dev, struct device_attribute *attr, const char *buf,
446 size_t count) 446 size_t count)
447{ 447{
448 int n; 448 int n;
@@ -518,25 +518,22 @@ static int __init tiocx_init(void)
518 return 0; 518 return 0;
519} 519}
520 520
521static void __exit tiocx_exit(void) 521static int cx_remove_device(struct device * dev, void * data)
522{ 522{
523 struct device *dev; 523 struct cx_dev *cx_dev = to_cx_dev(dev);
524 struct device *tdev; 524 device_remove_file(dev, &dev_attr_cxdev_control);
525 cx_device_unregister(cx_dev);
526 return 0;
527}
525 528
529static void __exit tiocx_exit(void)
530{
526 DBG("tiocx_exit\n"); 531 DBG("tiocx_exit\n");
527 532
528 /* 533 /*
529 * Unregister devices. 534 * Unregister devices.
530 */ 535 */
531 list_for_each_entry_safe(dev, tdev, &tiocx_bus_type.devices.list, 536 bus_for_each_dev(&tiocx_bus_type, NULL, NULL, cx_remove_device);
532 bus_list) {
533 if (dev) {
534 struct cx_dev *cx_dev = to_cx_dev(dev);
535 device_remove_file(dev, &dev_attr_cxdev_control);
536 cx_device_unregister(cx_dev);
537 }
538 }
539
540 bus_unregister(&tiocx_bus_type); 537 bus_unregister(&tiocx_bus_type);
541} 538}
542 539
diff --git a/arch/parisc/kernel/drivers.c b/arch/parisc/kernel/drivers.c
index ebf186656afb..d34bbe7ae0e3 100644
--- a/arch/parisc/kernel/drivers.c
+++ b/arch/parisc/kernel/drivers.c
@@ -466,7 +466,7 @@ static int parisc_generic_match(struct device *dev, struct device_driver *drv)
466} 466}
467 467
468#define pa_dev_attr(name, field, format_string) \ 468#define pa_dev_attr(name, field, format_string) \
469static ssize_t name##_show(struct device *dev, char *buf) \ 469static ssize_t name##_show(struct device *dev, struct device_attribute *attr, char *buf) \
470{ \ 470{ \
471 struct parisc_device *padev = to_parisc_device(dev); \ 471 struct parisc_device *padev = to_parisc_device(dev); \
472 return sprintf(buf, format_string, padev->field); \ 472 return sprintf(buf, format_string, padev->field); \
diff --git a/arch/ppc/kernel/pci.c b/arch/ppc/kernel/pci.c
index 47a15306823a..6d7b92d72458 100644
--- a/arch/ppc/kernel/pci.c
+++ b/arch/ppc/kernel/pci.c
@@ -1003,7 +1003,7 @@ pci_create_OF_bus_map(void)
1003 } 1003 }
1004} 1004}
1005 1005
1006static ssize_t pci_show_devspec(struct device *dev, char *buf) 1006static ssize_t pci_show_devspec(struct device *dev, struct device_attribute *attr, char *buf)
1007{ 1007{
1008 struct pci_dev *pdev; 1008 struct pci_dev *pdev;
1009 struct device_node *np; 1009 struct device_node *np;
diff --git a/arch/ppc/syslib/ocp.c b/arch/ppc/syslib/ocp.c
index a5156c5179a6..e5fd2ae503ea 100644
--- a/arch/ppc/syslib/ocp.c
+++ b/arch/ppc/syslib/ocp.c
@@ -68,7 +68,7 @@ static int ocp_inited;
68/* Sysfs support */ 68/* Sysfs support */
69#define OCP_DEF_ATTR(field, format_string) \ 69#define OCP_DEF_ATTR(field, format_string) \
70static ssize_t \ 70static ssize_t \
71show_##field(struct device *dev, char *buf) \ 71show_##field(struct device *dev, struct device_attribute *attr, char *buf) \
72{ \ 72{ \
73 struct ocp_device *odev = to_ocp_dev(dev); \ 73 struct ocp_device *odev = to_ocp_dev(dev); \
74 \ 74 \
diff --git a/arch/ppc/syslib/of_device.c b/arch/ppc/syslib/of_device.c
index 46269ed21aee..49c0e34e2d6b 100644
--- a/arch/ppc/syslib/of_device.c
+++ b/arch/ppc/syslib/of_device.c
@@ -161,7 +161,7 @@ void of_unregister_driver(struct of_platform_driver *drv)
161} 161}
162 162
163 163
164static ssize_t dev_show_devspec(struct device *dev, char *buf) 164static ssize_t dev_show_devspec(struct device *dev, struct device_attribute *attr, char *buf)
165{ 165{
166 struct of_device *ofdev; 166 struct of_device *ofdev;
167 167
diff --git a/arch/ppc64/kernel/iommu.c b/arch/ppc64/kernel/iommu.c
index 344164681d2c..8316426ccaf6 100644
--- a/arch/ppc64/kernel/iommu.c
+++ b/arch/ppc64/kernel/iommu.c
@@ -423,6 +423,9 @@ struct iommu_table *iommu_init_table(struct iommu_table *tbl)
423 tbl->it_largehint = tbl->it_halfpoint; 423 tbl->it_largehint = tbl->it_halfpoint;
424 spin_lock_init(&tbl->it_lock); 424 spin_lock_init(&tbl->it_lock);
425 425
426 /* Clear the hardware table in case firmware left allocations in it */
427 ppc_md.tce_free(tbl, tbl->it_offset, tbl->it_size);
428
426 if (!welcomed) { 429 if (!welcomed) {
427 printk(KERN_INFO "IOMMU table initialized, virtual merging %s\n", 430 printk(KERN_INFO "IOMMU table initialized, virtual merging %s\n",
428 novmerge ? "disabled" : "enabled"); 431 novmerge ? "disabled" : "enabled");
diff --git a/arch/ppc64/kernel/of_device.c b/arch/ppc64/kernel/of_device.c
index f4c825a69fa0..66bd5ab7c25a 100644
--- a/arch/ppc64/kernel/of_device.c
+++ b/arch/ppc64/kernel/of_device.c
@@ -161,7 +161,7 @@ void of_unregister_driver(struct of_platform_driver *drv)
161} 161}
162 162
163 163
164static ssize_t dev_show_devspec(struct device *dev, char *buf) 164static ssize_t dev_show_devspec(struct device *dev, struct device_attribute *attr, char *buf)
165{ 165{
166 struct of_device *ofdev; 166 struct of_device *ofdev;
167 167
diff --git a/arch/ppc64/kernel/pSeries_smp.c b/arch/ppc64/kernel/pSeries_smp.c
index fbad349ec58c..4203bd020c82 100644
--- a/arch/ppc64/kernel/pSeries_smp.c
+++ b/arch/ppc64/kernel/pSeries_smp.c
@@ -375,7 +375,7 @@ static int smp_pSeries_cpu_bootable(unsigned int nr)
375 * cpus are assumed to be secondary threads. 375 * cpus are assumed to be secondary threads.
376 */ 376 */
377 if (system_state < SYSTEM_RUNNING && 377 if (system_state < SYSTEM_RUNNING &&
378 cur_cpu_spec->cpu_features & CPU_FTR_SMT && 378 cpu_has_feature(CPU_FTR_SMT) &&
379 !smt_enabled_at_boot && nr % 2 != 0) 379 !smt_enabled_at_boot && nr % 2 != 0)
380 return 0; 380 return 0;
381 381
@@ -419,8 +419,8 @@ void __init smp_init_pSeries(void)
419#endif 419#endif
420 420
421 /* Mark threads which are still spinning in hold loops. */ 421 /* Mark threads which are still spinning in hold loops. */
422 if (cur_cpu_spec->cpu_features & CPU_FTR_SMT) 422 if (cpu_has_feature(CPU_FTR_SMT)) {
423 for_each_present_cpu(i) { 423 for_each_present_cpu(i) {
424 if (i % 2 == 0) 424 if (i % 2 == 0)
425 /* 425 /*
426 * Even-numbered logical cpus correspond to 426 * Even-numbered logical cpus correspond to
@@ -428,8 +428,9 @@ void __init smp_init_pSeries(void)
428 */ 428 */
429 cpu_set(i, of_spin_map); 429 cpu_set(i, of_spin_map);
430 } 430 }
431 else 431 } else {
432 of_spin_map = cpu_present_map; 432 of_spin_map = cpu_present_map;
433 }
433 434
434 cpu_clear(boot_cpuid, of_spin_map); 435 cpu_clear(boot_cpuid, of_spin_map);
435 436
diff --git a/arch/ppc64/kernel/pci.c b/arch/ppc64/kernel/pci.c
index d786d4b6af0b..2bf0513f3eca 100644
--- a/arch/ppc64/kernel/pci.c
+++ b/arch/ppc64/kernel/pci.c
@@ -507,7 +507,7 @@ int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
507} 507}
508 508
509#ifdef CONFIG_PPC_MULTIPLATFORM 509#ifdef CONFIG_PPC_MULTIPLATFORM
510static ssize_t pci_show_devspec(struct device *dev, char *buf) 510static ssize_t pci_show_devspec(struct device *dev, struct device_attribute *attr, char *buf)
511{ 511{
512 struct pci_dev *pdev; 512 struct pci_dev *pdev;
513 struct device_node *np; 513 struct device_node *np;
diff --git a/arch/ppc64/kernel/rtasd.c b/arch/ppc64/kernel/rtasd.c
index ff65dc33320e..b0c3b829fe47 100644
--- a/arch/ppc64/kernel/rtasd.c
+++ b/arch/ppc64/kernel/rtasd.c
@@ -440,7 +440,7 @@ static int rtasd(void *unused)
440 goto error; 440 goto error;
441 } 441 }
442 442
443 printk(KERN_ERR "RTAS daemon started\n"); 443 printk(KERN_INFO "RTAS daemon started\n");
444 444
445 DEBUG("will sleep for %d jiffies\n", (HZ*60/rtas_event_scan_rate) / 2); 445 DEBUG("will sleep for %d jiffies\n", (HZ*60/rtas_event_scan_rate) / 2);
446 446
@@ -485,7 +485,7 @@ static int __init rtas_init(void)
485 /* No RTAS, only warn if we are on a pSeries box */ 485 /* No RTAS, only warn if we are on a pSeries box */
486 if (rtas_token("event-scan") == RTAS_UNKNOWN_SERVICE) { 486 if (rtas_token("event-scan") == RTAS_UNKNOWN_SERVICE) {
487 if (systemcfg->platform & PLATFORM_PSERIES) 487 if (systemcfg->platform & PLATFORM_PSERIES)
488 printk(KERN_ERR "rtasd: no event-scan on system\n"); 488 printk(KERN_INFO "rtasd: no event-scan on system\n");
489 return 1; 489 return 1;
490 } 490 }
491 491
diff --git a/arch/ppc64/kernel/vio.c b/arch/ppc64/kernel/vio.c
index cdd830cb2768..79f2dc7a9833 100644
--- a/arch/ppc64/kernel/vio.c
+++ b/arch/ppc64/kernel/vio.c
@@ -300,7 +300,7 @@ static void __devinit vio_dev_release(struct device *dev)
300} 300}
301 301
302#ifdef CONFIG_PPC_PSERIES 302#ifdef CONFIG_PPC_PSERIES
303static ssize_t viodev_show_devspec(struct device *dev, char *buf) 303static ssize_t viodev_show_devspec(struct device *dev, struct device_attribute *attr, char *buf)
304{ 304{
305 struct device_node *of_node = dev->platform_data; 305 struct device_node *of_node = dev->platform_data;
306 306
@@ -309,7 +309,7 @@ static ssize_t viodev_show_devspec(struct device *dev, char *buf)
309DEVICE_ATTR(devspec, S_IRUSR | S_IRGRP | S_IROTH, viodev_show_devspec, NULL); 309DEVICE_ATTR(devspec, S_IRUSR | S_IRGRP | S_IROTH, viodev_show_devspec, NULL);
310#endif 310#endif
311 311
312static ssize_t viodev_show_name(struct device *dev, char *buf) 312static ssize_t viodev_show_name(struct device *dev, struct device_attribute *attr, char *buf)
313{ 313{
314 return sprintf(buf, "%s\n", to_vio_dev(dev)->name); 314 return sprintf(buf, "%s\n", to_vio_dev(dev)->name);
315} 315}
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 119c94093a13..e85885593280 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -65,14 +65,14 @@ static ssize_t acpi_device_attr_show(struct kobject *kobj,
65{ 65{
66 struct acpi_device *device = to_acpi_device(kobj); 66 struct acpi_device *device = to_acpi_device(kobj);
67 struct acpi_device_attribute *attribute = to_handle_attr(attr); 67 struct acpi_device_attribute *attribute = to_handle_attr(attr);
68 return attribute->show ? attribute->show(device, buf) : 0; 68 return attribute->show ? attribute->show(device, buf) : -EIO;
69} 69}
70static ssize_t acpi_device_attr_store(struct kobject *kobj, 70static ssize_t acpi_device_attr_store(struct kobject *kobj,
71 struct attribute *attr, const char *buf, size_t len) 71 struct attribute *attr, const char *buf, size_t len)
72{ 72{
73 struct acpi_device *device = to_acpi_device(kobj); 73 struct acpi_device *device = to_acpi_device(kobj);
74 struct acpi_device_attribute *attribute = to_handle_attr(attr); 74 struct acpi_device_attribute *attribute = to_handle_attr(attr);
75 return attribute->store ? attribute->store(device, buf, len) : len; 75 return attribute->store ? attribute->store(device, buf, len) : -EIO;
76} 76}
77 77
78static struct sysfs_ops acpi_device_sysfs_ops = { 78static struct sysfs_ops acpi_device_sysfs_ops = {
diff --git a/drivers/base/Makefile b/drivers/base/Makefile
index a47928a2e575..66d9c4643fc1 100644
--- a/drivers/base/Makefile
+++ b/drivers/base/Makefile
@@ -1,7 +1,7 @@
1# Makefile for the Linux device tree 1# Makefile for the Linux device tree
2 2
3obj-y := core.o sys.o bus.o \ 3obj-y := core.o sys.o bus.o dd.o \
4 driver.o class.o class_simple.o platform.o \ 4 driver.o class.o platform.o \
5 cpu.o firmware.o init.o map.o dmapool.o \ 5 cpu.o firmware.o init.o map.o dmapool.o \
6 attribute_container.o transport_class.o 6 attribute_container.o transport_class.o
7obj-y += power/ 7obj-y += power/
diff --git a/drivers/base/base.h b/drivers/base/base.h
index 8d1e8bd48632..645f62692920 100644
--- a/drivers/base/base.h
+++ b/drivers/base/base.h
@@ -4,6 +4,8 @@ extern void bus_remove_device(struct device * dev);
4extern int bus_add_driver(struct device_driver *); 4extern int bus_add_driver(struct device_driver *);
5extern void bus_remove_driver(struct device_driver *); 5extern void bus_remove_driver(struct device_driver *);
6 6
7extern void driver_detach(struct device_driver * drv);
8
7static inline struct class_device *to_class_dev(struct kobject *obj) 9static inline struct class_device *to_class_dev(struct kobject *obj)
8{ 10{
9 return container_of(obj, struct class_device, kobj); 11 return container_of(obj, struct class_device, kobj);
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 3cb04bb04c2b..43722af90bdd 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -17,9 +17,6 @@
17#include "base.h" 17#include "base.h"
18#include "power/power.h" 18#include "power/power.h"
19 19
20#define to_dev(node) container_of(node, struct device, bus_list)
21#define to_drv(node) container_of(node, struct device_driver, kobj.entry)
22
23#define to_bus_attr(_attr) container_of(_attr, struct bus_attribute, attr) 20#define to_bus_attr(_attr) container_of(_attr, struct bus_attribute, attr)
24#define to_bus(obj) container_of(obj, struct bus_type, subsys.kset.kobj) 21#define to_bus(obj) container_of(obj, struct bus_type, subsys.kset.kobj)
25 22
@@ -36,7 +33,7 @@ drv_attr_show(struct kobject * kobj, struct attribute * attr, char * buf)
36{ 33{
37 struct driver_attribute * drv_attr = to_drv_attr(attr); 34 struct driver_attribute * drv_attr = to_drv_attr(attr);
38 struct device_driver * drv = to_driver(kobj); 35 struct device_driver * drv = to_driver(kobj);
39 ssize_t ret = 0; 36 ssize_t ret = -EIO;
40 37
41 if (drv_attr->show) 38 if (drv_attr->show)
42 ret = drv_attr->show(drv, buf); 39 ret = drv_attr->show(drv, buf);
@@ -49,7 +46,7 @@ drv_attr_store(struct kobject * kobj, struct attribute * attr,
49{ 46{
50 struct driver_attribute * drv_attr = to_drv_attr(attr); 47 struct driver_attribute * drv_attr = to_drv_attr(attr);
51 struct device_driver * drv = to_driver(kobj); 48 struct device_driver * drv = to_driver(kobj);
52 ssize_t ret = 0; 49 ssize_t ret = -EIO;
53 50
54 if (drv_attr->store) 51 if (drv_attr->store)
55 ret = drv_attr->store(drv, buf, count); 52 ret = drv_attr->store(drv, buf, count);
@@ -135,50 +132,11 @@ static struct kobj_type ktype_bus = {
135 132
136decl_subsys(bus, &ktype_bus, NULL); 133decl_subsys(bus, &ktype_bus, NULL);
137 134
138static int __bus_for_each_dev(struct bus_type *bus, struct device *start,
139 void *data, int (*fn)(struct device *, void *))
140{
141 struct list_head *head;
142 struct device *dev;
143 int error = 0;
144
145 if (!(bus = get_bus(bus)))
146 return -EINVAL;
147
148 head = &bus->devices.list;
149 dev = list_prepare_entry(start, head, bus_list);
150 list_for_each_entry_continue(dev, head, bus_list) {
151 get_device(dev);
152 error = fn(dev, data);
153 put_device(dev);
154 if (error)
155 break;
156 }
157 put_bus(bus);
158 return error;
159}
160 135
161static int __bus_for_each_drv(struct bus_type *bus, struct device_driver *start, 136static struct device * next_device(struct klist_iter * i)
162 void * data, int (*fn)(struct device_driver *, void *))
163{ 137{
164 struct list_head *head; 138 struct klist_node * n = klist_next(i);
165 struct device_driver *drv; 139 return n ? container_of(n, struct device, knode_bus) : NULL;
166 int error = 0;
167
168 if (!(bus = get_bus(bus)))
169 return -EINVAL;
170
171 head = &bus->drivers.list;
172 drv = list_prepare_entry(start, head, kobj.entry);
173 list_for_each_entry_continue(drv, head, kobj.entry) {
174 get_driver(drv);
175 error = fn(drv, data);
176 put_driver(drv);
177 if (error)
178 break;
179 }
180 put_bus(bus);
181 return error;
182} 140}
183 141
184/** 142/**
@@ -204,12 +162,27 @@ static int __bus_for_each_drv(struct bus_type *bus, struct device_driver *start,
204int bus_for_each_dev(struct bus_type * bus, struct device * start, 162int bus_for_each_dev(struct bus_type * bus, struct device * start,
205 void * data, int (*fn)(struct device *, void *)) 163 void * data, int (*fn)(struct device *, void *))
206{ 164{
207 int ret; 165 struct klist_iter i;
166 struct device * dev;
167 int error = 0;
208 168
209 down_read(&bus->subsys.rwsem); 169 if (!bus)
210 ret = __bus_for_each_dev(bus, start, data, fn); 170 return -EINVAL;
211 up_read(&bus->subsys.rwsem); 171
212 return ret; 172 klist_iter_init_node(&bus->klist_devices, &i,
173 (start ? &start->knode_bus : NULL));
174 while ((dev = next_device(&i)) && !error)
175 error = fn(dev, data);
176 klist_iter_exit(&i);
177 return error;
178}
179
180
181
182static struct device_driver * next_driver(struct klist_iter * i)
183{
184 struct klist_node * n = klist_next(i);
185 return n ? container_of(n, struct device_driver, knode_bus) : NULL;
213} 186}
214 187
215/** 188/**
@@ -235,179 +208,19 @@ int bus_for_each_dev(struct bus_type * bus, struct device * start,
235int bus_for_each_drv(struct bus_type * bus, struct device_driver * start, 208int bus_for_each_drv(struct bus_type * bus, struct device_driver * start,
236 void * data, int (*fn)(struct device_driver *, void *)) 209 void * data, int (*fn)(struct device_driver *, void *))
237{ 210{
238 int ret; 211 struct klist_iter i;
239 212 struct device_driver * drv;
240 down_read(&bus->subsys.rwsem); 213 int error = 0;
241 ret = __bus_for_each_drv(bus, start, data, fn);
242 up_read(&bus->subsys.rwsem);
243 return ret;
244}
245
246/**
247 * device_bind_driver - bind a driver to one device.
248 * @dev: device.
249 *
250 * Allow manual attachment of a driver to a device.
251 * Caller must have already set @dev->driver.
252 *
253 * Note that this does not modify the bus reference count
254 * nor take the bus's rwsem. Please verify those are accounted
255 * for before calling this. (It is ok to call with no other effort
256 * from a driver's probe() method.)
257 */
258
259void device_bind_driver(struct device * dev)
260{
261 pr_debug("bound device '%s' to driver '%s'\n",
262 dev->bus_id, dev->driver->name);
263 list_add_tail(&dev->driver_list, &dev->driver->devices);
264 sysfs_create_link(&dev->driver->kobj, &dev->kobj,
265 kobject_name(&dev->kobj));
266 sysfs_create_link(&dev->kobj, &dev->driver->kobj, "driver");
267}
268
269
270/**
271 * driver_probe_device - attempt to bind device & driver.
272 * @drv: driver.
273 * @dev: device.
274 *
275 * First, we call the bus's match function, if one present, which
276 * should compare the device IDs the driver supports with the
277 * device IDs of the device. Note we don't do this ourselves
278 * because we don't know the format of the ID structures, nor what
279 * is to be considered a match and what is not.
280 *
281 * If we find a match, we call @drv->probe(@dev) if it exists, and
282 * call device_bind_driver() above.
283 */
284int driver_probe_device(struct device_driver * drv, struct device * dev)
285{
286 if (drv->bus->match && !drv->bus->match(dev, drv))
287 return -ENODEV;
288
289 dev->driver = drv;
290 if (drv->probe) {
291 int error = drv->probe(dev);
292 if (error) {
293 dev->driver = NULL;
294 return error;
295 }
296 }
297
298 device_bind_driver(dev);
299 return 0;
300}
301
302
303/**
304 * device_attach - try to attach device to a driver.
305 * @dev: device.
306 *
307 * Walk the list of drivers that the bus has and call
308 * driver_probe_device() for each pair. If a compatible
309 * pair is found, break out and return.
310 */
311int device_attach(struct device * dev)
312{
313 struct bus_type * bus = dev->bus;
314 struct list_head * entry;
315 int error;
316
317 if (dev->driver) {
318 device_bind_driver(dev);
319 return 1;
320 }
321
322 if (bus->match) {
323 list_for_each(entry, &bus->drivers.list) {
324 struct device_driver * drv = to_drv(entry);
325 error = driver_probe_device(drv, dev);
326 if (!error)
327 /* success, driver matched */
328 return 1;
329 if (error != -ENODEV && error != -ENXIO)
330 /* driver matched but the probe failed */
331 printk(KERN_WARNING
332 "%s: probe of %s failed with error %d\n",
333 drv->name, dev->bus_id, error);
334 }
335 }
336
337 return 0;
338}
339
340
341/**
342 * driver_attach - try to bind driver to devices.
343 * @drv: driver.
344 *
345 * Walk the list of devices that the bus has on it and try to
346 * match the driver with each one. If driver_probe_device()
347 * returns 0 and the @dev->driver is set, we've found a
348 * compatible pair.
349 *
350 * Note that we ignore the -ENODEV error from driver_probe_device(),
351 * since it's perfectly valid for a driver not to bind to any devices.
352 */
353void driver_attach(struct device_driver * drv)
354{
355 struct bus_type * bus = drv->bus;
356 struct list_head * entry;
357 int error;
358
359 if (!bus->match)
360 return;
361
362 list_for_each(entry, &bus->devices.list) {
363 struct device * dev = container_of(entry, struct device, bus_list);
364 if (!dev->driver) {
365 error = driver_probe_device(drv, dev);
366 if (error && (error != -ENODEV))
367 /* driver matched but the probe failed */
368 printk(KERN_WARNING
369 "%s: probe of %s failed with error %d\n",
370 drv->name, dev->bus_id, error);
371 }
372 }
373}
374
375
376/**
377 * device_release_driver - manually detach device from driver.
378 * @dev: device.
379 *
380 * Manually detach device from driver.
381 * Note that this is called without incrementing the bus
382 * reference count nor taking the bus's rwsem. Be sure that
383 * those are accounted for before calling this function.
384 */
385
386void device_release_driver(struct device * dev)
387{
388 struct device_driver * drv = dev->driver;
389 if (drv) {
390 sysfs_remove_link(&drv->kobj, kobject_name(&dev->kobj));
391 sysfs_remove_link(&dev->kobj, "driver");
392 list_del_init(&dev->driver_list);
393 if (drv->remove)
394 drv->remove(dev);
395 dev->driver = NULL;
396 }
397}
398
399 214
400/** 215 if (!bus)
401 * driver_detach - detach driver from all devices it controls. 216 return -EINVAL;
402 * @drv: driver.
403 */
404 217
405static void driver_detach(struct device_driver * drv) 218 klist_iter_init_node(&bus->klist_drivers, &i,
406{ 219 start ? &start->knode_bus : NULL);
407 while (!list_empty(&drv->devices)) { 220 while ((drv = next_driver(&i)) && !error)
408 struct device * dev = container_of(drv->devices.next, struct device, driver_list); 221 error = fn(drv, data);
409 device_release_driver(dev); 222 klist_iter_exit(&i);
410 } 223 return error;
411} 224}
412 225
413static int device_add_attrs(struct bus_type * bus, struct device * dev) 226static int device_add_attrs(struct bus_type * bus, struct device * dev)
@@ -456,14 +269,15 @@ int bus_add_device(struct device * dev)
456 int error = 0; 269 int error = 0;
457 270
458 if (bus) { 271 if (bus) {
459 down_write(&dev->bus->subsys.rwsem);
460 pr_debug("bus %s: add device %s\n", bus->name, dev->bus_id); 272 pr_debug("bus %s: add device %s\n", bus->name, dev->bus_id);
461 list_add_tail(&dev->bus_list, &dev->bus->devices.list); 273 error = device_attach(dev);
462 device_attach(dev); 274 klist_add_tail(&bus->klist_devices, &dev->knode_bus);
463 up_write(&dev->bus->subsys.rwsem); 275 if (error >= 0)
464 device_add_attrs(bus, dev); 276 error = device_add_attrs(bus, dev);
465 sysfs_create_link(&bus->devices.kobj, &dev->kobj, dev->bus_id); 277 if (!error) {
466 sysfs_create_link(&dev->kobj, &dev->bus->subsys.kset.kobj, "bus"); 278 sysfs_create_link(&bus->devices.kobj, &dev->kobj, dev->bus_id);
279 sysfs_create_link(&dev->kobj, &dev->bus->subsys.kset.kobj, "bus");
280 }
467 } 281 }
468 return error; 282 return error;
469} 283}
@@ -483,11 +297,9 @@ void bus_remove_device(struct device * dev)
483 sysfs_remove_link(&dev->kobj, "bus"); 297 sysfs_remove_link(&dev->kobj, "bus");
484 sysfs_remove_link(&dev->bus->devices.kobj, dev->bus_id); 298 sysfs_remove_link(&dev->bus->devices.kobj, dev->bus_id);
485 device_remove_attrs(dev->bus, dev); 299 device_remove_attrs(dev->bus, dev);
486 down_write(&dev->bus->subsys.rwsem); 300 klist_remove(&dev->knode_bus);
487 pr_debug("bus %s: remove device %s\n", dev->bus->name, dev->bus_id); 301 pr_debug("bus %s: remove device %s\n", dev->bus->name, dev->bus_id);
488 device_release_driver(dev); 302 device_release_driver(dev);
489 list_del_init(&dev->bus_list);
490 up_write(&dev->bus->subsys.rwsem);
491 put_bus(dev->bus); 303 put_bus(dev->bus);
492 } 304 }
493} 305}
@@ -547,9 +359,8 @@ int bus_add_driver(struct device_driver * drv)
547 return error; 359 return error;
548 } 360 }
549 361
550 down_write(&bus->subsys.rwsem);
551 driver_attach(drv); 362 driver_attach(drv);
552 up_write(&bus->subsys.rwsem); 363 klist_add_tail(&bus->klist_drivers, &drv->knode_bus);
553 module_add_driver(drv->owner, drv); 364 module_add_driver(drv->owner, drv);
554 365
555 driver_add_attrs(bus, drv); 366 driver_add_attrs(bus, drv);
@@ -571,10 +382,9 @@ void bus_remove_driver(struct device_driver * drv)
571{ 382{
572 if (drv->bus) { 383 if (drv->bus) {
573 driver_remove_attrs(drv->bus, drv); 384 driver_remove_attrs(drv->bus, drv);
574 down_write(&drv->bus->subsys.rwsem); 385 klist_remove(&drv->knode_bus);
575 pr_debug("bus %s: remove driver %s\n", drv->bus->name, drv->name); 386 pr_debug("bus %s: remove driver %s\n", drv->bus->name, drv->name);
576 driver_detach(drv); 387 driver_detach(drv);
577 up_write(&drv->bus->subsys.rwsem);
578 module_remove_driver(drv); 388 module_remove_driver(drv);
579 kobject_unregister(&drv->kobj); 389 kobject_unregister(&drv->kobj);
580 put_bus(drv->bus); 390 put_bus(drv->bus);
@@ -587,7 +397,7 @@ static int bus_rescan_devices_helper(struct device *dev, void *data)
587{ 397{
588 int *count = data; 398 int *count = data;
589 399
590 if (!dev->driver && device_attach(dev)) 400 if (!dev->driver && (device_attach(dev) > 0))
591 (*count)++; 401 (*count)++;
592 402
593 return 0; 403 return 0;
@@ -607,9 +417,7 @@ int bus_rescan_devices(struct bus_type * bus)
607{ 417{
608 int count = 0; 418 int count = 0;
609 419
610 down_write(&bus->subsys.rwsem); 420 bus_for_each_dev(bus, NULL, &count, bus_rescan_devices_helper);
611 __bus_for_each_dev(bus, NULL, &count, bus_rescan_devices_helper);
612 up_write(&bus->subsys.rwsem);
613 421
614 return count; 422 return count;
615} 423}
@@ -710,6 +518,9 @@ int bus_register(struct bus_type * bus)
710 retval = kset_register(&bus->drivers); 518 retval = kset_register(&bus->drivers);
711 if (retval) 519 if (retval)
712 goto bus_drivers_fail; 520 goto bus_drivers_fail;
521
522 klist_init(&bus->klist_devices);
523 klist_init(&bus->klist_drivers);
713 bus_add_attrs(bus); 524 bus_add_attrs(bus);
714 525
715 pr_debug("bus type '%s' registered\n", bus->name); 526 pr_debug("bus type '%s' registered\n", bus->name);
@@ -749,12 +560,6 @@ int __init buses_init(void)
749EXPORT_SYMBOL_GPL(bus_for_each_dev); 560EXPORT_SYMBOL_GPL(bus_for_each_dev);
750EXPORT_SYMBOL_GPL(bus_for_each_drv); 561EXPORT_SYMBOL_GPL(bus_for_each_drv);
751 562
752EXPORT_SYMBOL_GPL(driver_probe_device);
753EXPORT_SYMBOL_GPL(device_bind_driver);
754EXPORT_SYMBOL_GPL(device_release_driver);
755EXPORT_SYMBOL_GPL(device_attach);
756EXPORT_SYMBOL_GPL(driver_attach);
757
758EXPORT_SYMBOL_GPL(bus_add_device); 563EXPORT_SYMBOL_GPL(bus_add_device);
759EXPORT_SYMBOL_GPL(bus_remove_device); 564EXPORT_SYMBOL_GPL(bus_remove_device);
760EXPORT_SYMBOL_GPL(bus_register); 565EXPORT_SYMBOL_GPL(bus_register);
diff --git a/drivers/base/class.c b/drivers/base/class.c
index d2a2f8f2b4ed..479c12570881 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -16,6 +16,7 @@
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/string.h> 17#include <linux/string.h>
18#include <linux/kdev_t.h> 18#include <linux/kdev_t.h>
19#include <linux/err.h>
19#include "base.h" 20#include "base.h"
20 21
21#define to_class_attr(_attr) container_of(_attr, struct class_attribute, attr) 22#define to_class_attr(_attr) container_of(_attr, struct class_attribute, attr)
@@ -26,7 +27,7 @@ class_attr_show(struct kobject * kobj, struct attribute * attr, char * buf)
26{ 27{
27 struct class_attribute * class_attr = to_class_attr(attr); 28 struct class_attribute * class_attr = to_class_attr(attr);
28 struct class * dc = to_class(kobj); 29 struct class * dc = to_class(kobj);
29 ssize_t ret = 0; 30 ssize_t ret = -EIO;
30 31
31 if (class_attr->show) 32 if (class_attr->show)
32 ret = class_attr->show(dc, buf); 33 ret = class_attr->show(dc, buf);
@@ -39,7 +40,7 @@ class_attr_store(struct kobject * kobj, struct attribute * attr,
39{ 40{
40 struct class_attribute * class_attr = to_class_attr(attr); 41 struct class_attribute * class_attr = to_class_attr(attr);
41 struct class * dc = to_class(kobj); 42 struct class * dc = to_class(kobj);
42 ssize_t ret = 0; 43 ssize_t ret = -EIO;
43 44
44 if (class_attr->store) 45 if (class_attr->store)
45 ret = class_attr->store(dc, buf, count); 46 ret = class_attr->store(dc, buf, count);
@@ -162,6 +163,69 @@ void class_unregister(struct class * cls)
162 subsystem_unregister(&cls->subsys); 163 subsystem_unregister(&cls->subsys);
163} 164}
164 165
166static void class_create_release(struct class *cls)
167{
168 kfree(cls);
169}
170
171static void class_device_create_release(struct class_device *class_dev)
172{
173 kfree(class_dev);
174}
175
176/**
177 * class_create - create a struct class structure
178 * @owner: pointer to the module that is to "own" this struct class
179 * @name: pointer to a string for the name of this class.
180 *
181 * This is used to create a struct class pointer that can then be used
182 * in calls to class_device_create().
183 *
184 * Note, the pointer created here is to be destroyed when finished by
185 * making a call to class_destroy().
186 */
187struct class *class_create(struct module *owner, char *name)
188{
189 struct class *cls;
190 int retval;
191
192 cls = kmalloc(sizeof(struct class), GFP_KERNEL);
193 if (!cls) {
194 retval = -ENOMEM;
195 goto error;
196 }
197 memset(cls, 0x00, sizeof(struct class));
198
199 cls->name = name;
200 cls->owner = owner;
201 cls->class_release = class_create_release;
202 cls->release = class_device_create_release;
203
204 retval = class_register(cls);
205 if (retval)
206 goto error;
207
208 return cls;
209
210error:
211 kfree(cls);
212 return ERR_PTR(retval);
213}
214
215/**
216 * class_destroy - destroys a struct class structure
217 * @cs: pointer to the struct class that is to be destroyed
218 *
219 * Note, the pointer to be destroyed must have been created with a call
220 * to class_create().
221 */
222void class_destroy(struct class *cls)
223{
224 if ((cls == NULL) || (IS_ERR(cls)))
225 return;
226
227 class_unregister(cls);
228}
165 229
166/* Class Device Stuff */ 230/* Class Device Stuff */
167 231
@@ -262,7 +326,7 @@ static int class_hotplug_filter(struct kset *kset, struct kobject *kobj)
262 return 0; 326 return 0;
263} 327}
264 328
265static char *class_hotplug_name(struct kset *kset, struct kobject *kobj) 329static const char *class_hotplug_name(struct kset *kset, struct kobject *kobj)
266{ 330{
267 struct class_device *class_dev = to_class_dev(kobj); 331 struct class_device *class_dev = to_class_dev(kobj);
268 332
@@ -375,7 +439,6 @@ static ssize_t show_dev(struct class_device *class_dev, char *buf)
375{ 439{
376 return print_dev_t(buf, class_dev->devt); 440 return print_dev_t(buf, class_dev->devt);
377} 441}
378static CLASS_DEVICE_ATTR(dev, S_IRUGO, show_dev, NULL);
379 442
380void class_device_initialize(struct class_device *class_dev) 443void class_device_initialize(struct class_device *class_dev)
381{ 444{
@@ -412,7 +475,31 @@ int class_device_add(struct class_device *class_dev)
412 if ((error = kobject_add(&class_dev->kobj))) 475 if ((error = kobject_add(&class_dev->kobj)))
413 goto register_done; 476 goto register_done;
414 477
415 /* now take care of our own registration */ 478 /* add the needed attributes to this device */
479 if (MAJOR(class_dev->devt)) {
480 struct class_device_attribute *attr;
481 attr = kmalloc(sizeof(*attr), GFP_KERNEL);
482 if (!attr) {
483 error = -ENOMEM;
484 kobject_del(&class_dev->kobj);
485 goto register_done;
486 }
487 memset(attr, sizeof(*attr), 0x00);
488 attr->attr.name = "dev";
489 attr->attr.mode = S_IRUGO;
490 attr->attr.owner = parent->owner;
491 attr->show = show_dev;
492 attr->store = NULL;
493 class_device_create_file(class_dev, attr);
494 class_dev->devt_attr = attr;
495 }
496
497 class_device_add_attrs(class_dev);
498 if (class_dev->dev)
499 sysfs_create_link(&class_dev->kobj,
500 &class_dev->dev->kobj, "device");
501
502 /* notify any interfaces this device is now here */
416 if (parent) { 503 if (parent) {
417 down(&parent->sem); 504 down(&parent->sem);
418 list_add_tail(&class_dev->node, &parent->children); 505 list_add_tail(&class_dev->node, &parent->children);
@@ -421,16 +508,8 @@ int class_device_add(struct class_device *class_dev)
421 class_intf->add(class_dev); 508 class_intf->add(class_dev);
422 up(&parent->sem); 509 up(&parent->sem);
423 } 510 }
424
425 if (MAJOR(class_dev->devt))
426 class_device_create_file(class_dev, &class_device_attr_dev);
427
428 class_device_add_attrs(class_dev);
429 if (class_dev->dev)
430 sysfs_create_link(&class_dev->kobj,
431 &class_dev->dev->kobj, "device");
432
433 kobject_hotplug(&class_dev->kobj, KOBJ_ADD); 511 kobject_hotplug(&class_dev->kobj, KOBJ_ADD);
512
434 register_done: 513 register_done:
435 if (error && parent) 514 if (error && parent)
436 class_put(parent); 515 class_put(parent);
@@ -444,6 +523,58 @@ int class_device_register(struct class_device *class_dev)
444 return class_device_add(class_dev); 523 return class_device_add(class_dev);
445} 524}
446 525
526/**
527 * class_device_create - creates a class device and registers it with sysfs
528 * @cs: pointer to the struct class that this device should be registered to.
529 * @dev: the dev_t for the char device to be added.
530 * @device: a pointer to a struct device that is assiociated with this class device.
531 * @fmt: string for the class device's name
532 *
533 * This function can be used by char device classes. A struct
534 * class_device will be created in sysfs, registered to the specified
535 * class. A "dev" file will be created, showing the dev_t for the
536 * device. The pointer to the struct class_device will be returned from
537 * the call. Any further sysfs files that might be required can be
538 * created using this pointer.
539 *
540 * Note: the struct class passed to this function must have previously
541 * been created with a call to class_create().
542 */
543struct class_device *class_device_create(struct class *cls, dev_t devt,
544 struct device *device, char *fmt, ...)
545{
546 va_list args;
547 struct class_device *class_dev = NULL;
548 int retval = -ENODEV;
549
550 if (cls == NULL || IS_ERR(cls))
551 goto error;
552
553 class_dev = kmalloc(sizeof(struct class_device), GFP_KERNEL);
554 if (!class_dev) {
555 retval = -ENOMEM;
556 goto error;
557 }
558 memset(class_dev, 0x00, sizeof(struct class_device));
559
560 class_dev->devt = devt;
561 class_dev->dev = device;
562 class_dev->class = cls;
563
564 va_start(args, fmt);
565 vsnprintf(class_dev->class_id, BUS_ID_SIZE, fmt, args);
566 va_end(args);
567 retval = class_device_register(class_dev);
568 if (retval)
569 goto error;
570
571 return class_dev;
572
573error:
574 kfree(class_dev);
575 return ERR_PTR(retval);
576}
577
447void class_device_del(struct class_device *class_dev) 578void class_device_del(struct class_device *class_dev)
448{ 579{
449 struct class * parent = class_dev->class; 580 struct class * parent = class_dev->class;
@@ -460,6 +591,11 @@ void class_device_del(struct class_device *class_dev)
460 591
461 if (class_dev->dev) 592 if (class_dev->dev)
462 sysfs_remove_link(&class_dev->kobj, "device"); 593 sysfs_remove_link(&class_dev->kobj, "device");
594 if (class_dev->devt_attr) {
595 class_device_remove_file(class_dev, class_dev->devt_attr);
596 kfree(class_dev->devt_attr);
597 class_dev->devt_attr = NULL;
598 }
463 class_device_remove_attrs(class_dev); 599 class_device_remove_attrs(class_dev);
464 600
465 kobject_hotplug(&class_dev->kobj, KOBJ_REMOVE); 601 kobject_hotplug(&class_dev->kobj, KOBJ_REMOVE);
@@ -477,6 +613,32 @@ void class_device_unregister(struct class_device *class_dev)
477 class_device_put(class_dev); 613 class_device_put(class_dev);
478} 614}
479 615
616/**
617 * class_device_destroy - removes a class device that was created with class_device_create()
618 * @cls: the pointer to the struct class that this device was registered * with.
619 * @dev: the dev_t of the device that was previously registered.
620 *
621 * This call unregisters and cleans up a class device that was created with a
622 * call to class_device_create()
623 */
624void class_device_destroy(struct class *cls, dev_t devt)
625{
626 struct class_device *class_dev = NULL;
627 struct class_device *class_dev_tmp;
628
629 down(&cls->sem);
630 list_for_each_entry(class_dev_tmp, &cls->children, node) {
631 if (class_dev_tmp->devt == devt) {
632 class_dev = class_dev_tmp;
633 break;
634 }
635 }
636 up(&cls->sem);
637
638 if (class_dev)
639 class_device_unregister(class_dev);
640}
641
480int class_device_rename(struct class_device *class_dev, char *new_name) 642int class_device_rename(struct class_device *class_dev, char *new_name)
481{ 643{
482 int error = 0; 644 int error = 0;
@@ -576,6 +738,8 @@ EXPORT_SYMBOL_GPL(class_register);
576EXPORT_SYMBOL_GPL(class_unregister); 738EXPORT_SYMBOL_GPL(class_unregister);
577EXPORT_SYMBOL_GPL(class_get); 739EXPORT_SYMBOL_GPL(class_get);
578EXPORT_SYMBOL_GPL(class_put); 740EXPORT_SYMBOL_GPL(class_put);
741EXPORT_SYMBOL_GPL(class_create);
742EXPORT_SYMBOL_GPL(class_destroy);
579 743
580EXPORT_SYMBOL_GPL(class_device_register); 744EXPORT_SYMBOL_GPL(class_device_register);
581EXPORT_SYMBOL_GPL(class_device_unregister); 745EXPORT_SYMBOL_GPL(class_device_unregister);
@@ -584,6 +748,8 @@ EXPORT_SYMBOL_GPL(class_device_add);
584EXPORT_SYMBOL_GPL(class_device_del); 748EXPORT_SYMBOL_GPL(class_device_del);
585EXPORT_SYMBOL_GPL(class_device_get); 749EXPORT_SYMBOL_GPL(class_device_get);
586EXPORT_SYMBOL_GPL(class_device_put); 750EXPORT_SYMBOL_GPL(class_device_put);
751EXPORT_SYMBOL_GPL(class_device_create);
752EXPORT_SYMBOL_GPL(class_device_destroy);
587EXPORT_SYMBOL_GPL(class_device_create_file); 753EXPORT_SYMBOL_GPL(class_device_create_file);
588EXPORT_SYMBOL_GPL(class_device_remove_file); 754EXPORT_SYMBOL_GPL(class_device_remove_file);
589EXPORT_SYMBOL_GPL(class_device_create_bin_file); 755EXPORT_SYMBOL_GPL(class_device_create_bin_file);
diff --git a/drivers/base/class_simple.c b/drivers/base/class_simple.c
deleted file mode 100644
index 27699eb20a37..000000000000
--- a/drivers/base/class_simple.c
+++ /dev/null
@@ -1,199 +0,0 @@
1/*
2 * class_simple.c - a "simple" interface for classes for simple char devices.
3 *
4 * Copyright (c) 2003-2004 Greg Kroah-Hartman <greg@kroah.com>
5 * Copyright (c) 2003-2004 IBM Corp.
6 *
7 * This file is released under the GPLv2
8 *
9 */
10
11#include <linux/config.h>
12#include <linux/device.h>
13#include <linux/err.h>
14
15struct class_simple {
16 struct class class;
17};
18#define to_class_simple(d) container_of(d, struct class_simple, class)
19
20struct simple_dev {
21 struct list_head node;
22 struct class_device class_dev;
23};
24#define to_simple_dev(d) container_of(d, struct simple_dev, class_dev)
25
26static LIST_HEAD(simple_dev_list);
27static DEFINE_SPINLOCK(simple_dev_list_lock);
28
29static void release_simple_dev(struct class_device *class_dev)
30{
31 struct simple_dev *s_dev = to_simple_dev(class_dev);
32 kfree(s_dev);
33}
34
35static void class_simple_release(struct class *class)
36{
37 struct class_simple *cs = to_class_simple(class);
38 kfree(cs);
39}
40
41/**
42 * class_simple_create - create a struct class_simple structure
43 * @owner: pointer to the module that is to "own" this struct class_simple
44 * @name: pointer to a string for the name of this class.
45 *
46 * This is used to create a struct class_simple pointer that can then be used
47 * in calls to class_simple_device_add(). This is used when you do not wish to
48 * create a full blown class support for a type of char devices.
49 *
50 * Note, the pointer created here is to be destroyed when finished by making a
51 * call to class_simple_destroy().
52 */
53struct class_simple *class_simple_create(struct module *owner, char *name)
54{
55 struct class_simple *cs;
56 int retval;
57
58 cs = kmalloc(sizeof(*cs), GFP_KERNEL);
59 if (!cs) {
60 retval = -ENOMEM;
61 goto error;
62 }
63 memset(cs, 0x00, sizeof(*cs));
64
65 cs->class.name = name;
66 cs->class.class_release = class_simple_release;
67 cs->class.release = release_simple_dev;
68
69 retval = class_register(&cs->class);
70 if (retval)
71 goto error;
72
73 return cs;
74
75error:
76 kfree(cs);
77 return ERR_PTR(retval);
78}
79EXPORT_SYMBOL(class_simple_create);
80
81/**
82 * class_simple_destroy - destroys a struct class_simple structure
83 * @cs: pointer to the struct class_simple that is to be destroyed
84 *
85 * Note, the pointer to be destroyed must have been created with a call to
86 * class_simple_create().
87 */
88void class_simple_destroy(struct class_simple *cs)
89{
90 if ((cs == NULL) || (IS_ERR(cs)))
91 return;
92
93 class_unregister(&cs->class);
94}
95EXPORT_SYMBOL(class_simple_destroy);
96
97/**
98 * class_simple_device_add - adds a class device to sysfs for a character driver
99 * @cs: pointer to the struct class_simple that this device should be registered to.
100 * @dev: the dev_t for the device to be added.
101 * @device: a pointer to a struct device that is assiociated with this class device.
102 * @fmt: string for the class device's name
103 *
104 * This function can be used by simple char device classes that do not
105 * implement their own class device registration. A struct class_device will
106 * be created in sysfs, registered to the specified class. A "dev" file will
107 * be created, showing the dev_t for the device. The pointer to the struct
108 * class_device will be returned from the call. Any further sysfs files that
109 * might be required can be created using this pointer.
110 * Note: the struct class_simple passed to this function must have previously been
111 * created with a call to class_simple_create().
112 */
113struct class_device *class_simple_device_add(struct class_simple *cs, dev_t dev, struct device *device, const char *fmt, ...)
114{
115 va_list args;
116 struct simple_dev *s_dev = NULL;
117 int retval;
118
119 if ((cs == NULL) || (IS_ERR(cs))) {
120 retval = -ENODEV;
121 goto error;
122 }
123
124 s_dev = kmalloc(sizeof(*s_dev), GFP_KERNEL);
125 if (!s_dev) {
126 retval = -ENOMEM;
127 goto error;
128 }
129 memset(s_dev, 0x00, sizeof(*s_dev));
130
131 s_dev->class_dev.devt = dev;
132 s_dev->class_dev.dev = device;
133 s_dev->class_dev.class = &cs->class;
134
135 va_start(args, fmt);
136 vsnprintf(s_dev->class_dev.class_id, BUS_ID_SIZE, fmt, args);
137 va_end(args);
138 retval = class_device_register(&s_dev->class_dev);
139 if (retval)
140 goto error;
141
142 spin_lock(&simple_dev_list_lock);
143 list_add(&s_dev->node, &simple_dev_list);
144 spin_unlock(&simple_dev_list_lock);
145
146 return &s_dev->class_dev;
147
148error:
149 kfree(s_dev);
150 return ERR_PTR(retval);
151}
152EXPORT_SYMBOL(class_simple_device_add);
153
154/**
155 * class_simple_set_hotplug - set the hotplug callback in the embedded struct class
156 * @cs: pointer to the struct class_simple to hold the pointer
157 * @hotplug: function pointer to the hotplug function
158 *
159 * Implement and set a hotplug function to add environment variables specific to this
160 * class on the hotplug event.
161 */
162int class_simple_set_hotplug(struct class_simple *cs,
163 int (*hotplug)(struct class_device *dev, char **envp, int num_envp, char *buffer, int buffer_size))
164{
165 if ((cs == NULL) || (IS_ERR(cs)))
166 return -ENODEV;
167 cs->class.hotplug = hotplug;
168 return 0;
169}
170EXPORT_SYMBOL(class_simple_set_hotplug);
171
172/**
173 * class_simple_device_remove - removes a class device that was created with class_simple_device_add()
174 * @dev: the dev_t of the device that was previously registered.
175 *
176 * This call unregisters and cleans up a class device that was created with a
177 * call to class_device_simple_add()
178 */
179void class_simple_device_remove(dev_t dev)
180{
181 struct simple_dev *s_dev = NULL;
182 int found = 0;
183
184 spin_lock(&simple_dev_list_lock);
185 list_for_each_entry(s_dev, &simple_dev_list, node) {
186 if (s_dev->class_dev.devt == dev) {
187 found = 1;
188 break;
189 }
190 }
191 if (found) {
192 list_del(&s_dev->node);
193 spin_unlock(&simple_dev_list_lock);
194 class_device_unregister(&s_dev->class_dev);
195 } else {
196 spin_unlock(&simple_dev_list_lock);
197 }
198}
199EXPORT_SYMBOL(class_simple_device_remove);
diff --git a/drivers/base/core.c b/drivers/base/core.c
index fbc223486f81..86d79755fbfb 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -36,10 +36,10 @@ dev_attr_show(struct kobject * kobj, struct attribute * attr, char * buf)
36{ 36{
37 struct device_attribute * dev_attr = to_dev_attr(attr); 37 struct device_attribute * dev_attr = to_dev_attr(attr);
38 struct device * dev = to_dev(kobj); 38 struct device * dev = to_dev(kobj);
39 ssize_t ret = 0; 39 ssize_t ret = -EIO;
40 40
41 if (dev_attr->show) 41 if (dev_attr->show)
42 ret = dev_attr->show(dev, buf); 42 ret = dev_attr->show(dev, dev_attr, buf);
43 return ret; 43 return ret;
44} 44}
45 45
@@ -49,10 +49,10 @@ dev_attr_store(struct kobject * kobj, struct attribute * attr,
49{ 49{
50 struct device_attribute * dev_attr = to_dev_attr(attr); 50 struct device_attribute * dev_attr = to_dev_attr(attr);
51 struct device * dev = to_dev(kobj); 51 struct device * dev = to_dev(kobj);
52 ssize_t ret = 0; 52 ssize_t ret = -EIO;
53 53
54 if (dev_attr->store) 54 if (dev_attr->store)
55 ret = dev_attr->store(dev, buf, count); 55 ret = dev_attr->store(dev, dev_attr, buf, count);
56 return ret; 56 return ret;
57} 57}
58 58
@@ -102,7 +102,7 @@ static int dev_hotplug_filter(struct kset *kset, struct kobject *kobj)
102 return 0; 102 return 0;
103} 103}
104 104
105static char *dev_hotplug_name(struct kset *kset, struct kobject *kobj) 105static const char *dev_hotplug_name(struct kset *kset, struct kobject *kobj)
106{ 106{
107 struct device *dev = to_dev(kobj); 107 struct device *dev = to_dev(kobj);
108 108
@@ -207,11 +207,9 @@ void device_initialize(struct device *dev)
207{ 207{
208 kobj_set_kset_s(dev, devices_subsys); 208 kobj_set_kset_s(dev, devices_subsys);
209 kobject_init(&dev->kobj); 209 kobject_init(&dev->kobj);
210 INIT_LIST_HEAD(&dev->node); 210 klist_init(&dev->klist_children);
211 INIT_LIST_HEAD(&dev->children);
212 INIT_LIST_HEAD(&dev->driver_list);
213 INIT_LIST_HEAD(&dev->bus_list);
214 INIT_LIST_HEAD(&dev->dma_pools); 211 INIT_LIST_HEAD(&dev->dma_pools);
212 init_MUTEX(&dev->sem);
215} 213}
216 214
217/** 215/**
@@ -250,10 +248,8 @@ int device_add(struct device *dev)
250 goto PMError; 248 goto PMError;
251 if ((error = bus_add_device(dev))) 249 if ((error = bus_add_device(dev)))
252 goto BusError; 250 goto BusError;
253 down_write(&devices_subsys.rwsem);
254 if (parent) 251 if (parent)
255 list_add_tail(&dev->node, &parent->children); 252 klist_add_tail(&parent->klist_children, &dev->knode_parent);
256 up_write(&devices_subsys.rwsem);
257 253
258 /* notify platform of device entry */ 254 /* notify platform of device entry */
259 if (platform_notify) 255 if (platform_notify)
@@ -336,10 +332,8 @@ void device_del(struct device * dev)
336{ 332{
337 struct device * parent = dev->parent; 333 struct device * parent = dev->parent;
338 334
339 down_write(&devices_subsys.rwsem);
340 if (parent) 335 if (parent)
341 list_del_init(&dev->node); 336 klist_remove(&dev->knode_parent);
342 up_write(&devices_subsys.rwsem);
343 337
344 /* Notify the platform of the removal, in case they 338 /* Notify the platform of the removal, in case they
345 * need to do anything... 339 * need to do anything...
@@ -373,6 +367,12 @@ void device_unregister(struct device * dev)
373} 367}
374 368
375 369
370static struct device * next_device(struct klist_iter * i)
371{
372 struct klist_node * n = klist_next(i);
373 return n ? container_of(n, struct device, knode_parent) : NULL;
374}
375
376/** 376/**
377 * device_for_each_child - device child iterator. 377 * device_for_each_child - device child iterator.
378 * @dev: parent struct device. 378 * @dev: parent struct device.
@@ -385,39 +385,20 @@ void device_unregister(struct device * dev)
385 * We check the return of @fn each time. If it returns anything 385 * We check the return of @fn each time. If it returns anything
386 * other than 0, we break out and return that value. 386 * other than 0, we break out and return that value.
387 */ 387 */
388int device_for_each_child(struct device * dev, void * data, 388int device_for_each_child(struct device * parent, void * data,
389 int (*fn)(struct device *, void *)) 389 int (*fn)(struct device *, void *))
390{ 390{
391 struct klist_iter i;
391 struct device * child; 392 struct device * child;
392 int error = 0; 393 int error = 0;
393 394
394 down_read(&devices_subsys.rwsem); 395 klist_iter_init(&parent->klist_children, &i);
395 list_for_each_entry(child, &dev->children, node) { 396 while ((child = next_device(&i)) && !error)
396 if((error = fn(child, data))) 397 error = fn(child, data);
397 break; 398 klist_iter_exit(&i);
398 }
399 up_read(&devices_subsys.rwsem);
400 return error; 399 return error;
401} 400}
402 401
403/**
404 * device_find - locate device on a bus by name.
405 * @name: name of the device.
406 * @bus: bus to scan for the device.
407 *
408 * Call kset_find_obj() to iterate over list of devices on
409 * a bus to find device by name. Return device if found.
410 *
411 * Note that kset_find_obj increments device's reference count.
412 */
413struct device *device_find(const char *name, struct bus_type *bus)
414{
415 struct kobject *k = kset_find_obj(&bus->devices, name);
416 if (k)
417 return to_dev(k);
418 return NULL;
419}
420
421int __init devices_init(void) 402int __init devices_init(void)
422{ 403{
423 return subsystem_register(&devices_subsys); 404 return subsystem_register(&devices_subsys);
@@ -433,7 +414,6 @@ EXPORT_SYMBOL_GPL(device_del);
433EXPORT_SYMBOL_GPL(device_unregister); 414EXPORT_SYMBOL_GPL(device_unregister);
434EXPORT_SYMBOL_GPL(get_device); 415EXPORT_SYMBOL_GPL(get_device);
435EXPORT_SYMBOL_GPL(put_device); 416EXPORT_SYMBOL_GPL(put_device);
436EXPORT_SYMBOL_GPL(device_find);
437 417
438EXPORT_SYMBOL_GPL(device_create_file); 418EXPORT_SYMBOL_GPL(device_create_file);
439EXPORT_SYMBOL_GPL(device_remove_file); 419EXPORT_SYMBOL_GPL(device_remove_file);
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
new file mode 100644
index 000000000000..6db3a789c54f
--- /dev/null
+++ b/drivers/base/dd.c
@@ -0,0 +1,248 @@
1/*
2 * drivers/base/dd.c - The core device/driver interactions.
3 *
4 * This file contains the (sometimes tricky) code that controls the
5 * interactions between devices and drivers, which primarily includes
6 * driver binding and unbinding.
7 *
8 * All of this code used to exist in drivers/base/bus.c, but was
9 * relocated to here in the name of compartmentalization (since it wasn't
10 * strictly code just for the 'struct bus_type'.
11 *
12 * Copyright (c) 2002-5 Patrick Mochel
13 * Copyright (c) 2002-3 Open Source Development Labs
14 *
15 * This file is released under the GPLv2
16 */
17
18#include <linux/device.h>
19#include <linux/module.h>
20
21#include "base.h"
22#include "power/power.h"
23
24#define to_drv(node) container_of(node, struct device_driver, kobj.entry)
25
26
27/**
28 * device_bind_driver - bind a driver to one device.
29 * @dev: device.
30 *
31 * Allow manual attachment of a driver to a device.
32 * Caller must have already set @dev->driver.
33 *
34 * Note that this does not modify the bus reference count
35 * nor take the bus's rwsem. Please verify those are accounted
36 * for before calling this. (It is ok to call with no other effort
37 * from a driver's probe() method.)
38 *
39 * This function must be called with @dev->sem held.
40 */
41void device_bind_driver(struct device * dev)
42{
43 pr_debug("bound device '%s' to driver '%s'\n",
44 dev->bus_id, dev->driver->name);
45 klist_add_tail(&dev->driver->klist_devices, &dev->knode_driver);
46 sysfs_create_link(&dev->driver->kobj, &dev->kobj,
47 kobject_name(&dev->kobj));
48 sysfs_create_link(&dev->kobj, &dev->driver->kobj, "driver");
49}
50
51/**
52 * driver_probe_device - attempt to bind device & driver.
53 * @drv: driver.
54 * @dev: device.
55 *
56 * First, we call the bus's match function, if one present, which
57 * should compare the device IDs the driver supports with the
58 * device IDs of the device. Note we don't do this ourselves
59 * because we don't know the format of the ID structures, nor what
60 * is to be considered a match and what is not.
61 *
62 *
63 * This function returns 1 if a match is found, an error if one
64 * occurs (that is not -ENODEV or -ENXIO), and 0 otherwise.
65 *
66 * This function must be called with @dev->sem held.
67 */
68static int driver_probe_device(struct device_driver * drv, struct device * dev)
69{
70 int ret = 0;
71
72 if (drv->bus->match && !drv->bus->match(dev, drv))
73 goto Done;
74
75 pr_debug("%s: Matched Device %s with Driver %s\n",
76 drv->bus->name, dev->bus_id, drv->name);
77 dev->driver = drv;
78 if (drv->probe) {
79 ret = drv->probe(dev);
80 if (ret) {
81 dev->driver = NULL;
82 goto ProbeFailed;
83 }
84 }
85 device_bind_driver(dev);
86 ret = 1;
87 pr_debug("%s: Bound Device %s to Driver %s\n",
88 drv->bus->name, dev->bus_id, drv->name);
89 goto Done;
90
91 ProbeFailed:
92 if (ret == -ENODEV || ret == -ENXIO) {
93 /* Driver matched, but didn't support device
94 * or device not found.
95 * Not an error; keep going.
96 */
97 ret = 0;
98 } else {
99 /* driver matched but the probe failed */
100 printk(KERN_WARNING
101 "%s: probe of %s failed with error %d\n",
102 drv->name, dev->bus_id, ret);
103 }
104 Done:
105 return ret;
106}
107
108static int __device_attach(struct device_driver * drv, void * data)
109{
110 struct device * dev = data;
111 return driver_probe_device(drv, dev);
112}
113
114/**
115 * device_attach - try to attach device to a driver.
116 * @dev: device.
117 *
118 * Walk the list of drivers that the bus has and call
119 * driver_probe_device() for each pair. If a compatible
120 * pair is found, break out and return.
121 *
122 * Returns 1 if the device was bound to a driver;
123 * 0 if no matching device was found; error code otherwise.
124 */
125int device_attach(struct device * dev)
126{
127 int ret = 0;
128
129 down(&dev->sem);
130 if (dev->driver) {
131 device_bind_driver(dev);
132 ret = 1;
133 } else
134 ret = bus_for_each_drv(dev->bus, NULL, dev, __device_attach);
135 up(&dev->sem);
136 return ret;
137}
138
139static int __driver_attach(struct device * dev, void * data)
140{
141 struct device_driver * drv = data;
142
143 /*
144 * Lock device and try to bind to it. We drop the error
145 * here and always return 0, because we need to keep trying
146 * to bind to devices and some drivers will return an error
147 * simply if it didn't support the device.
148 *
149 * driver_probe_device() will spit a warning if there
150 * is an error.
151 */
152
153 down(&dev->sem);
154 if (!dev->driver)
155 driver_probe_device(drv, dev);
156 up(&dev->sem);
157
158
159 return 0;
160}
161
162/**
163 * driver_attach - try to bind driver to devices.
164 * @drv: driver.
165 *
166 * Walk the list of devices that the bus has on it and try to
167 * match the driver with each one. If driver_probe_device()
168 * returns 0 and the @dev->driver is set, we've found a
169 * compatible pair.
170 */
171void driver_attach(struct device_driver * drv)
172{
173 bus_for_each_dev(drv->bus, NULL, drv, __driver_attach);
174}
175
176/**
177 * device_release_driver - manually detach device from driver.
178 * @dev: device.
179 *
180 * Manually detach device from driver.
181 *
182 * __device_release_driver() must be called with @dev->sem held.
183 */
184
185static void __device_release_driver(struct device * dev)
186{
187 struct device_driver * drv;
188
189 drv = dev->driver;
190 if (drv) {
191 get_driver(drv);
192 sysfs_remove_link(&drv->kobj, kobject_name(&dev->kobj));
193 sysfs_remove_link(&dev->kobj, "driver");
194 klist_remove(&dev->knode_driver);
195
196 if (drv->remove)
197 drv->remove(dev);
198 dev->driver = NULL;
199 put_driver(drv);
200 }
201}
202
203void device_release_driver(struct device * dev)
204{
205 /*
206 * If anyone calls device_release_driver() recursively from
207 * within their ->remove callback for the same device, they
208 * will deadlock right here.
209 */
210 down(&dev->sem);
211 __device_release_driver(dev);
212 up(&dev->sem);
213}
214
215
216/**
217 * driver_detach - detach driver from all devices it controls.
218 * @drv: driver.
219 */
220void driver_detach(struct device_driver * drv)
221{
222 struct device * dev;
223
224 for (;;) {
225 spin_lock_irq(&drv->klist_devices.k_lock);
226 if (list_empty(&drv->klist_devices.k_list)) {
227 spin_unlock_irq(&drv->klist_devices.k_lock);
228 break;
229 }
230 dev = list_entry(drv->klist_devices.k_list.prev,
231 struct device, knode_driver.n_node);
232 get_device(dev);
233 spin_unlock_irq(&drv->klist_devices.k_lock);
234
235 down(&dev->sem);
236 if (dev->driver == drv)
237 __device_release_driver(dev);
238 up(&dev->sem);
239 put_device(dev);
240 }
241}
242
243
244EXPORT_SYMBOL_GPL(device_bind_driver);
245EXPORT_SYMBOL_GPL(device_release_driver);
246EXPORT_SYMBOL_GPL(device_attach);
247EXPORT_SYMBOL_GPL(driver_attach);
248
diff --git a/drivers/base/dmapool.c b/drivers/base/dmapool.c
index f48833df61a2..c4aebf2f522d 100644
--- a/drivers/base/dmapool.c
+++ b/drivers/base/dmapool.c
@@ -41,7 +41,7 @@ struct dma_page { /* cacheable header for 'allocation' bytes */
41static DECLARE_MUTEX (pools_lock); 41static DECLARE_MUTEX (pools_lock);
42 42
43static ssize_t 43static ssize_t
44show_pools (struct device *dev, char *buf) 44show_pools (struct device *dev, struct device_attribute *attr, char *buf)
45{ 45{
46 unsigned temp; 46 unsigned temp;
47 unsigned size; 47 unsigned size;
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 3b269f7e5213..1b645886e9eb 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -18,6 +18,43 @@
18#define to_dev(node) container_of(node, struct device, driver_list) 18#define to_dev(node) container_of(node, struct device, driver_list)
19#define to_drv(obj) container_of(obj, struct device_driver, kobj) 19#define to_drv(obj) container_of(obj, struct device_driver, kobj)
20 20
21
22static struct device * next_device(struct klist_iter * i)
23{
24 struct klist_node * n = klist_next(i);
25 return n ? container_of(n, struct device, knode_driver) : NULL;
26}
27
28/**
29 * driver_for_each_device - Iterator for devices bound to a driver.
30 * @drv: Driver we're iterating.
31 * @data: Data to pass to the callback.
32 * @fn: Function to call for each device.
33 *
34 * Iterate over the @drv's list of devices calling @fn for each one.
35 */
36
37int driver_for_each_device(struct device_driver * drv, struct device * start,
38 void * data, int (*fn)(struct device *, void *))
39{
40 struct klist_iter i;
41 struct device * dev;
42 int error = 0;
43
44 if (!drv)
45 return -EINVAL;
46
47 klist_iter_init_node(&drv->klist_devices, &i,
48 start ? &start->knode_driver : NULL);
49 while ((dev = next_device(&i)) && !error)
50 error = fn(dev, data);
51 klist_iter_exit(&i);
52 return error;
53}
54
55EXPORT_SYMBOL_GPL(driver_for_each_device);
56
57
21/** 58/**
22 * driver_create_file - create sysfs file for driver. 59 * driver_create_file - create sysfs file for driver.
23 * @drv: driver. 60 * @drv: driver.
@@ -85,7 +122,7 @@ void put_driver(struct device_driver * drv)
85 */ 122 */
86int driver_register(struct device_driver * drv) 123int driver_register(struct device_driver * drv)
87{ 124{
88 INIT_LIST_HEAD(&drv->devices); 125 klist_init(&drv->klist_devices);
89 init_completion(&drv->unloaded); 126 init_completion(&drv->unloaded);
90 return bus_add_driver(drv); 127 return bus_add_driver(drv);
91} 128}
diff --git a/drivers/base/node.c b/drivers/base/node.c
index 583d57ec49a8..5d4517ccc422 100644
--- a/drivers/base/node.c
+++ b/drivers/base/node.c
@@ -136,7 +136,7 @@ static SYSDEV_ATTR(distance, S_IRUGO, node_read_distance, NULL);
136 * 136 *
137 * Initialize and register the node device. 137 * Initialize and register the node device.
138 */ 138 */
139int __init register_node(struct node *node, int num, struct node *parent) 139int register_node(struct node *node, int num, struct node *parent)
140{ 140{
141 int error; 141 int error;
142 142
@@ -153,8 +153,24 @@ int __init register_node(struct node *node, int num, struct node *parent)
153 return error; 153 return error;
154} 154}
155 155
156/**
157 * unregister_node - unregister a node device
158 * @node: node going away
159 *
160 * Unregisters a node device @node. All the devices on the node must be
161 * unregistered before calling this function.
162 */
163void unregister_node(struct node *node)
164{
165 sysdev_remove_file(&node->sysdev, &attr_cpumap);
166 sysdev_remove_file(&node->sysdev, &attr_meminfo);
167 sysdev_remove_file(&node->sysdev, &attr_numastat);
168 sysdev_remove_file(&node->sysdev, &attr_distance);
169
170 sysdev_unregister(&node->sysdev);
171}
156 172
157int __init register_node_type(void) 173static int __init register_node_type(void)
158{ 174{
159 return sysdev_class_register(&node_class); 175 return sysdev_class_register(&node_class);
160} 176}
diff --git a/drivers/base/power/resume.c b/drivers/base/power/resume.c
index 26468971ef5a..bdd96b03b885 100644
--- a/drivers/base/power/resume.c
+++ b/drivers/base/power/resume.c
@@ -22,6 +22,9 @@ extern int sysdev_resume(void);
22 22
23int resume_device(struct device * dev) 23int resume_device(struct device * dev)
24{ 24{
25 int error = 0;
26
27 down(&dev->sem);
25 if (dev->power.pm_parent 28 if (dev->power.pm_parent
26 && dev->power.pm_parent->power.power_state) { 29 && dev->power.pm_parent->power.power_state) {
27 dev_err(dev, "PM: resume from %d, parent %s still %d\n", 30 dev_err(dev, "PM: resume from %d, parent %s still %d\n",
@@ -31,9 +34,10 @@ int resume_device(struct device * dev)
31 } 34 }
32 if (dev->bus && dev->bus->resume) { 35 if (dev->bus && dev->bus->resume) {
33 dev_dbg(dev,"resuming\n"); 36 dev_dbg(dev,"resuming\n");
34 return dev->bus->resume(dev); 37 error = dev->bus->resume(dev);
35 } 38 }
36 return 0; 39 up(&dev->sem);
40 return error;
37} 41}
38 42
39 43
diff --git a/drivers/base/power/suspend.c b/drivers/base/power/suspend.c
index 0ec44ef840be..2ccee3763acf 100644
--- a/drivers/base/power/suspend.c
+++ b/drivers/base/power/suspend.c
@@ -39,6 +39,7 @@ int suspend_device(struct device * dev, pm_message_t state)
39{ 39{
40 int error = 0; 40 int error = 0;
41 41
42 down(&dev->sem);
42 if (dev->power.power_state) { 43 if (dev->power.power_state) {
43 dev_dbg(dev, "PM: suspend %d-->%d\n", 44 dev_dbg(dev, "PM: suspend %d-->%d\n",
44 dev->power.power_state, state); 45 dev->power.power_state, state);
@@ -58,7 +59,7 @@ int suspend_device(struct device * dev, pm_message_t state)
58 dev_dbg(dev, "suspending\n"); 59 dev_dbg(dev, "suspending\n");
59 error = dev->bus->suspend(dev, state); 60 error = dev->bus->suspend(dev, state);
60 } 61 }
61 62 up(&dev->sem);
62 return error; 63 return error;
63} 64}
64 65
@@ -113,8 +114,19 @@ int device_suspend(pm_message_t state)
113 put_device(dev); 114 put_device(dev);
114 } 115 }
115 up(&dpm_list_sem); 116 up(&dpm_list_sem);
116 if (error) 117 if (error) {
118 /* we failed... before resuming, bring back devices from
119 * dpm_off_irq list back to main dpm_off list, we do want
120 * to call resume() on them, in case they partially suspended
121 * despite returning -EAGAIN
122 */
123 while (!list_empty(&dpm_off_irq)) {
124 struct list_head * entry = dpm_off_irq.next;
125 list_del(entry);
126 list_add(entry, &dpm_off);
127 }
117 dpm_resume(); 128 dpm_resume();
129 }
118 up(&dpm_sem); 130 up(&dpm_sem);
119 return error; 131 return error;
120} 132}
diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
index 6ac96349a8e8..f82b3df9545f 100644
--- a/drivers/base/power/sysfs.c
+++ b/drivers/base/power/sysfs.c
@@ -24,12 +24,12 @@
24 * low-power state. 24 * low-power state.
25 */ 25 */
26 26
27static ssize_t state_show(struct device * dev, char * buf) 27static ssize_t state_show(struct device * dev, struct device_attribute *attr, char * buf)
28{ 28{
29 return sprintf(buf, "%u\n", dev->power.power_state); 29 return sprintf(buf, "%u\n", dev->power.power_state);
30} 30}
31 31
32static ssize_t state_store(struct device * dev, const char * buf, size_t n) 32static ssize_t state_store(struct device * dev, struct device_attribute *attr, const char * buf, size_t n)
33{ 33{
34 u32 state; 34 u32 state;
35 char * rest; 35 char * rest;
diff --git a/drivers/base/sys.c b/drivers/base/sys.c
index 9102e3756f95..f37a13de804a 100644
--- a/drivers/base/sys.c
+++ b/drivers/base/sys.c
@@ -37,7 +37,7 @@ sysdev_show(struct kobject * kobj, struct attribute * attr, char * buffer)
37 37
38 if (sysdev_attr->show) 38 if (sysdev_attr->show)
39 return sysdev_attr->show(sysdev, buffer); 39 return sysdev_attr->show(sysdev, buffer);
40 return 0; 40 return -EIO;
41} 41}
42 42
43 43
@@ -50,7 +50,7 @@ sysdev_store(struct kobject * kobj, struct attribute * attr,
50 50
51 if (sysdev_attr->store) 51 if (sysdev_attr->store)
52 return sysdev_attr->store(sysdev, buffer, count); 52 return sysdev_attr->store(sysdev, buffer, count);
53 return 0; 53 return -EIO;
54} 54}
55 55
56static struct sysfs_ops sysfs_ops = { 56static struct sysfs_ops sysfs_ops = {
diff --git a/drivers/block/aoe/aoechr.c b/drivers/block/aoe/aoechr.c
index 14aeca3e2e8c..45a243096187 100644
--- a/drivers/block/aoe/aoechr.c
+++ b/drivers/block/aoe/aoechr.c
@@ -36,7 +36,7 @@ static int emsgs_head_idx, emsgs_tail_idx;
36static struct semaphore emsgs_sema; 36static struct semaphore emsgs_sema;
37static spinlock_t emsgs_lock; 37static spinlock_t emsgs_lock;
38static int nblocked_emsgs_readers; 38static int nblocked_emsgs_readers;
39static struct class_simple *aoe_class; 39static struct class *aoe_class;
40static struct aoe_chardev chardevs[] = { 40static struct aoe_chardev chardevs[] = {
41 { MINOR_ERR, "err" }, 41 { MINOR_ERR, "err" },
42 { MINOR_DISCOVER, "discover" }, 42 { MINOR_DISCOVER, "discover" },
@@ -218,13 +218,13 @@ aoechr_init(void)
218 } 218 }
219 sema_init(&emsgs_sema, 0); 219 sema_init(&emsgs_sema, 0);
220 spin_lock_init(&emsgs_lock); 220 spin_lock_init(&emsgs_lock);
221 aoe_class = class_simple_create(THIS_MODULE, "aoe"); 221 aoe_class = class_create(THIS_MODULE, "aoe");
222 if (IS_ERR(aoe_class)) { 222 if (IS_ERR(aoe_class)) {
223 unregister_chrdev(AOE_MAJOR, "aoechr"); 223 unregister_chrdev(AOE_MAJOR, "aoechr");
224 return PTR_ERR(aoe_class); 224 return PTR_ERR(aoe_class);
225 } 225 }
226 for (i = 0; i < ARRAY_SIZE(chardevs); ++i) 226 for (i = 0; i < ARRAY_SIZE(chardevs); ++i)
227 class_simple_device_add(aoe_class, 227 class_device_create(aoe_class,
228 MKDEV(AOE_MAJOR, chardevs[i].minor), 228 MKDEV(AOE_MAJOR, chardevs[i].minor),
229 NULL, chardevs[i].name); 229 NULL, chardevs[i].name);
230 230
@@ -237,8 +237,8 @@ aoechr_exit(void)
237 int i; 237 int i;
238 238
239 for (i = 0; i < ARRAY_SIZE(chardevs); ++i) 239 for (i = 0; i < ARRAY_SIZE(chardevs); ++i)
240 class_simple_device_remove(MKDEV(AOE_MAJOR, chardevs[i].minor)); 240 class_device_destroy(aoe_class, MKDEV(AOE_MAJOR, chardevs[i].minor));
241 class_simple_destroy(aoe_class); 241 class_destroy(aoe_class);
242 unregister_chrdev(AOE_MAJOR, "aoechr"); 242 unregister_chrdev(AOE_MAJOR, "aoechr");
243} 243}
244 244
diff --git a/drivers/block/as-iosched.c b/drivers/block/as-iosched.c
index a9575bb58a5e..638db06de2be 100644
--- a/drivers/block/as-iosched.c
+++ b/drivers/block/as-iosched.c
@@ -2044,7 +2044,7 @@ as_attr_show(struct kobject *kobj, struct attribute *attr, char *page)
2044 struct as_fs_entry *entry = to_as(attr); 2044 struct as_fs_entry *entry = to_as(attr);
2045 2045
2046 if (!entry->show) 2046 if (!entry->show)
2047 return 0; 2047 return -EIO;
2048 2048
2049 return entry->show(e->elevator_data, page); 2049 return entry->show(e->elevator_data, page);
2050} 2050}
@@ -2057,7 +2057,7 @@ as_attr_store(struct kobject *kobj, struct attribute *attr,
2057 struct as_fs_entry *entry = to_as(attr); 2057 struct as_fs_entry *entry = to_as(attr);
2058 2058
2059 if (!entry->store) 2059 if (!entry->store)
2060 return -EINVAL; 2060 return -EIO;
2061 2061
2062 return entry->store(e->elevator_data, page, length); 2062 return entry->store(e->elevator_data, page, length);
2063} 2063}
diff --git a/drivers/block/cfq-iosched.c b/drivers/block/cfq-iosched.c
index 2210bacad56a..3ac47dde64da 100644
--- a/drivers/block/cfq-iosched.c
+++ b/drivers/block/cfq-iosched.c
@@ -1775,7 +1775,7 @@ cfq_attr_show(struct kobject *kobj, struct attribute *attr, char *page)
1775 struct cfq_fs_entry *entry = to_cfq(attr); 1775 struct cfq_fs_entry *entry = to_cfq(attr);
1776 1776
1777 if (!entry->show) 1777 if (!entry->show)
1778 return 0; 1778 return -EIO;
1779 1779
1780 return entry->show(e->elevator_data, page); 1780 return entry->show(e->elevator_data, page);
1781} 1781}
@@ -1788,7 +1788,7 @@ cfq_attr_store(struct kobject *kobj, struct attribute *attr,
1788 struct cfq_fs_entry *entry = to_cfq(attr); 1788 struct cfq_fs_entry *entry = to_cfq(attr);
1789 1789
1790 if (!entry->store) 1790 if (!entry->store)
1791 return -EINVAL; 1791 return -EIO;
1792 1792
1793 return entry->store(e->elevator_data, page, length); 1793 return entry->store(e->elevator_data, page, length);
1794} 1794}
diff --git a/drivers/block/deadline-iosched.c b/drivers/block/deadline-iosched.c
index d63d34c671f7..7f79f3dd0165 100644
--- a/drivers/block/deadline-iosched.c
+++ b/drivers/block/deadline-iosched.c
@@ -886,7 +886,7 @@ deadline_attr_show(struct kobject *kobj, struct attribute *attr, char *page)
886 struct deadline_fs_entry *entry = to_deadline(attr); 886 struct deadline_fs_entry *entry = to_deadline(attr);
887 887
888 if (!entry->show) 888 if (!entry->show)
889 return 0; 889 return -EIO;
890 890
891 return entry->show(e->elevator_data, page); 891 return entry->show(e->elevator_data, page);
892} 892}
@@ -899,7 +899,7 @@ deadline_attr_store(struct kobject *kobj, struct attribute *attr,
899 struct deadline_fs_entry *entry = to_deadline(attr); 899 struct deadline_fs_entry *entry = to_deadline(attr);
900 900
901 if (!entry->store) 901 if (!entry->store)
902 return -EINVAL; 902 return -EIO;
903 903
904 return entry->store(e->elevator_data, page, length); 904 return entry->store(e->elevator_data, page, length);
905} 905}
diff --git a/drivers/block/genhd.c b/drivers/block/genhd.c
index 8bbe01d4b487..53f7d846b747 100644
--- a/drivers/block/genhd.c
+++ b/drivers/block/genhd.c
@@ -322,7 +322,7 @@ static ssize_t disk_attr_show(struct kobject *kobj, struct attribute *attr,
322 struct gendisk *disk = to_disk(kobj); 322 struct gendisk *disk = to_disk(kobj);
323 struct disk_attribute *disk_attr = 323 struct disk_attribute *disk_attr =
324 container_of(attr,struct disk_attribute,attr); 324 container_of(attr,struct disk_attribute,attr);
325 ssize_t ret = 0; 325 ssize_t ret = -EIO;
326 326
327 if (disk_attr->show) 327 if (disk_attr->show)
328 ret = disk_attr->show(disk,page); 328 ret = disk_attr->show(disk,page);
diff --git a/drivers/block/ll_rw_blk.c b/drivers/block/ll_rw_blk.c
index f20eba22b14b..81fe3a0c1fe7 100644
--- a/drivers/block/ll_rw_blk.c
+++ b/drivers/block/ll_rw_blk.c
@@ -3574,7 +3574,7 @@ queue_attr_show(struct kobject *kobj, struct attribute *attr, char *page)
3574 3574
3575 q = container_of(kobj, struct request_queue, kobj); 3575 q = container_of(kobj, struct request_queue, kobj);
3576 if (!entry->show) 3576 if (!entry->show)
3577 return 0; 3577 return -EIO;
3578 3578
3579 return entry->show(q, page); 3579 return entry->show(q, page);
3580} 3580}
@@ -3588,7 +3588,7 @@ queue_attr_store(struct kobject *kobj, struct attribute *attr,
3588 3588
3589 q = container_of(kobj, struct request_queue, kobj); 3589 q = container_of(kobj, struct request_queue, kobj);
3590 if (!entry->store) 3590 if (!entry->store)
3591 return -EINVAL; 3591 return -EIO;
3592 3592
3593 return entry->store(q, page, length); 3593 return entry->store(q, page, length);
3594} 3594}
diff --git a/drivers/block/paride/pg.c b/drivers/block/paride/pg.c
index dbeb107bb971..84d8e291ed96 100644
--- a/drivers/block/paride/pg.c
+++ b/drivers/block/paride/pg.c
@@ -222,7 +222,7 @@ static int pg_identify(struct pg *dev, int log);
222 222
223static char pg_scratch[512]; /* scratch block buffer */ 223static char pg_scratch[512]; /* scratch block buffer */
224 224
225static struct class_simple *pg_class; 225static struct class *pg_class;
226 226
227/* kernel glue structures */ 227/* kernel glue structures */
228 228
@@ -666,7 +666,7 @@ static int __init pg_init(void)
666 err = -1; 666 err = -1;
667 goto out; 667 goto out;
668 } 668 }
669 pg_class = class_simple_create(THIS_MODULE, "pg"); 669 pg_class = class_create(THIS_MODULE, "pg");
670 if (IS_ERR(pg_class)) { 670 if (IS_ERR(pg_class)) {
671 err = PTR_ERR(pg_class); 671 err = PTR_ERR(pg_class);
672 goto out_chrdev; 672 goto out_chrdev;
@@ -675,7 +675,7 @@ static int __init pg_init(void)
675 for (unit = 0; unit < PG_UNITS; unit++) { 675 for (unit = 0; unit < PG_UNITS; unit++) {
676 struct pg *dev = &devices[unit]; 676 struct pg *dev = &devices[unit];
677 if (dev->present) { 677 if (dev->present) {
678 class_simple_device_add(pg_class, MKDEV(major, unit), 678 class_device_create(pg_class, MKDEV(major, unit),
679 NULL, "pg%u", unit); 679 NULL, "pg%u", unit);
680 err = devfs_mk_cdev(MKDEV(major, unit), 680 err = devfs_mk_cdev(MKDEV(major, unit),
681 S_IFCHR | S_IRUSR | S_IWUSR, "pg/%u", 681 S_IFCHR | S_IRUSR | S_IWUSR, "pg/%u",
@@ -688,8 +688,8 @@ static int __init pg_init(void)
688 goto out; 688 goto out;
689 689
690out_class: 690out_class:
691 class_simple_device_remove(MKDEV(major, unit)); 691 class_device_destroy(pg_class, MKDEV(major, unit));
692 class_simple_destroy(pg_class); 692 class_destroy(pg_class);
693out_chrdev: 693out_chrdev:
694 unregister_chrdev(major, "pg"); 694 unregister_chrdev(major, "pg");
695out: 695out:
@@ -703,11 +703,11 @@ static void __exit pg_exit(void)
703 for (unit = 0; unit < PG_UNITS; unit++) { 703 for (unit = 0; unit < PG_UNITS; unit++) {
704 struct pg *dev = &devices[unit]; 704 struct pg *dev = &devices[unit];
705 if (dev->present) { 705 if (dev->present) {
706 class_simple_device_remove(MKDEV(major, unit)); 706 class_device_destroy(pg_class, MKDEV(major, unit));
707 devfs_remove("pg/%u", unit); 707 devfs_remove("pg/%u", unit);
708 } 708 }
709 } 709 }
710 class_simple_destroy(pg_class); 710 class_destroy(pg_class);
711 devfs_remove("pg"); 711 devfs_remove("pg");
712 unregister_chrdev(major, name); 712 unregister_chrdev(major, name);
713 713
diff --git a/drivers/block/paride/pt.c b/drivers/block/paride/pt.c
index 8fbd6922fe0d..5fe8ee86f095 100644
--- a/drivers/block/paride/pt.c
+++ b/drivers/block/paride/pt.c
@@ -242,7 +242,7 @@ static struct file_operations pt_fops = {
242}; 242};
243 243
244/* sysfs class support */ 244/* sysfs class support */
245static struct class_simple *pt_class; 245static struct class *pt_class;
246 246
247static inline int status_reg(struct pi_adapter *pi) 247static inline int status_reg(struct pi_adapter *pi)
248{ 248{
@@ -963,7 +963,7 @@ static int __init pt_init(void)
963 err = -1; 963 err = -1;
964 goto out; 964 goto out;
965 } 965 }
966 pt_class = class_simple_create(THIS_MODULE, "pt"); 966 pt_class = class_create(THIS_MODULE, "pt");
967 if (IS_ERR(pt_class)) { 967 if (IS_ERR(pt_class)) {
968 err = PTR_ERR(pt_class); 968 err = PTR_ERR(pt_class);
969 goto out_chrdev; 969 goto out_chrdev;
@@ -972,29 +972,29 @@ static int __init pt_init(void)
972 devfs_mk_dir("pt"); 972 devfs_mk_dir("pt");
973 for (unit = 0; unit < PT_UNITS; unit++) 973 for (unit = 0; unit < PT_UNITS; unit++)
974 if (pt[unit].present) { 974 if (pt[unit].present) {
975 class_simple_device_add(pt_class, MKDEV(major, unit), 975 class_device_create(pt_class, MKDEV(major, unit),
976 NULL, "pt%d", unit); 976 NULL, "pt%d", unit);
977 err = devfs_mk_cdev(MKDEV(major, unit), 977 err = devfs_mk_cdev(MKDEV(major, unit),
978 S_IFCHR | S_IRUSR | S_IWUSR, 978 S_IFCHR | S_IRUSR | S_IWUSR,
979 "pt/%d", unit); 979 "pt/%d", unit);
980 if (err) { 980 if (err) {
981 class_simple_device_remove(MKDEV(major, unit)); 981 class_device_destroy(pt_class, MKDEV(major, unit));
982 goto out_class; 982 goto out_class;
983 } 983 }
984 class_simple_device_add(pt_class, MKDEV(major, unit + 128), 984 class_device_create(pt_class, MKDEV(major, unit + 128),
985 NULL, "pt%dn", unit); 985 NULL, "pt%dn", unit);
986 err = devfs_mk_cdev(MKDEV(major, unit + 128), 986 err = devfs_mk_cdev(MKDEV(major, unit + 128),
987 S_IFCHR | S_IRUSR | S_IWUSR, 987 S_IFCHR | S_IRUSR | S_IWUSR,
988 "pt/%dn", unit); 988 "pt/%dn", unit);
989 if (err) { 989 if (err) {
990 class_simple_device_remove(MKDEV(major, unit + 128)); 990 class_device_destroy(pt_class, MKDEV(major, unit + 128));
991 goto out_class; 991 goto out_class;
992 } 992 }
993 } 993 }
994 goto out; 994 goto out;
995 995
996out_class: 996out_class:
997 class_simple_destroy(pt_class); 997 class_destroy(pt_class);
998out_chrdev: 998out_chrdev:
999 unregister_chrdev(major, "pt"); 999 unregister_chrdev(major, "pt");
1000out: 1000out:
@@ -1006,12 +1006,12 @@ static void __exit pt_exit(void)
1006 int unit; 1006 int unit;
1007 for (unit = 0; unit < PT_UNITS; unit++) 1007 for (unit = 0; unit < PT_UNITS; unit++)
1008 if (pt[unit].present) { 1008 if (pt[unit].present) {
1009 class_simple_device_remove(MKDEV(major, unit)); 1009 class_device_destroy(pt_class, MKDEV(major, unit));
1010 devfs_remove("pt/%d", unit); 1010 devfs_remove("pt/%d", unit);
1011 class_simple_device_remove(MKDEV(major, unit + 128)); 1011 class_device_destroy(pt_class, MKDEV(major, unit + 128));
1012 devfs_remove("pt/%dn", unit); 1012 devfs_remove("pt/%dn", unit);
1013 } 1013 }
1014 class_simple_destroy(pt_class); 1014 class_destroy(pt_class);
1015 devfs_remove("pt"); 1015 devfs_remove("pt");
1016 unregister_chrdev(major, name); 1016 unregister_chrdev(major, name);
1017 for (unit = 0; unit < PT_UNITS; unit++) 1017 for (unit = 0; unit < PT_UNITS; unit++)
diff --git a/drivers/block/ub.c b/drivers/block/ub.c
index 19c5e59bcfa8..685f061e69b2 100644
--- a/drivers/block/ub.c
+++ b/drivers/block/ub.c
@@ -430,7 +430,7 @@ static void ub_cmdtr_sense(struct ub_dev *sc, struct ub_scsi_cmd *cmd,
430 } 430 }
431} 431}
432 432
433static ssize_t ub_diag_show(struct device *dev, char *page) 433static ssize_t ub_diag_show(struct device *dev, struct device_attribute *attr, char *page)
434{ 434{
435 struct usb_interface *intf; 435 struct usb_interface *intf;
436 struct ub_dev *sc; 436 struct ub_dev *sc;
diff --git a/drivers/char/dsp56k.c b/drivers/char/dsp56k.c
index 37d6649011ad..26271e3ca823 100644
--- a/drivers/char/dsp56k.c
+++ b/drivers/char/dsp56k.c
@@ -144,7 +144,7 @@ static struct dsp56k_device {
144 int tx_wsize, rx_wsize; 144 int tx_wsize, rx_wsize;
145} dsp56k; 145} dsp56k;
146 146
147static struct class_simple *dsp56k_class; 147static struct class *dsp56k_class;
148 148
149static int dsp56k_reset(void) 149static int dsp56k_reset(void)
150{ 150{
@@ -510,12 +510,12 @@ static int __init dsp56k_init_driver(void)
510 printk("DSP56k driver: Unable to register driver\n"); 510 printk("DSP56k driver: Unable to register driver\n");
511 return -ENODEV; 511 return -ENODEV;
512 } 512 }
513 dsp56k_class = class_simple_create(THIS_MODULE, "dsp56k"); 513 dsp56k_class = class_create(THIS_MODULE, "dsp56k");
514 if (IS_ERR(dsp56k_class)) { 514 if (IS_ERR(dsp56k_class)) {
515 err = PTR_ERR(dsp56k_class); 515 err = PTR_ERR(dsp56k_class);
516 goto out_chrdev; 516 goto out_chrdev;
517 } 517 }
518 class_simple_device_add(dsp56k_class, MKDEV(DSP56K_MAJOR, 0), NULL, "dsp56k"); 518 class_device_create(dsp56k_class, MKDEV(DSP56K_MAJOR, 0), NULL, "dsp56k");
519 519
520 err = devfs_mk_cdev(MKDEV(DSP56K_MAJOR, 0), 520 err = devfs_mk_cdev(MKDEV(DSP56K_MAJOR, 0),
521 S_IFCHR | S_IRUSR | S_IWUSR, "dsp56k"); 521 S_IFCHR | S_IRUSR | S_IWUSR, "dsp56k");
@@ -526,8 +526,8 @@ static int __init dsp56k_init_driver(void)
526 goto out; 526 goto out;
527 527
528out_class: 528out_class:
529 class_simple_device_remove(MKDEV(DSP56K_MAJOR, 0)); 529 class_device_destroy(dsp56k_class, MKDEV(DSP56K_MAJOR, 0));
530 class_simple_destroy(dsp56k_class); 530 class_destroy(dsp56k_class);
531out_chrdev: 531out_chrdev:
532 unregister_chrdev(DSP56K_MAJOR, "dsp56k"); 532 unregister_chrdev(DSP56K_MAJOR, "dsp56k");
533out: 533out:
@@ -537,8 +537,8 @@ module_init(dsp56k_init_driver);
537 537
538static void __exit dsp56k_cleanup_driver(void) 538static void __exit dsp56k_cleanup_driver(void)
539{ 539{
540 class_simple_device_remove(MKDEV(DSP56K_MAJOR, 0)); 540 class_device_destroy(dsp56k_class, MKDEV(DSP56K_MAJOR, 0));
541 class_simple_destroy(dsp56k_class); 541 class_destroy(dsp56k_class);
542 unregister_chrdev(DSP56K_MAJOR, "dsp56k"); 542 unregister_chrdev(DSP56K_MAJOR, "dsp56k");
543 devfs_remove("dsp56k"); 543 devfs_remove("dsp56k");
544} 544}
diff --git a/drivers/char/ftape/zftape/zftape-init.c b/drivers/char/ftape/zftape/zftape-init.c
index dbac7e54e8e0..5745b74044ec 100644
--- a/drivers/char/ftape/zftape/zftape-init.c
+++ b/drivers/char/ftape/zftape/zftape-init.c
@@ -99,7 +99,7 @@ static struct file_operations zft_cdev =
99 .release = zft_close, 99 .release = zft_close,
100}; 100};
101 101
102static struct class_simple *zft_class; 102static struct class *zft_class;
103 103
104/* Open floppy tape device 104/* Open floppy tape device
105 */ 105 */
@@ -329,29 +329,29 @@ KERN_INFO
329 "installing zftape VFS interface for ftape driver ..."); 329 "installing zftape VFS interface for ftape driver ...");
330 TRACE_CATCH(register_chrdev(QIC117_TAPE_MAJOR, "zft", &zft_cdev),); 330 TRACE_CATCH(register_chrdev(QIC117_TAPE_MAJOR, "zft", &zft_cdev),);
331 331
332 zft_class = class_simple_create(THIS_MODULE, "zft"); 332 zft_class = class_create(THIS_MODULE, "zft");
333 for (i = 0; i < 4; i++) { 333 for (i = 0; i < 4; i++) {
334 class_simple_device_add(zft_class, MKDEV(QIC117_TAPE_MAJOR, i), NULL, "qft%i", i); 334 class_device_create(zft_class, MKDEV(QIC117_TAPE_MAJOR, i), NULL, "qft%i", i);
335 devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i), 335 devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i),
336 S_IFCHR | S_IRUSR | S_IWUSR, 336 S_IFCHR | S_IRUSR | S_IWUSR,
337 "qft%i", i); 337 "qft%i", i);
338 class_simple_device_add(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 4), NULL, "nqft%i", i); 338 class_device_create(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 4), NULL, "nqft%i", i);
339 devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 4), 339 devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 4),
340 S_IFCHR | S_IRUSR | S_IWUSR, 340 S_IFCHR | S_IRUSR | S_IWUSR,
341 "nqft%i", i); 341 "nqft%i", i);
342 class_simple_device_add(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 16), NULL, "zqft%i", i); 342 class_device_create(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 16), NULL, "zqft%i", i);
343 devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 16), 343 devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 16),
344 S_IFCHR | S_IRUSR | S_IWUSR, 344 S_IFCHR | S_IRUSR | S_IWUSR,
345 "zqft%i", i); 345 "zqft%i", i);
346 class_simple_device_add(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 20), NULL, "nzqft%i", i); 346 class_device_create(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 20), NULL, "nzqft%i", i);
347 devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 20), 347 devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 20),
348 S_IFCHR | S_IRUSR | S_IWUSR, 348 S_IFCHR | S_IRUSR | S_IWUSR,
349 "nzqft%i", i); 349 "nzqft%i", i);
350 class_simple_device_add(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 32), NULL, "rawqft%i", i); 350 class_device_create(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 32), NULL, "rawqft%i", i);
351 devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 32), 351 devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 32),
352 S_IFCHR | S_IRUSR | S_IWUSR, 352 S_IFCHR | S_IRUSR | S_IWUSR,
353 "rawqft%i", i); 353 "rawqft%i", i);
354 class_simple_device_add(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 36), NULL, "nrawrawqft%i", i); 354 class_device_create(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 36), NULL, "nrawrawqft%i", i);
355 devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 36), 355 devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 36),
356 S_IFCHR | S_IRUSR | S_IWUSR, 356 S_IFCHR | S_IRUSR | S_IWUSR,
357 "nrawqft%i", i); 357 "nrawqft%i", i);
@@ -381,19 +381,19 @@ static void zft_exit(void)
381 } 381 }
382 for (i = 0; i < 4; i++) { 382 for (i = 0; i < 4; i++) {
383 devfs_remove("qft%i", i); 383 devfs_remove("qft%i", i);
384 class_simple_device_remove(MKDEV(QIC117_TAPE_MAJOR, i)); 384 class_device_destroy(zft_class, MKDEV(QIC117_TAPE_MAJOR, i));
385 devfs_remove("nqft%i", i); 385 devfs_remove("nqft%i", i);
386 class_simple_device_remove(MKDEV(QIC117_TAPE_MAJOR, i + 4)); 386 class_device_destroy(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 4));
387 devfs_remove("zqft%i", i); 387 devfs_remove("zqft%i", i);
388 class_simple_device_remove(MKDEV(QIC117_TAPE_MAJOR, i + 16)); 388 class_device_destroy(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 16));
389 devfs_remove("nzqft%i", i); 389 devfs_remove("nzqft%i", i);
390 class_simple_device_remove(MKDEV(QIC117_TAPE_MAJOR, i + 20)); 390 class_device_destroy(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 20));
391 devfs_remove("rawqft%i", i); 391 devfs_remove("rawqft%i", i);
392 class_simple_device_remove(MKDEV(QIC117_TAPE_MAJOR, i + 32)); 392 class_device_destroy(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 32));
393 devfs_remove("nrawqft%i", i); 393 devfs_remove("nrawqft%i", i);
394 class_simple_device_remove(MKDEV(QIC117_TAPE_MAJOR, i + 36)); 394 class_device_destroy(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 36));
395 } 395 }
396 class_simple_destroy(zft_class); 396 class_destroy(zft_class);
397 zft_uninit_mem(); /* release remaining memory, if any */ 397 zft_uninit_mem(); /* release remaining memory, if any */
398 printk(KERN_INFO "zftape successfully unloaded.\n"); 398 printk(KERN_INFO "zftape successfully unloaded.\n");
399 TRACE_EXIT; 399 TRACE_EXIT;
diff --git a/drivers/char/hvcs.c b/drivers/char/hvcs.c
index abfbdcfd4e72..3236d2404905 100644
--- a/drivers/char/hvcs.c
+++ b/drivers/char/hvcs.c
@@ -1466,7 +1466,7 @@ static inline struct hvcs_struct *from_vio_dev(struct vio_dev *viod)
1466} 1466}
1467/* The sysfs interface for the driver and devices */ 1467/* The sysfs interface for the driver and devices */
1468 1468
1469static ssize_t hvcs_partner_vtys_show(struct device *dev, char *buf) 1469static ssize_t hvcs_partner_vtys_show(struct device *dev, struct device_attribute *attr, char *buf)
1470{ 1470{
1471 struct vio_dev *viod = to_vio_dev(dev); 1471 struct vio_dev *viod = to_vio_dev(dev);
1472 struct hvcs_struct *hvcsd = from_vio_dev(viod); 1472 struct hvcs_struct *hvcsd = from_vio_dev(viod);
@@ -1480,7 +1480,7 @@ static ssize_t hvcs_partner_vtys_show(struct device *dev, char *buf)
1480} 1480}
1481static DEVICE_ATTR(partner_vtys, S_IRUGO, hvcs_partner_vtys_show, NULL); 1481static DEVICE_ATTR(partner_vtys, S_IRUGO, hvcs_partner_vtys_show, NULL);
1482 1482
1483static ssize_t hvcs_partner_clcs_show(struct device *dev, char *buf) 1483static ssize_t hvcs_partner_clcs_show(struct device *dev, struct device_attribute *attr, char *buf)
1484{ 1484{
1485 struct vio_dev *viod = to_vio_dev(dev); 1485 struct vio_dev *viod = to_vio_dev(dev);
1486 struct hvcs_struct *hvcsd = from_vio_dev(viod); 1486 struct hvcs_struct *hvcsd = from_vio_dev(viod);
@@ -1494,7 +1494,7 @@ static ssize_t hvcs_partner_clcs_show(struct device *dev, char *buf)
1494} 1494}
1495static DEVICE_ATTR(partner_clcs, S_IRUGO, hvcs_partner_clcs_show, NULL); 1495static DEVICE_ATTR(partner_clcs, S_IRUGO, hvcs_partner_clcs_show, NULL);
1496 1496
1497static ssize_t hvcs_current_vty_store(struct device *dev, const char * buf, 1497static ssize_t hvcs_current_vty_store(struct device *dev, struct device_attribute *attr, const char * buf,
1498 size_t count) 1498 size_t count)
1499{ 1499{
1500 /* 1500 /*
@@ -1505,7 +1505,7 @@ static ssize_t hvcs_current_vty_store(struct device *dev, const char * buf,
1505 return -EPERM; 1505 return -EPERM;
1506} 1506}
1507 1507
1508static ssize_t hvcs_current_vty_show(struct device *dev, char *buf) 1508static ssize_t hvcs_current_vty_show(struct device *dev, struct device_attribute *attr, char *buf)
1509{ 1509{
1510 struct vio_dev *viod = to_vio_dev(dev); 1510 struct vio_dev *viod = to_vio_dev(dev);
1511 struct hvcs_struct *hvcsd = from_vio_dev(viod); 1511 struct hvcs_struct *hvcsd = from_vio_dev(viod);
@@ -1521,7 +1521,7 @@ static ssize_t hvcs_current_vty_show(struct device *dev, char *buf)
1521static DEVICE_ATTR(current_vty, 1521static DEVICE_ATTR(current_vty,
1522 S_IRUGO | S_IWUSR, hvcs_current_vty_show, hvcs_current_vty_store); 1522 S_IRUGO | S_IWUSR, hvcs_current_vty_show, hvcs_current_vty_store);
1523 1523
1524static ssize_t hvcs_vterm_state_store(struct device *dev, const char *buf, 1524static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribute *attr, const char *buf,
1525 size_t count) 1525 size_t count)
1526{ 1526{
1527 struct vio_dev *viod = to_vio_dev(dev); 1527 struct vio_dev *viod = to_vio_dev(dev);
@@ -1559,7 +1559,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, const char *buf,
1559 return count; 1559 return count;
1560} 1560}
1561 1561
1562static ssize_t hvcs_vterm_state_show(struct device *dev, char *buf) 1562static ssize_t hvcs_vterm_state_show(struct device *dev, struct device_attribute *attr, char *buf)
1563{ 1563{
1564 struct vio_dev *viod = to_vio_dev(dev); 1564 struct vio_dev *viod = to_vio_dev(dev);
1565 struct hvcs_struct *hvcsd = from_vio_dev(viod); 1565 struct hvcs_struct *hvcsd = from_vio_dev(viod);
@@ -1574,7 +1574,7 @@ static ssize_t hvcs_vterm_state_show(struct device *dev, char *buf)
1574static DEVICE_ATTR(vterm_state, S_IRUGO | S_IWUSR, 1574static DEVICE_ATTR(vterm_state, S_IRUGO | S_IWUSR,
1575 hvcs_vterm_state_show, hvcs_vterm_state_store); 1575 hvcs_vterm_state_show, hvcs_vterm_state_store);
1576 1576
1577static ssize_t hvcs_index_show(struct device *dev, char *buf) 1577static ssize_t hvcs_index_show(struct device *dev, struct device_attribute *attr, char *buf)
1578{ 1578{
1579 struct vio_dev *viod = to_vio_dev(dev); 1579 struct vio_dev *viod = to_vio_dev(dev);
1580 struct hvcs_struct *hvcsd = from_vio_dev(viod); 1580 struct hvcs_struct *hvcsd = from_vio_dev(viod);
diff --git a/drivers/char/ip2main.c b/drivers/char/ip2main.c
index fca9a978fb73..3b8314b4249a 100644
--- a/drivers/char/ip2main.c
+++ b/drivers/char/ip2main.c
@@ -302,7 +302,7 @@ static char rirqs[IP2_MAX_BOARDS];
302static int Valid_Irqs[] = { 3, 4, 5, 7, 10, 11, 12, 15, 0}; 302static int Valid_Irqs[] = { 3, 4, 5, 7, 10, 11, 12, 15, 0};
303 303
304/* for sysfs class support */ 304/* for sysfs class support */
305static struct class_simple *ip2_class; 305static struct class *ip2_class;
306 306
307// Some functions to keep track of what irq's we have 307// Some functions to keep track of what irq's we have
308 308
@@ -414,9 +414,9 @@ cleanup_module(void)
414 iiResetDelay( i2BoardPtrTable[i] ); 414 iiResetDelay( i2BoardPtrTable[i] );
415 /* free io addresses and Tibet */ 415 /* free io addresses and Tibet */
416 release_region( ip2config.addr[i], 8 ); 416 release_region( ip2config.addr[i], 8 );
417 class_simple_device_remove(MKDEV(IP2_IPL_MAJOR, 4 * i)); 417 class_device_destroy(ip2_class, MKDEV(IP2_IPL_MAJOR, 4 * i));
418 devfs_remove("ip2/ipl%d", i); 418 devfs_remove("ip2/ipl%d", i);
419 class_simple_device_remove(MKDEV(IP2_IPL_MAJOR, 4 * i + 1)); 419 class_device_destroy(ip2_class, MKDEV(IP2_IPL_MAJOR, 4 * i + 1));
420 devfs_remove("ip2/stat%d", i); 420 devfs_remove("ip2/stat%d", i);
421 } 421 }
422 /* Disable and remove interrupt handler. */ 422 /* Disable and remove interrupt handler. */
@@ -425,7 +425,7 @@ cleanup_module(void)
425 clear_requested_irq( ip2config.irq[i]); 425 clear_requested_irq( ip2config.irq[i]);
426 } 426 }
427 } 427 }
428 class_simple_destroy(ip2_class); 428 class_destroy(ip2_class);
429 devfs_remove("ip2"); 429 devfs_remove("ip2");
430 if ( ( err = tty_unregister_driver ( ip2_tty_driver ) ) ) { 430 if ( ( err = tty_unregister_driver ( ip2_tty_driver ) ) ) {
431 printk(KERN_ERR "IP2: failed to unregister tty driver (%d)\n", err); 431 printk(KERN_ERR "IP2: failed to unregister tty driver (%d)\n", err);
@@ -700,7 +700,7 @@ ip2_loadmain(int *iop, int *irqp, unsigned char *firmware, int firmsize)
700 printk(KERN_ERR "IP2: failed to register IPL device (%d)\n", err ); 700 printk(KERN_ERR "IP2: failed to register IPL device (%d)\n", err );
701 } else { 701 } else {
702 /* create the sysfs class */ 702 /* create the sysfs class */
703 ip2_class = class_simple_create(THIS_MODULE, "ip2"); 703 ip2_class = class_create(THIS_MODULE, "ip2");
704 if (IS_ERR(ip2_class)) { 704 if (IS_ERR(ip2_class)) {
705 err = PTR_ERR(ip2_class); 705 err = PTR_ERR(ip2_class);
706 goto out_chrdev; 706 goto out_chrdev;
@@ -722,25 +722,25 @@ ip2_loadmain(int *iop, int *irqp, unsigned char *firmware, int firmsize)
722 } 722 }
723 723
724 if ( NULL != ( pB = i2BoardPtrTable[i] ) ) { 724 if ( NULL != ( pB = i2BoardPtrTable[i] ) ) {
725 class_simple_device_add(ip2_class, MKDEV(IP2_IPL_MAJOR, 725 class_device_create(ip2_class, MKDEV(IP2_IPL_MAJOR,
726 4 * i), NULL, "ipl%d", i); 726 4 * i), NULL, "ipl%d", i);
727 err = devfs_mk_cdev(MKDEV(IP2_IPL_MAJOR, 4 * i), 727 err = devfs_mk_cdev(MKDEV(IP2_IPL_MAJOR, 4 * i),
728 S_IRUSR | S_IWUSR | S_IRGRP | S_IFCHR, 728 S_IRUSR | S_IWUSR | S_IRGRP | S_IFCHR,
729 "ip2/ipl%d", i); 729 "ip2/ipl%d", i);
730 if (err) { 730 if (err) {
731 class_simple_device_remove(MKDEV(IP2_IPL_MAJOR, 731 class_device_destroy(ip2_class,
732 4 * i)); 732 MKDEV(IP2_IPL_MAJOR, 4 * i));
733 goto out_class; 733 goto out_class;
734 } 734 }
735 735
736 class_simple_device_add(ip2_class, MKDEV(IP2_IPL_MAJOR, 736 class_device_create(ip2_class, MKDEV(IP2_IPL_MAJOR,
737 4 * i + 1), NULL, "stat%d", i); 737 4 * i + 1), NULL, "stat%d", i);
738 err = devfs_mk_cdev(MKDEV(IP2_IPL_MAJOR, 4 * i + 1), 738 err = devfs_mk_cdev(MKDEV(IP2_IPL_MAJOR, 4 * i + 1),
739 S_IRUSR | S_IWUSR | S_IRGRP | S_IFCHR, 739 S_IRUSR | S_IWUSR | S_IRGRP | S_IFCHR,
740 "ip2/stat%d", i); 740 "ip2/stat%d", i);
741 if (err) { 741 if (err) {
742 class_simple_device_remove(MKDEV(IP2_IPL_MAJOR, 742 class_device_destroy(ip2_class,
743 4 * i + 1)); 743 MKDEV(IP2_IPL_MAJOR, 4 * i + 1));
744 goto out_class; 744 goto out_class;
745 } 745 }
746 746
@@ -798,7 +798,7 @@ retry:
798 goto out; 798 goto out;
799 799
800out_class: 800out_class:
801 class_simple_destroy(ip2_class); 801 class_destroy(ip2_class);
802out_chrdev: 802out_chrdev:
803 unregister_chrdev(IP2_IPL_MAJOR, "ip2"); 803 unregister_chrdev(IP2_IPL_MAJOR, "ip2");
804out: 804out:
diff --git a/drivers/char/ipmi/ipmi_devintf.c b/drivers/char/ipmi/ipmi_devintf.c
index 6dc765dc5413..88d1ad656e99 100644
--- a/drivers/char/ipmi/ipmi_devintf.c
+++ b/drivers/char/ipmi/ipmi_devintf.c
@@ -520,7 +520,7 @@ MODULE_PARM_DESC(ipmi_major, "Sets the major number of the IPMI device. By"
520 " interface. Other values will set the major device number" 520 " interface. Other values will set the major device number"
521 " to that value."); 521 " to that value.");
522 522
523static struct class_simple *ipmi_class; 523static struct class *ipmi_class;
524 524
525static void ipmi_new_smi(int if_num) 525static void ipmi_new_smi(int if_num)
526{ 526{
@@ -529,12 +529,12 @@ static void ipmi_new_smi(int if_num)
529 devfs_mk_cdev(dev, S_IFCHR | S_IRUSR | S_IWUSR, 529 devfs_mk_cdev(dev, S_IFCHR | S_IRUSR | S_IWUSR,
530 "ipmidev/%d", if_num); 530 "ipmidev/%d", if_num);
531 531
532 class_simple_device_add(ipmi_class, dev, NULL, "ipmi%d", if_num); 532 class_device_create(ipmi_class, dev, NULL, "ipmi%d", if_num);
533} 533}
534 534
535static void ipmi_smi_gone(int if_num) 535static void ipmi_smi_gone(int if_num)
536{ 536{
537 class_simple_device_remove(MKDEV(ipmi_major, if_num)); 537 class_device_destroy(ipmi_class, MKDEV(ipmi_major, if_num));
538 devfs_remove("ipmidev/%d", if_num); 538 devfs_remove("ipmidev/%d", if_num);
539} 539}
540 540
@@ -555,7 +555,7 @@ static __init int init_ipmi_devintf(void)
555 printk(KERN_INFO "ipmi device interface version " 555 printk(KERN_INFO "ipmi device interface version "
556 IPMI_DEVINTF_VERSION "\n"); 556 IPMI_DEVINTF_VERSION "\n");
557 557
558 ipmi_class = class_simple_create(THIS_MODULE, "ipmi"); 558 ipmi_class = class_create(THIS_MODULE, "ipmi");
559 if (IS_ERR(ipmi_class)) { 559 if (IS_ERR(ipmi_class)) {
560 printk(KERN_ERR "ipmi: can't register device class\n"); 560 printk(KERN_ERR "ipmi: can't register device class\n");
561 return PTR_ERR(ipmi_class); 561 return PTR_ERR(ipmi_class);
@@ -563,7 +563,7 @@ static __init int init_ipmi_devintf(void)
563 563
564 rv = register_chrdev(ipmi_major, DEVICE_NAME, &ipmi_fops); 564 rv = register_chrdev(ipmi_major, DEVICE_NAME, &ipmi_fops);
565 if (rv < 0) { 565 if (rv < 0) {
566 class_simple_destroy(ipmi_class); 566 class_destroy(ipmi_class);
567 printk(KERN_ERR "ipmi: can't get major %d\n", ipmi_major); 567 printk(KERN_ERR "ipmi: can't get major %d\n", ipmi_major);
568 return rv; 568 return rv;
569 } 569 }
@@ -577,7 +577,7 @@ static __init int init_ipmi_devintf(void)
577 rv = ipmi_smi_watcher_register(&smi_watcher); 577 rv = ipmi_smi_watcher_register(&smi_watcher);
578 if (rv) { 578 if (rv) {
579 unregister_chrdev(ipmi_major, DEVICE_NAME); 579 unregister_chrdev(ipmi_major, DEVICE_NAME);
580 class_simple_destroy(ipmi_class); 580 class_destroy(ipmi_class);
581 printk(KERN_WARNING "ipmi: can't register smi watcher\n"); 581 printk(KERN_WARNING "ipmi: can't register smi watcher\n");
582 return rv; 582 return rv;
583 } 583 }
@@ -588,7 +588,7 @@ module_init(init_ipmi_devintf);
588 588
589static __exit void cleanup_ipmi(void) 589static __exit void cleanup_ipmi(void)
590{ 590{
591 class_simple_destroy(ipmi_class); 591 class_destroy(ipmi_class);
592 ipmi_smi_watcher_unregister(&smi_watcher); 592 ipmi_smi_watcher_unregister(&smi_watcher);
593 devfs_remove(DEVICE_NAME); 593 devfs_remove(DEVICE_NAME);
594 unregister_chrdev(ipmi_major, DEVICE_NAME); 594 unregister_chrdev(ipmi_major, DEVICE_NAME);
diff --git a/drivers/char/istallion.c b/drivers/char/istallion.c
index 21aed0e8779d..c02a21dbad5d 100644
--- a/drivers/char/istallion.c
+++ b/drivers/char/istallion.c
@@ -792,7 +792,7 @@ static int stli_timeron;
792 792
793/*****************************************************************************/ 793/*****************************************************************************/
794 794
795static struct class_simple *istallion_class; 795static struct class *istallion_class;
796 796
797#ifdef MODULE 797#ifdef MODULE
798 798
@@ -854,10 +854,10 @@ static void __exit istallion_module_exit(void)
854 put_tty_driver(stli_serial); 854 put_tty_driver(stli_serial);
855 for (i = 0; i < 4; i++) { 855 for (i = 0; i < 4; i++) {
856 devfs_remove("staliomem/%d", i); 856 devfs_remove("staliomem/%d", i);
857 class_simple_device_remove(MKDEV(STL_SIOMEMMAJOR, i)); 857 class_device_destroy(istallion_class, MKDEV(STL_SIOMEMMAJOR, i));
858 } 858 }
859 devfs_remove("staliomem"); 859 devfs_remove("staliomem");
860 class_simple_destroy(istallion_class); 860 class_destroy(istallion_class);
861 if ((i = unregister_chrdev(STL_SIOMEMMAJOR, "staliomem"))) 861 if ((i = unregister_chrdev(STL_SIOMEMMAJOR, "staliomem")))
862 printk("STALLION: failed to un-register serial memory device, " 862 printk("STALLION: failed to un-register serial memory device, "
863 "errno=%d\n", -i); 863 "errno=%d\n", -i);
@@ -5242,12 +5242,12 @@ int __init stli_init(void)
5242 "device\n"); 5242 "device\n");
5243 5243
5244 devfs_mk_dir("staliomem"); 5244 devfs_mk_dir("staliomem");
5245 istallion_class = class_simple_create(THIS_MODULE, "staliomem"); 5245 istallion_class = class_create(THIS_MODULE, "staliomem");
5246 for (i = 0; i < 4; i++) { 5246 for (i = 0; i < 4; i++) {
5247 devfs_mk_cdev(MKDEV(STL_SIOMEMMAJOR, i), 5247 devfs_mk_cdev(MKDEV(STL_SIOMEMMAJOR, i),
5248 S_IFCHR | S_IRUSR | S_IWUSR, 5248 S_IFCHR | S_IRUSR | S_IWUSR,
5249 "staliomem/%d", i); 5249 "staliomem/%d", i);
5250 class_simple_device_add(istallion_class, MKDEV(STL_SIOMEMMAJOR, i), 5250 class_device_create(istallion_class, MKDEV(STL_SIOMEMMAJOR, i),
5251 NULL, "staliomem%d", i); 5251 NULL, "staliomem%d", i);
5252 } 5252 }
5253 5253
diff --git a/drivers/char/lp.c b/drivers/char/lp.c
index 4dee945031d4..59eebe5a035f 100644
--- a/drivers/char/lp.c
+++ b/drivers/char/lp.c
@@ -146,7 +146,7 @@
146static struct lp_struct lp_table[LP_NO]; 146static struct lp_struct lp_table[LP_NO];
147 147
148static unsigned int lp_count = 0; 148static unsigned int lp_count = 0;
149static struct class_simple *lp_class; 149static struct class *lp_class;
150 150
151#ifdef CONFIG_LP_CONSOLE 151#ifdef CONFIG_LP_CONSOLE
152static struct parport *console_registered; // initially NULL 152static struct parport *console_registered; // initially NULL
@@ -804,7 +804,7 @@ static int lp_register(int nr, struct parport *port)
804 if (reset) 804 if (reset)
805 lp_reset(nr); 805 lp_reset(nr);
806 806
807 class_simple_device_add(lp_class, MKDEV(LP_MAJOR, nr), NULL, 807 class_device_create(lp_class, MKDEV(LP_MAJOR, nr), NULL,
808 "lp%d", nr); 808 "lp%d", nr);
809 devfs_mk_cdev(MKDEV(LP_MAJOR, nr), S_IFCHR | S_IRUGO | S_IWUGO, 809 devfs_mk_cdev(MKDEV(LP_MAJOR, nr), S_IFCHR | S_IRUGO | S_IWUGO,
810 "printers/%d", nr); 810 "printers/%d", nr);
@@ -907,7 +907,7 @@ static int __init lp_init (void)
907 } 907 }
908 908
909 devfs_mk_dir("printers"); 909 devfs_mk_dir("printers");
910 lp_class = class_simple_create(THIS_MODULE, "printer"); 910 lp_class = class_create(THIS_MODULE, "printer");
911 if (IS_ERR(lp_class)) { 911 if (IS_ERR(lp_class)) {
912 err = PTR_ERR(lp_class); 912 err = PTR_ERR(lp_class);
913 goto out_devfs; 913 goto out_devfs;
@@ -930,7 +930,7 @@ static int __init lp_init (void)
930 return 0; 930 return 0;
931 931
932out_class: 932out_class:
933 class_simple_destroy(lp_class); 933 class_destroy(lp_class);
934out_devfs: 934out_devfs:
935 devfs_remove("printers"); 935 devfs_remove("printers");
936 unregister_chrdev(LP_MAJOR, "lp"); 936 unregister_chrdev(LP_MAJOR, "lp");
@@ -981,10 +981,10 @@ static void lp_cleanup_module (void)
981 continue; 981 continue;
982 parport_unregister_device(lp_table[offset].dev); 982 parport_unregister_device(lp_table[offset].dev);
983 devfs_remove("printers/%d", offset); 983 devfs_remove("printers/%d", offset);
984 class_simple_device_remove(MKDEV(LP_MAJOR, offset)); 984 class_device_destroy(lp_class, MKDEV(LP_MAJOR, offset));
985 } 985 }
986 devfs_remove("printers"); 986 devfs_remove("printers");
987 class_simple_destroy(lp_class); 987 class_destroy(lp_class);
988} 988}
989 989
990__setup("lp=", lp_setup); 990__setup("lp=", lp_setup);
diff --git a/drivers/char/mbcs.c b/drivers/char/mbcs.c
index ac9cfa9701ea..115dbb35334b 100644
--- a/drivers/char/mbcs.c
+++ b/drivers/char/mbcs.c
@@ -699,7 +699,7 @@ static inline int mbcs_hw_init(struct mbcs_soft *soft)
699 return 0; 699 return 0;
700} 700}
701 701
702static ssize_t show_algo(struct device *dev, char *buf) 702static ssize_t show_algo(struct device *dev, struct device_attribute *attr, char *buf)
703{ 703{
704 struct cx_dev *cx_dev = to_cx_dev(dev); 704 struct cx_dev *cx_dev = to_cx_dev(dev);
705 struct mbcs_soft *soft = cx_dev->soft; 705 struct mbcs_soft *soft = cx_dev->soft;
@@ -715,7 +715,7 @@ static ssize_t show_algo(struct device *dev, char *buf)
715 (debug0 >> 32), (debug0 & 0xffffffff)); 715 (debug0 >> 32), (debug0 & 0xffffffff));
716} 716}
717 717
718static ssize_t store_algo(struct device *dev, const char *buf, size_t count) 718static ssize_t store_algo(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
719{ 719{
720 int n; 720 int n;
721 struct cx_dev *cx_dev = to_cx_dev(dev); 721 struct cx_dev *cx_dev = to_cx_dev(dev);
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index 947cb3cef816..257b8ee605e5 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -856,7 +856,7 @@ static const struct {
856 {11,"kmsg", S_IRUGO | S_IWUSR, &kmsg_fops}, 856 {11,"kmsg", S_IRUGO | S_IWUSR, &kmsg_fops},
857}; 857};
858 858
859static struct class_simple *mem_class; 859static struct class *mem_class;
860 860
861static int __init chr_dev_init(void) 861static int __init chr_dev_init(void)
862{ 862{
@@ -865,10 +865,9 @@ static int __init chr_dev_init(void)
865 if (register_chrdev(MEM_MAJOR,"mem",&memory_fops)) 865 if (register_chrdev(MEM_MAJOR,"mem",&memory_fops))
866 printk("unable to get major %d for memory devs\n", MEM_MAJOR); 866 printk("unable to get major %d for memory devs\n", MEM_MAJOR);
867 867
868 mem_class = class_simple_create(THIS_MODULE, "mem"); 868 mem_class = class_create(THIS_MODULE, "mem");
869 for (i = 0; i < ARRAY_SIZE(devlist); i++) { 869 for (i = 0; i < ARRAY_SIZE(devlist); i++) {
870 class_simple_device_add(mem_class, 870 class_device_create(mem_class, MKDEV(MEM_MAJOR, devlist[i].minor),
871 MKDEV(MEM_MAJOR, devlist[i].minor),
872 NULL, devlist[i].name); 871 NULL, devlist[i].name);
873 devfs_mk_cdev(MKDEV(MEM_MAJOR, devlist[i].minor), 872 devfs_mk_cdev(MKDEV(MEM_MAJOR, devlist[i].minor),
874 S_IFCHR | devlist[i].mode, devlist[i].name); 873 S_IFCHR | devlist[i].mode, devlist[i].name);
diff --git a/drivers/char/misc.c b/drivers/char/misc.c
index 0937544762da..3115d318b997 100644
--- a/drivers/char/misc.c
+++ b/drivers/char/misc.c
@@ -177,10 +177,10 @@ fail:
177 177
178/* 178/*
179 * TODO for 2.7: 179 * TODO for 2.7:
180 * - add a struct class_device to struct miscdevice and make all usages of 180 * - add a struct kref to struct miscdevice and make all usages of
181 * them dynamic. 181 * them dynamic.
182 */ 182 */
183static struct class_simple *misc_class; 183static struct class *misc_class;
184 184
185static struct file_operations misc_fops = { 185static struct file_operations misc_fops = {
186 .owner = THIS_MODULE, 186 .owner = THIS_MODULE,
@@ -238,8 +238,8 @@ int misc_register(struct miscdevice * misc)
238 } 238 }
239 dev = MKDEV(MISC_MAJOR, misc->minor); 239 dev = MKDEV(MISC_MAJOR, misc->minor);
240 240
241 misc->class = class_simple_device_add(misc_class, dev, 241 misc->class = class_device_create(misc_class, dev, misc->dev,
242 misc->dev, misc->name); 242 "%s", misc->name);
243 if (IS_ERR(misc->class)) { 243 if (IS_ERR(misc->class)) {
244 err = PTR_ERR(misc->class); 244 err = PTR_ERR(misc->class);
245 goto out; 245 goto out;
@@ -248,7 +248,7 @@ int misc_register(struct miscdevice * misc)
248 err = devfs_mk_cdev(dev, S_IFCHR|S_IRUSR|S_IWUSR|S_IRGRP, 248 err = devfs_mk_cdev(dev, S_IFCHR|S_IRUSR|S_IWUSR|S_IRGRP,
249 misc->devfs_name); 249 misc->devfs_name);
250 if (err) { 250 if (err) {
251 class_simple_device_remove(dev); 251 class_device_destroy(misc_class, dev);
252 goto out; 252 goto out;
253 } 253 }
254 254
@@ -281,7 +281,7 @@ int misc_deregister(struct miscdevice * misc)
281 281
282 down(&misc_sem); 282 down(&misc_sem);
283 list_del(&misc->list); 283 list_del(&misc->list);
284 class_simple_device_remove(MKDEV(MISC_MAJOR, misc->minor)); 284 class_device_destroy(misc_class, MKDEV(MISC_MAJOR, misc->minor));
285 devfs_remove(misc->devfs_name); 285 devfs_remove(misc->devfs_name);
286 if (i < DYNAMIC_MINORS && i>0) { 286 if (i < DYNAMIC_MINORS && i>0) {
287 misc_minors[i>>3] &= ~(1 << (misc->minor & 7)); 287 misc_minors[i>>3] &= ~(1 << (misc->minor & 7));
@@ -302,7 +302,7 @@ static int __init misc_init(void)
302 if (ent) 302 if (ent)
303 ent->proc_fops = &misc_proc_fops; 303 ent->proc_fops = &misc_proc_fops;
304#endif 304#endif
305 misc_class = class_simple_create(THIS_MODULE, "misc"); 305 misc_class = class_create(THIS_MODULE, "misc");
306 if (IS_ERR(misc_class)) 306 if (IS_ERR(misc_class))
307 return PTR_ERR(misc_class); 307 return PTR_ERR(misc_class);
308#ifdef CONFIG_MVME16x 308#ifdef CONFIG_MVME16x
@@ -323,7 +323,7 @@ static int __init misc_init(void)
323 if (register_chrdev(MISC_MAJOR,"misc",&misc_fops)) { 323 if (register_chrdev(MISC_MAJOR,"misc",&misc_fops)) {
324 printk("unable to get major %d for misc devices\n", 324 printk("unable to get major %d for misc devices\n",
325 MISC_MAJOR); 325 MISC_MAJOR);
326 class_simple_destroy(misc_class); 326 class_destroy(misc_class);
327 return -EIO; 327 return -EIO;
328 } 328 }
329 return 0; 329 return 0;
diff --git a/drivers/char/mwave/mwavedd.c b/drivers/char/mwave/mwavedd.c
index d37625d47746..d568991ac6b3 100644
--- a/drivers/char/mwave/mwavedd.c
+++ b/drivers/char/mwave/mwavedd.c
@@ -472,7 +472,7 @@ struct device mwave_device;
472 472
473/* Prevent code redundancy, create a macro for mwave_show_* functions. */ 473/* Prevent code redundancy, create a macro for mwave_show_* functions. */
474#define mwave_show_function(attr_name, format_string, field) \ 474#define mwave_show_function(attr_name, format_string, field) \
475static ssize_t mwave_show_##attr_name(struct device *dev, char *buf) \ 475static ssize_t mwave_show_##attr_name(struct device *dev, struct device_attribute *attr, char *buf) \
476{ \ 476{ \
477 DSP_3780I_CONFIG_SETTINGS *pSettings = \ 477 DSP_3780I_CONFIG_SETTINGS *pSettings = \
478 &mwave_s_mdd.rBDData.rDspSettings; \ 478 &mwave_s_mdd.rBDData.rDspSettings; \
diff --git a/drivers/char/ppdev.c b/drivers/char/ppdev.c
index 5eda075c62bd..0e22880432bc 100644
--- a/drivers/char/ppdev.c
+++ b/drivers/char/ppdev.c
@@ -737,7 +737,7 @@ static unsigned int pp_poll (struct file * file, poll_table * wait)
737 return mask; 737 return mask;
738} 738}
739 739
740static struct class_simple *ppdev_class; 740static struct class *ppdev_class;
741 741
742static struct file_operations pp_fops = { 742static struct file_operations pp_fops = {
743 .owner = THIS_MODULE, 743 .owner = THIS_MODULE,
@@ -752,13 +752,13 @@ static struct file_operations pp_fops = {
752 752
753static void pp_attach(struct parport *port) 753static void pp_attach(struct parport *port)
754{ 754{
755 class_simple_device_add(ppdev_class, MKDEV(PP_MAJOR, port->number), 755 class_device_create(ppdev_class, MKDEV(PP_MAJOR, port->number),
756 NULL, "parport%d", port->number); 756 NULL, "parport%d", port->number);
757} 757}
758 758
759static void pp_detach(struct parport *port) 759static void pp_detach(struct parport *port)
760{ 760{
761 class_simple_device_remove(MKDEV(PP_MAJOR, port->number)); 761 class_device_destroy(ppdev_class, MKDEV(PP_MAJOR, port->number));
762} 762}
763 763
764static struct parport_driver pp_driver = { 764static struct parport_driver pp_driver = {
@@ -776,7 +776,7 @@ static int __init ppdev_init (void)
776 PP_MAJOR); 776 PP_MAJOR);
777 return -EIO; 777 return -EIO;
778 } 778 }
779 ppdev_class = class_simple_create(THIS_MODULE, CHRDEV); 779 ppdev_class = class_create(THIS_MODULE, CHRDEV);
780 if (IS_ERR(ppdev_class)) { 780 if (IS_ERR(ppdev_class)) {
781 err = PTR_ERR(ppdev_class); 781 err = PTR_ERR(ppdev_class);
782 goto out_chrdev; 782 goto out_chrdev;
@@ -798,7 +798,7 @@ out_class:
798 for (i = 0; i < PARPORT_MAX; i++) 798 for (i = 0; i < PARPORT_MAX; i++)
799 devfs_remove("parports/%d", i); 799 devfs_remove("parports/%d", i);
800 devfs_remove("parports"); 800 devfs_remove("parports");
801 class_simple_destroy(ppdev_class); 801 class_destroy(ppdev_class);
802out_chrdev: 802out_chrdev:
803 unregister_chrdev(PP_MAJOR, CHRDEV); 803 unregister_chrdev(PP_MAJOR, CHRDEV);
804out: 804out:
@@ -813,7 +813,7 @@ static void __exit ppdev_cleanup (void)
813 devfs_remove("parports/%d", i); 813 devfs_remove("parports/%d", i);
814 parport_unregister_driver(&pp_driver); 814 parport_unregister_driver(&pp_driver);
815 devfs_remove("parports"); 815 devfs_remove("parports");
816 class_simple_destroy(ppdev_class); 816 class_destroy(ppdev_class);
817 unregister_chrdev (PP_MAJOR, CHRDEV); 817 unregister_chrdev (PP_MAJOR, CHRDEV);
818} 818}
819 819
diff --git a/drivers/char/raw.c b/drivers/char/raw.c
index ca5f42bcaad9..f13e5de02207 100644
--- a/drivers/char/raw.c
+++ b/drivers/char/raw.c
@@ -27,7 +27,7 @@ struct raw_device_data {
27 int inuse; 27 int inuse;
28}; 28};
29 29
30static struct class_simple *raw_class; 30static struct class *raw_class;
31static struct raw_device_data raw_devices[MAX_RAW_MINORS]; 31static struct raw_device_data raw_devices[MAX_RAW_MINORS];
32static DECLARE_MUTEX(raw_mutex); 32static DECLARE_MUTEX(raw_mutex);
33static struct file_operations raw_ctl_fops; /* forward declaration */ 33static struct file_operations raw_ctl_fops; /* forward declaration */
@@ -127,8 +127,8 @@ raw_ioctl(struct inode *inode, struct file *filp,
127 127
128static void bind_device(struct raw_config_request *rq) 128static void bind_device(struct raw_config_request *rq)
129{ 129{
130 class_simple_device_remove(MKDEV(RAW_MAJOR, rq->raw_minor)); 130 class_device_destroy(raw_class, MKDEV(RAW_MAJOR, rq->raw_minor));
131 class_simple_device_add(raw_class, MKDEV(RAW_MAJOR, rq->raw_minor), 131 class_device_create(raw_class, MKDEV(RAW_MAJOR, rq->raw_minor),
132 NULL, "raw%d", rq->raw_minor); 132 NULL, "raw%d", rq->raw_minor);
133} 133}
134 134
@@ -200,8 +200,8 @@ static int raw_ctl_ioctl(struct inode *inode, struct file *filp,
200 if (rq.block_major == 0 && rq.block_minor == 0) { 200 if (rq.block_major == 0 && rq.block_minor == 0) {
201 /* unbind */ 201 /* unbind */
202 rawdev->binding = NULL; 202 rawdev->binding = NULL;
203 class_simple_device_remove(MKDEV(RAW_MAJOR, 203 class_device_destroy(raw_class,
204 rq.raw_minor)); 204 MKDEV(RAW_MAJOR, rq.raw_minor));
205 } else { 205 } else {
206 rawdev->binding = bdget(dev); 206 rawdev->binding = bdget(dev);
207 if (rawdev->binding == NULL) 207 if (rawdev->binding == NULL)
@@ -300,14 +300,14 @@ static int __init raw_init(void)
300 goto error; 300 goto error;
301 } 301 }
302 302
303 raw_class = class_simple_create(THIS_MODULE, "raw"); 303 raw_class = class_create(THIS_MODULE, "raw");
304 if (IS_ERR(raw_class)) { 304 if (IS_ERR(raw_class)) {
305 printk(KERN_ERR "Error creating raw class.\n"); 305 printk(KERN_ERR "Error creating raw class.\n");
306 cdev_del(&raw_cdev); 306 cdev_del(&raw_cdev);
307 unregister_chrdev_region(dev, MAX_RAW_MINORS); 307 unregister_chrdev_region(dev, MAX_RAW_MINORS);
308 goto error; 308 goto error;
309 } 309 }
310 class_simple_device_add(raw_class, MKDEV(RAW_MAJOR, 0), NULL, "rawctl"); 310 class_device_create(raw_class, MKDEV(RAW_MAJOR, 0), NULL, "rawctl");
311 311
312 devfs_mk_cdev(MKDEV(RAW_MAJOR, 0), 312 devfs_mk_cdev(MKDEV(RAW_MAJOR, 0),
313 S_IFCHR | S_IRUGO | S_IWUGO, 313 S_IFCHR | S_IRUGO | S_IWUGO,
@@ -331,8 +331,8 @@ static void __exit raw_exit(void)
331 devfs_remove("raw/raw%d", i); 331 devfs_remove("raw/raw%d", i);
332 devfs_remove("raw/rawctl"); 332 devfs_remove("raw/rawctl");
333 devfs_remove("raw"); 333 devfs_remove("raw");
334 class_simple_device_remove(MKDEV(RAW_MAJOR, 0)); 334 class_device_destroy(raw_class, MKDEV(RAW_MAJOR, 0));
335 class_simple_destroy(raw_class); 335 class_destroy(raw_class);
336 cdev_del(&raw_cdev); 336 cdev_del(&raw_cdev);
337 unregister_chrdev_region(MKDEV(RAW_MAJOR, 0), MAX_RAW_MINORS); 337 unregister_chrdev_region(MKDEV(RAW_MAJOR, 0), MAX_RAW_MINORS);
338} 338}
diff --git a/drivers/char/snsc.c b/drivers/char/snsc.c
index e3c0b52d943f..261a41bf6d02 100644
--- a/drivers/char/snsc.c
+++ b/drivers/char/snsc.c
@@ -357,6 +357,8 @@ static struct file_operations scdrv_fops = {
357 .release = scdrv_release, 357 .release = scdrv_release,
358}; 358};
359 359
360static struct class *snsc_class;
361
360/* 362/*
361 * scdrv_init 363 * scdrv_init
362 * 364 *
@@ -372,7 +374,6 @@ scdrv_init(void)
372 char *devnamep; 374 char *devnamep;
373 struct sysctl_data_s *scd; 375 struct sysctl_data_s *scd;
374 void *salbuf; 376 void *salbuf;
375 struct class_simple *snsc_class;
376 dev_t first_dev, dev; 377 dev_t first_dev, dev;
377 nasid_t event_nasid = ia64_sn_get_console_nasid(); 378 nasid_t event_nasid = ia64_sn_get_console_nasid();
378 379
@@ -382,7 +383,7 @@ scdrv_init(void)
382 __FUNCTION__); 383 __FUNCTION__);
383 return -ENODEV; 384 return -ENODEV;
384 } 385 }
385 snsc_class = class_simple_create(THIS_MODULE, SYSCTL_BASENAME); 386 snsc_class = class_create(THIS_MODULE, SYSCTL_BASENAME);
386 387
387 for (cnode = 0; cnode < numionodes; cnode++) { 388 for (cnode = 0; cnode < numionodes; cnode++) {
388 geoid = cnodeid_get_geoid(cnode); 389 geoid = cnodeid_get_geoid(cnode);
@@ -436,7 +437,7 @@ scdrv_init(void)
436 continue; 437 continue;
437 } 438 }
438 439
439 class_simple_device_add(snsc_class, dev, NULL, 440 class_device_create(snsc_class, dev, NULL,
440 "%s", devname); 441 "%s", devname);
441 442
442 ia64_sn_irtr_intr_enable(scd->scd_nasid, 443 ia64_sn_irtr_intr_enable(scd->scd_nasid,
diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c
index b8899f560b5e..951545a6ef2d 100644
--- a/drivers/char/stallion.c
+++ b/drivers/char/stallion.c
@@ -719,7 +719,7 @@ static struct file_operations stl_fsiomem = {
719 719
720/*****************************************************************************/ 720/*****************************************************************************/
721 721
722static struct class_simple *stallion_class; 722static struct class *stallion_class;
723 723
724/* 724/*
725 * Loadable module initialization stuff. 725 * Loadable module initialization stuff.
@@ -777,13 +777,13 @@ static void __exit stallion_module_exit(void)
777 } 777 }
778 for (i = 0; i < 4; i++) { 778 for (i = 0; i < 4; i++) {
779 devfs_remove("staliomem/%d", i); 779 devfs_remove("staliomem/%d", i);
780 class_simple_device_remove(MKDEV(STL_SIOMEMMAJOR, i)); 780 class_device_destroy(stallion_class, MKDEV(STL_SIOMEMMAJOR, i));
781 } 781 }
782 devfs_remove("staliomem"); 782 devfs_remove("staliomem");
783 if ((i = unregister_chrdev(STL_SIOMEMMAJOR, "staliomem"))) 783 if ((i = unregister_chrdev(STL_SIOMEMMAJOR, "staliomem")))
784 printk("STALLION: failed to un-register serial memory device, " 784 printk("STALLION: failed to un-register serial memory device, "
785 "errno=%d\n", -i); 785 "errno=%d\n", -i);
786 class_simple_destroy(stallion_class); 786 class_destroy(stallion_class);
787 787
788 if (stl_tmpwritebuf != (char *) NULL) 788 if (stl_tmpwritebuf != (char *) NULL)
789 kfree(stl_tmpwritebuf); 789 kfree(stl_tmpwritebuf);
@@ -3090,12 +3090,12 @@ static int __init stl_init(void)
3090 printk("STALLION: failed to register serial board device\n"); 3090 printk("STALLION: failed to register serial board device\n");
3091 devfs_mk_dir("staliomem"); 3091 devfs_mk_dir("staliomem");
3092 3092
3093 stallion_class = class_simple_create(THIS_MODULE, "staliomem"); 3093 stallion_class = class_create(THIS_MODULE, "staliomem");
3094 for (i = 0; i < 4; i++) { 3094 for (i = 0; i < 4; i++) {
3095 devfs_mk_cdev(MKDEV(STL_SIOMEMMAJOR, i), 3095 devfs_mk_cdev(MKDEV(STL_SIOMEMMAJOR, i),
3096 S_IFCHR|S_IRUSR|S_IWUSR, 3096 S_IFCHR|S_IRUSR|S_IWUSR,
3097 "staliomem/%d", i); 3097 "staliomem/%d", i);
3098 class_simple_device_add(stallion_class, MKDEV(STL_SIOMEMMAJOR, i), NULL, "staliomem%d", i); 3098 class_device_create(stallion_class, MKDEV(STL_SIOMEMMAJOR, i), NULL, "staliomem%d", i);
3099 } 3099 }
3100 3100
3101 stl_serial->owner = THIS_MODULE; 3101 stl_serial->owner = THIS_MODULE;
diff --git a/drivers/char/tipar.c b/drivers/char/tipar.c
index 0c5ba9dc9063..659335d80ee7 100644
--- a/drivers/char/tipar.c
+++ b/drivers/char/tipar.c
@@ -90,7 +90,7 @@ static int timeout = TIMAXTIME; /* timeout in tenth of seconds */
90static unsigned int tp_count; /* tipar count */ 90static unsigned int tp_count; /* tipar count */
91static unsigned long opened; /* opened devices */ 91static unsigned long opened; /* opened devices */
92 92
93static struct class_simple *tipar_class; 93static struct class *tipar_class;
94 94
95/* --- macros for parport access -------------------------------------- */ 95/* --- macros for parport access -------------------------------------- */
96 96
@@ -436,7 +436,7 @@ tipar_register(int nr, struct parport *port)
436 goto out; 436 goto out;
437 } 437 }
438 438
439 class_simple_device_add(tipar_class, MKDEV(TIPAR_MAJOR, 439 class_device_create(tipar_class, MKDEV(TIPAR_MAJOR,
440 TIPAR_MINOR + nr), NULL, "par%d", nr); 440 TIPAR_MINOR + nr), NULL, "par%d", nr);
441 /* Use devfs, tree: /dev/ticables/par/[0..2] */ 441 /* Use devfs, tree: /dev/ticables/par/[0..2] */
442 err = devfs_mk_cdev(MKDEV(TIPAR_MAJOR, TIPAR_MINOR + nr), 442 err = devfs_mk_cdev(MKDEV(TIPAR_MAJOR, TIPAR_MINOR + nr),
@@ -458,8 +458,8 @@ tipar_register(int nr, struct parport *port)
458 goto out; 458 goto out;
459 459
460out_class: 460out_class:
461 class_simple_device_remove(MKDEV(TIPAR_MAJOR, TIPAR_MINOR + nr)); 461 class_device_destroy(tipar_class, MKDEV(TIPAR_MAJOR, TIPAR_MINOR + nr));
462 class_simple_destroy(tipar_class); 462 class_destroy(tipar_class);
463out: 463out:
464 return err; 464 return err;
465} 465}
@@ -505,7 +505,7 @@ tipar_init_module(void)
505 /* Use devfs with tree: /dev/ticables/par/[0..2] */ 505 /* Use devfs with tree: /dev/ticables/par/[0..2] */
506 devfs_mk_dir("ticables/par"); 506 devfs_mk_dir("ticables/par");
507 507
508 tipar_class = class_simple_create(THIS_MODULE, "ticables"); 508 tipar_class = class_create(THIS_MODULE, "ticables");
509 if (IS_ERR(tipar_class)) { 509 if (IS_ERR(tipar_class)) {
510 err = PTR_ERR(tipar_class); 510 err = PTR_ERR(tipar_class);
511 goto out_chrdev; 511 goto out_chrdev;
@@ -539,10 +539,10 @@ tipar_cleanup_module(void)
539 if (table[i].dev == NULL) 539 if (table[i].dev == NULL)
540 continue; 540 continue;
541 parport_unregister_device(table[i].dev); 541 parport_unregister_device(table[i].dev);
542 class_simple_device_remove(MKDEV(TIPAR_MAJOR, i)); 542 class_device_destroy(tipar_class, MKDEV(TIPAR_MAJOR, i));
543 devfs_remove("ticables/par/%d", i); 543 devfs_remove("ticables/par/%d", i);
544 } 544 }
545 class_simple_destroy(tipar_class); 545 class_destroy(tipar_class);
546 devfs_remove("ticables/par"); 546 devfs_remove("ticables/par");
547 547
548 pr_info("tipar: module unloaded\n"); 548 pr_info("tipar: module unloaded\n");
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
index 87235330fdbe..8ce508b29865 100644
--- a/drivers/char/tpm/tpm.c
+++ b/drivers/char/tpm/tpm.c
@@ -212,7 +212,7 @@ static u8 pcrread[] = {
212 0, 0, 0, 0 /* PCR index */ 212 0, 0, 0, 0 /* PCR index */
213}; 213};
214 214
215static ssize_t show_pcrs(struct device *dev, char *buf) 215static ssize_t show_pcrs(struct device *dev, struct device_attribute *attr, char *buf)
216{ 216{
217 u8 data[READ_PCR_RESULT_SIZE]; 217 u8 data[READ_PCR_RESULT_SIZE];
218 ssize_t len; 218 ssize_t len;
@@ -255,7 +255,7 @@ static u8 readpubek[] = {
255 0, 0, 0, 124, /* TPM_ORD_ReadPubek */ 255 0, 0, 0, 124, /* TPM_ORD_ReadPubek */
256}; 256};
257 257
258static ssize_t show_pubek(struct device *dev, char *buf) 258static ssize_t show_pubek(struct device *dev, struct device_attribute *attr, char *buf)
259{ 259{
260 u8 data[READ_PUBEK_RESULT_SIZE]; 260 u8 data[READ_PUBEK_RESULT_SIZE];
261 ssize_t len; 261 ssize_t len;
@@ -330,7 +330,7 @@ static u8 cap_manufacturer[] = {
330 0, 0, 1, 3 330 0, 0, 1, 3
331}; 331};
332 332
333static ssize_t show_caps(struct device *dev, char *buf) 333static ssize_t show_caps(struct device *dev, struct device_attribute *attr, char *buf)
334{ 334{
335 u8 data[READ_PUBEK_RESULT_SIZE]; 335 u8 data[READ_PUBEK_RESULT_SIZE];
336 ssize_t len; 336 ssize_t len;
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index 26e5e19ed854..31831030f73f 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -2654,7 +2654,7 @@ static void tty_default_put_char(struct tty_struct *tty, unsigned char ch)
2654 tty->driver->write(tty, &ch, 1); 2654 tty->driver->write(tty, &ch, 1);
2655} 2655}
2656 2656
2657static struct class_simple *tty_class; 2657static struct class *tty_class;
2658 2658
2659/** 2659/**
2660 * tty_register_device - register a tty device 2660 * tty_register_device - register a tty device
@@ -2687,7 +2687,7 @@ void tty_register_device(struct tty_driver *driver, unsigned index,
2687 pty_line_name(driver, index, name); 2687 pty_line_name(driver, index, name);
2688 else 2688 else
2689 tty_line_name(driver, index, name); 2689 tty_line_name(driver, index, name);
2690 class_simple_device_add(tty_class, dev, device, name); 2690 class_device_create(tty_class, dev, device, name);
2691} 2691}
2692 2692
2693/** 2693/**
@@ -2701,7 +2701,7 @@ void tty_register_device(struct tty_driver *driver, unsigned index,
2701void tty_unregister_device(struct tty_driver *driver, unsigned index) 2701void tty_unregister_device(struct tty_driver *driver, unsigned index)
2702{ 2702{
2703 devfs_remove("%s%d", driver->devfs_name, index + driver->name_base); 2703 devfs_remove("%s%d", driver->devfs_name, index + driver->name_base);
2704 class_simple_device_remove(MKDEV(driver->major, driver->minor_start) + index); 2704 class_device_destroy(tty_class, MKDEV(driver->major, driver->minor_start) + index);
2705} 2705}
2706 2706
2707EXPORT_SYMBOL(tty_register_device); 2707EXPORT_SYMBOL(tty_register_device);
@@ -2918,7 +2918,7 @@ extern int vty_init(void);
2918 2918
2919static int __init tty_class_init(void) 2919static int __init tty_class_init(void)
2920{ 2920{
2921 tty_class = class_simple_create(THIS_MODULE, "tty"); 2921 tty_class = class_create(THIS_MODULE, "tty");
2922 if (IS_ERR(tty_class)) 2922 if (IS_ERR(tty_class))
2923 return PTR_ERR(tty_class); 2923 return PTR_ERR(tty_class);
2924 return 0; 2924 return 0;
@@ -2947,14 +2947,14 @@ static int __init tty_init(void)
2947 register_chrdev_region(MKDEV(TTYAUX_MAJOR, 0), 1, "/dev/tty") < 0) 2947 register_chrdev_region(MKDEV(TTYAUX_MAJOR, 0), 1, "/dev/tty") < 0)
2948 panic("Couldn't register /dev/tty driver\n"); 2948 panic("Couldn't register /dev/tty driver\n");
2949 devfs_mk_cdev(MKDEV(TTYAUX_MAJOR, 0), S_IFCHR|S_IRUGO|S_IWUGO, "tty"); 2949 devfs_mk_cdev(MKDEV(TTYAUX_MAJOR, 0), S_IFCHR|S_IRUGO|S_IWUGO, "tty");
2950 class_simple_device_add(tty_class, MKDEV(TTYAUX_MAJOR, 0), NULL, "tty"); 2950 class_device_create(tty_class, MKDEV(TTYAUX_MAJOR, 0), NULL, "tty");
2951 2951
2952 cdev_init(&console_cdev, &console_fops); 2952 cdev_init(&console_cdev, &console_fops);
2953 if (cdev_add(&console_cdev, MKDEV(TTYAUX_MAJOR, 1), 1) || 2953 if (cdev_add(&console_cdev, MKDEV(TTYAUX_MAJOR, 1), 1) ||
2954 register_chrdev_region(MKDEV(TTYAUX_MAJOR, 1), 1, "/dev/console") < 0) 2954 register_chrdev_region(MKDEV(TTYAUX_MAJOR, 1), 1, "/dev/console") < 0)
2955 panic("Couldn't register /dev/console driver\n"); 2955 panic("Couldn't register /dev/console driver\n");
2956 devfs_mk_cdev(MKDEV(TTYAUX_MAJOR, 1), S_IFCHR|S_IRUSR|S_IWUSR, "console"); 2956 devfs_mk_cdev(MKDEV(TTYAUX_MAJOR, 1), S_IFCHR|S_IRUSR|S_IWUSR, "console");
2957 class_simple_device_add(tty_class, MKDEV(TTYAUX_MAJOR, 1), NULL, "console"); 2957 class_device_create(tty_class, MKDEV(TTYAUX_MAJOR, 1), NULL, "console");
2958 2958
2959#ifdef CONFIG_UNIX98_PTYS 2959#ifdef CONFIG_UNIX98_PTYS
2960 cdev_init(&ptmx_cdev, &ptmx_fops); 2960 cdev_init(&ptmx_cdev, &ptmx_fops);
@@ -2962,7 +2962,7 @@ static int __init tty_init(void)
2962 register_chrdev_region(MKDEV(TTYAUX_MAJOR, 2), 1, "/dev/ptmx") < 0) 2962 register_chrdev_region(MKDEV(TTYAUX_MAJOR, 2), 1, "/dev/ptmx") < 0)
2963 panic("Couldn't register /dev/ptmx driver\n"); 2963 panic("Couldn't register /dev/ptmx driver\n");
2964 devfs_mk_cdev(MKDEV(TTYAUX_MAJOR, 2), S_IFCHR|S_IRUGO|S_IWUGO, "ptmx"); 2964 devfs_mk_cdev(MKDEV(TTYAUX_MAJOR, 2), S_IFCHR|S_IRUGO|S_IWUGO, "ptmx");
2965 class_simple_device_add(tty_class, MKDEV(TTYAUX_MAJOR, 2), NULL, "ptmx"); 2965 class_device_create(tty_class, MKDEV(TTYAUX_MAJOR, 2), NULL, "ptmx");
2966#endif 2966#endif
2967 2967
2968#ifdef CONFIG_VT 2968#ifdef CONFIG_VT
@@ -2971,7 +2971,7 @@ static int __init tty_init(void)
2971 register_chrdev_region(MKDEV(TTY_MAJOR, 0), 1, "/dev/vc/0") < 0) 2971 register_chrdev_region(MKDEV(TTY_MAJOR, 0), 1, "/dev/vc/0") < 0)
2972 panic("Couldn't register /dev/tty0 driver\n"); 2972 panic("Couldn't register /dev/tty0 driver\n");
2973 devfs_mk_cdev(MKDEV(TTY_MAJOR, 0), S_IFCHR|S_IRUSR|S_IWUSR, "vc/0"); 2973 devfs_mk_cdev(MKDEV(TTY_MAJOR, 0), S_IFCHR|S_IRUSR|S_IWUSR, "vc/0");
2974 class_simple_device_add(tty_class, MKDEV(TTY_MAJOR, 0), NULL, "tty0"); 2974 class_device_create(tty_class, MKDEV(TTY_MAJOR, 0), NULL, "tty0");
2975 2975
2976 vty_init(); 2976 vty_init();
2977#endif 2977#endif
diff --git a/drivers/char/vc_screen.c b/drivers/char/vc_screen.c
index 7abe405b8657..79c2928a8817 100644
--- a/drivers/char/vc_screen.c
+++ b/drivers/char/vc_screen.c
@@ -474,7 +474,7 @@ static struct file_operations vcs_fops = {
474 .open = vcs_open, 474 .open = vcs_open,
475}; 475};
476 476
477static struct class_simple *vc_class; 477static struct class *vc_class;
478 478
479void vcs_make_devfs(struct tty_struct *tty) 479void vcs_make_devfs(struct tty_struct *tty)
480{ 480{
@@ -484,26 +484,26 @@ void vcs_make_devfs(struct tty_struct *tty)
484 devfs_mk_cdev(MKDEV(VCS_MAJOR, tty->index + 129), 484 devfs_mk_cdev(MKDEV(VCS_MAJOR, tty->index + 129),
485 S_IFCHR|S_IRUSR|S_IWUSR, 485 S_IFCHR|S_IRUSR|S_IWUSR,
486 "vcc/a%u", tty->index + 1); 486 "vcc/a%u", tty->index + 1);
487 class_simple_device_add(vc_class, MKDEV(VCS_MAJOR, tty->index + 1), NULL, "vcs%u", tty->index + 1); 487 class_device_create(vc_class, MKDEV(VCS_MAJOR, tty->index + 1), NULL, "vcs%u", tty->index + 1);
488 class_simple_device_add(vc_class, MKDEV(VCS_MAJOR, tty->index + 129), NULL, "vcsa%u", tty->index + 1); 488 class_device_create(vc_class, MKDEV(VCS_MAJOR, tty->index + 129), NULL, "vcsa%u", tty->index + 1);
489} 489}
490void vcs_remove_devfs(struct tty_struct *tty) 490void vcs_remove_devfs(struct tty_struct *tty)
491{ 491{
492 devfs_remove("vcc/%u", tty->index + 1); 492 devfs_remove("vcc/%u", tty->index + 1);
493 devfs_remove("vcc/a%u", tty->index + 1); 493 devfs_remove("vcc/a%u", tty->index + 1);
494 class_simple_device_remove(MKDEV(VCS_MAJOR, tty->index + 1)); 494 class_device_destroy(vc_class, MKDEV(VCS_MAJOR, tty->index + 1));
495 class_simple_device_remove(MKDEV(VCS_MAJOR, tty->index + 129)); 495 class_device_destroy(vc_class, MKDEV(VCS_MAJOR, tty->index + 129));
496} 496}
497 497
498int __init vcs_init(void) 498int __init vcs_init(void)
499{ 499{
500 if (register_chrdev(VCS_MAJOR, "vcs", &vcs_fops)) 500 if (register_chrdev(VCS_MAJOR, "vcs", &vcs_fops))
501 panic("unable to get major %d for vcs device", VCS_MAJOR); 501 panic("unable to get major %d for vcs device", VCS_MAJOR);
502 vc_class = class_simple_create(THIS_MODULE, "vc"); 502 vc_class = class_create(THIS_MODULE, "vc");
503 503
504 devfs_mk_cdev(MKDEV(VCS_MAJOR, 0), S_IFCHR|S_IRUSR|S_IWUSR, "vcc/0"); 504 devfs_mk_cdev(MKDEV(VCS_MAJOR, 0), S_IFCHR|S_IRUSR|S_IWUSR, "vcc/0");
505 devfs_mk_cdev(MKDEV(VCS_MAJOR, 128), S_IFCHR|S_IRUSR|S_IWUSR, "vcc/a0"); 505 devfs_mk_cdev(MKDEV(VCS_MAJOR, 128), S_IFCHR|S_IRUSR|S_IWUSR, "vcc/a0");
506 class_simple_device_add(vc_class, MKDEV(VCS_MAJOR, 0), NULL, "vcs"); 506 class_device_create(vc_class, MKDEV(VCS_MAJOR, 0), NULL, "vcs");
507 class_simple_device_add(vc_class, MKDEV(VCS_MAJOR, 128), NULL, "vcsa"); 507 class_device_create(vc_class, MKDEV(VCS_MAJOR, 128), NULL, "vcsa");
508 return 0; 508 return 0;
509} 509}
diff --git a/drivers/char/viotape.c b/drivers/char/viotape.c
index aea3cbf5219d..4764b4f9555d 100644
--- a/drivers/char/viotape.c
+++ b/drivers/char/viotape.c
@@ -237,7 +237,7 @@ static dma_addr_t viotape_unitinfo_token;
237 237
238static struct mtget viomtget[VIOTAPE_MAX_TAPE]; 238static struct mtget viomtget[VIOTAPE_MAX_TAPE];
239 239
240static struct class_simple *tape_class; 240static struct class *tape_class;
241 241
242static struct device *tape_device[VIOTAPE_MAX_TAPE]; 242static struct device *tape_device[VIOTAPE_MAX_TAPE];
243 243
@@ -956,9 +956,9 @@ static int viotape_probe(struct vio_dev *vdev, const struct vio_device_id *id)
956 state[i].cur_part = 0; 956 state[i].cur_part = 0;
957 for (j = 0; j < MAX_PARTITIONS; ++j) 957 for (j = 0; j < MAX_PARTITIONS; ++j)
958 state[i].part_stat_rwi[j] = VIOT_IDLE; 958 state[i].part_stat_rwi[j] = VIOT_IDLE;
959 class_simple_device_add(tape_class, MKDEV(VIOTAPE_MAJOR, i), NULL, 959 class_device_create(tape_class, MKDEV(VIOTAPE_MAJOR, i), NULL,
960 "iseries!vt%d", i); 960 "iseries!vt%d", i);
961 class_simple_device_add(tape_class, MKDEV(VIOTAPE_MAJOR, i | 0x80), 961 class_device_create(tape_class, MKDEV(VIOTAPE_MAJOR, i | 0x80),
962 NULL, "iseries!nvt%d", i); 962 NULL, "iseries!nvt%d", i);
963 devfs_mk_cdev(MKDEV(VIOTAPE_MAJOR, i), S_IFCHR | S_IRUSR | S_IWUSR, 963 devfs_mk_cdev(MKDEV(VIOTAPE_MAJOR, i), S_IFCHR | S_IRUSR | S_IWUSR,
964 "iseries/vt%d", i); 964 "iseries/vt%d", i);
@@ -980,8 +980,8 @@ static int viotape_remove(struct vio_dev *vdev)
980 devfs_remove("iseries/nvt%d", i); 980 devfs_remove("iseries/nvt%d", i);
981 devfs_remove("iseries/vt%d", i); 981 devfs_remove("iseries/vt%d", i);
982 devfs_unregister_tape(state[i].dev_handle); 982 devfs_unregister_tape(state[i].dev_handle);
983 class_simple_device_remove(MKDEV(VIOTAPE_MAJOR, i | 0x80)); 983 class_device_destroy(tape_class, MKDEV(VIOTAPE_MAJOR, i | 0x80));
984 class_simple_device_remove(MKDEV(VIOTAPE_MAJOR, i)); 984 class_device_destroy(tape_class, MKDEV(VIOTAPE_MAJOR, i));
985 return 0; 985 return 0;
986} 986}
987 987
@@ -1045,7 +1045,7 @@ int __init viotap_init(void)
1045 goto clear_handler; 1045 goto clear_handler;
1046 } 1046 }
1047 1047
1048 tape_class = class_simple_create(THIS_MODULE, "tape"); 1048 tape_class = class_create(THIS_MODULE, "tape");
1049 if (IS_ERR(tape_class)) { 1049 if (IS_ERR(tape_class)) {
1050 printk(VIOTAPE_KERN_WARN "Unable to allocat class\n"); 1050 printk(VIOTAPE_KERN_WARN "Unable to allocat class\n");
1051 ret = PTR_ERR(tape_class); 1051 ret = PTR_ERR(tape_class);
@@ -1070,7 +1070,7 @@ int __init viotap_init(void)
1070 return 0; 1070 return 0;
1071 1071
1072unreg_class: 1072unreg_class:
1073 class_simple_destroy(tape_class); 1073 class_destroy(tape_class);
1074unreg_chrdev: 1074unreg_chrdev:
1075 unregister_chrdev(VIOTAPE_MAJOR, "viotape"); 1075 unregister_chrdev(VIOTAPE_MAJOR, "viotape");
1076clear_handler: 1076clear_handler:
@@ -1110,7 +1110,7 @@ static void __exit viotap_exit(void)
1110 1110
1111 remove_proc_entry("iSeries/viotape", NULL); 1111 remove_proc_entry("iSeries/viotape", NULL);
1112 vio_unregister_driver(&viotape_driver); 1112 vio_unregister_driver(&viotape_driver);
1113 class_simple_destroy(tape_class); 1113 class_destroy(tape_class);
1114 ret = unregister_chrdev(VIOTAPE_MAJOR, "viotape"); 1114 ret = unregister_chrdev(VIOTAPE_MAJOR, "viotape");
1115 if (ret < 0) 1115 if (ret < 0)
1116 printk(VIOTAPE_KERN_WARN "Error unregistering device: %d\n", 1116 printk(VIOTAPE_KERN_WARN "Error unregistering device: %d\n",
diff --git a/drivers/char/watchdog/ixp2000_wdt.c b/drivers/char/watchdog/ixp2000_wdt.c
index ab659d37b4d2..4e98c215e5b1 100644
--- a/drivers/char/watchdog/ixp2000_wdt.c
+++ b/drivers/char/watchdog/ixp2000_wdt.c
@@ -192,7 +192,12 @@ static struct miscdevice ixp2000_wdt_miscdev =
192 192
193static int __init ixp2000_wdt_init(void) 193static int __init ixp2000_wdt_init(void)
194{ 194{
195 wdt_tick_rate = (*IXP2000_T1_CLD * HZ)/ 256;; 195 if ((*IXP2000_PRODUCT_ID & 0x001ffef0) == 0x00000000) {
196 printk(KERN_INFO "Unable to use IXP2000 watchdog due to IXP2800 erratum #25.\n");
197 return -EIO;
198 }
199
200 wdt_tick_rate = (*IXP2000_T1_CLD * HZ) / 256;
196 201
197 return misc_register(&ixp2000_wdt_miscdev); 202 return misc_register(&ixp2000_wdt_miscdev);
198} 203}
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 03b5fb2ddcf4..bf62dfe4976a 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -521,7 +521,7 @@ static ssize_t show(struct kobject * kobj, struct attribute * attr ,char * buf)
521 policy = cpufreq_cpu_get(policy->cpu); 521 policy = cpufreq_cpu_get(policy->cpu);
522 if (!policy) 522 if (!policy)
523 return -EINVAL; 523 return -EINVAL;
524 ret = fattr->show ? fattr->show(policy,buf) : 0; 524 ret = fattr->show ? fattr->show(policy,buf) : -EIO;
525 cpufreq_cpu_put(policy); 525 cpufreq_cpu_put(policy);
526 return ret; 526 return ret;
527} 527}
@@ -535,7 +535,7 @@ static ssize_t store(struct kobject * kobj, struct attribute * attr,
535 policy = cpufreq_cpu_get(policy->cpu); 535 policy = cpufreq_cpu_get(policy->cpu);
536 if (!policy) 536 if (!policy)
537 return -EINVAL; 537 return -EINVAL;
538 ret = fattr->store ? fattr->store(policy,buf,count) : 0; 538 ret = fattr->store ? fattr->store(policy,buf,count) : -EIO;
539 cpufreq_cpu_put(policy); 539 cpufreq_cpu_put(policy);
540 return ret; 540 return ret;
541} 541}
diff --git a/drivers/dio/dio-sysfs.c b/drivers/dio/dio-sysfs.c
index d30591f69dd9..f46463038847 100644
--- a/drivers/dio/dio-sysfs.c
+++ b/drivers/dio/dio-sysfs.c
@@ -17,7 +17,7 @@
17 17
18/* show configuration fields */ 18/* show configuration fields */
19 19
20static ssize_t dio_show_id(struct device *dev, char *buf) 20static ssize_t dio_show_id(struct device *dev, struct device_attribute *attr, char *buf)
21{ 21{
22 struct dio_dev *d; 22 struct dio_dev *d;
23 23
@@ -26,7 +26,7 @@ static ssize_t dio_show_id(struct device *dev, char *buf)
26} 26}
27static DEVICE_ATTR(id, S_IRUGO, dio_show_id, NULL); 27static DEVICE_ATTR(id, S_IRUGO, dio_show_id, NULL);
28 28
29static ssize_t dio_show_ipl(struct device *dev, char *buf) 29static ssize_t dio_show_ipl(struct device *dev, struct device_attribute *attr, char *buf)
30{ 30{
31 struct dio_dev *d; 31 struct dio_dev *d;
32 32
@@ -35,7 +35,7 @@ static ssize_t dio_show_ipl(struct device *dev, char *buf)
35} 35}
36static DEVICE_ATTR(ipl, S_IRUGO, dio_show_ipl, NULL); 36static DEVICE_ATTR(ipl, S_IRUGO, dio_show_ipl, NULL);
37 37
38static ssize_t dio_show_secid(struct device *dev, char *buf) 38static ssize_t dio_show_secid(struct device *dev, struct device_attribute *attr, char *buf)
39{ 39{
40 struct dio_dev *d; 40 struct dio_dev *d;
41 41
@@ -44,7 +44,7 @@ static ssize_t dio_show_secid(struct device *dev, char *buf)
44} 44}
45static DEVICE_ATTR(secid, S_IRUGO, dio_show_secid, NULL); 45static DEVICE_ATTR(secid, S_IRUGO, dio_show_secid, NULL);
46 46
47static ssize_t dio_show_name(struct device *dev, char *buf) 47static ssize_t dio_show_name(struct device *dev, struct device_attribute *attr, char *buf)
48{ 48{
49 struct dio_dev *d; 49 struct dio_dev *d;
50 50
@@ -53,7 +53,7 @@ static ssize_t dio_show_name(struct device *dev, char *buf)
53} 53}
54static DEVICE_ATTR(name, S_IRUGO, dio_show_name, NULL); 54static DEVICE_ATTR(name, S_IRUGO, dio_show_name, NULL);
55 55
56static ssize_t dio_show_resource(struct device *dev, char *buf) 56static ssize_t dio_show_resource(struct device *dev, struct device_attribute *attr, char *buf)
57{ 57{
58 struct dio_dev *d = to_dio_dev(dev); 58 struct dio_dev *d = to_dio_dev(dev);
59 59
diff --git a/drivers/eisa/eisa-bus.c b/drivers/eisa/eisa-bus.c
index 6381ba53853c..1937743c8e29 100644
--- a/drivers/eisa/eisa-bus.c
+++ b/drivers/eisa/eisa-bus.c
@@ -149,7 +149,7 @@ void eisa_driver_unregister (struct eisa_driver *edrv)
149 driver_unregister (&edrv->driver); 149 driver_unregister (&edrv->driver);
150} 150}
151 151
152static ssize_t eisa_show_sig (struct device *dev, char *buf) 152static ssize_t eisa_show_sig (struct device *dev, struct device_attribute *attr, char *buf)
153{ 153{
154 struct eisa_device *edev = to_eisa_device (dev); 154 struct eisa_device *edev = to_eisa_device (dev);
155 return sprintf (buf,"%s\n", edev->id.sig); 155 return sprintf (buf,"%s\n", edev->id.sig);
@@ -157,7 +157,7 @@ static ssize_t eisa_show_sig (struct device *dev, char *buf)
157 157
158static DEVICE_ATTR(signature, S_IRUGO, eisa_show_sig, NULL); 158static DEVICE_ATTR(signature, S_IRUGO, eisa_show_sig, NULL);
159 159
160static ssize_t eisa_show_state (struct device *dev, char *buf) 160static ssize_t eisa_show_state (struct device *dev, struct device_attribute *attr, char *buf)
161{ 161{
162 struct eisa_device *edev = to_eisa_device (dev); 162 struct eisa_device *edev = to_eisa_device (dev);
163 return sprintf (buf,"%d\n", edev->state & EISA_CONFIG_ENABLED); 163 return sprintf (buf,"%d\n", edev->state & EISA_CONFIG_ENABLED);
diff --git a/drivers/fc4/fc.c b/drivers/fc4/fc.c
index fbd9ff79b7b8..e3c958823533 100644
--- a/drivers/fc4/fc.c
+++ b/drivers/fc4/fc.c
@@ -765,8 +765,6 @@ void fcp_release(fc_channel *fcchain, int count) /* count must > 0 */
765 765
766static void fcp_scsi_done (Scsi_Cmnd *SCpnt) 766static void fcp_scsi_done (Scsi_Cmnd *SCpnt)
767{ 767{
768 unsigned long flags;
769
770 if (FCP_CMND(SCpnt)->done) 768 if (FCP_CMND(SCpnt)->done)
771 FCP_CMND(SCpnt)->done(SCpnt); 769 FCP_CMND(SCpnt)->done(SCpnt);
772} 770}
@@ -907,8 +905,6 @@ int fcp_scsi_abort(Scsi_Cmnd *SCpnt)
907 */ 905 */
908 906
909 if (++fc->abort_count < (fc->can_queue >> 1)) { 907 if (++fc->abort_count < (fc->can_queue >> 1)) {
910 unsigned long flags;
911
912 SCpnt->result = DID_ABORT; 908 SCpnt->result = DID_ABORT;
913 fcmd->done(SCpnt); 909 fcmd->done(SCpnt);
914 printk("FC: soft abort\n"); 910 printk("FC: soft abort\n");
@@ -931,6 +927,7 @@ void fcp_scsi_reset_done(Scsi_Cmnd *SCpnt)
931 927
932int fcp_scsi_dev_reset(Scsi_Cmnd *SCpnt) 928int fcp_scsi_dev_reset(Scsi_Cmnd *SCpnt)
933{ 929{
930 unsigned long flags;
934 fcp_cmd *cmd; 931 fcp_cmd *cmd;
935 fcp_cmnd *fcmd; 932 fcp_cmnd *fcmd;
936 fc_channel *fc = FC_SCMND(SCpnt); 933 fc_channel *fc = FC_SCMND(SCpnt);
@@ -1028,6 +1025,7 @@ static int __fcp_scsi_host_reset(Scsi_Cmnd *SCpnt)
1028 1025
1029int fcp_scsi_host_reset(Scsi_Cmnd *SCpnt) 1026int fcp_scsi_host_reset(Scsi_Cmnd *SCpnt)
1030{ 1027{
1028 unsigned long flags;
1031 int rc; 1029 int rc;
1032 1030
1033 spin_lock_irqsave(SCpnt->device->host->host_lock, flags); 1031 spin_lock_irqsave(SCpnt->device->host->host_lock, flags);
diff --git a/drivers/firmware/edd.c b/drivers/firmware/edd.c
index 33b669e6f977..6996476669f1 100644
--- a/drivers/firmware/edd.c
+++ b/drivers/firmware/edd.c
@@ -115,7 +115,7 @@ edd_attr_show(struct kobject * kobj, struct attribute *attr, char *buf)
115{ 115{
116 struct edd_device *dev = to_edd_device(kobj); 116 struct edd_device *dev = to_edd_device(kobj);
117 struct edd_attribute *edd_attr = to_edd_attr(attr); 117 struct edd_attribute *edd_attr = to_edd_attr(attr);
118 ssize_t ret = 0; 118 ssize_t ret = -EIO;
119 119
120 if (edd_attr->show) 120 if (edd_attr->show)
121 ret = edd_attr->show(dev, buf); 121 ret = edd_attr->show(dev, buf);
diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
index 0287ff65963b..a3451cb94004 100644
--- a/drivers/firmware/efivars.c
+++ b/drivers/firmware/efivars.c
@@ -352,7 +352,7 @@ static ssize_t efivar_attr_show(struct kobject *kobj, struct attribute *attr,
352{ 352{
353 struct efivar_entry *var = to_efivar_entry(kobj); 353 struct efivar_entry *var = to_efivar_entry(kobj);
354 struct efivar_attribute *efivar_attr = to_efivar_attr(attr); 354 struct efivar_attribute *efivar_attr = to_efivar_attr(attr);
355 ssize_t ret = 0; 355 ssize_t ret = -EIO;
356 356
357 if (!capable(CAP_SYS_ADMIN)) 357 if (!capable(CAP_SYS_ADMIN))
358 return -EACCES; 358 return -EACCES;
@@ -368,7 +368,7 @@ static ssize_t efivar_attr_store(struct kobject *kobj, struct attribute *attr,
368{ 368{
369 struct efivar_entry *var = to_efivar_entry(kobj); 369 struct efivar_entry *var = to_efivar_entry(kobj);
370 struct efivar_attribute *efivar_attr = to_efivar_attr(attr); 370 struct efivar_attribute *efivar_attr = to_efivar_attr(attr);
371 ssize_t ret = 0; 371 ssize_t ret = -EIO;
372 372
373 if (!capable(CAP_SYS_ADMIN)) 373 if (!capable(CAP_SYS_ADMIN))
374 return -EACCES; 374 return -EACCES;
diff --git a/drivers/i2c/chips/adm1021.c b/drivers/i2c/chips/adm1021.c
index 9c59a370b6d9..9058c3956710 100644
--- a/drivers/i2c/chips/adm1021.c
+++ b/drivers/i2c/chips/adm1021.c
@@ -137,7 +137,7 @@ static struct i2c_driver adm1021_driver = {
137}; 137};
138 138
139#define show(value) \ 139#define show(value) \
140static ssize_t show_##value(struct device *dev, char *buf) \ 140static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \
141{ \ 141{ \
142 struct adm1021_data *data = adm1021_update_device(dev); \ 142 struct adm1021_data *data = adm1021_update_device(dev); \
143 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->value)); \ 143 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->value)); \
@@ -150,7 +150,7 @@ show(remote_temp_hyst);
150show(remote_temp_input); 150show(remote_temp_input);
151 151
152#define show2(value) \ 152#define show2(value) \
153static ssize_t show_##value(struct device *dev, char *buf) \ 153static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \
154{ \ 154{ \
155 struct adm1021_data *data = adm1021_update_device(dev); \ 155 struct adm1021_data *data = adm1021_update_device(dev); \
156 return sprintf(buf, "%d\n", data->value); \ 156 return sprintf(buf, "%d\n", data->value); \
@@ -159,7 +159,7 @@ show2(alarms);
159show2(die_code); 159show2(die_code);
160 160
161#define set(value, reg) \ 161#define set(value, reg) \
162static ssize_t set_##value(struct device *dev, const char *buf, size_t count) \ 162static ssize_t set_##value(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \
163{ \ 163{ \
164 struct i2c_client *client = to_i2c_client(dev); \ 164 struct i2c_client *client = to_i2c_client(dev); \
165 struct adm1021_data *data = i2c_get_clientdata(client); \ 165 struct adm1021_data *data = i2c_get_clientdata(client); \
diff --git a/drivers/i2c/chips/adm1025.c b/drivers/i2c/chips/adm1025.c
index e0771a3d05c9..111f0c86c933 100644
--- a/drivers/i2c/chips/adm1025.c
+++ b/drivers/i2c/chips/adm1025.c
@@ -153,19 +153,19 @@ struct adm1025_data {
153 */ 153 */
154 154
155#define show_in(offset) \ 155#define show_in(offset) \
156static ssize_t show_in##offset(struct device *dev, char *buf) \ 156static ssize_t show_in##offset(struct device *dev, struct device_attribute *attr, char *buf) \
157{ \ 157{ \
158 struct adm1025_data *data = adm1025_update_device(dev); \ 158 struct adm1025_data *data = adm1025_update_device(dev); \
159 return sprintf(buf, "%u\n", IN_FROM_REG(data->in[offset], \ 159 return sprintf(buf, "%u\n", IN_FROM_REG(data->in[offset], \
160 in_scale[offset])); \ 160 in_scale[offset])); \
161} \ 161} \
162static ssize_t show_in##offset##_min(struct device *dev, char *buf) \ 162static ssize_t show_in##offset##_min(struct device *dev, struct device_attribute *attr, char *buf) \
163{ \ 163{ \
164 struct adm1025_data *data = adm1025_update_device(dev); \ 164 struct adm1025_data *data = adm1025_update_device(dev); \
165 return sprintf(buf, "%u\n", IN_FROM_REG(data->in_min[offset], \ 165 return sprintf(buf, "%u\n", IN_FROM_REG(data->in_min[offset], \
166 in_scale[offset])); \ 166 in_scale[offset])); \
167} \ 167} \
168static ssize_t show_in##offset##_max(struct device *dev, char *buf) \ 168static ssize_t show_in##offset##_max(struct device *dev, struct device_attribute *attr, char *buf) \
169{ \ 169{ \
170 struct adm1025_data *data = adm1025_update_device(dev); \ 170 struct adm1025_data *data = adm1025_update_device(dev); \
171 return sprintf(buf, "%u\n", IN_FROM_REG(data->in_max[offset], \ 171 return sprintf(buf, "%u\n", IN_FROM_REG(data->in_max[offset], \
@@ -180,17 +180,17 @@ show_in(4);
180show_in(5); 180show_in(5);
181 181
182#define show_temp(offset) \ 182#define show_temp(offset) \
183static ssize_t show_temp##offset(struct device *dev, char *buf) \ 183static ssize_t show_temp##offset(struct device *dev, struct device_attribute *attr, char *buf) \
184{ \ 184{ \
185 struct adm1025_data *data = adm1025_update_device(dev); \ 185 struct adm1025_data *data = adm1025_update_device(dev); \
186 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[offset-1])); \ 186 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[offset-1])); \
187} \ 187} \
188static ssize_t show_temp##offset##_min(struct device *dev, char *buf) \ 188static ssize_t show_temp##offset##_min(struct device *dev, struct device_attribute *attr, char *buf) \
189{ \ 189{ \
190 struct adm1025_data *data = adm1025_update_device(dev); \ 190 struct adm1025_data *data = adm1025_update_device(dev); \
191 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_min[offset-1])); \ 191 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_min[offset-1])); \
192} \ 192} \
193static ssize_t show_temp##offset##_max(struct device *dev, char *buf) \ 193static ssize_t show_temp##offset##_max(struct device *dev, struct device_attribute *attr, char *buf) \
194{ \ 194{ \
195 struct adm1025_data *data = adm1025_update_device(dev); \ 195 struct adm1025_data *data = adm1025_update_device(dev); \
196 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_max[offset-1])); \ 196 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_max[offset-1])); \
@@ -200,7 +200,7 @@ show_temp(1);
200show_temp(2); 200show_temp(2);
201 201
202#define set_in(offset) \ 202#define set_in(offset) \
203static ssize_t set_in##offset##_min(struct device *dev, const char *buf, \ 203static ssize_t set_in##offset##_min(struct device *dev, struct device_attribute *attr, const char *buf, \
204 size_t count) \ 204 size_t count) \
205{ \ 205{ \
206 struct i2c_client *client = to_i2c_client(dev); \ 206 struct i2c_client *client = to_i2c_client(dev); \
@@ -214,7 +214,7 @@ static ssize_t set_in##offset##_min(struct device *dev, const char *buf, \
214 up(&data->update_lock); \ 214 up(&data->update_lock); \
215 return count; \ 215 return count; \
216} \ 216} \
217static ssize_t set_in##offset##_max(struct device *dev, const char *buf, \ 217static ssize_t set_in##offset##_max(struct device *dev, struct device_attribute *attr, const char *buf, \
218 size_t count) \ 218 size_t count) \
219{ \ 219{ \
220 struct i2c_client *client = to_i2c_client(dev); \ 220 struct i2c_client *client = to_i2c_client(dev); \
@@ -240,7 +240,7 @@ set_in(4);
240set_in(5); 240set_in(5);
241 241
242#define set_temp(offset) \ 242#define set_temp(offset) \
243static ssize_t set_temp##offset##_min(struct device *dev, const char *buf, \ 243static ssize_t set_temp##offset##_min(struct device *dev, struct device_attribute *attr, const char *buf, \
244 size_t count) \ 244 size_t count) \
245{ \ 245{ \
246 struct i2c_client *client = to_i2c_client(dev); \ 246 struct i2c_client *client = to_i2c_client(dev); \
@@ -254,7 +254,7 @@ static ssize_t set_temp##offset##_min(struct device *dev, const char *buf, \
254 up(&data->update_lock); \ 254 up(&data->update_lock); \
255 return count; \ 255 return count; \
256} \ 256} \
257static ssize_t set_temp##offset##_max(struct device *dev, const char *buf, \ 257static ssize_t set_temp##offset##_max(struct device *dev, struct device_attribute *attr, const char *buf, \
258 size_t count) \ 258 size_t count) \
259{ \ 259{ \
260 struct i2c_client *client = to_i2c_client(dev); \ 260 struct i2c_client *client = to_i2c_client(dev); \
@@ -275,26 +275,26 @@ static DEVICE_ATTR(temp##offset##_max, S_IWUSR | S_IRUGO, \
275set_temp(1); 275set_temp(1);
276set_temp(2); 276set_temp(2);
277 277
278static ssize_t show_alarms(struct device *dev, char *buf) 278static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf)
279{ 279{
280 struct adm1025_data *data = adm1025_update_device(dev); 280 struct adm1025_data *data = adm1025_update_device(dev);
281 return sprintf(buf, "%u\n", data->alarms); 281 return sprintf(buf, "%u\n", data->alarms);
282} 282}
283static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); 283static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
284 284
285static ssize_t show_vid(struct device *dev, char *buf) 285static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char *buf)
286{ 286{
287 struct adm1025_data *data = adm1025_update_device(dev); 287 struct adm1025_data *data = adm1025_update_device(dev);
288 return sprintf(buf, "%u\n", vid_from_reg(data->vid, data->vrm)); 288 return sprintf(buf, "%u\n", vid_from_reg(data->vid, data->vrm));
289} 289}
290static DEVICE_ATTR(in1_ref, S_IRUGO, show_vid, NULL); 290static DEVICE_ATTR(in1_ref, S_IRUGO, show_vid, NULL);
291 291
292static ssize_t show_vrm(struct device *dev, char *buf) 292static ssize_t show_vrm(struct device *dev, struct device_attribute *attr, char *buf)
293{ 293{
294 struct adm1025_data *data = adm1025_update_device(dev); 294 struct adm1025_data *data = adm1025_update_device(dev);
295 return sprintf(buf, "%u\n", data->vrm); 295 return sprintf(buf, "%u\n", data->vrm);
296} 296}
297static ssize_t set_vrm(struct device *dev, const char *buf, size_t count) 297static ssize_t set_vrm(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
298{ 298{
299 struct i2c_client *client = to_i2c_client(dev); 299 struct i2c_client *client = to_i2c_client(dev);
300 struct adm1025_data *data = i2c_get_clientdata(client); 300 struct adm1025_data *data = i2c_get_clientdata(client);
diff --git a/drivers/i2c/chips/adm1026.c b/drivers/i2c/chips/adm1026.c
index 39e2f4a900bf..b15fafe8f111 100644
--- a/drivers/i2c/chips/adm1026.c
+++ b/drivers/i2c/chips/adm1026.c
@@ -30,6 +30,7 @@
30#include <linux/jiffies.h> 30#include <linux/jiffies.h>
31#include <linux/i2c.h> 31#include <linux/i2c.h>
32#include <linux/i2c-sensor.h> 32#include <linux/i2c-sensor.h>
33#include <linux/i2c-sysfs.h>
33#include <linux/i2c-vid.h> 34#include <linux/i2c-vid.h>
34 35
35/* Addresses to scan */ 36/* Addresses to scan */
@@ -711,19 +712,27 @@ static struct adm1026_data *adm1026_update_device(struct device *dev)
711 return data; 712 return data;
712} 713}
713 714
714static ssize_t show_in(struct device *dev, char *buf, int nr) 715static ssize_t show_in(struct device *dev, struct device_attribute *attr,
716 char *buf)
715{ 717{
718 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
719 int nr = sensor_attr->index;
716 struct adm1026_data *data = adm1026_update_device(dev); 720 struct adm1026_data *data = adm1026_update_device(dev);
717 return sprintf(buf,"%d\n", INS_FROM_REG(nr, data->in[nr])); 721 return sprintf(buf,"%d\n", INS_FROM_REG(nr, data->in[nr]));
718} 722}
719static ssize_t show_in_min(struct device *dev, char *buf, int nr) 723static ssize_t show_in_min(struct device *dev, struct device_attribute *attr,
724 char *buf)
720{ 725{
726 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
727 int nr = sensor_attr->index;
721 struct adm1026_data *data = adm1026_update_device(dev); 728 struct adm1026_data *data = adm1026_update_device(dev);
722 return sprintf(buf,"%d\n", INS_FROM_REG(nr, data->in_min[nr])); 729 return sprintf(buf,"%d\n", INS_FROM_REG(nr, data->in_min[nr]));
723} 730}
724static ssize_t set_in_min(struct device *dev, const char *buf, 731static ssize_t set_in_min(struct device *dev, struct device_attribute *attr,
725 size_t count, int nr) 732 const char *buf, size_t count)
726{ 733{
734 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
735 int nr = sensor_attr->index;
727 struct i2c_client *client = to_i2c_client(dev); 736 struct i2c_client *client = to_i2c_client(dev);
728 struct adm1026_data *data = i2c_get_clientdata(client); 737 struct adm1026_data *data = i2c_get_clientdata(client);
729 int val = simple_strtol(buf, NULL, 10); 738 int val = simple_strtol(buf, NULL, 10);
@@ -734,14 +743,19 @@ static ssize_t set_in_min(struct device *dev, const char *buf,
734 up(&data->update_lock); 743 up(&data->update_lock);
735 return count; 744 return count;
736} 745}
737static ssize_t show_in_max(struct device *dev, char *buf, int nr) 746static ssize_t show_in_max(struct device *dev, struct device_attribute *attr,
747 char *buf)
738{ 748{
749 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
750 int nr = sensor_attr->index;
739 struct adm1026_data *data = adm1026_update_device(dev); 751 struct adm1026_data *data = adm1026_update_device(dev);
740 return sprintf(buf,"%d\n", INS_FROM_REG(nr, data->in_max[nr])); 752 return sprintf(buf,"%d\n", INS_FROM_REG(nr, data->in_max[nr]));
741} 753}
742static ssize_t set_in_max(struct device *dev, const char *buf, 754static ssize_t set_in_max(struct device *dev, struct device_attribute *attr,
743 size_t count, int nr) 755 const char *buf, size_t count)
744{ 756{
757 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
758 int nr = sensor_attr->index;
745 struct i2c_client *client = to_i2c_client(dev); 759 struct i2c_client *client = to_i2c_client(dev);
746 struct adm1026_data *data = i2c_get_clientdata(client); 760 struct adm1026_data *data = i2c_get_clientdata(client);
747 int val = simple_strtol(buf, NULL, 10); 761 int val = simple_strtol(buf, NULL, 10);
@@ -753,34 +767,13 @@ static ssize_t set_in_max(struct device *dev, const char *buf,
753 return count; 767 return count;
754} 768}
755 769
756#define in_reg(offset) \ 770#define in_reg(offset) \
757static ssize_t show_in##offset (struct device *dev, char *buf) \ 771static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in, \
758{ \ 772 NULL, offset); \
759 return show_in(dev, buf, offset); \ 773static SENSOR_DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \
760} \ 774 show_in_min, set_in_min, offset); \
761static ssize_t show_in##offset##_min (struct device *dev, char *buf) \ 775static SENSOR_DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \
762{ \ 776 show_in_max, set_in_max, offset);
763 return show_in_min(dev, buf, offset); \
764} \
765static ssize_t set_in##offset##_min (struct device *dev, \
766 const char *buf, size_t count) \
767{ \
768 return set_in_min(dev, buf, count, offset); \
769} \
770static ssize_t show_in##offset##_max (struct device *dev, char *buf) \
771{ \
772 return show_in_max(dev, buf, offset); \
773} \
774static ssize_t set_in##offset##_max (struct device *dev, \
775 const char *buf, size_t count) \
776{ \
777 return set_in_max(dev, buf, count, offset); \
778} \
779static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in##offset, NULL); \
780static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \
781 show_in##offset##_min, set_in##offset##_min); \
782static DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \
783 show_in##offset##_max, set_in##offset##_max);
784 777
785 778
786in_reg(0); 779in_reg(0);
@@ -800,19 +793,19 @@ in_reg(13);
800in_reg(14); 793in_reg(14);
801in_reg(15); 794in_reg(15);
802 795
803static ssize_t show_in16(struct device *dev, char *buf) 796static ssize_t show_in16(struct device *dev, struct device_attribute *attr, char *buf)
804{ 797{
805 struct adm1026_data *data = adm1026_update_device(dev); 798 struct adm1026_data *data = adm1026_update_device(dev);
806 return sprintf(buf,"%d\n", INS_FROM_REG(16, data->in[16]) - 799 return sprintf(buf,"%d\n", INS_FROM_REG(16, data->in[16]) -
807 NEG12_OFFSET); 800 NEG12_OFFSET);
808} 801}
809static ssize_t show_in16_min(struct device *dev, char *buf) 802static ssize_t show_in16_min(struct device *dev, struct device_attribute *attr, char *buf)
810{ 803{
811 struct adm1026_data *data = adm1026_update_device(dev); 804 struct adm1026_data *data = adm1026_update_device(dev);
812 return sprintf(buf,"%d\n", INS_FROM_REG(16, data->in_min[16]) 805 return sprintf(buf,"%d\n", INS_FROM_REG(16, data->in_min[16])
813 - NEG12_OFFSET); 806 - NEG12_OFFSET);
814} 807}
815static ssize_t set_in16_min(struct device *dev, const char *buf, size_t count) 808static ssize_t set_in16_min(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
816{ 809{
817 struct i2c_client *client = to_i2c_client(dev); 810 struct i2c_client *client = to_i2c_client(dev);
818 struct adm1026_data *data = i2c_get_clientdata(client); 811 struct adm1026_data *data = i2c_get_clientdata(client);
@@ -824,13 +817,13 @@ static ssize_t set_in16_min(struct device *dev, const char *buf, size_t count)
824 up(&data->update_lock); 817 up(&data->update_lock);
825 return count; 818 return count;
826} 819}
827static ssize_t show_in16_max(struct device *dev, char *buf) 820static ssize_t show_in16_max(struct device *dev, struct device_attribute *attr, char *buf)
828{ 821{
829 struct adm1026_data *data = adm1026_update_device(dev); 822 struct adm1026_data *data = adm1026_update_device(dev);
830 return sprintf(buf,"%d\n", INS_FROM_REG(16, data->in_max[16]) 823 return sprintf(buf,"%d\n", INS_FROM_REG(16, data->in_max[16])
831 - NEG12_OFFSET); 824 - NEG12_OFFSET);
832} 825}
833static ssize_t set_in16_max(struct device *dev, const char *buf, size_t count) 826static ssize_t set_in16_max(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
834{ 827{
835 struct i2c_client *client = to_i2c_client(dev); 828 struct i2c_client *client = to_i2c_client(dev);
836 struct adm1026_data *data = i2c_get_clientdata(client); 829 struct adm1026_data *data = i2c_get_clientdata(client);
@@ -843,30 +836,38 @@ static ssize_t set_in16_max(struct device *dev, const char *buf, size_t count)
843 return count; 836 return count;
844} 837}
845 838
846static DEVICE_ATTR(in16_input, S_IRUGO, show_in16, NULL); 839static SENSOR_DEVICE_ATTR(in16_input, S_IRUGO, show_in16, NULL, 16);
847static DEVICE_ATTR(in16_min, S_IRUGO | S_IWUSR, show_in16_min, set_in16_min); 840static SENSOR_DEVICE_ATTR(in16_min, S_IRUGO | S_IWUSR, show_in16_min, set_in16_min, 16);
848static DEVICE_ATTR(in16_max, S_IRUGO | S_IWUSR, show_in16_max, set_in16_max); 841static SENSOR_DEVICE_ATTR(in16_max, S_IRUGO | S_IWUSR, show_in16_max, set_in16_max, 16);
849 842
850 843
851 844
852 845
853/* Now add fan read/write functions */ 846/* Now add fan read/write functions */
854 847
855static ssize_t show_fan(struct device *dev, char *buf, int nr) 848static ssize_t show_fan(struct device *dev, struct device_attribute *attr,
849 char *buf)
856{ 850{
851 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
852 int nr = sensor_attr->index;
857 struct adm1026_data *data = adm1026_update_device(dev); 853 struct adm1026_data *data = adm1026_update_device(dev);
858 return sprintf(buf,"%d\n", FAN_FROM_REG(data->fan[nr], 854 return sprintf(buf,"%d\n", FAN_FROM_REG(data->fan[nr],
859 data->fan_div[nr])); 855 data->fan_div[nr]));
860} 856}
861static ssize_t show_fan_min(struct device *dev, char *buf, int nr) 857static ssize_t show_fan_min(struct device *dev, struct device_attribute *attr,
858 char *buf)
862{ 859{
860 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
861 int nr = sensor_attr->index;
863 struct adm1026_data *data = adm1026_update_device(dev); 862 struct adm1026_data *data = adm1026_update_device(dev);
864 return sprintf(buf,"%d\n", FAN_FROM_REG(data->fan_min[nr], 863 return sprintf(buf,"%d\n", FAN_FROM_REG(data->fan_min[nr],
865 data->fan_div[nr])); 864 data->fan_div[nr]));
866} 865}
867static ssize_t set_fan_min(struct device *dev, const char *buf, 866static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr,
868 size_t count, int nr) 867 const char *buf, size_t count)
869{ 868{
869 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
870 int nr = sensor_attr->index;
870 struct i2c_client *client = to_i2c_client(dev); 871 struct i2c_client *client = to_i2c_client(dev);
871 struct adm1026_data *data = i2c_get_clientdata(client); 872 struct adm1026_data *data = i2c_get_clientdata(client);
872 int val = simple_strtol(buf, NULL, 10); 873 int val = simple_strtol(buf, NULL, 10);
@@ -879,23 +880,11 @@ static ssize_t set_fan_min(struct device *dev, const char *buf,
879 return count; 880 return count;
880} 881}
881 882
882#define fan_offset(offset) \ 883#define fan_offset(offset) \
883static ssize_t show_fan_##offset (struct device *dev, char *buf) \ 884static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan, NULL, \
884{ \ 885 offset - 1); \
885 return show_fan(dev, buf, offset - 1); \ 886static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
886} \ 887 show_fan_min, set_fan_min, offset - 1);
887static ssize_t show_fan_##offset##_min (struct device *dev, char *buf) \
888{ \
889 return show_fan_min(dev, buf, offset - 1); \
890} \
891static ssize_t set_fan_##offset##_min (struct device *dev, \
892 const char *buf, size_t count) \
893{ \
894 return set_fan_min(dev, buf, count, offset - 1); \
895} \
896static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan_##offset, NULL); \
897static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
898 show_fan_##offset##_min, set_fan_##offset##_min);
899 888
900fan_offset(1); 889fan_offset(1);
901fan_offset(2); 890fan_offset(2);
@@ -926,14 +915,19 @@ static void fixup_fan_min(struct device *dev, int fan, int old_div)
926} 915}
927 916
928/* Now add fan_div read/write functions */ 917/* Now add fan_div read/write functions */
929static ssize_t show_fan_div(struct device *dev, char *buf, int nr) 918static ssize_t show_fan_div(struct device *dev, struct device_attribute *attr,
919 char *buf)
930{ 920{
921 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
922 int nr = sensor_attr->index;
931 struct adm1026_data *data = adm1026_update_device(dev); 923 struct adm1026_data *data = adm1026_update_device(dev);
932 return sprintf(buf,"%d\n", data->fan_div[nr]); 924 return sprintf(buf,"%d\n", data->fan_div[nr]);
933} 925}
934static ssize_t set_fan_div(struct device *dev, const char *buf, 926static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
935 size_t count, int nr) 927 const char *buf, size_t count)
936{ 928{
929 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
930 int nr = sensor_attr->index;
937 struct i2c_client *client = to_i2c_client(dev); 931 struct i2c_client *client = to_i2c_client(dev);
938 struct adm1026_data *data = i2c_get_clientdata(client); 932 struct adm1026_data *data = i2c_get_clientdata(client);
939 int val,orig_div,new_div,shift; 933 int val,orig_div,new_div,shift;
@@ -967,17 +961,8 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
967} 961}
968 962
969#define fan_offset_div(offset) \ 963#define fan_offset_div(offset) \
970static ssize_t show_fan_##offset##_div (struct device *dev, char *buf) \ 964static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \
971{ \ 965 show_fan_div, set_fan_div, offset - 1);
972 return show_fan_div(dev, buf, offset - 1); \
973} \
974static ssize_t set_fan_##offset##_div (struct device *dev, \
975 const char *buf, size_t count) \
976{ \
977 return set_fan_div(dev, buf, count, offset - 1); \
978} \
979static DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \
980 show_fan_##offset##_div, set_fan_##offset##_div);
981 966
982fan_offset_div(1); 967fan_offset_div(1);
983fan_offset_div(2); 968fan_offset_div(2);
@@ -989,19 +974,27 @@ fan_offset_div(7);
989fan_offset_div(8); 974fan_offset_div(8);
990 975
991/* Temps */ 976/* Temps */
992static ssize_t show_temp(struct device *dev, char *buf, int nr) 977static ssize_t show_temp(struct device *dev, struct device_attribute *attr,
978 char *buf)
993{ 979{
980 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
981 int nr = sensor_attr->index;
994 struct adm1026_data *data = adm1026_update_device(dev); 982 struct adm1026_data *data = adm1026_update_device(dev);
995 return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp[nr])); 983 return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp[nr]));
996} 984}
997static ssize_t show_temp_min(struct device *dev, char *buf, int nr) 985static ssize_t show_temp_min(struct device *dev, struct device_attribute *attr,
986 char *buf)
998{ 987{
988 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
989 int nr = sensor_attr->index;
999 struct adm1026_data *data = adm1026_update_device(dev); 990 struct adm1026_data *data = adm1026_update_device(dev);
1000 return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_min[nr])); 991 return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_min[nr]));
1001} 992}
1002static ssize_t set_temp_min(struct device *dev, const char *buf, 993static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr,
1003 size_t count, int nr) 994 const char *buf, size_t count)
1004{ 995{
996 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
997 int nr = sensor_attr->index;
1005 struct i2c_client *client = to_i2c_client(dev); 998 struct i2c_client *client = to_i2c_client(dev);
1006 struct adm1026_data *data = i2c_get_clientdata(client); 999 struct adm1026_data *data = i2c_get_clientdata(client);
1007 int val = simple_strtol(buf, NULL, 10); 1000 int val = simple_strtol(buf, NULL, 10);
@@ -1013,14 +1006,19 @@ static ssize_t set_temp_min(struct device *dev, const char *buf,
1013 up(&data->update_lock); 1006 up(&data->update_lock);
1014 return count; 1007 return count;
1015} 1008}
1016static ssize_t show_temp_max(struct device *dev, char *buf, int nr) 1009static ssize_t show_temp_max(struct device *dev, struct device_attribute *attr,
1010 char *buf)
1017{ 1011{
1012 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
1013 int nr = sensor_attr->index;
1018 struct adm1026_data *data = adm1026_update_device(dev); 1014 struct adm1026_data *data = adm1026_update_device(dev);
1019 return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_max[nr])); 1015 return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_max[nr]));
1020} 1016}
1021static ssize_t set_temp_max(struct device *dev, const char *buf, 1017static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr,
1022 size_t count, int nr) 1018 const char *buf, size_t count)
1023{ 1019{
1020 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
1021 int nr = sensor_attr->index;
1024 struct i2c_client *client = to_i2c_client(dev); 1022 struct i2c_client *client = to_i2c_client(dev);
1025 struct adm1026_data *data = i2c_get_clientdata(client); 1023 struct adm1026_data *data = i2c_get_clientdata(client);
1026 int val = simple_strtol(buf, NULL, 10); 1024 int val = simple_strtol(buf, NULL, 10);
@@ -1032,48 +1030,34 @@ static ssize_t set_temp_max(struct device *dev, const char *buf,
1032 up(&data->update_lock); 1030 up(&data->update_lock);
1033 return count; 1031 return count;
1034} 1032}
1035#define temp_reg(offset) \ 1033
1036static ssize_t show_temp_##offset (struct device *dev, char *buf) \ 1034#define temp_reg(offset) \
1037{ \ 1035static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp, \
1038 return show_temp(dev, buf, offset - 1); \ 1036 NULL, offset - 1); \
1039} \ 1037static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR, \
1040static ssize_t show_temp_##offset##_min (struct device *dev, char *buf) \ 1038 show_temp_min, set_temp_min, offset - 1); \
1041{ \ 1039static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \
1042 return show_temp_min(dev, buf, offset - 1); \ 1040 show_temp_max, set_temp_max, offset - 1);
1043} \
1044static ssize_t show_temp_##offset##_max (struct device *dev, char *buf) \
1045{ \
1046 return show_temp_max(dev, buf, offset - 1); \
1047} \
1048static ssize_t set_temp_##offset##_min (struct device *dev, \
1049 const char *buf, size_t count) \
1050{ \
1051 return set_temp_min(dev, buf, count, offset - 1); \
1052} \
1053static ssize_t set_temp_##offset##_max (struct device *dev, \
1054 const char *buf, size_t count) \
1055{ \
1056 return set_temp_max(dev, buf, count, offset - 1); \
1057} \
1058static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp_##offset, NULL); \
1059static DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR, \
1060 show_temp_##offset##_min, set_temp_##offset##_min); \
1061static DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \
1062 show_temp_##offset##_max, set_temp_##offset##_max);
1063 1041
1064 1042
1065temp_reg(1); 1043temp_reg(1);
1066temp_reg(2); 1044temp_reg(2);
1067temp_reg(3); 1045temp_reg(3);
1068 1046
1069static ssize_t show_temp_offset(struct device *dev, char *buf, int nr) 1047static ssize_t show_temp_offset(struct device *dev,
1048 struct device_attribute *attr, char *buf)
1070{ 1049{
1050 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
1051 int nr = sensor_attr->index;
1071 struct adm1026_data *data = adm1026_update_device(dev); 1052 struct adm1026_data *data = adm1026_update_device(dev);
1072 return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_offset[nr])); 1053 return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_offset[nr]));
1073} 1054}
1074static ssize_t set_temp_offset(struct device *dev, const char *buf, 1055static ssize_t set_temp_offset(struct device *dev,
1075 size_t count, int nr) 1056 struct device_attribute *attr, const char *buf,
1057 size_t count)
1076{ 1058{
1059 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
1060 int nr = sensor_attr->index;
1077 struct i2c_client *client = to_i2c_client(dev); 1061 struct i2c_client *client = to_i2c_client(dev);
1078 struct adm1026_data *data = i2c_get_clientdata(client); 1062 struct adm1026_data *data = i2c_get_clientdata(client);
1079 int val = simple_strtol(buf, NULL, 10); 1063 int val = simple_strtol(buf, NULL, 10);
@@ -1086,46 +1070,45 @@ static ssize_t set_temp_offset(struct device *dev, const char *buf,
1086 return count; 1070 return count;
1087} 1071}
1088 1072
1089#define temp_offset_reg(offset) \ 1073#define temp_offset_reg(offset) \
1090static ssize_t show_temp_##offset##_offset (struct device *dev, char *buf) \ 1074static SENSOR_DEVICE_ATTR(temp##offset##_offset, S_IRUGO | S_IWUSR, \
1091{ \ 1075 show_temp_offset, set_temp_offset, offset - 1);
1092 return show_temp_offset(dev, buf, offset - 1); \
1093} \
1094static ssize_t set_temp_##offset##_offset (struct device *dev, \
1095 const char *buf, size_t count) \
1096{ \
1097 return set_temp_offset(dev, buf, count, offset - 1); \
1098} \
1099static DEVICE_ATTR(temp##offset##_offset, S_IRUGO | S_IWUSR, \
1100 show_temp_##offset##_offset, set_temp_##offset##_offset);
1101 1076
1102temp_offset_reg(1); 1077temp_offset_reg(1);
1103temp_offset_reg(2); 1078temp_offset_reg(2);
1104temp_offset_reg(3); 1079temp_offset_reg(3);
1105 1080
1106static ssize_t show_temp_auto_point1_temp_hyst(struct device *dev, char *buf, 1081static ssize_t show_temp_auto_point1_temp_hyst(struct device *dev,
1107 int nr) 1082 struct device_attribute *attr, char *buf)
1108{ 1083{
1084 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
1085 int nr = sensor_attr->index;
1109 struct adm1026_data *data = adm1026_update_device(dev); 1086 struct adm1026_data *data = adm1026_update_device(dev);
1110 return sprintf(buf,"%d\n", TEMP_FROM_REG( 1087 return sprintf(buf,"%d\n", TEMP_FROM_REG(
1111 ADM1026_FAN_ACTIVATION_TEMP_HYST + data->temp_tmin[nr])); 1088 ADM1026_FAN_ACTIVATION_TEMP_HYST + data->temp_tmin[nr]));
1112} 1089}
1113static ssize_t show_temp_auto_point2_temp(struct device *dev, char *buf, 1090static ssize_t show_temp_auto_point2_temp(struct device *dev,
1114 int nr) 1091 struct device_attribute *attr, char *buf)
1115{ 1092{
1093 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
1094 int nr = sensor_attr->index;
1116 struct adm1026_data *data = adm1026_update_device(dev); 1095 struct adm1026_data *data = adm1026_update_device(dev);
1117 return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_tmin[nr] + 1096 return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_tmin[nr] +
1118 ADM1026_FAN_CONTROL_TEMP_RANGE)); 1097 ADM1026_FAN_CONTROL_TEMP_RANGE));
1119} 1098}
1120static ssize_t show_temp_auto_point1_temp(struct device *dev, char *buf, 1099static ssize_t show_temp_auto_point1_temp(struct device *dev,
1121 int nr) 1100 struct device_attribute *attr, char *buf)
1122{ 1101{
1102 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
1103 int nr = sensor_attr->index;
1123 struct adm1026_data *data = adm1026_update_device(dev); 1104 struct adm1026_data *data = adm1026_update_device(dev);
1124 return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_tmin[nr])); 1105 return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_tmin[nr]));
1125} 1106}
1126static ssize_t set_temp_auto_point1_temp(struct device *dev, const char *buf, 1107static ssize_t set_temp_auto_point1_temp(struct device *dev,
1127 size_t count, int nr) 1108 struct device_attribute *attr, const char *buf, size_t count)
1128{ 1109{
1110 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
1111 int nr = sensor_attr->index;
1129 struct i2c_client *client = to_i2c_client(dev); 1112 struct i2c_client *client = to_i2c_client(dev);
1130 struct adm1026_data *data = i2c_get_clientdata(client); 1113 struct adm1026_data *data = i2c_get_clientdata(client);
1131 int val = simple_strtol(buf, NULL, 10); 1114 int val = simple_strtol(buf, NULL, 10);
@@ -1138,46 +1121,27 @@ static ssize_t set_temp_auto_point1_temp(struct device *dev, const char *buf,
1138 return count; 1121 return count;
1139} 1122}
1140 1123
1141#define temp_auto_point(offset) \ 1124#define temp_auto_point(offset) \
1142static ssize_t show_temp##offset##_auto_point1_temp (struct device *dev, \ 1125static SENSOR_DEVICE_ATTR(temp##offset##_auto_point1_temp, S_IRUGO | S_IWUSR, \
1143 char *buf) \ 1126 show_temp_auto_point1_temp, set_temp_auto_point1_temp, \
1144{ \ 1127 offset - 1); \
1145 return show_temp_auto_point1_temp(dev, buf, offset - 1); \ 1128static SENSOR_DEVICE_ATTR(temp##offset##_auto_point1_temp_hyst, S_IRUGO, \
1146} \ 1129 show_temp_auto_point1_temp_hyst, NULL, offset - 1); \
1147static ssize_t set_temp##offset##_auto_point1_temp (struct device *dev, \ 1130static SENSOR_DEVICE_ATTR(temp##offset##_auto_point2_temp, S_IRUGO, \
1148 const char *buf, size_t count) \ 1131 show_temp_auto_point2_temp, NULL, offset - 1);
1149{ \
1150 return set_temp_auto_point1_temp(dev, buf, count, offset - 1); \
1151} \
1152static ssize_t show_temp##offset##_auto_point1_temp_hyst (struct device \
1153 *dev, char *buf) \
1154{ \
1155 return show_temp_auto_point1_temp_hyst(dev, buf, offset - 1); \
1156} \
1157static ssize_t show_temp##offset##_auto_point2_temp (struct device *dev, \
1158 char *buf) \
1159{ \
1160 return show_temp_auto_point2_temp(dev, buf, offset - 1); \
1161} \
1162static DEVICE_ATTR(temp##offset##_auto_point1_temp, S_IRUGO | S_IWUSR, \
1163 show_temp##offset##_auto_point1_temp, \
1164 set_temp##offset##_auto_point1_temp); \
1165static DEVICE_ATTR(temp##offset##_auto_point1_temp_hyst, S_IRUGO, \
1166 show_temp##offset##_auto_point1_temp_hyst, NULL); \
1167static DEVICE_ATTR(temp##offset##_auto_point2_temp, S_IRUGO, \
1168 show_temp##offset##_auto_point2_temp, NULL);
1169 1132
1170temp_auto_point(1); 1133temp_auto_point(1);
1171temp_auto_point(2); 1134temp_auto_point(2);
1172temp_auto_point(3); 1135temp_auto_point(3);
1173 1136
1174static ssize_t show_temp_crit_enable(struct device *dev, char *buf) 1137static ssize_t show_temp_crit_enable(struct device *dev,
1138 struct device_attribute *attr, char *buf)
1175{ 1139{
1176 struct adm1026_data *data = adm1026_update_device(dev); 1140 struct adm1026_data *data = adm1026_update_device(dev);
1177 return sprintf(buf,"%d\n", (data->config1 & CFG1_THERM_HOT) >> 4); 1141 return sprintf(buf,"%d\n", (data->config1 & CFG1_THERM_HOT) >> 4);
1178} 1142}
1179static ssize_t set_temp_crit_enable(struct device *dev, const char *buf, 1143static ssize_t set_temp_crit_enable(struct device *dev,
1180 size_t count) 1144 struct device_attribute *attr, const char *buf, size_t count)
1181{ 1145{
1182 struct i2c_client *client = to_i2c_client(dev); 1146 struct i2c_client *client = to_i2c_client(dev);
1183 struct adm1026_data *data = i2c_get_clientdata(client); 1147 struct adm1026_data *data = i2c_get_clientdata(client);
@@ -1193,24 +1157,27 @@ static ssize_t set_temp_crit_enable(struct device *dev, const char *buf,
1193 return count; 1157 return count;
1194} 1158}
1195 1159
1196static DEVICE_ATTR(temp1_crit_enable, S_IRUGO | S_IWUSR, 1160#define temp_crit_enable(offset) \
1197 show_temp_crit_enable, set_temp_crit_enable); 1161static DEVICE_ATTR(temp##offset##_crit_enable, S_IRUGO | S_IWUSR, \
1198
1199static DEVICE_ATTR(temp2_crit_enable, S_IRUGO | S_IWUSR,
1200 show_temp_crit_enable, set_temp_crit_enable);
1201
1202static DEVICE_ATTR(temp3_crit_enable, S_IRUGO | S_IWUSR,
1203 show_temp_crit_enable, set_temp_crit_enable); 1162 show_temp_crit_enable, set_temp_crit_enable);
1204 1163
1164temp_crit_enable(1);
1165temp_crit_enable(2);
1166temp_crit_enable(3);
1205 1167
1206static ssize_t show_temp_crit(struct device *dev, char *buf, int nr) 1168static ssize_t show_temp_crit(struct device *dev,
1169 struct device_attribute *attr, char *buf)
1207{ 1170{
1171 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
1172 int nr = sensor_attr->index;
1208 struct adm1026_data *data = adm1026_update_device(dev); 1173 struct adm1026_data *data = adm1026_update_device(dev);
1209 return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_crit[nr])); 1174 return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_crit[nr]));
1210} 1175}
1211static ssize_t set_temp_crit(struct device *dev, const char *buf, 1176static ssize_t set_temp_crit(struct device *dev, struct device_attribute *attr,
1212 size_t count, int nr) 1177 const char *buf, size_t count)
1213{ 1178{
1179 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
1180 int nr = sensor_attr->index;
1214 struct i2c_client *client = to_i2c_client(dev); 1181 struct i2c_client *client = to_i2c_client(dev);
1215 struct adm1026_data *data = i2c_get_clientdata(client); 1182 struct adm1026_data *data = i2c_get_clientdata(client);
1216 int val = simple_strtol(buf, NULL, 10); 1183 int val = simple_strtol(buf, NULL, 10);
@@ -1223,29 +1190,20 @@ static ssize_t set_temp_crit(struct device *dev, const char *buf,
1223 return count; 1190 return count;
1224} 1191}
1225 1192
1226#define temp_crit_reg(offset) \ 1193#define temp_crit_reg(offset) \
1227static ssize_t show_temp_##offset##_crit (struct device *dev, char *buf) \ 1194static SENSOR_DEVICE_ATTR(temp##offset##_crit, S_IRUGO | S_IWUSR, \
1228{ \ 1195 show_temp_crit, set_temp_crit, offset - 1);
1229 return show_temp_crit(dev, buf, offset - 1); \
1230} \
1231static ssize_t set_temp_##offset##_crit (struct device *dev, \
1232 const char *buf, size_t count) \
1233{ \
1234 return set_temp_crit(dev, buf, count, offset - 1); \
1235} \
1236static DEVICE_ATTR(temp##offset##_crit, S_IRUGO | S_IWUSR, \
1237 show_temp_##offset##_crit, set_temp_##offset##_crit);
1238 1196
1239temp_crit_reg(1); 1197temp_crit_reg(1);
1240temp_crit_reg(2); 1198temp_crit_reg(2);
1241temp_crit_reg(3); 1199temp_crit_reg(3);
1242 1200
1243static ssize_t show_analog_out_reg(struct device *dev, char *buf) 1201static ssize_t show_analog_out_reg(struct device *dev, struct device_attribute *attr, char *buf)
1244{ 1202{
1245 struct adm1026_data *data = adm1026_update_device(dev); 1203 struct adm1026_data *data = adm1026_update_device(dev);
1246 return sprintf(buf,"%d\n", DAC_FROM_REG(data->analog_out)); 1204 return sprintf(buf,"%d\n", DAC_FROM_REG(data->analog_out));
1247} 1205}
1248static ssize_t set_analog_out_reg(struct device *dev, const char *buf, 1206static ssize_t set_analog_out_reg(struct device *dev, struct device_attribute *attr, const char *buf,
1249 size_t count) 1207 size_t count)
1250{ 1208{
1251 struct i2c_client *client = to_i2c_client(dev); 1209 struct i2c_client *client = to_i2c_client(dev);
@@ -1262,7 +1220,7 @@ static ssize_t set_analog_out_reg(struct device *dev, const char *buf,
1262static DEVICE_ATTR(analog_out, S_IRUGO | S_IWUSR, show_analog_out_reg, 1220static DEVICE_ATTR(analog_out, S_IRUGO | S_IWUSR, show_analog_out_reg,
1263 set_analog_out_reg); 1221 set_analog_out_reg);
1264 1222
1265static ssize_t show_vid_reg(struct device *dev, char *buf) 1223static ssize_t show_vid_reg(struct device *dev, struct device_attribute *attr, char *buf)
1266{ 1224{
1267 struct adm1026_data *data = adm1026_update_device(dev); 1225 struct adm1026_data *data = adm1026_update_device(dev);
1268 return sprintf(buf,"%d\n", vid_from_reg(data->vid & 0x3f, data->vrm)); 1226 return sprintf(buf,"%d\n", vid_from_reg(data->vid & 0x3f, data->vrm));
@@ -1270,12 +1228,12 @@ static ssize_t show_vid_reg(struct device *dev, char *buf)
1270 1228
1271static DEVICE_ATTR(vid, S_IRUGO, show_vid_reg, NULL); 1229static DEVICE_ATTR(vid, S_IRUGO, show_vid_reg, NULL);
1272 1230
1273static ssize_t show_vrm_reg(struct device *dev, char *buf) 1231static ssize_t show_vrm_reg(struct device *dev, struct device_attribute *attr, char *buf)
1274{ 1232{
1275 struct adm1026_data *data = adm1026_update_device(dev); 1233 struct adm1026_data *data = adm1026_update_device(dev);
1276 return sprintf(buf,"%d\n", data->vrm); 1234 return sprintf(buf,"%d\n", data->vrm);
1277} 1235}
1278static ssize_t store_vrm_reg(struct device *dev, const char *buf, 1236static ssize_t store_vrm_reg(struct device *dev, struct device_attribute *attr, const char *buf,
1279 size_t count) 1237 size_t count)
1280{ 1238{
1281 struct i2c_client *client = to_i2c_client(dev); 1239 struct i2c_client *client = to_i2c_client(dev);
@@ -1287,7 +1245,7 @@ static ssize_t store_vrm_reg(struct device *dev, const char *buf,
1287 1245
1288static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg); 1246static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg);
1289 1247
1290static ssize_t show_alarms_reg(struct device *dev, char *buf) 1248static ssize_t show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf)
1291{ 1249{
1292 struct adm1026_data *data = adm1026_update_device(dev); 1250 struct adm1026_data *data = adm1026_update_device(dev);
1293 return sprintf(buf, "%ld\n", (long) (data->alarms)); 1251 return sprintf(buf, "%ld\n", (long) (data->alarms));
@@ -1295,12 +1253,12 @@ static ssize_t show_alarms_reg(struct device *dev, char *buf)
1295 1253
1296static DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL); 1254static DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL);
1297 1255
1298static ssize_t show_alarm_mask(struct device *dev, char *buf) 1256static ssize_t show_alarm_mask(struct device *dev, struct device_attribute *attr, char *buf)
1299{ 1257{
1300 struct adm1026_data *data = adm1026_update_device(dev); 1258 struct adm1026_data *data = adm1026_update_device(dev);
1301 return sprintf(buf,"%ld\n", data->alarm_mask); 1259 return sprintf(buf,"%ld\n", data->alarm_mask);
1302} 1260}
1303static ssize_t set_alarm_mask(struct device *dev, const char *buf, 1261static ssize_t set_alarm_mask(struct device *dev, struct device_attribute *attr, const char *buf,
1304 size_t count) 1262 size_t count)
1305{ 1263{
1306 struct i2c_client *client = to_i2c_client(dev); 1264 struct i2c_client *client = to_i2c_client(dev);
@@ -1331,12 +1289,12 @@ static DEVICE_ATTR(alarm_mask, S_IRUGO | S_IWUSR, show_alarm_mask,
1331 set_alarm_mask); 1289 set_alarm_mask);
1332 1290
1333 1291
1334static ssize_t show_gpio(struct device *dev, char *buf) 1292static ssize_t show_gpio(struct device *dev, struct device_attribute *attr, char *buf)
1335{ 1293{
1336 struct adm1026_data *data = adm1026_update_device(dev); 1294 struct adm1026_data *data = adm1026_update_device(dev);
1337 return sprintf(buf,"%ld\n", data->gpio); 1295 return sprintf(buf,"%ld\n", data->gpio);
1338} 1296}
1339static ssize_t set_gpio(struct device *dev, const char *buf, 1297static ssize_t set_gpio(struct device *dev, struct device_attribute *attr, const char *buf,
1340 size_t count) 1298 size_t count)
1341{ 1299{
1342 struct i2c_client *client = to_i2c_client(dev); 1300 struct i2c_client *client = to_i2c_client(dev);
@@ -1359,12 +1317,12 @@ static ssize_t set_gpio(struct device *dev, const char *buf,
1359static DEVICE_ATTR(gpio, S_IRUGO | S_IWUSR, show_gpio, set_gpio); 1317static DEVICE_ATTR(gpio, S_IRUGO | S_IWUSR, show_gpio, set_gpio);
1360 1318
1361 1319
1362static ssize_t show_gpio_mask(struct device *dev, char *buf) 1320static ssize_t show_gpio_mask(struct device *dev, struct device_attribute *attr, char *buf)
1363{ 1321{
1364 struct adm1026_data *data = adm1026_update_device(dev); 1322 struct adm1026_data *data = adm1026_update_device(dev);
1365 return sprintf(buf,"%ld\n", data->gpio_mask); 1323 return sprintf(buf,"%ld\n", data->gpio_mask);
1366} 1324}
1367static ssize_t set_gpio_mask(struct device *dev, const char *buf, 1325static ssize_t set_gpio_mask(struct device *dev, struct device_attribute *attr, const char *buf,
1368 size_t count) 1326 size_t count)
1369{ 1327{
1370 struct i2c_client *client = to_i2c_client(dev); 1328 struct i2c_client *client = to_i2c_client(dev);
@@ -1386,12 +1344,12 @@ static ssize_t set_gpio_mask(struct device *dev, const char *buf,
1386 1344
1387static DEVICE_ATTR(gpio_mask, S_IRUGO | S_IWUSR, show_gpio_mask, set_gpio_mask); 1345static DEVICE_ATTR(gpio_mask, S_IRUGO | S_IWUSR, show_gpio_mask, set_gpio_mask);
1388 1346
1389static ssize_t show_pwm_reg(struct device *dev, char *buf) 1347static ssize_t show_pwm_reg(struct device *dev, struct device_attribute *attr, char *buf)
1390{ 1348{
1391 struct adm1026_data *data = adm1026_update_device(dev); 1349 struct adm1026_data *data = adm1026_update_device(dev);
1392 return sprintf(buf,"%d\n", PWM_FROM_REG(data->pwm1.pwm)); 1350 return sprintf(buf,"%d\n", PWM_FROM_REG(data->pwm1.pwm));
1393} 1351}
1394static ssize_t set_pwm_reg(struct device *dev, const char *buf, 1352static ssize_t set_pwm_reg(struct device *dev, struct device_attribute *attr, const char *buf,
1395 size_t count) 1353 size_t count)
1396{ 1354{
1397 struct i2c_client *client = to_i2c_client(dev); 1355 struct i2c_client *client = to_i2c_client(dev);
@@ -1407,12 +1365,12 @@ static ssize_t set_pwm_reg(struct device *dev, const char *buf,
1407 } 1365 }
1408 return count; 1366 return count;
1409} 1367}
1410static ssize_t show_auto_pwm_min(struct device *dev, char *buf) 1368static ssize_t show_auto_pwm_min(struct device *dev, struct device_attribute *attr, char *buf)
1411{ 1369{
1412 struct adm1026_data *data = adm1026_update_device(dev); 1370 struct adm1026_data *data = adm1026_update_device(dev);
1413 return sprintf(buf,"%d\n", data->pwm1.auto_pwm_min); 1371 return sprintf(buf,"%d\n", data->pwm1.auto_pwm_min);
1414} 1372}
1415static ssize_t set_auto_pwm_min(struct device *dev, const char *buf, 1373static ssize_t set_auto_pwm_min(struct device *dev, struct device_attribute *attr, const char *buf,
1416 size_t count) 1374 size_t count)
1417{ 1375{
1418 struct i2c_client *client = to_i2c_client(dev); 1376 struct i2c_client *client = to_i2c_client(dev);
@@ -1429,16 +1387,16 @@ static ssize_t set_auto_pwm_min(struct device *dev, const char *buf,
1429 up(&data->update_lock); 1387 up(&data->update_lock);
1430 return count; 1388 return count;
1431} 1389}
1432static ssize_t show_auto_pwm_max(struct device *dev, char *buf) 1390static ssize_t show_auto_pwm_max(struct device *dev, struct device_attribute *attr, char *buf)
1433{ 1391{
1434 return sprintf(buf,"%d\n", ADM1026_PWM_MAX); 1392 return sprintf(buf,"%d\n", ADM1026_PWM_MAX);
1435} 1393}
1436static ssize_t show_pwm_enable(struct device *dev, char *buf) 1394static ssize_t show_pwm_enable(struct device *dev, struct device_attribute *attr, char *buf)
1437{ 1395{
1438 struct adm1026_data *data = adm1026_update_device(dev); 1396 struct adm1026_data *data = adm1026_update_device(dev);
1439 return sprintf(buf,"%d\n", data->pwm1.enable); 1397 return sprintf(buf,"%d\n", data->pwm1.enable);
1440} 1398}
1441static ssize_t set_pwm_enable(struct device *dev, const char *buf, 1399static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *attr, const char *buf,
1442 size_t count) 1400 size_t count)
1443{ 1401{
1444 struct i2c_client *client = to_i2c_client(dev); 1402 struct i2c_client *client = to_i2c_client(dev);
@@ -1597,114 +1555,114 @@ int adm1026_detect(struct i2c_adapter *adapter, int address,
1597 adm1026_init_client(new_client); 1555 adm1026_init_client(new_client);
1598 1556
1599 /* Register sysfs hooks */ 1557 /* Register sysfs hooks */
1600 device_create_file(&new_client->dev, &dev_attr_in0_input); 1558 device_create_file(&new_client->dev, &sensor_dev_attr_in0_input.dev_attr);
1601 device_create_file(&new_client->dev, &dev_attr_in0_max); 1559 device_create_file(&new_client->dev, &sensor_dev_attr_in0_max.dev_attr);
1602 device_create_file(&new_client->dev, &dev_attr_in0_min); 1560 device_create_file(&new_client->dev, &sensor_dev_attr_in0_min.dev_attr);
1603 device_create_file(&new_client->dev, &dev_attr_in1_input); 1561 device_create_file(&new_client->dev, &sensor_dev_attr_in1_input.dev_attr);
1604 device_create_file(&new_client->dev, &dev_attr_in1_max); 1562 device_create_file(&new_client->dev, &sensor_dev_attr_in1_max.dev_attr);
1605 device_create_file(&new_client->dev, &dev_attr_in1_min); 1563 device_create_file(&new_client->dev, &sensor_dev_attr_in1_min.dev_attr);
1606 device_create_file(&new_client->dev, &dev_attr_in2_input); 1564 device_create_file(&new_client->dev, &sensor_dev_attr_in2_input.dev_attr);
1607 device_create_file(&new_client->dev, &dev_attr_in2_max); 1565 device_create_file(&new_client->dev, &sensor_dev_attr_in2_max.dev_attr);
1608 device_create_file(&new_client->dev, &dev_attr_in2_min); 1566 device_create_file(&new_client->dev, &sensor_dev_attr_in2_min.dev_attr);
1609 device_create_file(&new_client->dev, &dev_attr_in3_input); 1567 device_create_file(&new_client->dev, &sensor_dev_attr_in3_input.dev_attr);
1610 device_create_file(&new_client->dev, &dev_attr_in3_max); 1568 device_create_file(&new_client->dev, &sensor_dev_attr_in3_max.dev_attr);
1611 device_create_file(&new_client->dev, &dev_attr_in3_min); 1569 device_create_file(&new_client->dev, &sensor_dev_attr_in3_min.dev_attr);
1612 device_create_file(&new_client->dev, &dev_attr_in4_input); 1570 device_create_file(&new_client->dev, &sensor_dev_attr_in4_input.dev_attr);
1613 device_create_file(&new_client->dev, &dev_attr_in4_max); 1571 device_create_file(&new_client->dev, &sensor_dev_attr_in4_max.dev_attr);
1614 device_create_file(&new_client->dev, &dev_attr_in4_min); 1572 device_create_file(&new_client->dev, &sensor_dev_attr_in4_min.dev_attr);
1615 device_create_file(&new_client->dev, &dev_attr_in5_input); 1573 device_create_file(&new_client->dev, &sensor_dev_attr_in5_input.dev_attr);
1616 device_create_file(&new_client->dev, &dev_attr_in5_max); 1574 device_create_file(&new_client->dev, &sensor_dev_attr_in5_max.dev_attr);
1617 device_create_file(&new_client->dev, &dev_attr_in5_min); 1575 device_create_file(&new_client->dev, &sensor_dev_attr_in5_min.dev_attr);
1618 device_create_file(&new_client->dev, &dev_attr_in6_input); 1576 device_create_file(&new_client->dev, &sensor_dev_attr_in6_input.dev_attr);
1619 device_create_file(&new_client->dev, &dev_attr_in6_max); 1577 device_create_file(&new_client->dev, &sensor_dev_attr_in6_max.dev_attr);
1620 device_create_file(&new_client->dev, &dev_attr_in6_min); 1578 device_create_file(&new_client->dev, &sensor_dev_attr_in6_min.dev_attr);
1621 device_create_file(&new_client->dev, &dev_attr_in7_input); 1579 device_create_file(&new_client->dev, &sensor_dev_attr_in7_input.dev_attr);
1622 device_create_file(&new_client->dev, &dev_attr_in7_max); 1580 device_create_file(&new_client->dev, &sensor_dev_attr_in7_max.dev_attr);
1623 device_create_file(&new_client->dev, &dev_attr_in7_min); 1581 device_create_file(&new_client->dev, &sensor_dev_attr_in7_min.dev_attr);
1624 device_create_file(&new_client->dev, &dev_attr_in8_input); 1582 device_create_file(&new_client->dev, &sensor_dev_attr_in8_input.dev_attr);
1625 device_create_file(&new_client->dev, &dev_attr_in8_max); 1583 device_create_file(&new_client->dev, &sensor_dev_attr_in8_max.dev_attr);
1626 device_create_file(&new_client->dev, &dev_attr_in8_min); 1584 device_create_file(&new_client->dev, &sensor_dev_attr_in8_min.dev_attr);
1627 device_create_file(&new_client->dev, &dev_attr_in9_input); 1585 device_create_file(&new_client->dev, &sensor_dev_attr_in9_input.dev_attr);
1628 device_create_file(&new_client->dev, &dev_attr_in9_max); 1586 device_create_file(&new_client->dev, &sensor_dev_attr_in9_max.dev_attr);
1629 device_create_file(&new_client->dev, &dev_attr_in9_min); 1587 device_create_file(&new_client->dev, &sensor_dev_attr_in9_min.dev_attr);
1630 device_create_file(&new_client->dev, &dev_attr_in10_input); 1588 device_create_file(&new_client->dev, &sensor_dev_attr_in10_input.dev_attr);
1631 device_create_file(&new_client->dev, &dev_attr_in10_max); 1589 device_create_file(&new_client->dev, &sensor_dev_attr_in10_max.dev_attr);
1632 device_create_file(&new_client->dev, &dev_attr_in10_min); 1590 device_create_file(&new_client->dev, &sensor_dev_attr_in10_min.dev_attr);
1633 device_create_file(&new_client->dev, &dev_attr_in11_input); 1591 device_create_file(&new_client->dev, &sensor_dev_attr_in11_input.dev_attr);
1634 device_create_file(&new_client->dev, &dev_attr_in11_max); 1592 device_create_file(&new_client->dev, &sensor_dev_attr_in11_max.dev_attr);
1635 device_create_file(&new_client->dev, &dev_attr_in11_min); 1593 device_create_file(&new_client->dev, &sensor_dev_attr_in11_min.dev_attr);
1636 device_create_file(&new_client->dev, &dev_attr_in12_input); 1594 device_create_file(&new_client->dev, &sensor_dev_attr_in12_input.dev_attr);
1637 device_create_file(&new_client->dev, &dev_attr_in12_max); 1595 device_create_file(&new_client->dev, &sensor_dev_attr_in12_max.dev_attr);
1638 device_create_file(&new_client->dev, &dev_attr_in12_min); 1596 device_create_file(&new_client->dev, &sensor_dev_attr_in12_min.dev_attr);
1639 device_create_file(&new_client->dev, &dev_attr_in13_input); 1597 device_create_file(&new_client->dev, &sensor_dev_attr_in13_input.dev_attr);
1640 device_create_file(&new_client->dev, &dev_attr_in13_max); 1598 device_create_file(&new_client->dev, &sensor_dev_attr_in13_max.dev_attr);
1641 device_create_file(&new_client->dev, &dev_attr_in13_min); 1599 device_create_file(&new_client->dev, &sensor_dev_attr_in13_min.dev_attr);
1642 device_create_file(&new_client->dev, &dev_attr_in14_input); 1600 device_create_file(&new_client->dev, &sensor_dev_attr_in14_input.dev_attr);
1643 device_create_file(&new_client->dev, &dev_attr_in14_max); 1601 device_create_file(&new_client->dev, &sensor_dev_attr_in14_max.dev_attr);
1644 device_create_file(&new_client->dev, &dev_attr_in14_min); 1602 device_create_file(&new_client->dev, &sensor_dev_attr_in14_min.dev_attr);
1645 device_create_file(&new_client->dev, &dev_attr_in15_input); 1603 device_create_file(&new_client->dev, &sensor_dev_attr_in15_input.dev_attr);
1646 device_create_file(&new_client->dev, &dev_attr_in15_max); 1604 device_create_file(&new_client->dev, &sensor_dev_attr_in15_max.dev_attr);
1647 device_create_file(&new_client->dev, &dev_attr_in15_min); 1605 device_create_file(&new_client->dev, &sensor_dev_attr_in15_min.dev_attr);
1648 device_create_file(&new_client->dev, &dev_attr_in16_input); 1606 device_create_file(&new_client->dev, &sensor_dev_attr_in16_input.dev_attr);
1649 device_create_file(&new_client->dev, &dev_attr_in16_max); 1607 device_create_file(&new_client->dev, &sensor_dev_attr_in16_max.dev_attr);
1650 device_create_file(&new_client->dev, &dev_attr_in16_min); 1608 device_create_file(&new_client->dev, &sensor_dev_attr_in16_min.dev_attr);
1651 device_create_file(&new_client->dev, &dev_attr_fan1_input); 1609 device_create_file(&new_client->dev, &sensor_dev_attr_fan1_input.dev_attr);
1652 device_create_file(&new_client->dev, &dev_attr_fan1_div); 1610 device_create_file(&new_client->dev, &sensor_dev_attr_fan1_div.dev_attr);
1653 device_create_file(&new_client->dev, &dev_attr_fan1_min); 1611 device_create_file(&new_client->dev, &sensor_dev_attr_fan1_min.dev_attr);
1654 device_create_file(&new_client->dev, &dev_attr_fan2_input); 1612 device_create_file(&new_client->dev, &sensor_dev_attr_fan2_input.dev_attr);
1655 device_create_file(&new_client->dev, &dev_attr_fan2_div); 1613 device_create_file(&new_client->dev, &sensor_dev_attr_fan2_div.dev_attr);
1656 device_create_file(&new_client->dev, &dev_attr_fan2_min); 1614 device_create_file(&new_client->dev, &sensor_dev_attr_fan2_min.dev_attr);
1657 device_create_file(&new_client->dev, &dev_attr_fan3_input); 1615 device_create_file(&new_client->dev, &sensor_dev_attr_fan3_input.dev_attr);
1658 device_create_file(&new_client->dev, &dev_attr_fan3_div); 1616 device_create_file(&new_client->dev, &sensor_dev_attr_fan3_div.dev_attr);
1659 device_create_file(&new_client->dev, &dev_attr_fan3_min); 1617 device_create_file(&new_client->dev, &sensor_dev_attr_fan3_min.dev_attr);
1660 device_create_file(&new_client->dev, &dev_attr_fan4_input); 1618 device_create_file(&new_client->dev, &sensor_dev_attr_fan4_input.dev_attr);
1661 device_create_file(&new_client->dev, &dev_attr_fan4_div); 1619 device_create_file(&new_client->dev, &sensor_dev_attr_fan4_div.dev_attr);
1662 device_create_file(&new_client->dev, &dev_attr_fan4_min); 1620 device_create_file(&new_client->dev, &sensor_dev_attr_fan4_min.dev_attr);
1663 device_create_file(&new_client->dev, &dev_attr_fan5_input); 1621 device_create_file(&new_client->dev, &sensor_dev_attr_fan5_input.dev_attr);
1664 device_create_file(&new_client->dev, &dev_attr_fan5_div); 1622 device_create_file(&new_client->dev, &sensor_dev_attr_fan5_div.dev_attr);
1665 device_create_file(&new_client->dev, &dev_attr_fan5_min); 1623 device_create_file(&new_client->dev, &sensor_dev_attr_fan5_min.dev_attr);
1666 device_create_file(&new_client->dev, &dev_attr_fan6_input); 1624 device_create_file(&new_client->dev, &sensor_dev_attr_fan6_input.dev_attr);
1667 device_create_file(&new_client->dev, &dev_attr_fan6_div); 1625 device_create_file(&new_client->dev, &sensor_dev_attr_fan6_div.dev_attr);
1668 device_create_file(&new_client->dev, &dev_attr_fan6_min); 1626 device_create_file(&new_client->dev, &sensor_dev_attr_fan6_min.dev_attr);
1669 device_create_file(&new_client->dev, &dev_attr_fan7_input); 1627 device_create_file(&new_client->dev, &sensor_dev_attr_fan7_input.dev_attr);
1670 device_create_file(&new_client->dev, &dev_attr_fan7_div); 1628 device_create_file(&new_client->dev, &sensor_dev_attr_fan7_div.dev_attr);
1671 device_create_file(&new_client->dev, &dev_attr_fan7_min); 1629 device_create_file(&new_client->dev, &sensor_dev_attr_fan7_min.dev_attr);
1672 device_create_file(&new_client->dev, &dev_attr_fan8_input); 1630 device_create_file(&new_client->dev, &sensor_dev_attr_fan8_input.dev_attr);
1673 device_create_file(&new_client->dev, &dev_attr_fan8_div); 1631 device_create_file(&new_client->dev, &sensor_dev_attr_fan8_div.dev_attr);
1674 device_create_file(&new_client->dev, &dev_attr_fan8_min); 1632 device_create_file(&new_client->dev, &sensor_dev_attr_fan8_min.dev_attr);
1675 device_create_file(&new_client->dev, &dev_attr_temp1_input); 1633 device_create_file(&new_client->dev, &sensor_dev_attr_temp1_input.dev_attr);
1676 device_create_file(&new_client->dev, &dev_attr_temp1_max); 1634 device_create_file(&new_client->dev, &sensor_dev_attr_temp1_max.dev_attr);
1677 device_create_file(&new_client->dev, &dev_attr_temp1_min); 1635 device_create_file(&new_client->dev, &sensor_dev_attr_temp1_min.dev_attr);
1678 device_create_file(&new_client->dev, &dev_attr_temp2_input); 1636 device_create_file(&new_client->dev, &sensor_dev_attr_temp2_input.dev_attr);
1679 device_create_file(&new_client->dev, &dev_attr_temp2_max); 1637 device_create_file(&new_client->dev, &sensor_dev_attr_temp2_max.dev_attr);
1680 device_create_file(&new_client->dev, &dev_attr_temp2_min); 1638 device_create_file(&new_client->dev, &sensor_dev_attr_temp2_min.dev_attr);
1681 device_create_file(&new_client->dev, &dev_attr_temp3_input); 1639 device_create_file(&new_client->dev, &sensor_dev_attr_temp3_input.dev_attr);
1682 device_create_file(&new_client->dev, &dev_attr_temp3_max); 1640 device_create_file(&new_client->dev, &sensor_dev_attr_temp3_max.dev_attr);
1683 device_create_file(&new_client->dev, &dev_attr_temp3_min); 1641 device_create_file(&new_client->dev, &sensor_dev_attr_temp3_min.dev_attr);
1684 device_create_file(&new_client->dev, &dev_attr_temp1_offset); 1642 device_create_file(&new_client->dev, &sensor_dev_attr_temp1_offset.dev_attr);
1685 device_create_file(&new_client->dev, &dev_attr_temp2_offset); 1643 device_create_file(&new_client->dev, &sensor_dev_attr_temp2_offset.dev_attr);
1686 device_create_file(&new_client->dev, &dev_attr_temp3_offset); 1644 device_create_file(&new_client->dev, &sensor_dev_attr_temp3_offset.dev_attr);
1687 device_create_file(&new_client->dev, 1645 device_create_file(&new_client->dev,
1688 &dev_attr_temp1_auto_point1_temp); 1646 &sensor_dev_attr_temp1_auto_point1_temp.dev_attr);
1689 device_create_file(&new_client->dev, 1647 device_create_file(&new_client->dev,
1690 &dev_attr_temp2_auto_point1_temp); 1648 &sensor_dev_attr_temp2_auto_point1_temp.dev_attr);
1691 device_create_file(&new_client->dev, 1649 device_create_file(&new_client->dev,
1692 &dev_attr_temp3_auto_point1_temp); 1650 &sensor_dev_attr_temp3_auto_point1_temp.dev_attr);
1693 device_create_file(&new_client->dev, 1651 device_create_file(&new_client->dev,
1694 &dev_attr_temp1_auto_point1_temp_hyst); 1652 &sensor_dev_attr_temp1_auto_point1_temp_hyst.dev_attr);
1695 device_create_file(&new_client->dev, 1653 device_create_file(&new_client->dev,
1696 &dev_attr_temp2_auto_point1_temp_hyst); 1654 &sensor_dev_attr_temp2_auto_point1_temp_hyst.dev_attr);
1697 device_create_file(&new_client->dev, 1655 device_create_file(&new_client->dev,
1698 &dev_attr_temp3_auto_point1_temp_hyst); 1656 &sensor_dev_attr_temp3_auto_point1_temp_hyst.dev_attr);
1699 device_create_file(&new_client->dev, 1657 device_create_file(&new_client->dev,
1700 &dev_attr_temp1_auto_point2_temp); 1658 &sensor_dev_attr_temp1_auto_point2_temp.dev_attr);
1701 device_create_file(&new_client->dev, 1659 device_create_file(&new_client->dev,
1702 &dev_attr_temp2_auto_point2_temp); 1660 &sensor_dev_attr_temp2_auto_point2_temp.dev_attr);
1703 device_create_file(&new_client->dev, 1661 device_create_file(&new_client->dev,
1704 &dev_attr_temp3_auto_point2_temp); 1662 &sensor_dev_attr_temp3_auto_point2_temp.dev_attr);
1705 device_create_file(&new_client->dev, &dev_attr_temp1_crit); 1663 device_create_file(&new_client->dev, &sensor_dev_attr_temp1_crit.dev_attr);
1706 device_create_file(&new_client->dev, &dev_attr_temp2_crit); 1664 device_create_file(&new_client->dev, &sensor_dev_attr_temp2_crit.dev_attr);
1707 device_create_file(&new_client->dev, &dev_attr_temp3_crit); 1665 device_create_file(&new_client->dev, &sensor_dev_attr_temp3_crit.dev_attr);
1708 device_create_file(&new_client->dev, &dev_attr_temp1_crit_enable); 1666 device_create_file(&new_client->dev, &dev_attr_temp1_crit_enable);
1709 device_create_file(&new_client->dev, &dev_attr_temp2_crit_enable); 1667 device_create_file(&new_client->dev, &dev_attr_temp2_crit_enable);
1710 device_create_file(&new_client->dev, &dev_attr_temp3_crit_enable); 1668 device_create_file(&new_client->dev, &dev_attr_temp3_crit_enable);
diff --git a/drivers/i2c/chips/adm1031.c b/drivers/i2c/chips/adm1031.c
index d4385a23f79a..2163dba467c4 100644
--- a/drivers/i2c/chips/adm1031.c
+++ b/drivers/i2c/chips/adm1031.c
@@ -292,11 +292,11 @@ set_fan_auto_channel(struct device *dev, const char *buf, size_t count, int nr)
292} 292}
293 293
294#define fan_auto_channel_offset(offset) \ 294#define fan_auto_channel_offset(offset) \
295static ssize_t show_fan_auto_channel_##offset (struct device *dev, char *buf) \ 295static ssize_t show_fan_auto_channel_##offset (struct device *dev, struct device_attribute *attr, char *buf) \
296{ \ 296{ \
297 return show_fan_auto_channel(dev, buf, offset - 1); \ 297 return show_fan_auto_channel(dev, buf, offset - 1); \
298} \ 298} \
299static ssize_t set_fan_auto_channel_##offset (struct device *dev, \ 299static ssize_t set_fan_auto_channel_##offset (struct device *dev, struct device_attribute *attr, \
300 const char *buf, size_t count) \ 300 const char *buf, size_t count) \
301{ \ 301{ \
302 return set_fan_auto_channel(dev, buf, count, offset - 1); \ 302 return set_fan_auto_channel(dev, buf, count, offset - 1); \
@@ -357,24 +357,24 @@ set_auto_temp_max(struct device *dev, const char *buf, size_t count, int nr)
357} 357}
358 358
359#define auto_temp_reg(offset) \ 359#define auto_temp_reg(offset) \
360static ssize_t show_auto_temp_##offset##_off (struct device *dev, char *buf) \ 360static ssize_t show_auto_temp_##offset##_off (struct device *dev, struct device_attribute *attr, char *buf) \
361{ \ 361{ \
362 return show_auto_temp_off(dev, buf, offset - 1); \ 362 return show_auto_temp_off(dev, buf, offset - 1); \
363} \ 363} \
364static ssize_t show_auto_temp_##offset##_min (struct device *dev, char *buf) \ 364static ssize_t show_auto_temp_##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \
365{ \ 365{ \
366 return show_auto_temp_min(dev, buf, offset - 1); \ 366 return show_auto_temp_min(dev, buf, offset - 1); \
367} \ 367} \
368static ssize_t show_auto_temp_##offset##_max (struct device *dev, char *buf) \ 368static ssize_t show_auto_temp_##offset##_max (struct device *dev, struct device_attribute *attr, char *buf) \
369{ \ 369{ \
370 return show_auto_temp_max(dev, buf, offset - 1); \ 370 return show_auto_temp_max(dev, buf, offset - 1); \
371} \ 371} \
372static ssize_t set_auto_temp_##offset##_min (struct device *dev, \ 372static ssize_t set_auto_temp_##offset##_min (struct device *dev, struct device_attribute *attr, \
373 const char *buf, size_t count) \ 373 const char *buf, size_t count) \
374{ \ 374{ \
375 return set_auto_temp_min(dev, buf, count, offset - 1); \ 375 return set_auto_temp_min(dev, buf, count, offset - 1); \
376} \ 376} \
377static ssize_t set_auto_temp_##offset##_max (struct device *dev, \ 377static ssize_t set_auto_temp_##offset##_max (struct device *dev, struct device_attribute *attr, \
378 const char *buf, size_t count) \ 378 const char *buf, size_t count) \
379{ \ 379{ \
380 return set_auto_temp_max(dev, buf, count, offset - 1); \ 380 return set_auto_temp_max(dev, buf, count, offset - 1); \
@@ -421,11 +421,11 @@ set_pwm(struct device *dev, const char *buf, size_t count, int nr)
421} 421}
422 422
423#define pwm_reg(offset) \ 423#define pwm_reg(offset) \
424static ssize_t show_pwm_##offset (struct device *dev, char *buf) \ 424static ssize_t show_pwm_##offset (struct device *dev, struct device_attribute *attr, char *buf) \
425{ \ 425{ \
426 return show_pwm(dev, buf, offset - 1); \ 426 return show_pwm(dev, buf, offset - 1); \
427} \ 427} \
428static ssize_t set_pwm_##offset (struct device *dev, \ 428static ssize_t set_pwm_##offset (struct device *dev, struct device_attribute *attr, \
429 const char *buf, size_t count) \ 429 const char *buf, size_t count) \
430{ \ 430{ \
431 return set_pwm(dev, buf, count, offset - 1); \ 431 return set_pwm(dev, buf, count, offset - 1); \
@@ -557,24 +557,24 @@ set_fan_div(struct device *dev, const char *buf, size_t count, int nr)
557} 557}
558 558
559#define fan_offset(offset) \ 559#define fan_offset(offset) \
560static ssize_t show_fan_##offset (struct device *dev, char *buf) \ 560static ssize_t show_fan_##offset (struct device *dev, struct device_attribute *attr, char *buf) \
561{ \ 561{ \
562 return show_fan(dev, buf, offset - 1); \ 562 return show_fan(dev, buf, offset - 1); \
563} \ 563} \
564static ssize_t show_fan_##offset##_min (struct device *dev, char *buf) \ 564static ssize_t show_fan_##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \
565{ \ 565{ \
566 return show_fan_min(dev, buf, offset - 1); \ 566 return show_fan_min(dev, buf, offset - 1); \
567} \ 567} \
568static ssize_t show_fan_##offset##_div (struct device *dev, char *buf) \ 568static ssize_t show_fan_##offset##_div (struct device *dev, struct device_attribute *attr, char *buf) \
569{ \ 569{ \
570 return show_fan_div(dev, buf, offset - 1); \ 570 return show_fan_div(dev, buf, offset - 1); \
571} \ 571} \
572static ssize_t set_fan_##offset##_min (struct device *dev, \ 572static ssize_t set_fan_##offset##_min (struct device *dev, struct device_attribute *attr, \
573 const char *buf, size_t count) \ 573 const char *buf, size_t count) \
574{ \ 574{ \
575 return set_fan_min(dev, buf, count, offset - 1); \ 575 return set_fan_min(dev, buf, count, offset - 1); \
576} \ 576} \
577static ssize_t set_fan_##offset##_div (struct device *dev, \ 577static ssize_t set_fan_##offset##_div (struct device *dev, struct device_attribute *attr, \
578 const char *buf, size_t count) \ 578 const char *buf, size_t count) \
579{ \ 579{ \
580 return set_fan_div(dev, buf, count, offset - 1); \ 580 return set_fan_div(dev, buf, count, offset - 1); \
@@ -667,33 +667,33 @@ set_temp_crit(struct device *dev, const char *buf, size_t count, int nr)
667} 667}
668 668
669#define temp_reg(offset) \ 669#define temp_reg(offset) \
670static ssize_t show_temp_##offset (struct device *dev, char *buf) \ 670static ssize_t show_temp_##offset (struct device *dev, struct device_attribute *attr, char *buf) \
671{ \ 671{ \
672 return show_temp(dev, buf, offset - 1); \ 672 return show_temp(dev, buf, offset - 1); \
673} \ 673} \
674static ssize_t show_temp_##offset##_min (struct device *dev, char *buf) \ 674static ssize_t show_temp_##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \
675{ \ 675{ \
676 return show_temp_min(dev, buf, offset - 1); \ 676 return show_temp_min(dev, buf, offset - 1); \
677} \ 677} \
678static ssize_t show_temp_##offset##_max (struct device *dev, char *buf) \ 678static ssize_t show_temp_##offset##_max (struct device *dev, struct device_attribute *attr, char *buf) \
679{ \ 679{ \
680 return show_temp_max(dev, buf, offset - 1); \ 680 return show_temp_max(dev, buf, offset - 1); \
681} \ 681} \
682static ssize_t show_temp_##offset##_crit (struct device *dev, char *buf) \ 682static ssize_t show_temp_##offset##_crit (struct device *dev, struct device_attribute *attr, char *buf) \
683{ \ 683{ \
684 return show_temp_crit(dev, buf, offset - 1); \ 684 return show_temp_crit(dev, buf, offset - 1); \
685} \ 685} \
686static ssize_t set_temp_##offset##_min (struct device *dev, \ 686static ssize_t set_temp_##offset##_min (struct device *dev, struct device_attribute *attr, \
687 const char *buf, size_t count) \ 687 const char *buf, size_t count) \
688{ \ 688{ \
689 return set_temp_min(dev, buf, count, offset - 1); \ 689 return set_temp_min(dev, buf, count, offset - 1); \
690} \ 690} \
691static ssize_t set_temp_##offset##_max (struct device *dev, \ 691static ssize_t set_temp_##offset##_max (struct device *dev, struct device_attribute *attr, \
692 const char *buf, size_t count) \ 692 const char *buf, size_t count) \
693{ \ 693{ \
694 return set_temp_max(dev, buf, count, offset - 1); \ 694 return set_temp_max(dev, buf, count, offset - 1); \
695} \ 695} \
696static ssize_t set_temp_##offset##_crit (struct device *dev, \ 696static ssize_t set_temp_##offset##_crit (struct device *dev, struct device_attribute *attr, \
697 const char *buf, size_t count) \ 697 const char *buf, size_t count) \
698{ \ 698{ \
699 return set_temp_crit(dev, buf, count, offset - 1); \ 699 return set_temp_crit(dev, buf, count, offset - 1); \
@@ -712,7 +712,7 @@ temp_reg(2);
712temp_reg(3); 712temp_reg(3);
713 713
714/* Alarms */ 714/* Alarms */
715static ssize_t show_alarms(struct device *dev, char *buf) 715static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf)
716{ 716{
717 struct adm1031_data *data = adm1031_update_device(dev); 717 struct adm1031_data *data = adm1031_update_device(dev);
718 return sprintf(buf, "%d\n", data->alarm); 718 return sprintf(buf, "%d\n", data->alarm);
diff --git a/drivers/i2c/chips/asb100.c b/drivers/i2c/chips/asb100.c
index 7f899002bc54..4a47b4493e34 100644
--- a/drivers/i2c/chips/asb100.c
+++ b/drivers/i2c/chips/asb100.c
@@ -260,28 +260,28 @@ set_in_reg(MAX, max)
260 260
261#define sysfs_in(offset) \ 261#define sysfs_in(offset) \
262static ssize_t \ 262static ssize_t \
263 show_in##offset (struct device *dev, char *buf) \ 263 show_in##offset (struct device *dev, struct device_attribute *attr, char *buf) \
264{ \ 264{ \
265 return show_in(dev, buf, offset); \ 265 return show_in(dev, buf, offset); \
266} \ 266} \
267static DEVICE_ATTR(in##offset##_input, S_IRUGO, \ 267static DEVICE_ATTR(in##offset##_input, S_IRUGO, \
268 show_in##offset, NULL); \ 268 show_in##offset, NULL); \
269static ssize_t \ 269static ssize_t \
270 show_in##offset##_min (struct device *dev, char *buf) \ 270 show_in##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \
271{ \ 271{ \
272 return show_in_min(dev, buf, offset); \ 272 return show_in_min(dev, buf, offset); \
273} \ 273} \
274static ssize_t \ 274static ssize_t \
275 show_in##offset##_max (struct device *dev, char *buf) \ 275 show_in##offset##_max (struct device *dev, struct device_attribute *attr, char *buf) \
276{ \ 276{ \
277 return show_in_max(dev, buf, offset); \ 277 return show_in_max(dev, buf, offset); \
278} \ 278} \
279static ssize_t set_in##offset##_min (struct device *dev, \ 279static ssize_t set_in##offset##_min (struct device *dev, struct device_attribute *attr, \
280 const char *buf, size_t count) \ 280 const char *buf, size_t count) \
281{ \ 281{ \
282 return set_in_min(dev, buf, count, offset); \ 282 return set_in_min(dev, buf, count, offset); \
283} \ 283} \
284static ssize_t set_in##offset##_max (struct device *dev, \ 284static ssize_t set_in##offset##_max (struct device *dev, struct device_attribute *attr, \
285 const char *buf, size_t count) \ 285 const char *buf, size_t count) \
286{ \ 286{ \
287 return set_in_max(dev, buf, count, offset); \ 287 return set_in_max(dev, buf, count, offset); \
@@ -389,24 +389,24 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
389} 389}
390 390
391#define sysfs_fan(offset) \ 391#define sysfs_fan(offset) \
392static ssize_t show_fan##offset(struct device *dev, char *buf) \ 392static ssize_t show_fan##offset(struct device *dev, struct device_attribute *attr, char *buf) \
393{ \ 393{ \
394 return show_fan(dev, buf, offset - 1); \ 394 return show_fan(dev, buf, offset - 1); \
395} \ 395} \
396static ssize_t show_fan##offset##_min(struct device *dev, char *buf) \ 396static ssize_t show_fan##offset##_min(struct device *dev, struct device_attribute *attr, char *buf) \
397{ \ 397{ \
398 return show_fan_min(dev, buf, offset - 1); \ 398 return show_fan_min(dev, buf, offset - 1); \
399} \ 399} \
400static ssize_t show_fan##offset##_div(struct device *dev, char *buf) \ 400static ssize_t show_fan##offset##_div(struct device *dev, struct device_attribute *attr, char *buf) \
401{ \ 401{ \
402 return show_fan_div(dev, buf, offset - 1); \ 402 return show_fan_div(dev, buf, offset - 1); \
403} \ 403} \
404static ssize_t set_fan##offset##_min(struct device *dev, const char *buf, \ 404static ssize_t set_fan##offset##_min(struct device *dev, struct device_attribute *attr, const char *buf, \
405 size_t count) \ 405 size_t count) \
406{ \ 406{ \
407 return set_fan_min(dev, buf, count, offset - 1); \ 407 return set_fan_min(dev, buf, count, offset - 1); \
408} \ 408} \
409static ssize_t set_fan##offset##_div(struct device *dev, const char *buf, \ 409static ssize_t set_fan##offset##_div(struct device *dev, struct device_attribute *attr, const char *buf, \
410 size_t count) \ 410 size_t count) \
411{ \ 411{ \
412 return set_fan_div(dev, buf, count, offset - 1); \ 412 return set_fan_div(dev, buf, count, offset - 1); \
@@ -482,27 +482,27 @@ set_temp_reg(MAX, temp_max);
482set_temp_reg(HYST, temp_hyst); 482set_temp_reg(HYST, temp_hyst);
483 483
484#define sysfs_temp(num) \ 484#define sysfs_temp(num) \
485static ssize_t show_temp##num(struct device *dev, char *buf) \ 485static ssize_t show_temp##num(struct device *dev, struct device_attribute *attr, char *buf) \
486{ \ 486{ \
487 return show_temp(dev, buf, num-1); \ 487 return show_temp(dev, buf, num-1); \
488} \ 488} \
489static DEVICE_ATTR(temp##num##_input, S_IRUGO, show_temp##num, NULL); \ 489static DEVICE_ATTR(temp##num##_input, S_IRUGO, show_temp##num, NULL); \
490static ssize_t show_temp_max##num(struct device *dev, char *buf) \ 490static ssize_t show_temp_max##num(struct device *dev, struct device_attribute *attr, char *buf) \
491{ \ 491{ \
492 return show_temp_max(dev, buf, num-1); \ 492 return show_temp_max(dev, buf, num-1); \
493} \ 493} \
494static ssize_t set_temp_max##num(struct device *dev, const char *buf, \ 494static ssize_t set_temp_max##num(struct device *dev, struct device_attribute *attr, const char *buf, \
495 size_t count) \ 495 size_t count) \
496{ \ 496{ \
497 return set_temp_max(dev, buf, count, num-1); \ 497 return set_temp_max(dev, buf, count, num-1); \
498} \ 498} \
499static DEVICE_ATTR(temp##num##_max, S_IRUGO | S_IWUSR, \ 499static DEVICE_ATTR(temp##num##_max, S_IRUGO | S_IWUSR, \
500 show_temp_max##num, set_temp_max##num); \ 500 show_temp_max##num, set_temp_max##num); \
501static ssize_t show_temp_hyst##num(struct device *dev, char *buf) \ 501static ssize_t show_temp_hyst##num(struct device *dev, struct device_attribute *attr, char *buf) \
502{ \ 502{ \
503 return show_temp_hyst(dev, buf, num-1); \ 503 return show_temp_hyst(dev, buf, num-1); \
504} \ 504} \
505static ssize_t set_temp_hyst##num(struct device *dev, const char *buf, \ 505static ssize_t set_temp_hyst##num(struct device *dev, struct device_attribute *attr, const char *buf, \
506 size_t count) \ 506 size_t count) \
507{ \ 507{ \
508 return set_temp_hyst(dev, buf, count, num-1); \ 508 return set_temp_hyst(dev, buf, count, num-1); \
@@ -522,7 +522,7 @@ sysfs_temp(4);
522 device_create_file(&client->dev, &dev_attr_temp##num##_max_hyst); \ 522 device_create_file(&client->dev, &dev_attr_temp##num##_max_hyst); \
523} while (0) 523} while (0)
524 524
525static ssize_t show_vid(struct device *dev, char *buf) 525static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char *buf)
526{ 526{
527 struct asb100_data *data = asb100_update_device(dev); 527 struct asb100_data *data = asb100_update_device(dev);
528 return sprintf(buf, "%d\n", vid_from_reg(data->vid, data->vrm)); 528 return sprintf(buf, "%d\n", vid_from_reg(data->vid, data->vrm));
@@ -533,13 +533,13 @@ static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL);
533device_create_file(&client->dev, &dev_attr_cpu0_vid) 533device_create_file(&client->dev, &dev_attr_cpu0_vid)
534 534
535/* VRM */ 535/* VRM */
536static ssize_t show_vrm(struct device *dev, char *buf) 536static ssize_t show_vrm(struct device *dev, struct device_attribute *attr, char *buf)
537{ 537{
538 struct asb100_data *data = asb100_update_device(dev); 538 struct asb100_data *data = asb100_update_device(dev);
539 return sprintf(buf, "%d\n", data->vrm); 539 return sprintf(buf, "%d\n", data->vrm);
540} 540}
541 541
542static ssize_t set_vrm(struct device *dev, const char *buf, size_t count) 542static ssize_t set_vrm(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
543{ 543{
544 struct i2c_client *client = to_i2c_client(dev); 544 struct i2c_client *client = to_i2c_client(dev);
545 struct asb100_data *data = i2c_get_clientdata(client); 545 struct asb100_data *data = i2c_get_clientdata(client);
@@ -553,7 +553,7 @@ static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm, set_vrm);
553#define device_create_file_vrm(client) \ 553#define device_create_file_vrm(client) \
554device_create_file(&client->dev, &dev_attr_vrm); 554device_create_file(&client->dev, &dev_attr_vrm);
555 555
556static ssize_t show_alarms(struct device *dev, char *buf) 556static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf)
557{ 557{
558 struct asb100_data *data = asb100_update_device(dev); 558 struct asb100_data *data = asb100_update_device(dev);
559 return sprintf(buf, "%d\n", ALARMS_FROM_REG(data->alarms)); 559 return sprintf(buf, "%d\n", ALARMS_FROM_REG(data->alarms));
@@ -564,13 +564,13 @@ static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
564device_create_file(&client->dev, &dev_attr_alarms) 564device_create_file(&client->dev, &dev_attr_alarms)
565 565
566/* 1 PWM */ 566/* 1 PWM */
567static ssize_t show_pwm1(struct device *dev, char *buf) 567static ssize_t show_pwm1(struct device *dev, struct device_attribute *attr, char *buf)
568{ 568{
569 struct asb100_data *data = asb100_update_device(dev); 569 struct asb100_data *data = asb100_update_device(dev);
570 return sprintf(buf, "%d\n", ASB100_PWM_FROM_REG(data->pwm & 0x0f)); 570 return sprintf(buf, "%d\n", ASB100_PWM_FROM_REG(data->pwm & 0x0f));
571} 571}
572 572
573static ssize_t set_pwm1(struct device *dev, const char *buf, size_t count) 573static ssize_t set_pwm1(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
574{ 574{
575 struct i2c_client *client = to_i2c_client(dev); 575 struct i2c_client *client = to_i2c_client(dev);
576 struct asb100_data *data = i2c_get_clientdata(client); 576 struct asb100_data *data = i2c_get_clientdata(client);
@@ -584,13 +584,13 @@ static ssize_t set_pwm1(struct device *dev, const char *buf, size_t count)
584 return count; 584 return count;
585} 585}
586 586
587static ssize_t show_pwm_enable1(struct device *dev, char *buf) 587static ssize_t show_pwm_enable1(struct device *dev, struct device_attribute *attr, char *buf)
588{ 588{
589 struct asb100_data *data = asb100_update_device(dev); 589 struct asb100_data *data = asb100_update_device(dev);
590 return sprintf(buf, "%d\n", (data->pwm & 0x80) ? 1 : 0); 590 return sprintf(buf, "%d\n", (data->pwm & 0x80) ? 1 : 0);
591} 591}
592 592
593static ssize_t set_pwm_enable1(struct device *dev, const char *buf, 593static ssize_t set_pwm_enable1(struct device *dev, struct device_attribute *attr, const char *buf,
594 size_t count) 594 size_t count)
595{ 595{
596 struct i2c_client *client = to_i2c_client(dev); 596 struct i2c_client *client = to_i2c_client(dev);
diff --git a/drivers/i2c/chips/ds1621.c b/drivers/i2c/chips/ds1621.c
index bb1fefb2162e..4ae15bd5dcfb 100644
--- a/drivers/i2c/chips/ds1621.c
+++ b/drivers/i2c/chips/ds1621.c
@@ -137,7 +137,7 @@ static void ds1621_init_client(struct i2c_client *client)
137} 137}
138 138
139#define show(value) \ 139#define show(value) \
140static ssize_t show_##value(struct device *dev, char *buf) \ 140static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \
141{ \ 141{ \
142 struct ds1621_data *data = ds1621_update_client(dev); \ 142 struct ds1621_data *data = ds1621_update_client(dev); \
143 return sprintf(buf, "%d\n", LM75_TEMP_FROM_REG(data->value)); \ 143 return sprintf(buf, "%d\n", LM75_TEMP_FROM_REG(data->value)); \
@@ -148,7 +148,7 @@ show(temp_min);
148show(temp_max); 148show(temp_max);
149 149
150#define set_temp(suffix, value, reg) \ 150#define set_temp(suffix, value, reg) \
151static ssize_t set_temp_##suffix(struct device *dev, const char *buf, \ 151static ssize_t set_temp_##suffix(struct device *dev, struct device_attribute *attr, const char *buf, \
152 size_t count) \ 152 size_t count) \
153{ \ 153{ \
154 struct i2c_client *client = to_i2c_client(dev); \ 154 struct i2c_client *client = to_i2c_client(dev); \
@@ -165,7 +165,7 @@ static ssize_t set_temp_##suffix(struct device *dev, const char *buf, \
165set_temp(min, temp_min, DS1621_REG_TEMP_MIN); 165set_temp(min, temp_min, DS1621_REG_TEMP_MIN);
166set_temp(max, temp_max, DS1621_REG_TEMP_MAX); 166set_temp(max, temp_max, DS1621_REG_TEMP_MAX);
167 167
168static ssize_t show_alarms(struct device *dev, char *buf) 168static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf)
169{ 169{
170 struct ds1621_data *data = ds1621_update_client(dev); 170 struct ds1621_data *data = ds1621_update_client(dev);
171 return sprintf(buf, "%d\n", ALARMS_FROM_REG(data->conf)); 171 return sprintf(buf, "%d\n", ALARMS_FROM_REG(data->conf));
diff --git a/drivers/i2c/chips/fscher.c b/drivers/i2c/chips/fscher.c
index 18e33ac59d0c..c3f37dbec11a 100644
--- a/drivers/i2c/chips/fscher.c
+++ b/drivers/i2c/chips/fscher.c
@@ -157,8 +157,8 @@ struct fscher_data {
157 157
158#define sysfs_r(kind, sub, offset, reg) \ 158#define sysfs_r(kind, sub, offset, reg) \
159static ssize_t show_##kind##sub (struct fscher_data *, char *, int); \ 159static ssize_t show_##kind##sub (struct fscher_data *, char *, int); \
160static ssize_t show_##kind##offset##sub (struct device *, char *); \ 160static ssize_t show_##kind##offset##sub (struct device *, struct device_attribute *attr, char *); \
161static ssize_t show_##kind##offset##sub (struct device *dev, char *buf) \ 161static ssize_t show_##kind##offset##sub (struct device *dev, struct device_attribute *attr, char *buf) \
162{ \ 162{ \
163 struct fscher_data *data = fscher_update_device(dev); \ 163 struct fscher_data *data = fscher_update_device(dev); \
164 return show_##kind##sub(data, buf, (offset)); \ 164 return show_##kind##sub(data, buf, (offset)); \
@@ -166,8 +166,8 @@ static ssize_t show_##kind##offset##sub (struct device *dev, char *buf) \
166 166
167#define sysfs_w(kind, sub, offset, reg) \ 167#define sysfs_w(kind, sub, offset, reg) \
168static ssize_t set_##kind##sub (struct i2c_client *, struct fscher_data *, const char *, size_t, int, int); \ 168static ssize_t set_##kind##sub (struct i2c_client *, struct fscher_data *, const char *, size_t, int, int); \
169static ssize_t set_##kind##offset##sub (struct device *, const char *, size_t); \ 169static ssize_t set_##kind##offset##sub (struct device *, struct device_attribute *attr, const char *, size_t); \
170static ssize_t set_##kind##offset##sub (struct device *dev, const char *buf, size_t count) \ 170static ssize_t set_##kind##offset##sub (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \
171{ \ 171{ \
172 struct i2c_client *client = to_i2c_client(dev); \ 172 struct i2c_client *client = to_i2c_client(dev); \
173 struct fscher_data *data = i2c_get_clientdata(client); \ 173 struct fscher_data *data = i2c_get_clientdata(client); \
diff --git a/drivers/i2c/chips/fscpos.c b/drivers/i2c/chips/fscpos.c
index 2cac79145c75..3beaa6191ef4 100644
--- a/drivers/i2c/chips/fscpos.c
+++ b/drivers/i2c/chips/fscpos.c
@@ -245,19 +245,19 @@ static void reset_fan_alarm(struct i2c_client *client, int nr)
245/* Volts */ 245/* Volts */
246#define VOLT_FROM_REG(val, mult) ((val) * (mult) / 255) 246#define VOLT_FROM_REG(val, mult) ((val) * (mult) / 255)
247 247
248static ssize_t show_volt_12(struct device *dev, char *buf) 248static ssize_t show_volt_12(struct device *dev, struct device_attribute *attr, char *buf)
249{ 249{
250 struct fscpos_data *data = fscpos_update_device(dev); 250 struct fscpos_data *data = fscpos_update_device(dev);
251 return sprintf(buf, "%u\n", VOLT_FROM_REG(data->volt[0], 14200)); 251 return sprintf(buf, "%u\n", VOLT_FROM_REG(data->volt[0], 14200));
252} 252}
253 253
254static ssize_t show_volt_5(struct device *dev, char *buf) 254static ssize_t show_volt_5(struct device *dev, struct device_attribute *attr, char *buf)
255{ 255{
256 struct fscpos_data *data = fscpos_update_device(dev); 256 struct fscpos_data *data = fscpos_update_device(dev);
257 return sprintf(buf, "%u\n", VOLT_FROM_REG(data->volt[1], 6600)); 257 return sprintf(buf, "%u\n", VOLT_FROM_REG(data->volt[1], 6600));
258} 258}
259 259
260static ssize_t show_volt_batt(struct device *dev, char *buf) 260static ssize_t show_volt_batt(struct device *dev, struct device_attribute *attr, char *buf)
261{ 261{
262 struct fscpos_data *data = fscpos_update_device(dev); 262 struct fscpos_data *data = fscpos_update_device(dev);
263 return sprintf(buf, "%u\n", VOLT_FROM_REG(data->volt[2], 3300)); 263 return sprintf(buf, "%u\n", VOLT_FROM_REG(data->volt[2], 3300));
@@ -327,7 +327,7 @@ static ssize_t set_wdog_preset(struct i2c_client *client, struct fscpos_data
327} 327}
328 328
329/* Event */ 329/* Event */
330static ssize_t show_event(struct device *dev, char *buf) 330static ssize_t show_event(struct device *dev, struct device_attribute *attr, char *buf)
331{ 331{
332 /* bits 5..7 reserved => mask with 0x1f */ 332 /* bits 5..7 reserved => mask with 0x1f */
333 struct fscpos_data *data = fscpos_update_device(dev); 333 struct fscpos_data *data = fscpos_update_device(dev);
@@ -338,14 +338,14 @@ static ssize_t show_event(struct device *dev, char *buf)
338 * Sysfs stuff 338 * Sysfs stuff
339 */ 339 */
340#define create_getter(kind, sub) \ 340#define create_getter(kind, sub) \
341 static ssize_t sysfs_show_##kind##sub(struct device *dev, char *buf) \ 341 static ssize_t sysfs_show_##kind##sub(struct device *dev, struct device_attribute *attr, char *buf) \
342 { \ 342 { \
343 struct fscpos_data *data = fscpos_update_device(dev); \ 343 struct fscpos_data *data = fscpos_update_device(dev); \
344 return show_##kind##sub(data, buf); \ 344 return show_##kind##sub(data, buf); \
345 } 345 }
346 346
347#define create_getter_n(kind, offset, sub) \ 347#define create_getter_n(kind, offset, sub) \
348 static ssize_t sysfs_show_##kind##offset##sub(struct device *dev, char\ 348 static ssize_t sysfs_show_##kind##offset##sub(struct device *dev, struct device_attribute *attr, char\
349 *buf) \ 349 *buf) \
350 { \ 350 { \
351 struct fscpos_data *data = fscpos_update_device(dev); \ 351 struct fscpos_data *data = fscpos_update_device(dev); \
@@ -353,7 +353,7 @@ static ssize_t show_event(struct device *dev, char *buf)
353 } 353 }
354 354
355#define create_setter(kind, sub, reg) \ 355#define create_setter(kind, sub, reg) \
356 static ssize_t sysfs_set_##kind##sub (struct device *dev, const char \ 356 static ssize_t sysfs_set_##kind##sub (struct device *dev, struct device_attribute *attr, const char \
357 *buf, size_t count) \ 357 *buf, size_t count) \
358 { \ 358 { \
359 struct i2c_client *client = to_i2c_client(dev); \ 359 struct i2c_client *client = to_i2c_client(dev); \
@@ -362,7 +362,7 @@ static ssize_t show_event(struct device *dev, char *buf)
362 } 362 }
363 363
364#define create_setter_n(kind, offset, sub, reg) \ 364#define create_setter_n(kind, offset, sub, reg) \
365 static ssize_t sysfs_set_##kind##offset##sub (struct device *dev, \ 365 static ssize_t sysfs_set_##kind##offset##sub (struct device *dev, struct device_attribute *attr, \
366 const char *buf, size_t count) \ 366 const char *buf, size_t count) \
367 { \ 367 { \
368 struct i2c_client *client = to_i2c_client(dev); \ 368 struct i2c_client *client = to_i2c_client(dev); \
diff --git a/drivers/i2c/chips/gl518sm.c b/drivers/i2c/chips/gl518sm.c
index c82d6ce21205..4316a1562251 100644
--- a/drivers/i2c/chips/gl518sm.c
+++ b/drivers/i2c/chips/gl518sm.c
@@ -164,14 +164,14 @@ static struct i2c_driver gl518_driver = {
164 */ 164 */
165 165
166#define show(type, suffix, value) \ 166#define show(type, suffix, value) \
167static ssize_t show_##suffix(struct device *dev, char *buf) \ 167static ssize_t show_##suffix(struct device *dev, struct device_attribute *attr, char *buf) \
168{ \ 168{ \
169 struct gl518_data *data = gl518_update_device(dev); \ 169 struct gl518_data *data = gl518_update_device(dev); \
170 return sprintf(buf, "%d\n", type##_FROM_REG(data->value)); \ 170 return sprintf(buf, "%d\n", type##_FROM_REG(data->value)); \
171} 171}
172 172
173#define show_fan(suffix, value, index) \ 173#define show_fan(suffix, value, index) \
174static ssize_t show_##suffix(struct device *dev, char *buf) \ 174static ssize_t show_##suffix(struct device *dev, struct device_attribute *attr, char *buf) \
175{ \ 175{ \
176 struct gl518_data *data = gl518_update_device(dev); \ 176 struct gl518_data *data = gl518_update_device(dev); \
177 return sprintf(buf, "%d\n", FAN_FROM_REG(data->value[index], \ 177 return sprintf(buf, "%d\n", FAN_FROM_REG(data->value[index], \
@@ -205,7 +205,7 @@ show(BOOL, beep_enable, beep_enable);
205show(BEEP_MASK, beep_mask, beep_mask); 205show(BEEP_MASK, beep_mask, beep_mask);
206 206
207#define set(type, suffix, value, reg) \ 207#define set(type, suffix, value, reg) \
208static ssize_t set_##suffix(struct device *dev, const char *buf, \ 208static ssize_t set_##suffix(struct device *dev, struct device_attribute *attr, const char *buf, \
209 size_t count) \ 209 size_t count) \
210{ \ 210{ \
211 struct i2c_client *client = to_i2c_client(dev); \ 211 struct i2c_client *client = to_i2c_client(dev); \
@@ -220,7 +220,7 @@ static ssize_t set_##suffix(struct device *dev, const char *buf, \
220} 220}
221 221
222#define set_bits(type, suffix, value, reg, mask, shift) \ 222#define set_bits(type, suffix, value, reg, mask, shift) \
223static ssize_t set_##suffix(struct device *dev, const char *buf, \ 223static ssize_t set_##suffix(struct device *dev, struct device_attribute *attr, const char *buf, \
224 size_t count) \ 224 size_t count) \
225{ \ 225{ \
226 struct i2c_client *client = to_i2c_client(dev); \ 226 struct i2c_client *client = to_i2c_client(dev); \
@@ -258,7 +258,7 @@ set_high(IN, in_max3, voltage_max[3], GL518_REG_VIN3_LIMIT);
258set_bits(BOOL, beep_enable, beep_enable, GL518_REG_CONF, 0x04, 2); 258set_bits(BOOL, beep_enable, beep_enable, GL518_REG_CONF, 0x04, 2);
259set(BEEP_MASK, beep_mask, beep_mask, GL518_REG_ALARM); 259set(BEEP_MASK, beep_mask, beep_mask, GL518_REG_ALARM);
260 260
261static ssize_t set_fan_min1(struct device *dev, const char *buf, size_t count) 261static ssize_t set_fan_min1(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
262{ 262{
263 struct i2c_client *client = to_i2c_client(dev); 263 struct i2c_client *client = to_i2c_client(dev);
264 struct gl518_data *data = i2c_get_clientdata(client); 264 struct gl518_data *data = i2c_get_clientdata(client);
@@ -284,7 +284,7 @@ static ssize_t set_fan_min1(struct device *dev, const char *buf, size_t count)
284 return count; 284 return count;
285} 285}
286 286
287static ssize_t set_fan_min2(struct device *dev, const char *buf, size_t count) 287static ssize_t set_fan_min2(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
288{ 288{
289 struct i2c_client *client = to_i2c_client(dev); 289 struct i2c_client *client = to_i2c_client(dev);
290 struct gl518_data *data = i2c_get_clientdata(client); 290 struct gl518_data *data = i2c_get_clientdata(client);
diff --git a/drivers/i2c/chips/gl520sm.c b/drivers/i2c/chips/gl520sm.c
index 3fd17e46ffc6..a13a504f5bfa 100644
--- a/drivers/i2c/chips/gl520sm.c
+++ b/drivers/i2c/chips/gl520sm.c
@@ -148,8 +148,8 @@ struct gl520_data {
148 148
149#define sysfs_r(type, n, item, reg) \ 149#define sysfs_r(type, n, item, reg) \
150static ssize_t get_##type##item (struct gl520_data *, char *, int); \ 150static ssize_t get_##type##item (struct gl520_data *, char *, int); \
151static ssize_t get_##type##n##item (struct device *, char *); \ 151static ssize_t get_##type##n##item (struct device *, struct device_attribute *attr, char *); \
152static ssize_t get_##type##n##item (struct device *dev, char *buf) \ 152static ssize_t get_##type##n##item (struct device *dev, struct device_attribute *attr, char *buf) \
153{ \ 153{ \
154 struct gl520_data *data = gl520_update_device(dev); \ 154 struct gl520_data *data = gl520_update_device(dev); \
155 return get_##type##item(data, buf, (n)); \ 155 return get_##type##item(data, buf, (n)); \
@@ -157,8 +157,8 @@ static ssize_t get_##type##n##item (struct device *dev, char *buf) \
157 157
158#define sysfs_w(type, n, item, reg) \ 158#define sysfs_w(type, n, item, reg) \
159static ssize_t set_##type##item (struct i2c_client *, struct gl520_data *, const char *, size_t, int, int); \ 159static ssize_t set_##type##item (struct i2c_client *, struct gl520_data *, const char *, size_t, int, int); \
160static ssize_t set_##type##n##item (struct device *, const char *, size_t); \ 160static ssize_t set_##type##n##item (struct device *, struct device_attribute *attr, const char *, size_t); \
161static ssize_t set_##type##n##item (struct device *dev, const char *buf, size_t count) \ 161static ssize_t set_##type##n##item (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \
162{ \ 162{ \
163 struct i2c_client *client = to_i2c_client(dev); \ 163 struct i2c_client *client = to_i2c_client(dev); \
164 struct gl520_data *data = i2c_get_clientdata(client); \ 164 struct gl520_data *data = i2c_get_clientdata(client); \
diff --git a/drivers/i2c/chips/it87.c b/drivers/i2c/chips/it87.c
index cf7e6898754f..007bdf9e7e2a 100644
--- a/drivers/i2c/chips/it87.c
+++ b/drivers/i2c/chips/it87.c
@@ -290,7 +290,7 @@ static ssize_t set_in_max(struct device *dev, const char *buf,
290 290
291#define show_in_offset(offset) \ 291#define show_in_offset(offset) \
292static ssize_t \ 292static ssize_t \
293 show_in##offset (struct device *dev, char *buf) \ 293 show_in##offset (struct device *dev, struct device_attribute *attr, char *buf) \
294{ \ 294{ \
295 return show_in(dev, buf, offset); \ 295 return show_in(dev, buf, offset); \
296} \ 296} \
@@ -298,21 +298,21 @@ static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in##offset, NULL);
298 298
299#define limit_in_offset(offset) \ 299#define limit_in_offset(offset) \
300static ssize_t \ 300static ssize_t \
301 show_in##offset##_min (struct device *dev, char *buf) \ 301 show_in##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \
302{ \ 302{ \
303 return show_in_min(dev, buf, offset); \ 303 return show_in_min(dev, buf, offset); \
304} \ 304} \
305static ssize_t \ 305static ssize_t \
306 show_in##offset##_max (struct device *dev, char *buf) \ 306 show_in##offset##_max (struct device *dev, struct device_attribute *attr, char *buf) \
307{ \ 307{ \
308 return show_in_max(dev, buf, offset); \ 308 return show_in_max(dev, buf, offset); \
309} \ 309} \
310static ssize_t set_in##offset##_min (struct device *dev, \ 310static ssize_t set_in##offset##_min (struct device *dev, struct device_attribute *attr, \
311 const char *buf, size_t count) \ 311 const char *buf, size_t count) \
312{ \ 312{ \
313 return set_in_min(dev, buf, count, offset); \ 313 return set_in_min(dev, buf, count, offset); \
314} \ 314} \
315static ssize_t set_in##offset##_max (struct device *dev, \ 315static ssize_t set_in##offset##_max (struct device *dev, struct device_attribute *attr, \
316 const char *buf, size_t count) \ 316 const char *buf, size_t count) \
317{ \ 317{ \
318 return set_in_max(dev, buf, count, offset); \ 318 return set_in_max(dev, buf, count, offset); \
@@ -383,26 +383,26 @@ static ssize_t set_temp_min(struct device *dev, const char *buf,
383 return count; 383 return count;
384} 384}
385#define show_temp_offset(offset) \ 385#define show_temp_offset(offset) \
386static ssize_t show_temp_##offset (struct device *dev, char *buf) \ 386static ssize_t show_temp_##offset (struct device *dev, struct device_attribute *attr, char *buf) \
387{ \ 387{ \
388 return show_temp(dev, buf, offset - 1); \ 388 return show_temp(dev, buf, offset - 1); \
389} \ 389} \
390static ssize_t \ 390static ssize_t \
391show_temp_##offset##_max (struct device *dev, char *buf) \ 391show_temp_##offset##_max (struct device *dev, struct device_attribute *attr, char *buf) \
392{ \ 392{ \
393 return show_temp_max(dev, buf, offset - 1); \ 393 return show_temp_max(dev, buf, offset - 1); \
394} \ 394} \
395static ssize_t \ 395static ssize_t \
396show_temp_##offset##_min (struct device *dev, char *buf) \ 396show_temp_##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \
397{ \ 397{ \
398 return show_temp_min(dev, buf, offset - 1); \ 398 return show_temp_min(dev, buf, offset - 1); \
399} \ 399} \
400static ssize_t set_temp_##offset##_max (struct device *dev, \ 400static ssize_t set_temp_##offset##_max (struct device *dev, struct device_attribute *attr, \
401 const char *buf, size_t count) \ 401 const char *buf, size_t count) \
402{ \ 402{ \
403 return set_temp_max(dev, buf, count, offset - 1); \ 403 return set_temp_max(dev, buf, count, offset - 1); \
404} \ 404} \
405static ssize_t set_temp_##offset##_min (struct device *dev, \ 405static ssize_t set_temp_##offset##_min (struct device *dev, struct device_attribute *attr, \
406 const char *buf, size_t count) \ 406 const char *buf, size_t count) \
407{ \ 407{ \
408 return set_temp_min(dev, buf, count, offset - 1); \ 408 return set_temp_min(dev, buf, count, offset - 1); \
@@ -453,11 +453,11 @@ static ssize_t set_sensor(struct device *dev, const char *buf,
453 return count; 453 return count;
454} 454}
455#define show_sensor_offset(offset) \ 455#define show_sensor_offset(offset) \
456static ssize_t show_sensor_##offset (struct device *dev, char *buf) \ 456static ssize_t show_sensor_##offset (struct device *dev, struct device_attribute *attr, char *buf) \
457{ \ 457{ \
458 return show_sensor(dev, buf, offset - 1); \ 458 return show_sensor(dev, buf, offset - 1); \
459} \ 459} \
460static ssize_t set_sensor_##offset (struct device *dev, \ 460static ssize_t set_sensor_##offset (struct device *dev, struct device_attribute *attr, \
461 const char *buf, size_t count) \ 461 const char *buf, size_t count) \
462{ \ 462{ \
463 return set_sensor(dev, buf, count, offset - 1); \ 463 return set_sensor(dev, buf, count, offset - 1); \
@@ -600,24 +600,24 @@ static ssize_t set_pwm(struct device *dev, const char *buf,
600} 600}
601 601
602#define show_fan_offset(offset) \ 602#define show_fan_offset(offset) \
603static ssize_t show_fan_##offset (struct device *dev, char *buf) \ 603static ssize_t show_fan_##offset (struct device *dev, struct device_attribute *attr, char *buf) \
604{ \ 604{ \
605 return show_fan(dev, buf, offset - 1); \ 605 return show_fan(dev, buf, offset - 1); \
606} \ 606} \
607static ssize_t show_fan_##offset##_min (struct device *dev, char *buf) \ 607static ssize_t show_fan_##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \
608{ \ 608{ \
609 return show_fan_min(dev, buf, offset - 1); \ 609 return show_fan_min(dev, buf, offset - 1); \
610} \ 610} \
611static ssize_t show_fan_##offset##_div (struct device *dev, char *buf) \ 611static ssize_t show_fan_##offset##_div (struct device *dev, struct device_attribute *attr, char *buf) \
612{ \ 612{ \
613 return show_fan_div(dev, buf, offset - 1); \ 613 return show_fan_div(dev, buf, offset - 1); \
614} \ 614} \
615static ssize_t set_fan_##offset##_min (struct device *dev, \ 615static ssize_t set_fan_##offset##_min (struct device *dev, struct device_attribute *attr, \
616 const char *buf, size_t count) \ 616 const char *buf, size_t count) \
617{ \ 617{ \
618 return set_fan_min(dev, buf, count, offset - 1); \ 618 return set_fan_min(dev, buf, count, offset - 1); \
619} \ 619} \
620static ssize_t set_fan_##offset##_div (struct device *dev, \ 620static ssize_t set_fan_##offset##_div (struct device *dev, struct device_attribute *attr, \
621 const char *buf, size_t count) \ 621 const char *buf, size_t count) \
622{ \ 622{ \
623 return set_fan_div(dev, buf, count, offset - 1); \ 623 return set_fan_div(dev, buf, count, offset - 1); \
@@ -633,21 +633,21 @@ show_fan_offset(2);
633show_fan_offset(3); 633show_fan_offset(3);
634 634
635#define show_pwm_offset(offset) \ 635#define show_pwm_offset(offset) \
636static ssize_t show_pwm##offset##_enable (struct device *dev, \ 636static ssize_t show_pwm##offset##_enable (struct device *dev, struct device_attribute *attr, \
637 char *buf) \ 637 char *buf) \
638{ \ 638{ \
639 return show_pwm_enable(dev, buf, offset - 1); \ 639 return show_pwm_enable(dev, buf, offset - 1); \
640} \ 640} \
641static ssize_t show_pwm##offset (struct device *dev, char *buf) \ 641static ssize_t show_pwm##offset (struct device *dev, struct device_attribute *attr, char *buf) \
642{ \ 642{ \
643 return show_pwm(dev, buf, offset - 1); \ 643 return show_pwm(dev, buf, offset - 1); \
644} \ 644} \
645static ssize_t set_pwm##offset##_enable (struct device *dev, \ 645static ssize_t set_pwm##offset##_enable (struct device *dev, struct device_attribute *attr, \
646 const char *buf, size_t count) \ 646 const char *buf, size_t count) \
647{ \ 647{ \
648 return set_pwm_enable(dev, buf, count, offset - 1); \ 648 return set_pwm_enable(dev, buf, count, offset - 1); \
649} \ 649} \
650static ssize_t set_pwm##offset (struct device *dev, \ 650static ssize_t set_pwm##offset (struct device *dev, struct device_attribute *attr, \
651 const char *buf, size_t count) \ 651 const char *buf, size_t count) \
652{ \ 652{ \
653 return set_pwm(dev, buf, count, offset - 1); \ 653 return set_pwm(dev, buf, count, offset - 1); \
@@ -663,7 +663,7 @@ show_pwm_offset(2);
663show_pwm_offset(3); 663show_pwm_offset(3);
664 664
665/* Alarms */ 665/* Alarms */
666static ssize_t show_alarms(struct device *dev, char *buf) 666static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf)
667{ 667{
668 struct it87_data *data = it87_update_device(dev); 668 struct it87_data *data = it87_update_device(dev);
669 return sprintf(buf,"%d\n", ALARMS_FROM_REG(data->alarms)); 669 return sprintf(buf,"%d\n", ALARMS_FROM_REG(data->alarms));
@@ -671,13 +671,13 @@ static ssize_t show_alarms(struct device *dev, char *buf)
671static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); 671static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
672 672
673static ssize_t 673static ssize_t
674show_vrm_reg(struct device *dev, char *buf) 674show_vrm_reg(struct device *dev, struct device_attribute *attr, char *buf)
675{ 675{
676 struct it87_data *data = it87_update_device(dev); 676 struct it87_data *data = it87_update_device(dev);
677 return sprintf(buf, "%ld\n", (long) data->vrm); 677 return sprintf(buf, "%ld\n", (long) data->vrm);
678} 678}
679static ssize_t 679static ssize_t
680store_vrm_reg(struct device *dev, const char *buf, size_t count) 680store_vrm_reg(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
681{ 681{
682 struct i2c_client *client = to_i2c_client(dev); 682 struct i2c_client *client = to_i2c_client(dev);
683 struct it87_data *data = i2c_get_clientdata(client); 683 struct it87_data *data = i2c_get_clientdata(client);
@@ -693,7 +693,7 @@ static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg);
693device_create_file(&client->dev, &dev_attr_vrm) 693device_create_file(&client->dev, &dev_attr_vrm)
694 694
695static ssize_t 695static ssize_t
696show_vid_reg(struct device *dev, char *buf) 696show_vid_reg(struct device *dev, struct device_attribute *attr, char *buf)
697{ 697{
698 struct it87_data *data = it87_update_device(dev); 698 struct it87_data *data = it87_update_device(dev);
699 return sprintf(buf, "%ld\n", (long) vid_from_reg(data->vid, data->vrm)); 699 return sprintf(buf, "%ld\n", (long) vid_from_reg(data->vid, data->vrm));
diff --git a/drivers/i2c/chips/lm63.c b/drivers/i2c/chips/lm63.c
index 14cc5af03739..bc68e031392b 100644
--- a/drivers/i2c/chips/lm63.c
+++ b/drivers/i2c/chips/lm63.c
@@ -177,7 +177,7 @@ struct lm63_data {
177 */ 177 */
178 178
179#define show_fan(value) \ 179#define show_fan(value) \
180static ssize_t show_##value(struct device *dev, char *buf) \ 180static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \
181{ \ 181{ \
182 struct lm63_data *data = lm63_update_device(dev); \ 182 struct lm63_data *data = lm63_update_device(dev); \
183 return sprintf(buf, "%d\n", FAN_FROM_REG(data->value)); \ 183 return sprintf(buf, "%d\n", FAN_FROM_REG(data->value)); \
@@ -185,7 +185,7 @@ static ssize_t show_##value(struct device *dev, char *buf) \
185show_fan(fan1_input); 185show_fan(fan1_input);
186show_fan(fan1_low); 186show_fan(fan1_low);
187 187
188static ssize_t set_fan1_low(struct device *dev, const char *buf, 188static ssize_t set_fan1_low(struct device *dev, struct device_attribute *attr, const char *buf,
189 size_t count) 189 size_t count)
190{ 190{
191 struct i2c_client *client = to_i2c_client(dev); 191 struct i2c_client *client = to_i2c_client(dev);
@@ -202,7 +202,7 @@ static ssize_t set_fan1_low(struct device *dev, const char *buf,
202 return count; 202 return count;
203} 203}
204 204
205static ssize_t show_pwm1(struct device *dev, char *buf) 205static ssize_t show_pwm1(struct device *dev, struct device_attribute *attr, char *buf)
206{ 206{
207 struct lm63_data *data = lm63_update_device(dev); 207 struct lm63_data *data = lm63_update_device(dev);
208 return sprintf(buf, "%d\n", data->pwm1_value >= 2 * data->pwm1_freq ? 208 return sprintf(buf, "%d\n", data->pwm1_value >= 2 * data->pwm1_freq ?
@@ -210,7 +210,7 @@ static ssize_t show_pwm1(struct device *dev, char *buf)
210 (2 * data->pwm1_freq)); 210 (2 * data->pwm1_freq));
211} 211}
212 212
213static ssize_t set_pwm1(struct device *dev, const char *buf, size_t count) 213static ssize_t set_pwm1(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
214{ 214{
215 struct i2c_client *client = to_i2c_client(dev); 215 struct i2c_client *client = to_i2c_client(dev);
216 struct lm63_data *data = i2c_get_clientdata(client); 216 struct lm63_data *data = i2c_get_clientdata(client);
@@ -229,20 +229,20 @@ static ssize_t set_pwm1(struct device *dev, const char *buf, size_t count)
229 return count; 229 return count;
230} 230}
231 231
232static ssize_t show_pwm1_enable(struct device *dev, char *buf) 232static ssize_t show_pwm1_enable(struct device *dev, struct device_attribute *attr, char *buf)
233{ 233{
234 struct lm63_data *data = lm63_update_device(dev); 234 struct lm63_data *data = lm63_update_device(dev);
235 return sprintf(buf, "%d\n", data->config_fan & 0x20 ? 1 : 2); 235 return sprintf(buf, "%d\n", data->config_fan & 0x20 ? 1 : 2);
236} 236}
237 237
238#define show_temp8(value) \ 238#define show_temp8(value) \
239static ssize_t show_##value(struct device *dev, char *buf) \ 239static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \
240{ \ 240{ \
241 struct lm63_data *data = lm63_update_device(dev); \ 241 struct lm63_data *data = lm63_update_device(dev); \
242 return sprintf(buf, "%d\n", TEMP8_FROM_REG(data->value)); \ 242 return sprintf(buf, "%d\n", TEMP8_FROM_REG(data->value)); \
243} 243}
244#define show_temp11(value) \ 244#define show_temp11(value) \
245static ssize_t show_##value(struct device *dev, char *buf) \ 245static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \
246{ \ 246{ \
247 struct lm63_data *data = lm63_update_device(dev); \ 247 struct lm63_data *data = lm63_update_device(dev); \
248 return sprintf(buf, "%d\n", TEMP11_FROM_REG(data->value)); \ 248 return sprintf(buf, "%d\n", TEMP11_FROM_REG(data->value)); \
@@ -255,7 +255,7 @@ show_temp11(temp2_low);
255show_temp8(temp2_crit); 255show_temp8(temp2_crit);
256 256
257#define set_temp8(value, reg) \ 257#define set_temp8(value, reg) \
258static ssize_t set_##value(struct device *dev, const char *buf, \ 258static ssize_t set_##value(struct device *dev, struct device_attribute *attr, const char *buf, \
259 size_t count) \ 259 size_t count) \
260{ \ 260{ \
261 struct i2c_client *client = to_i2c_client(dev); \ 261 struct i2c_client *client = to_i2c_client(dev); \
@@ -269,7 +269,7 @@ static ssize_t set_##value(struct device *dev, const char *buf, \
269 return count; \ 269 return count; \
270} 270}
271#define set_temp11(value, reg_msb, reg_lsb) \ 271#define set_temp11(value, reg_msb, reg_lsb) \
272static ssize_t set_##value(struct device *dev, const char *buf, \ 272static ssize_t set_##value(struct device *dev, struct device_attribute *attr, const char *buf, \
273 size_t count) \ 273 size_t count) \
274{ \ 274{ \
275 struct i2c_client *client = to_i2c_client(dev); \ 275 struct i2c_client *client = to_i2c_client(dev); \
@@ -289,7 +289,7 @@ set_temp11(temp2_low, LM63_REG_REMOTE_LOW_MSB, LM63_REG_REMOTE_LOW_LSB);
289 289
290/* Hysteresis register holds a relative value, while we want to present 290/* Hysteresis register holds a relative value, while we want to present
291 an absolute to user-space */ 291 an absolute to user-space */
292static ssize_t show_temp2_crit_hyst(struct device *dev, char *buf) 292static ssize_t show_temp2_crit_hyst(struct device *dev, struct device_attribute *attr, char *buf)
293{ 293{
294 struct lm63_data *data = lm63_update_device(dev); 294 struct lm63_data *data = lm63_update_device(dev);
295 return sprintf(buf, "%d\n", TEMP8_FROM_REG(data->temp2_crit) 295 return sprintf(buf, "%d\n", TEMP8_FROM_REG(data->temp2_crit)
@@ -298,7 +298,7 @@ static ssize_t show_temp2_crit_hyst(struct device *dev, char *buf)
298 298
299/* And now the other way around, user-space provides an absolute 299/* And now the other way around, user-space provides an absolute
300 hysteresis value and we have to store a relative one */ 300 hysteresis value and we have to store a relative one */
301static ssize_t set_temp2_crit_hyst(struct device *dev, const char *buf, 301static ssize_t set_temp2_crit_hyst(struct device *dev, struct device_attribute *attr, const char *buf,
302 size_t count) 302 size_t count)
303{ 303{
304 struct i2c_client *client = to_i2c_client(dev); 304 struct i2c_client *client = to_i2c_client(dev);
@@ -314,7 +314,7 @@ static ssize_t set_temp2_crit_hyst(struct device *dev, const char *buf,
314 return count; 314 return count;
315} 315}
316 316
317static ssize_t show_alarms(struct device *dev, char *buf) 317static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf)
318{ 318{
319 struct lm63_data *data = lm63_update_device(dev); 319 struct lm63_data *data = lm63_update_device(dev);
320 return sprintf(buf, "%u\n", data->alarms); 320 return sprintf(buf, "%u\n", data->alarms);
diff --git a/drivers/i2c/chips/lm75.c b/drivers/i2c/chips/lm75.c
index 0e86cc893981..57c51ac37c04 100644
--- a/drivers/i2c/chips/lm75.c
+++ b/drivers/i2c/chips/lm75.c
@@ -75,7 +75,7 @@ static struct i2c_driver lm75_driver = {
75}; 75};
76 76
77#define show(value) \ 77#define show(value) \
78static ssize_t show_##value(struct device *dev, char *buf) \ 78static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \
79{ \ 79{ \
80 struct lm75_data *data = lm75_update_device(dev); \ 80 struct lm75_data *data = lm75_update_device(dev); \
81 return sprintf(buf, "%d\n", LM75_TEMP_FROM_REG(data->value)); \ 81 return sprintf(buf, "%d\n", LM75_TEMP_FROM_REG(data->value)); \
@@ -85,7 +85,7 @@ show(temp_hyst);
85show(temp_input); 85show(temp_input);
86 86
87#define set(value, reg) \ 87#define set(value, reg) \
88static ssize_t set_##value(struct device *dev, const char *buf, size_t count) \ 88static ssize_t set_##value(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \
89{ \ 89{ \
90 struct i2c_client *client = to_i2c_client(dev); \ 90 struct i2c_client *client = to_i2c_client(dev); \
91 struct lm75_data *data = i2c_get_clientdata(client); \ 91 struct lm75_data *data = i2c_get_clientdata(client); \
diff --git a/drivers/i2c/chips/lm77.c b/drivers/i2c/chips/lm77.c
index f56b7a37de75..9d15cd5189f6 100644
--- a/drivers/i2c/chips/lm77.c
+++ b/drivers/i2c/chips/lm77.c
@@ -103,7 +103,7 @@ static inline int LM77_TEMP_FROM_REG(u16 reg)
103 103
104/* read routines for temperature limits */ 104/* read routines for temperature limits */
105#define show(value) \ 105#define show(value) \
106static ssize_t show_##value(struct device *dev, char *buf) \ 106static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \
107{ \ 107{ \
108 struct lm77_data *data = lm77_update_device(dev); \ 108 struct lm77_data *data = lm77_update_device(dev); \
109 return sprintf(buf, "%d\n", data->value); \ 109 return sprintf(buf, "%d\n", data->value); \
@@ -116,17 +116,17 @@ show(temp_max);
116show(alarms); 116show(alarms);
117 117
118/* read routines for hysteresis values */ 118/* read routines for hysteresis values */
119static ssize_t show_temp_crit_hyst(struct device *dev, char *buf) 119static ssize_t show_temp_crit_hyst(struct device *dev, struct device_attribute *attr, char *buf)
120{ 120{
121 struct lm77_data *data = lm77_update_device(dev); 121 struct lm77_data *data = lm77_update_device(dev);
122 return sprintf(buf, "%d\n", data->temp_crit - data->temp_hyst); 122 return sprintf(buf, "%d\n", data->temp_crit - data->temp_hyst);
123} 123}
124static ssize_t show_temp_min_hyst(struct device *dev, char *buf) 124static ssize_t show_temp_min_hyst(struct device *dev, struct device_attribute *attr, char *buf)
125{ 125{
126 struct lm77_data *data = lm77_update_device(dev); 126 struct lm77_data *data = lm77_update_device(dev);
127 return sprintf(buf, "%d\n", data->temp_min + data->temp_hyst); 127 return sprintf(buf, "%d\n", data->temp_min + data->temp_hyst);
128} 128}
129static ssize_t show_temp_max_hyst(struct device *dev, char *buf) 129static ssize_t show_temp_max_hyst(struct device *dev, struct device_attribute *attr, char *buf)
130{ 130{
131 struct lm77_data *data = lm77_update_device(dev); 131 struct lm77_data *data = lm77_update_device(dev);
132 return sprintf(buf, "%d\n", data->temp_max - data->temp_hyst); 132 return sprintf(buf, "%d\n", data->temp_max - data->temp_hyst);
@@ -134,7 +134,7 @@ static ssize_t show_temp_max_hyst(struct device *dev, char *buf)
134 134
135/* write routines */ 135/* write routines */
136#define set(value, reg) \ 136#define set(value, reg) \
137static ssize_t set_##value(struct device *dev, const char *buf, size_t count) \ 137static ssize_t set_##value(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \
138{ \ 138{ \
139 struct i2c_client *client = to_i2c_client(dev); \ 139 struct i2c_client *client = to_i2c_client(dev); \
140 struct lm77_data *data = i2c_get_clientdata(client); \ 140 struct lm77_data *data = i2c_get_clientdata(client); \
@@ -152,7 +152,7 @@ set(temp_max, LM77_REG_TEMP_MAX);
152 152
153/* hysteresis is stored as a relative value on the chip, so it has to be 153/* hysteresis is stored as a relative value on the chip, so it has to be
154 converted first */ 154 converted first */
155static ssize_t set_temp_crit_hyst(struct device *dev, const char *buf, size_t count) 155static ssize_t set_temp_crit_hyst(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
156{ 156{
157 struct i2c_client *client = to_i2c_client(dev); 157 struct i2c_client *client = to_i2c_client(dev);
158 struct lm77_data *data = i2c_get_clientdata(client); 158 struct lm77_data *data = i2c_get_clientdata(client);
@@ -167,7 +167,7 @@ static ssize_t set_temp_crit_hyst(struct device *dev, const char *buf, size_t co
167} 167}
168 168
169/* preserve hysteresis when setting T_crit */ 169/* preserve hysteresis when setting T_crit */
170static ssize_t set_temp_crit(struct device *dev, const char *buf, size_t count) 170static ssize_t set_temp_crit(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
171{ 171{
172 struct i2c_client *client = to_i2c_client(dev); 172 struct i2c_client *client = to_i2c_client(dev);
173 struct lm77_data *data = i2c_get_clientdata(client); 173 struct lm77_data *data = i2c_get_clientdata(client);
diff --git a/drivers/i2c/chips/lm78.c b/drivers/i2c/chips/lm78.c
index 6d52d14eb31c..21b195ff3871 100644
--- a/drivers/i2c/chips/lm78.c
+++ b/drivers/i2c/chips/lm78.c
@@ -224,28 +224,28 @@ static ssize_t set_in_max(struct device *dev, const char *buf,
224 224
225#define show_in_offset(offset) \ 225#define show_in_offset(offset) \
226static ssize_t \ 226static ssize_t \
227 show_in##offset (struct device *dev, char *buf) \ 227 show_in##offset (struct device *dev, struct device_attribute *attr, char *buf) \
228{ \ 228{ \
229 return show_in(dev, buf, offset); \ 229 return show_in(dev, buf, offset); \
230} \ 230} \
231static DEVICE_ATTR(in##offset##_input, S_IRUGO, \ 231static DEVICE_ATTR(in##offset##_input, S_IRUGO, \
232 show_in##offset, NULL); \ 232 show_in##offset, NULL); \
233static ssize_t \ 233static ssize_t \
234 show_in##offset##_min (struct device *dev, char *buf) \ 234 show_in##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \
235{ \ 235{ \
236 return show_in_min(dev, buf, offset); \ 236 return show_in_min(dev, buf, offset); \
237} \ 237} \
238static ssize_t \ 238static ssize_t \
239 show_in##offset##_max (struct device *dev, char *buf) \ 239 show_in##offset##_max (struct device *dev, struct device_attribute *attr, char *buf) \
240{ \ 240{ \
241 return show_in_max(dev, buf, offset); \ 241 return show_in_max(dev, buf, offset); \
242} \ 242} \
243static ssize_t set_in##offset##_min (struct device *dev, \ 243static ssize_t set_in##offset##_min (struct device *dev, struct device_attribute *attr, \
244 const char *buf, size_t count) \ 244 const char *buf, size_t count) \
245{ \ 245{ \
246 return set_in_min(dev, buf, count, offset); \ 246 return set_in_min(dev, buf, count, offset); \
247} \ 247} \
248static ssize_t set_in##offset##_max (struct device *dev, \ 248static ssize_t set_in##offset##_max (struct device *dev, struct device_attribute *attr, \
249 const char *buf, size_t count) \ 249 const char *buf, size_t count) \
250{ \ 250{ \
251 return set_in_max(dev, buf, count, offset); \ 251 return set_in_max(dev, buf, count, offset); \
@@ -264,19 +264,19 @@ show_in_offset(5);
264show_in_offset(6); 264show_in_offset(6);
265 265
266/* Temperature */ 266/* Temperature */
267static ssize_t show_temp(struct device *dev, char *buf) 267static ssize_t show_temp(struct device *dev, struct device_attribute *attr, char *buf)
268{ 268{
269 struct lm78_data *data = lm78_update_device(dev); 269 struct lm78_data *data = lm78_update_device(dev);
270 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp)); 270 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp));
271} 271}
272 272
273static ssize_t show_temp_over(struct device *dev, char *buf) 273static ssize_t show_temp_over(struct device *dev, struct device_attribute *attr, char *buf)
274{ 274{
275 struct lm78_data *data = lm78_update_device(dev); 275 struct lm78_data *data = lm78_update_device(dev);
276 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_over)); 276 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_over));
277} 277}
278 278
279static ssize_t set_temp_over(struct device *dev, const char *buf, size_t count) 279static ssize_t set_temp_over(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
280{ 280{
281 struct i2c_client *client = to_i2c_client(dev); 281 struct i2c_client *client = to_i2c_client(dev);
282 struct lm78_data *data = i2c_get_clientdata(client); 282 struct lm78_data *data = i2c_get_clientdata(client);
@@ -289,13 +289,13 @@ static ssize_t set_temp_over(struct device *dev, const char *buf, size_t count)
289 return count; 289 return count;
290} 290}
291 291
292static ssize_t show_temp_hyst(struct device *dev, char *buf) 292static ssize_t show_temp_hyst(struct device *dev, struct device_attribute *attr, char *buf)
293{ 293{
294 struct lm78_data *data = lm78_update_device(dev); 294 struct lm78_data *data = lm78_update_device(dev);
295 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_hyst)); 295 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_hyst));
296} 296}
297 297
298static ssize_t set_temp_hyst(struct device *dev, const char *buf, size_t count) 298static ssize_t set_temp_hyst(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
299{ 299{
300 struct i2c_client *client = to_i2c_client(dev); 300 struct i2c_client *client = to_i2c_client(dev);
301 struct lm78_data *data = i2c_get_clientdata(client); 301 struct lm78_data *data = i2c_get_clientdata(client);
@@ -398,19 +398,19 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
398} 398}
399 399
400#define show_fan_offset(offset) \ 400#define show_fan_offset(offset) \
401static ssize_t show_fan_##offset (struct device *dev, char *buf) \ 401static ssize_t show_fan_##offset (struct device *dev, struct device_attribute *attr, char *buf) \
402{ \ 402{ \
403 return show_fan(dev, buf, offset - 1); \ 403 return show_fan(dev, buf, offset - 1); \
404} \ 404} \
405static ssize_t show_fan_##offset##_min (struct device *dev, char *buf) \ 405static ssize_t show_fan_##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \
406{ \ 406{ \
407 return show_fan_min(dev, buf, offset - 1); \ 407 return show_fan_min(dev, buf, offset - 1); \
408} \ 408} \
409static ssize_t show_fan_##offset##_div (struct device *dev, char *buf) \ 409static ssize_t show_fan_##offset##_div (struct device *dev, struct device_attribute *attr, char *buf) \
410{ \ 410{ \
411 return show_fan_div(dev, buf, offset - 1); \ 411 return show_fan_div(dev, buf, offset - 1); \
412} \ 412} \
413static ssize_t set_fan_##offset##_min (struct device *dev, \ 413static ssize_t set_fan_##offset##_min (struct device *dev, struct device_attribute *attr, \
414 const char *buf, size_t count) \ 414 const char *buf, size_t count) \
415{ \ 415{ \
416 return set_fan_min(dev, buf, count, offset - 1); \ 416 return set_fan_min(dev, buf, count, offset - 1); \
@@ -419,13 +419,13 @@ static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan_##offset, NULL);\
419static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ 419static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
420 show_fan_##offset##_min, set_fan_##offset##_min); 420 show_fan_##offset##_min, set_fan_##offset##_min);
421 421
422static ssize_t set_fan_1_div(struct device *dev, const char *buf, 422static ssize_t set_fan_1_div(struct device *dev, struct device_attribute *attr, const char *buf,
423 size_t count) 423 size_t count)
424{ 424{
425 return set_fan_div(dev, buf, count, 0) ; 425 return set_fan_div(dev, buf, count, 0) ;
426} 426}
427 427
428static ssize_t set_fan_2_div(struct device *dev, const char *buf, 428static ssize_t set_fan_2_div(struct device *dev, struct device_attribute *attr, const char *buf,
429 size_t count) 429 size_t count)
430{ 430{
431 return set_fan_div(dev, buf, count, 1) ; 431 return set_fan_div(dev, buf, count, 1) ;
@@ -443,7 +443,7 @@ static DEVICE_ATTR(fan2_div, S_IRUGO | S_IWUSR,
443static DEVICE_ATTR(fan3_div, S_IRUGO, show_fan_3_div, NULL); 443static DEVICE_ATTR(fan3_div, S_IRUGO, show_fan_3_div, NULL);
444 444
445/* VID */ 445/* VID */
446static ssize_t show_vid(struct device *dev, char *buf) 446static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char *buf)
447{ 447{
448 struct lm78_data *data = lm78_update_device(dev); 448 struct lm78_data *data = lm78_update_device(dev);
449 return sprintf(buf, "%d\n", VID_FROM_REG(data->vid)); 449 return sprintf(buf, "%d\n", VID_FROM_REG(data->vid));
@@ -451,7 +451,7 @@ static ssize_t show_vid(struct device *dev, char *buf)
451static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL); 451static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL);
452 452
453/* Alarms */ 453/* Alarms */
454static ssize_t show_alarms(struct device *dev, char *buf) 454static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf)
455{ 455{
456 struct lm78_data *data = lm78_update_device(dev); 456 struct lm78_data *data = lm78_update_device(dev);
457 return sprintf(buf, "%u\n", data->alarms); 457 return sprintf(buf, "%u\n", data->alarms);
diff --git a/drivers/i2c/chips/lm80.c b/drivers/i2c/chips/lm80.c
index a72f431971bb..404057b70e90 100644
--- a/drivers/i2c/chips/lm80.c
+++ b/drivers/i2c/chips/lm80.c
@@ -156,7 +156,7 @@ static struct i2c_driver lm80_driver = {
156 */ 156 */
157 157
158#define show_in(suffix, value) \ 158#define show_in(suffix, value) \
159static ssize_t show_in_##suffix(struct device *dev, char *buf) \ 159static ssize_t show_in_##suffix(struct device *dev, struct device_attribute *attr, char *buf) \
160{ \ 160{ \
161 struct lm80_data *data = lm80_update_device(dev); \ 161 struct lm80_data *data = lm80_update_device(dev); \
162 return sprintf(buf, "%d\n", IN_FROM_REG(data->value)); \ 162 return sprintf(buf, "%d\n", IN_FROM_REG(data->value)); \
@@ -184,7 +184,7 @@ show_in(input5, in[5]);
184show_in(input6, in[6]); 184show_in(input6, in[6]);
185 185
186#define set_in(suffix, value, reg) \ 186#define set_in(suffix, value, reg) \
187static ssize_t set_in_##suffix(struct device *dev, const char *buf, \ 187static ssize_t set_in_##suffix(struct device *dev, struct device_attribute *attr, const char *buf, \
188 size_t count) \ 188 size_t count) \
189{ \ 189{ \
190 struct i2c_client *client = to_i2c_client(dev); \ 190 struct i2c_client *client = to_i2c_client(dev); \
@@ -213,7 +213,7 @@ set_in(max5, in_max[5], LM80_REG_IN_MAX(5));
213set_in(max6, in_max[6], LM80_REG_IN_MAX(6)); 213set_in(max6, in_max[6], LM80_REG_IN_MAX(6));
214 214
215#define show_fan(suffix, value, div) \ 215#define show_fan(suffix, value, div) \
216static ssize_t show_fan_##suffix(struct device *dev, char *buf) \ 216static ssize_t show_fan_##suffix(struct device *dev, struct device_attribute *attr, char *buf) \
217{ \ 217{ \
218 struct lm80_data *data = lm80_update_device(dev); \ 218 struct lm80_data *data = lm80_update_device(dev); \
219 return sprintf(buf, "%d\n", FAN_FROM_REG(data->value, \ 219 return sprintf(buf, "%d\n", FAN_FROM_REG(data->value, \
@@ -225,7 +225,7 @@ show_fan(input1, fan[0], fan_div[0]);
225show_fan(input2, fan[1], fan_div[1]); 225show_fan(input2, fan[1], fan_div[1]);
226 226
227#define show_fan_div(suffix, value) \ 227#define show_fan_div(suffix, value) \
228static ssize_t show_fan_div##suffix(struct device *dev, char *buf) \ 228static ssize_t show_fan_div##suffix(struct device *dev, struct device_attribute *attr, char *buf) \
229{ \ 229{ \
230 struct lm80_data *data = lm80_update_device(dev); \ 230 struct lm80_data *data = lm80_update_device(dev); \
231 return sprintf(buf, "%d\n", DIV_FROM_REG(data->value)); \ 231 return sprintf(buf, "%d\n", DIV_FROM_REG(data->value)); \
@@ -234,7 +234,7 @@ show_fan_div(1, fan_div[0]);
234show_fan_div(2, fan_div[1]); 234show_fan_div(2, fan_div[1]);
235 235
236#define set_fan(suffix, value, reg, div) \ 236#define set_fan(suffix, value, reg, div) \
237static ssize_t set_fan_##suffix(struct device *dev, const char *buf, \ 237static ssize_t set_fan_##suffix(struct device *dev, struct device_attribute *attr, const char *buf, \
238 size_t count) \ 238 size_t count) \
239{ \ 239{ \
240 struct i2c_client *client = to_i2c_client(dev); \ 240 struct i2c_client *client = to_i2c_client(dev); \
@@ -292,7 +292,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
292} 292}
293 293
294#define set_fan_div(number) \ 294#define set_fan_div(number) \
295static ssize_t set_fan_div##number(struct device *dev, const char *buf, \ 295static ssize_t set_fan_div##number(struct device *dev, struct device_attribute *attr, const char *buf, \
296 size_t count) \ 296 size_t count) \
297{ \ 297{ \
298 return set_fan_div(dev, buf, count, number - 1); \ 298 return set_fan_div(dev, buf, count, number - 1); \
@@ -300,14 +300,14 @@ static ssize_t set_fan_div##number(struct device *dev, const char *buf, \
300set_fan_div(1); 300set_fan_div(1);
301set_fan_div(2); 301set_fan_div(2);
302 302
303static ssize_t show_temp_input1(struct device *dev, char *buf) 303static ssize_t show_temp_input1(struct device *dev, struct device_attribute *attr, char *buf)
304{ 304{
305 struct lm80_data *data = lm80_update_device(dev); 305 struct lm80_data *data = lm80_update_device(dev);
306 return sprintf(buf, "%ld\n", TEMP_FROM_REG(data->temp)); 306 return sprintf(buf, "%ld\n", TEMP_FROM_REG(data->temp));
307} 307}
308 308
309#define show_temp(suffix, value) \ 309#define show_temp(suffix, value) \
310static ssize_t show_temp_##suffix(struct device *dev, char *buf) \ 310static ssize_t show_temp_##suffix(struct device *dev, struct device_attribute *attr, char *buf) \
311{ \ 311{ \
312 struct lm80_data *data = lm80_update_device(dev); \ 312 struct lm80_data *data = lm80_update_device(dev); \
313 return sprintf(buf, "%d\n", TEMP_LIMIT_FROM_REG(data->value)); \ 313 return sprintf(buf, "%d\n", TEMP_LIMIT_FROM_REG(data->value)); \
@@ -318,7 +318,7 @@ show_temp(os_max, temp_os_max);
318show_temp(os_hyst, temp_os_hyst); 318show_temp(os_hyst, temp_os_hyst);
319 319
320#define set_temp(suffix, value, reg) \ 320#define set_temp(suffix, value, reg) \
321static ssize_t set_temp_##suffix(struct device *dev, const char *buf, \ 321static ssize_t set_temp_##suffix(struct device *dev, struct device_attribute *attr, const char *buf, \
322 size_t count) \ 322 size_t count) \
323{ \ 323{ \
324 struct i2c_client *client = to_i2c_client(dev); \ 324 struct i2c_client *client = to_i2c_client(dev); \
@@ -336,7 +336,7 @@ set_temp(hot_hyst, temp_hot_hyst, LM80_REG_TEMP_HOT_HYST);
336set_temp(os_max, temp_os_max, LM80_REG_TEMP_OS_MAX); 336set_temp(os_max, temp_os_max, LM80_REG_TEMP_OS_MAX);
337set_temp(os_hyst, temp_os_hyst, LM80_REG_TEMP_OS_HYST); 337set_temp(os_hyst, temp_os_hyst, LM80_REG_TEMP_OS_HYST);
338 338
339static ssize_t show_alarms(struct device *dev, char *buf) 339static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf)
340{ 340{
341 struct lm80_data *data = lm80_update_device(dev); 341 struct lm80_data *data = lm80_update_device(dev);
342 return sprintf(buf, "%u\n", data->alarms); 342 return sprintf(buf, "%u\n", data->alarms);
diff --git a/drivers/i2c/chips/lm83.c b/drivers/i2c/chips/lm83.c
index 3dafe60766ad..4d6d7d21e14b 100644
--- a/drivers/i2c/chips/lm83.c
+++ b/drivers/i2c/chips/lm83.c
@@ -155,7 +155,7 @@ struct lm83_data {
155 */ 155 */
156 156
157#define show_temp(suffix, value) \ 157#define show_temp(suffix, value) \
158static ssize_t show_temp_##suffix(struct device *dev, char *buf) \ 158static ssize_t show_temp_##suffix(struct device *dev, struct device_attribute *attr, char *buf) \
159{ \ 159{ \
160 struct lm83_data *data = lm83_update_device(dev); \ 160 struct lm83_data *data = lm83_update_device(dev); \
161 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->value)); \ 161 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->value)); \
@@ -171,7 +171,7 @@ show_temp(high4, temp_high[3]);
171show_temp(crit, temp_crit); 171show_temp(crit, temp_crit);
172 172
173#define set_temp(suffix, value, reg) \ 173#define set_temp(suffix, value, reg) \
174static ssize_t set_temp_##suffix(struct device *dev, const char *buf, \ 174static ssize_t set_temp_##suffix(struct device *dev, struct device_attribute *attr, const char *buf, \
175 size_t count) \ 175 size_t count) \
176{ \ 176{ \
177 struct i2c_client *client = to_i2c_client(dev); \ 177 struct i2c_client *client = to_i2c_client(dev); \
@@ -190,7 +190,7 @@ set_temp(high3, temp_high[2], LM83_REG_W_REMOTE2_HIGH);
190set_temp(high4, temp_high[3], LM83_REG_W_REMOTE3_HIGH); 190set_temp(high4, temp_high[3], LM83_REG_W_REMOTE3_HIGH);
191set_temp(crit, temp_crit, LM83_REG_W_TCRIT); 191set_temp(crit, temp_crit, LM83_REG_W_TCRIT);
192 192
193static ssize_t show_alarms(struct device *dev, char *buf) 193static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf)
194{ 194{
195 struct lm83_data *data = lm83_update_device(dev); 195 struct lm83_data *data = lm83_update_device(dev);
196 return sprintf(buf, "%d\n", data->alarms); 196 return sprintf(buf, "%d\n", data->alarms);
diff --git a/drivers/i2c/chips/lm85.c b/drivers/i2c/chips/lm85.c
index b1a0dc5f6b34..b1976775b4ba 100644
--- a/drivers/i2c/chips/lm85.c
+++ b/drivers/i2c/chips/lm85.c
@@ -426,15 +426,15 @@ static ssize_t set_fan_min(struct device *dev, const char *buf,
426} 426}
427 427
428#define show_fan_offset(offset) \ 428#define show_fan_offset(offset) \
429static ssize_t show_fan_##offset (struct device *dev, char *buf) \ 429static ssize_t show_fan_##offset (struct device *dev, struct device_attribute *attr, char *buf) \
430{ \ 430{ \
431 return show_fan(dev, buf, offset - 1); \ 431 return show_fan(dev, buf, offset - 1); \
432} \ 432} \
433static ssize_t show_fan_##offset##_min (struct device *dev, char *buf) \ 433static ssize_t show_fan_##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \
434{ \ 434{ \
435 return show_fan_min(dev, buf, offset - 1); \ 435 return show_fan_min(dev, buf, offset - 1); \
436} \ 436} \
437static ssize_t set_fan_##offset##_min (struct device *dev, \ 437static ssize_t set_fan_##offset##_min (struct device *dev, struct device_attribute *attr, \
438 const char *buf, size_t count) \ 438 const char *buf, size_t count) \
439{ \ 439{ \
440 return set_fan_min(dev, buf, count, offset - 1); \ 440 return set_fan_min(dev, buf, count, offset - 1); \
@@ -451,7 +451,7 @@ show_fan_offset(4);
451 451
452/* vid, vrm, alarms */ 452/* vid, vrm, alarms */
453 453
454static ssize_t show_vid_reg(struct device *dev, char *buf) 454static ssize_t show_vid_reg(struct device *dev, struct device_attribute *attr, char *buf)
455{ 455{
456 struct lm85_data *data = lm85_update_device(dev); 456 struct lm85_data *data = lm85_update_device(dev);
457 return sprintf(buf, "%ld\n", (long) vid_from_reg(data->vid, data->vrm)); 457 return sprintf(buf, "%ld\n", (long) vid_from_reg(data->vid, data->vrm));
@@ -459,13 +459,13 @@ static ssize_t show_vid_reg(struct device *dev, char *buf)
459 459
460static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid_reg, NULL); 460static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid_reg, NULL);
461 461
462static ssize_t show_vrm_reg(struct device *dev, char *buf) 462static ssize_t show_vrm_reg(struct device *dev, struct device_attribute *attr, char *buf)
463{ 463{
464 struct lm85_data *data = lm85_update_device(dev); 464 struct lm85_data *data = lm85_update_device(dev);
465 return sprintf(buf, "%ld\n", (long) data->vrm); 465 return sprintf(buf, "%ld\n", (long) data->vrm);
466} 466}
467 467
468static ssize_t store_vrm_reg(struct device *dev, const char *buf, size_t count) 468static ssize_t store_vrm_reg(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
469{ 469{
470 struct i2c_client *client = to_i2c_client(dev); 470 struct i2c_client *client = to_i2c_client(dev);
471 struct lm85_data *data = i2c_get_clientdata(client); 471 struct lm85_data *data = i2c_get_clientdata(client);
@@ -478,7 +478,7 @@ static ssize_t store_vrm_reg(struct device *dev, const char *buf, size_t count)
478 478
479static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg); 479static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg);
480 480
481static ssize_t show_alarms_reg(struct device *dev, char *buf) 481static ssize_t show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf)
482{ 482{
483 struct lm85_data *data = lm85_update_device(dev); 483 struct lm85_data *data = lm85_update_device(dev);
484 return sprintf(buf, "%ld\n", (long) ALARMS_FROM_REG(data->alarms)); 484 return sprintf(buf, "%ld\n", (long) ALARMS_FROM_REG(data->alarms));
@@ -516,16 +516,16 @@ static ssize_t show_pwm_enable(struct device *dev, char *buf, int nr)
516} 516}
517 517
518#define show_pwm_reg(offset) \ 518#define show_pwm_reg(offset) \
519static ssize_t show_pwm_##offset (struct device *dev, char *buf) \ 519static ssize_t show_pwm_##offset (struct device *dev, struct device_attribute *attr, char *buf) \
520{ \ 520{ \
521 return show_pwm(dev, buf, offset - 1); \ 521 return show_pwm(dev, buf, offset - 1); \
522} \ 522} \
523static ssize_t set_pwm_##offset (struct device *dev, \ 523static ssize_t set_pwm_##offset (struct device *dev, struct device_attribute *attr, \
524 const char *buf, size_t count) \ 524 const char *buf, size_t count) \
525{ \ 525{ \
526 return set_pwm(dev, buf, count, offset - 1); \ 526 return set_pwm(dev, buf, count, offset - 1); \
527} \ 527} \
528static ssize_t show_pwm_enable##offset (struct device *dev, char *buf) \ 528static ssize_t show_pwm_enable##offset (struct device *dev, struct device_attribute *attr, char *buf) \
529{ \ 529{ \
530 return show_pwm_enable(dev, buf, offset - 1); \ 530 return show_pwm_enable(dev, buf, offset - 1); \
531} \ 531} \
@@ -585,24 +585,24 @@ static ssize_t set_in_max(struct device *dev, const char *buf,
585 return count; 585 return count;
586} 586}
587#define show_in_reg(offset) \ 587#define show_in_reg(offset) \
588static ssize_t show_in_##offset (struct device *dev, char *buf) \ 588static ssize_t show_in_##offset (struct device *dev, struct device_attribute *attr, char *buf) \
589{ \ 589{ \
590 return show_in(dev, buf, offset); \ 590 return show_in(dev, buf, offset); \
591} \ 591} \
592static ssize_t show_in_##offset##_min (struct device *dev, char *buf) \ 592static ssize_t show_in_##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \
593{ \ 593{ \
594 return show_in_min(dev, buf, offset); \ 594 return show_in_min(dev, buf, offset); \
595} \ 595} \
596static ssize_t show_in_##offset##_max (struct device *dev, char *buf) \ 596static ssize_t show_in_##offset##_max (struct device *dev, struct device_attribute *attr, char *buf) \
597{ \ 597{ \
598 return show_in_max(dev, buf, offset); \ 598 return show_in_max(dev, buf, offset); \
599} \ 599} \
600static ssize_t set_in_##offset##_min (struct device *dev, \ 600static ssize_t set_in_##offset##_min (struct device *dev, struct device_attribute *attr, \
601 const char *buf, size_t count) \ 601 const char *buf, size_t count) \
602{ \ 602{ \
603 return set_in_min(dev, buf, count, offset); \ 603 return set_in_min(dev, buf, count, offset); \
604} \ 604} \
605static ssize_t set_in_##offset##_max (struct device *dev, \ 605static ssize_t set_in_##offset##_max (struct device *dev, struct device_attribute *attr, \
606 const char *buf, size_t count) \ 606 const char *buf, size_t count) \
607{ \ 607{ \
608 return set_in_max(dev, buf, count, offset); \ 608 return set_in_max(dev, buf, count, offset); \
@@ -666,24 +666,24 @@ static ssize_t set_temp_max(struct device *dev, const char *buf,
666 return count; 666 return count;
667} 667}
668#define show_temp_reg(offset) \ 668#define show_temp_reg(offset) \
669static ssize_t show_temp_##offset (struct device *dev, char *buf) \ 669static ssize_t show_temp_##offset (struct device *dev, struct device_attribute *attr, char *buf) \
670{ \ 670{ \
671 return show_temp(dev, buf, offset - 1); \ 671 return show_temp(dev, buf, offset - 1); \
672} \ 672} \
673static ssize_t show_temp_##offset##_min (struct device *dev, char *buf) \ 673static ssize_t show_temp_##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \
674{ \ 674{ \
675 return show_temp_min(dev, buf, offset - 1); \ 675 return show_temp_min(dev, buf, offset - 1); \
676} \ 676} \
677static ssize_t show_temp_##offset##_max (struct device *dev, char *buf) \ 677static ssize_t show_temp_##offset##_max (struct device *dev, struct device_attribute *attr, char *buf) \
678{ \ 678{ \
679 return show_temp_max(dev, buf, offset - 1); \ 679 return show_temp_max(dev, buf, offset - 1); \
680} \ 680} \
681static ssize_t set_temp_##offset##_min (struct device *dev, \ 681static ssize_t set_temp_##offset##_min (struct device *dev, struct device_attribute *attr, \
682 const char *buf, size_t count) \ 682 const char *buf, size_t count) \
683{ \ 683{ \
684 return set_temp_min(dev, buf, count, offset - 1); \ 684 return set_temp_min(dev, buf, count, offset - 1); \
685} \ 685} \
686static ssize_t set_temp_##offset##_max (struct device *dev, \ 686static ssize_t set_temp_##offset##_max (struct device *dev, struct device_attribute *attr, \
687 const char *buf, size_t count) \ 687 const char *buf, size_t count) \
688{ \ 688{ \
689 return set_temp_max(dev, buf, count, offset - 1); \ 689 return set_temp_max(dev, buf, count, offset - 1); \
@@ -786,42 +786,42 @@ static ssize_t set_pwm_auto_pwm_freq(struct device *dev, const char *buf,
786 return count; 786 return count;
787} 787}
788#define pwm_auto(offset) \ 788#define pwm_auto(offset) \
789static ssize_t show_pwm##offset##_auto_channels (struct device *dev, \ 789static ssize_t show_pwm##offset##_auto_channels (struct device *dev, struct device_attribute *attr, \
790 char *buf) \ 790 char *buf) \
791{ \ 791{ \
792 return show_pwm_auto_channels(dev, buf, offset - 1); \ 792 return show_pwm_auto_channels(dev, buf, offset - 1); \
793} \ 793} \
794static ssize_t set_pwm##offset##_auto_channels (struct device *dev, \ 794static ssize_t set_pwm##offset##_auto_channels (struct device *dev, struct device_attribute *attr, \
795 const char *buf, size_t count) \ 795 const char *buf, size_t count) \
796{ \ 796{ \
797 return set_pwm_auto_channels(dev, buf, count, offset - 1); \ 797 return set_pwm_auto_channels(dev, buf, count, offset - 1); \
798} \ 798} \
799static ssize_t show_pwm##offset##_auto_pwm_min (struct device *dev, \ 799static ssize_t show_pwm##offset##_auto_pwm_min (struct device *dev, struct device_attribute *attr, \
800 char *buf) \ 800 char *buf) \
801{ \ 801{ \
802 return show_pwm_auto_pwm_min(dev, buf, offset - 1); \ 802 return show_pwm_auto_pwm_min(dev, buf, offset - 1); \
803} \ 803} \
804static ssize_t set_pwm##offset##_auto_pwm_min (struct device *dev, \ 804static ssize_t set_pwm##offset##_auto_pwm_min (struct device *dev, struct device_attribute *attr, \
805 const char *buf, size_t count) \ 805 const char *buf, size_t count) \
806{ \ 806{ \
807 return set_pwm_auto_pwm_min(dev, buf, count, offset - 1); \ 807 return set_pwm_auto_pwm_min(dev, buf, count, offset - 1); \
808} \ 808} \
809static ssize_t show_pwm##offset##_auto_pwm_minctl (struct device *dev, \ 809static ssize_t show_pwm##offset##_auto_pwm_minctl (struct device *dev, struct device_attribute *attr, \
810 char *buf) \ 810 char *buf) \
811{ \ 811{ \
812 return show_pwm_auto_pwm_minctl(dev, buf, offset - 1); \ 812 return show_pwm_auto_pwm_minctl(dev, buf, offset - 1); \
813} \ 813} \
814static ssize_t set_pwm##offset##_auto_pwm_minctl (struct device *dev, \ 814static ssize_t set_pwm##offset##_auto_pwm_minctl (struct device *dev, struct device_attribute *attr, \
815 const char *buf, size_t count) \ 815 const char *buf, size_t count) \
816{ \ 816{ \
817 return set_pwm_auto_pwm_minctl(dev, buf, count, offset - 1); \ 817 return set_pwm_auto_pwm_minctl(dev, buf, count, offset - 1); \
818} \ 818} \
819static ssize_t show_pwm##offset##_auto_pwm_freq (struct device *dev, \ 819static ssize_t show_pwm##offset##_auto_pwm_freq (struct device *dev, struct device_attribute *attr, \
820 char *buf) \ 820 char *buf) \
821{ \ 821{ \
822 return show_pwm_auto_pwm_freq(dev, buf, offset - 1); \ 822 return show_pwm_auto_pwm_freq(dev, buf, offset - 1); \
823} \ 823} \
824static ssize_t set_pwm##offset##_auto_pwm_freq(struct device *dev, \ 824static ssize_t set_pwm##offset##_auto_pwm_freq(struct device *dev, struct device_attribute *attr, \
825 const char *buf, size_t count) \ 825 const char *buf, size_t count) \
826{ \ 826{ \
827 return set_pwm_auto_pwm_freq(dev, buf, count, offset - 1); \ 827 return set_pwm_auto_pwm_freq(dev, buf, count, offset - 1); \
@@ -962,42 +962,42 @@ static ssize_t set_temp_auto_temp_crit(struct device *dev, const char *buf,
962 return count; 962 return count;
963} 963}
964#define temp_auto(offset) \ 964#define temp_auto(offset) \
965static ssize_t show_temp##offset##_auto_temp_off (struct device *dev, \ 965static ssize_t show_temp##offset##_auto_temp_off (struct device *dev, struct device_attribute *attr, \
966 char *buf) \ 966 char *buf) \
967{ \ 967{ \
968 return show_temp_auto_temp_off(dev, buf, offset - 1); \ 968 return show_temp_auto_temp_off(dev, buf, offset - 1); \
969} \ 969} \
970static ssize_t set_temp##offset##_auto_temp_off (struct device *dev, \ 970static ssize_t set_temp##offset##_auto_temp_off (struct device *dev, struct device_attribute *attr, \
971 const char *buf, size_t count) \ 971 const char *buf, size_t count) \
972{ \ 972{ \
973 return set_temp_auto_temp_off(dev, buf, count, offset - 1); \ 973 return set_temp_auto_temp_off(dev, buf, count, offset - 1); \
974} \ 974} \
975static ssize_t show_temp##offset##_auto_temp_min (struct device *dev, \ 975static ssize_t show_temp##offset##_auto_temp_min (struct device *dev, struct device_attribute *attr, \
976 char *buf) \ 976 char *buf) \
977{ \ 977{ \
978 return show_temp_auto_temp_min(dev, buf, offset - 1); \ 978 return show_temp_auto_temp_min(dev, buf, offset - 1); \
979} \ 979} \
980static ssize_t set_temp##offset##_auto_temp_min (struct device *dev, \ 980static ssize_t set_temp##offset##_auto_temp_min (struct device *dev, struct device_attribute *attr, \
981 const char *buf, size_t count) \ 981 const char *buf, size_t count) \
982{ \ 982{ \
983 return set_temp_auto_temp_min(dev, buf, count, offset - 1); \ 983 return set_temp_auto_temp_min(dev, buf, count, offset - 1); \
984} \ 984} \
985static ssize_t show_temp##offset##_auto_temp_max (struct device *dev, \ 985static ssize_t show_temp##offset##_auto_temp_max (struct device *dev, struct device_attribute *attr, \
986 char *buf) \ 986 char *buf) \
987{ \ 987{ \
988 return show_temp_auto_temp_max(dev, buf, offset - 1); \ 988 return show_temp_auto_temp_max(dev, buf, offset - 1); \
989} \ 989} \
990static ssize_t set_temp##offset##_auto_temp_max (struct device *dev, \ 990static ssize_t set_temp##offset##_auto_temp_max (struct device *dev, struct device_attribute *attr, \
991 const char *buf, size_t count) \ 991 const char *buf, size_t count) \
992{ \ 992{ \
993 return set_temp_auto_temp_max(dev, buf, count, offset - 1); \ 993 return set_temp_auto_temp_max(dev, buf, count, offset - 1); \
994} \ 994} \
995static ssize_t show_temp##offset##_auto_temp_crit (struct device *dev, \ 995static ssize_t show_temp##offset##_auto_temp_crit (struct device *dev, struct device_attribute *attr, \
996 char *buf) \ 996 char *buf) \
997{ \ 997{ \
998 return show_temp_auto_temp_crit(dev, buf, offset - 1); \ 998 return show_temp_auto_temp_crit(dev, buf, offset - 1); \
999} \ 999} \
1000static ssize_t set_temp##offset##_auto_temp_crit (struct device *dev, \ 1000static ssize_t set_temp##offset##_auto_temp_crit (struct device *dev, struct device_attribute *attr, \
1001 const char *buf, size_t count) \ 1001 const char *buf, size_t count) \
1002{ \ 1002{ \
1003 return set_temp_auto_temp_crit(dev, buf, count, offset - 1); \ 1003 return set_temp_auto_temp_crit(dev, buf, count, offset - 1); \
diff --git a/drivers/i2c/chips/lm87.c b/drivers/i2c/chips/lm87.c
index 98cabd665063..4372b61a0882 100644
--- a/drivers/i2c/chips/lm87.c
+++ b/drivers/i2c/chips/lm87.c
@@ -218,19 +218,19 @@ static inline int lm87_write_value(struct i2c_client *client, u8 reg, u8 value)
218} 218}
219 219
220#define show_in(offset) \ 220#define show_in(offset) \
221static ssize_t show_in##offset##_input(struct device *dev, char *buf) \ 221static ssize_t show_in##offset##_input(struct device *dev, struct device_attribute *attr, char *buf) \
222{ \ 222{ \
223 struct lm87_data *data = lm87_update_device(dev); \ 223 struct lm87_data *data = lm87_update_device(dev); \
224 return sprintf(buf, "%u\n", IN_FROM_REG(data->in[offset], \ 224 return sprintf(buf, "%u\n", IN_FROM_REG(data->in[offset], \
225 data->in_scale[offset])); \ 225 data->in_scale[offset])); \
226} \ 226} \
227static ssize_t show_in##offset##_min(struct device *dev, char *buf) \ 227static ssize_t show_in##offset##_min(struct device *dev, struct device_attribute *attr, char *buf) \
228{ \ 228{ \
229 struct lm87_data *data = lm87_update_device(dev); \ 229 struct lm87_data *data = lm87_update_device(dev); \
230 return sprintf(buf, "%u\n", IN_FROM_REG(data->in_min[offset], \ 230 return sprintf(buf, "%u\n", IN_FROM_REG(data->in_min[offset], \
231 data->in_scale[offset])); \ 231 data->in_scale[offset])); \
232} \ 232} \
233static ssize_t show_in##offset##_max(struct device *dev, char *buf) \ 233static ssize_t show_in##offset##_max(struct device *dev, struct device_attribute *attr, char *buf) \
234{ \ 234{ \
235 struct lm87_data *data = lm87_update_device(dev); \ 235 struct lm87_data *data = lm87_update_device(dev); \
236 return sprintf(buf, "%u\n", IN_FROM_REG(data->in_max[offset], \ 236 return sprintf(buf, "%u\n", IN_FROM_REG(data->in_max[offset], \
@@ -274,13 +274,13 @@ static void set_in_max(struct device *dev, const char *buf, int nr)
274} 274}
275 275
276#define set_in(offset) \ 276#define set_in(offset) \
277static ssize_t set_in##offset##_min(struct device *dev, \ 277static ssize_t set_in##offset##_min(struct device *dev, struct device_attribute *attr, \
278 const char *buf, size_t count) \ 278 const char *buf, size_t count) \
279{ \ 279{ \
280 set_in_min(dev, buf, offset); \ 280 set_in_min(dev, buf, offset); \
281 return count; \ 281 return count; \
282} \ 282} \
283static ssize_t set_in##offset##_max(struct device *dev, \ 283static ssize_t set_in##offset##_max(struct device *dev, struct device_attribute *attr, \
284 const char *buf, size_t count) \ 284 const char *buf, size_t count) \
285{ \ 285{ \
286 set_in_max(dev, buf, offset); \ 286 set_in_max(dev, buf, offset); \
@@ -300,17 +300,17 @@ set_in(6);
300set_in(7); 300set_in(7);
301 301
302#define show_temp(offset) \ 302#define show_temp(offset) \
303static ssize_t show_temp##offset##_input(struct device *dev, char *buf) \ 303static ssize_t show_temp##offset##_input(struct device *dev, struct device_attribute *attr, char *buf) \
304{ \ 304{ \
305 struct lm87_data *data = lm87_update_device(dev); \ 305 struct lm87_data *data = lm87_update_device(dev); \
306 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[offset-1])); \ 306 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[offset-1])); \
307} \ 307} \
308static ssize_t show_temp##offset##_low(struct device *dev, char *buf) \ 308static ssize_t show_temp##offset##_low(struct device *dev, struct device_attribute *attr, char *buf) \
309{ \ 309{ \
310 struct lm87_data *data = lm87_update_device(dev); \ 310 struct lm87_data *data = lm87_update_device(dev); \
311 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_low[offset-1])); \ 311 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_low[offset-1])); \
312} \ 312} \
313static ssize_t show_temp##offset##_high(struct device *dev, char *buf) \ 313static ssize_t show_temp##offset##_high(struct device *dev, struct device_attribute *attr, char *buf) \
314{ \ 314{ \
315 struct lm87_data *data = lm87_update_device(dev); \ 315 struct lm87_data *data = lm87_update_device(dev); \
316 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_high[offset-1])); \ 316 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_high[offset-1])); \
@@ -346,13 +346,13 @@ static void set_temp_high(struct device *dev, const char *buf, int nr)
346} 346}
347 347
348#define set_temp(offset) \ 348#define set_temp(offset) \
349static ssize_t set_temp##offset##_low(struct device *dev, \ 349static ssize_t set_temp##offset##_low(struct device *dev, struct device_attribute *attr, \
350 const char *buf, size_t count) \ 350 const char *buf, size_t count) \
351{ \ 351{ \
352 set_temp_low(dev, buf, offset-1); \ 352 set_temp_low(dev, buf, offset-1); \
353 return count; \ 353 return count; \
354} \ 354} \
355static ssize_t set_temp##offset##_high(struct device *dev, \ 355static ssize_t set_temp##offset##_high(struct device *dev, struct device_attribute *attr, \
356 const char *buf, size_t count) \ 356 const char *buf, size_t count) \
357{ \ 357{ \
358 set_temp_high(dev, buf, offset-1); \ 358 set_temp_high(dev, buf, offset-1); \
@@ -366,13 +366,13 @@ set_temp(1);
366set_temp(2); 366set_temp(2);
367set_temp(3); 367set_temp(3);
368 368
369static ssize_t show_temp_crit_int(struct device *dev, char *buf) 369static ssize_t show_temp_crit_int(struct device *dev, struct device_attribute *attr, char *buf)
370{ 370{
371 struct lm87_data *data = lm87_update_device(dev); 371 struct lm87_data *data = lm87_update_device(dev);
372 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_crit_int)); 372 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_crit_int));
373} 373}
374 374
375static ssize_t show_temp_crit_ext(struct device *dev, char *buf) 375static ssize_t show_temp_crit_ext(struct device *dev, struct device_attribute *attr, char *buf)
376{ 376{
377 struct lm87_data *data = lm87_update_device(dev); 377 struct lm87_data *data = lm87_update_device(dev);
378 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_crit_ext)); 378 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_crit_ext));
@@ -383,19 +383,19 @@ static DEVICE_ATTR(temp2_crit, S_IRUGO, show_temp_crit_ext, NULL);
383static DEVICE_ATTR(temp3_crit, S_IRUGO, show_temp_crit_ext, NULL); 383static DEVICE_ATTR(temp3_crit, S_IRUGO, show_temp_crit_ext, NULL);
384 384
385#define show_fan(offset) \ 385#define show_fan(offset) \
386static ssize_t show_fan##offset##_input(struct device *dev, char *buf) \ 386static ssize_t show_fan##offset##_input(struct device *dev, struct device_attribute *attr, char *buf) \
387{ \ 387{ \
388 struct lm87_data *data = lm87_update_device(dev); \ 388 struct lm87_data *data = lm87_update_device(dev); \
389 return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[offset-1], \ 389 return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[offset-1], \
390 FAN_DIV_FROM_REG(data->fan_div[offset-1]))); \ 390 FAN_DIV_FROM_REG(data->fan_div[offset-1]))); \
391} \ 391} \
392static ssize_t show_fan##offset##_min(struct device *dev, char *buf) \ 392static ssize_t show_fan##offset##_min(struct device *dev, struct device_attribute *attr, char *buf) \
393{ \ 393{ \
394 struct lm87_data *data = lm87_update_device(dev); \ 394 struct lm87_data *data = lm87_update_device(dev); \
395 return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan_min[offset-1], \ 395 return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan_min[offset-1], \
396 FAN_DIV_FROM_REG(data->fan_div[offset-1]))); \ 396 FAN_DIV_FROM_REG(data->fan_div[offset-1]))); \
397} \ 397} \
398static ssize_t show_fan##offset##_div(struct device *dev, char *buf) \ 398static ssize_t show_fan##offset##_div(struct device *dev, struct device_attribute *attr, char *buf) \
399{ \ 399{ \
400 struct lm87_data *data = lm87_update_device(dev); \ 400 struct lm87_data *data = lm87_update_device(dev); \
401 return sprintf(buf, "%d\n", FAN_DIV_FROM_REG(data->fan_div[offset-1])); \ 401 return sprintf(buf, "%d\n", FAN_DIV_FROM_REG(data->fan_div[offset-1])); \
@@ -465,13 +465,13 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
465} 465}
466 466
467#define set_fan(offset) \ 467#define set_fan(offset) \
468static ssize_t set_fan##offset##_min(struct device *dev, const char *buf, \ 468static ssize_t set_fan##offset##_min(struct device *dev, struct device_attribute *attr, const char *buf, \
469 size_t count) \ 469 size_t count) \
470{ \ 470{ \
471 set_fan_min(dev, buf, offset-1); \ 471 set_fan_min(dev, buf, offset-1); \
472 return count; \ 472 return count; \
473} \ 473} \
474static ssize_t set_fan##offset##_div(struct device *dev, const char *buf, \ 474static ssize_t set_fan##offset##_div(struct device *dev, struct device_attribute *attr, const char *buf, \
475 size_t count) \ 475 size_t count) \
476{ \ 476{ \
477 return set_fan_div(dev, buf, count, offset-1); \ 477 return set_fan_div(dev, buf, count, offset-1); \
@@ -483,26 +483,26 @@ static DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \
483set_fan(1); 483set_fan(1);
484set_fan(2); 484set_fan(2);
485 485
486static ssize_t show_alarms(struct device *dev, char *buf) 486static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf)
487{ 487{
488 struct lm87_data *data = lm87_update_device(dev); 488 struct lm87_data *data = lm87_update_device(dev);
489 return sprintf(buf, "%d\n", data->alarms); 489 return sprintf(buf, "%d\n", data->alarms);
490} 490}
491static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); 491static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
492 492
493static ssize_t show_vid(struct device *dev, char *buf) 493static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char *buf)
494{ 494{
495 struct lm87_data *data = lm87_update_device(dev); 495 struct lm87_data *data = lm87_update_device(dev);
496 return sprintf(buf, "%d\n", vid_from_reg(data->vid, data->vrm)); 496 return sprintf(buf, "%d\n", vid_from_reg(data->vid, data->vrm));
497} 497}
498static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL); 498static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL);
499 499
500static ssize_t show_vrm(struct device *dev, char *buf) 500static ssize_t show_vrm(struct device *dev, struct device_attribute *attr, char *buf)
501{ 501{
502 struct lm87_data *data = lm87_update_device(dev); 502 struct lm87_data *data = lm87_update_device(dev);
503 return sprintf(buf, "%d\n", data->vrm); 503 return sprintf(buf, "%d\n", data->vrm);
504} 504}
505static ssize_t set_vrm(struct device *dev, const char *buf, size_t count) 505static ssize_t set_vrm(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
506{ 506{
507 struct i2c_client *client = to_i2c_client(dev); 507 struct i2c_client *client = to_i2c_client(dev);
508 struct lm87_data *data = i2c_get_clientdata(client); 508 struct lm87_data *data = i2c_get_clientdata(client);
@@ -511,12 +511,12 @@ static ssize_t set_vrm(struct device *dev, const char *buf, size_t count)
511} 511}
512static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm, set_vrm); 512static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm, set_vrm);
513 513
514static ssize_t show_aout(struct device *dev, char *buf) 514static ssize_t show_aout(struct device *dev, struct device_attribute *attr, char *buf)
515{ 515{
516 struct lm87_data *data = lm87_update_device(dev); 516 struct lm87_data *data = lm87_update_device(dev);
517 return sprintf(buf, "%d\n", AOUT_FROM_REG(data->aout)); 517 return sprintf(buf, "%d\n", AOUT_FROM_REG(data->aout));
518} 518}
519static ssize_t set_aout(struct device *dev, const char *buf, size_t count) 519static ssize_t set_aout(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
520{ 520{
521 struct i2c_client *client = to_i2c_client(dev); 521 struct i2c_client *client = to_i2c_client(dev);
522 struct lm87_data *data = i2c_get_clientdata(client); 522 struct lm87_data *data = i2c_get_clientdata(client);
diff --git a/drivers/i2c/chips/lm90.c b/drivers/i2c/chips/lm90.c
index 2c00ff83babc..9b127a07f56b 100644
--- a/drivers/i2c/chips/lm90.c
+++ b/drivers/i2c/chips/lm90.c
@@ -218,7 +218,7 @@ struct lm90_data {
218 */ 218 */
219 219
220#define show_temp(value, converter) \ 220#define show_temp(value, converter) \
221static ssize_t show_##value(struct device *dev, char *buf) \ 221static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \
222{ \ 222{ \
223 struct lm90_data *data = lm90_update_device(dev); \ 223 struct lm90_data *data = lm90_update_device(dev); \
224 return sprintf(buf, "%d\n", converter(data->value)); \ 224 return sprintf(buf, "%d\n", converter(data->value)); \
@@ -233,7 +233,7 @@ show_temp(temp_crit1, TEMP1_FROM_REG);
233show_temp(temp_crit2, TEMP1_FROM_REG); 233show_temp(temp_crit2, TEMP1_FROM_REG);
234 234
235#define set_temp1(value, reg) \ 235#define set_temp1(value, reg) \
236static ssize_t set_##value(struct device *dev, const char *buf, \ 236static ssize_t set_##value(struct device *dev, struct device_attribute *attr, const char *buf, \
237 size_t count) \ 237 size_t count) \
238{ \ 238{ \
239 struct i2c_client *client = to_i2c_client(dev); \ 239 struct i2c_client *client = to_i2c_client(dev); \
@@ -250,7 +250,7 @@ static ssize_t set_##value(struct device *dev, const char *buf, \
250 return count; \ 250 return count; \
251} 251}
252#define set_temp2(value, regh, regl) \ 252#define set_temp2(value, regh, regl) \
253static ssize_t set_##value(struct device *dev, const char *buf, \ 253static ssize_t set_##value(struct device *dev, struct device_attribute *attr, const char *buf, \
254 size_t count) \ 254 size_t count) \
255{ \ 255{ \
256 struct i2c_client *client = to_i2c_client(dev); \ 256 struct i2c_client *client = to_i2c_client(dev); \
@@ -275,7 +275,7 @@ set_temp1(temp_crit1, LM90_REG_W_LOCAL_CRIT);
275set_temp1(temp_crit2, LM90_REG_W_REMOTE_CRIT); 275set_temp1(temp_crit2, LM90_REG_W_REMOTE_CRIT);
276 276
277#define show_temp_hyst(value, basereg) \ 277#define show_temp_hyst(value, basereg) \
278static ssize_t show_##value(struct device *dev, char *buf) \ 278static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \
279{ \ 279{ \
280 struct lm90_data *data = lm90_update_device(dev); \ 280 struct lm90_data *data = lm90_update_device(dev); \
281 return sprintf(buf, "%d\n", TEMP1_FROM_REG(data->basereg) \ 281 return sprintf(buf, "%d\n", TEMP1_FROM_REG(data->basereg) \
@@ -284,7 +284,7 @@ static ssize_t show_##value(struct device *dev, char *buf) \
284show_temp_hyst(temp_hyst1, temp_crit1); 284show_temp_hyst(temp_hyst1, temp_crit1);
285show_temp_hyst(temp_hyst2, temp_crit2); 285show_temp_hyst(temp_hyst2, temp_crit2);
286 286
287static ssize_t set_temp_hyst1(struct device *dev, const char *buf, 287static ssize_t set_temp_hyst1(struct device *dev, struct device_attribute *attr, const char *buf,
288 size_t count) 288 size_t count)
289{ 289{
290 struct i2c_client *client = to_i2c_client(dev); 290 struct i2c_client *client = to_i2c_client(dev);
@@ -300,7 +300,7 @@ static ssize_t set_temp_hyst1(struct device *dev, const char *buf,
300 return count; 300 return count;
301} 301}
302 302
303static ssize_t show_alarms(struct device *dev, char *buf) 303static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf)
304{ 304{
305 struct lm90_data *data = lm90_update_device(dev); 305 struct lm90_data *data = lm90_update_device(dev);
306 return sprintf(buf, "%d\n", data->alarms); 306 return sprintf(buf, "%d\n", data->alarms);
diff --git a/drivers/i2c/chips/lm92.c b/drivers/i2c/chips/lm92.c
index fe6e83d70a72..215c8e40ffdd 100644
--- a/drivers/i2c/chips/lm92.c
+++ b/drivers/i2c/chips/lm92.c
@@ -140,7 +140,7 @@ static struct lm92_data *lm92_update_device(struct device *dev)
140} 140}
141 141
142#define show_temp(value) \ 142#define show_temp(value) \
143static ssize_t show_##value(struct device *dev, char *buf) \ 143static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \
144{ \ 144{ \
145 struct lm92_data *data = lm92_update_device(dev); \ 145 struct lm92_data *data = lm92_update_device(dev); \
146 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->value)); \ 146 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->value)); \
@@ -151,7 +151,7 @@ show_temp(temp1_min);
151show_temp(temp1_max); 151show_temp(temp1_max);
152 152
153#define set_temp(value, reg) \ 153#define set_temp(value, reg) \
154static ssize_t set_##value(struct device *dev, const char *buf, \ 154static ssize_t set_##value(struct device *dev, struct device_attribute *attr, const char *buf, \
155 size_t count) \ 155 size_t count) \
156{ \ 156{ \
157 struct i2c_client *client = to_i2c_client(dev); \ 157 struct i2c_client *client = to_i2c_client(dev); \
@@ -168,26 +168,26 @@ set_temp(temp1_crit, LM92_REG_TEMP_CRIT);
168set_temp(temp1_min, LM92_REG_TEMP_LOW); 168set_temp(temp1_min, LM92_REG_TEMP_LOW);
169set_temp(temp1_max, LM92_REG_TEMP_HIGH); 169set_temp(temp1_max, LM92_REG_TEMP_HIGH);
170 170
171static ssize_t show_temp1_crit_hyst(struct device *dev, char *buf) 171static ssize_t show_temp1_crit_hyst(struct device *dev, struct device_attribute *attr, char *buf)
172{ 172{
173 struct lm92_data *data = lm92_update_device(dev); 173 struct lm92_data *data = lm92_update_device(dev);
174 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp1_crit) 174 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp1_crit)
175 - TEMP_FROM_REG(data->temp1_hyst)); 175 - TEMP_FROM_REG(data->temp1_hyst));
176} 176}
177static ssize_t show_temp1_max_hyst(struct device *dev, char *buf) 177static ssize_t show_temp1_max_hyst(struct device *dev, struct device_attribute *attr, char *buf)
178{ 178{
179 struct lm92_data *data = lm92_update_device(dev); 179 struct lm92_data *data = lm92_update_device(dev);
180 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp1_max) 180 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp1_max)
181 - TEMP_FROM_REG(data->temp1_hyst)); 181 - TEMP_FROM_REG(data->temp1_hyst));
182} 182}
183static ssize_t show_temp1_min_hyst(struct device *dev, char *buf) 183static ssize_t show_temp1_min_hyst(struct device *dev, struct device_attribute *attr, char *buf)
184{ 184{
185 struct lm92_data *data = lm92_update_device(dev); 185 struct lm92_data *data = lm92_update_device(dev);
186 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp1_min) 186 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp1_min)
187 + TEMP_FROM_REG(data->temp1_hyst)); 187 + TEMP_FROM_REG(data->temp1_hyst));
188} 188}
189 189
190static ssize_t set_temp1_crit_hyst(struct device *dev, const char *buf, 190static ssize_t set_temp1_crit_hyst(struct device *dev, struct device_attribute *attr, const char *buf,
191 size_t count) 191 size_t count)
192{ 192{
193 struct i2c_client *client = to_i2c_client(dev); 193 struct i2c_client *client = to_i2c_client(dev);
@@ -202,7 +202,7 @@ static ssize_t set_temp1_crit_hyst(struct device *dev, const char *buf,
202 return count; 202 return count;
203} 203}
204 204
205static ssize_t show_alarms(struct device *dev, char *buf) 205static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf)
206{ 206{
207 struct lm92_data *data = lm92_update_device(dev); 207 struct lm92_data *data = lm92_update_device(dev);
208 return sprintf(buf, "%d\n", ALARMS_FROM_REG(data->temp1_input)); 208 return sprintf(buf, "%d\n", ALARMS_FROM_REG(data->temp1_input));
diff --git a/drivers/i2c/chips/max1619.c b/drivers/i2c/chips/max1619.c
index 5afa961a5e10..30a196155fd9 100644
--- a/drivers/i2c/chips/max1619.c
+++ b/drivers/i2c/chips/max1619.c
@@ -122,7 +122,7 @@ struct max1619_data {
122 */ 122 */
123 123
124#define show_temp(value) \ 124#define show_temp(value) \
125static ssize_t show_##value(struct device *dev, char *buf) \ 125static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \
126{ \ 126{ \
127 struct max1619_data *data = max1619_update_device(dev); \ 127 struct max1619_data *data = max1619_update_device(dev); \
128 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->value)); \ 128 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->value)); \
@@ -135,7 +135,7 @@ show_temp(temp_crit2);
135show_temp(temp_hyst2); 135show_temp(temp_hyst2);
136 136
137#define set_temp2(value, reg) \ 137#define set_temp2(value, reg) \
138static ssize_t set_##value(struct device *dev, const char *buf, \ 138static ssize_t set_##value(struct device *dev, struct device_attribute *attr, const char *buf, \
139 size_t count) \ 139 size_t count) \
140{ \ 140{ \
141 struct i2c_client *client = to_i2c_client(dev); \ 141 struct i2c_client *client = to_i2c_client(dev); \
@@ -154,7 +154,7 @@ set_temp2(temp_high2, MAX1619_REG_W_REMOTE_HIGH);
154set_temp2(temp_crit2, MAX1619_REG_W_REMOTE_CRIT); 154set_temp2(temp_crit2, MAX1619_REG_W_REMOTE_CRIT);
155set_temp2(temp_hyst2, MAX1619_REG_W_TCRIT_HYST); 155set_temp2(temp_hyst2, MAX1619_REG_W_TCRIT_HYST);
156 156
157static ssize_t show_alarms(struct device *dev, char *buf) 157static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf)
158{ 158{
159 struct max1619_data *data = max1619_update_device(dev); 159 struct max1619_data *data = max1619_update_device(dev);
160 return sprintf(buf, "%d\n", data->alarms); 160 return sprintf(buf, "%d\n", data->alarms);
diff --git a/drivers/i2c/chips/pc87360.c b/drivers/i2c/chips/pc87360.c
index 6d94c36c9218..65637b2cd170 100644
--- a/drivers/i2c/chips/pc87360.c
+++ b/drivers/i2c/chips/pc87360.c
@@ -282,31 +282,31 @@ static ssize_t set_fan_min(struct device *dev, const char *buf,
282} 282}
283 283
284#define show_and_set_fan(offset) \ 284#define show_and_set_fan(offset) \
285static ssize_t show_fan##offset##_input(struct device *dev, char *buf) \ 285static ssize_t show_fan##offset##_input(struct device *dev, struct device_attribute *attr, char *buf) \
286{ \ 286{ \
287 struct pc87360_data *data = pc87360_update_device(dev); \ 287 struct pc87360_data *data = pc87360_update_device(dev); \
288 return sprintf(buf, "%u\n", FAN_FROM_REG(data->fan[offset-1], \ 288 return sprintf(buf, "%u\n", FAN_FROM_REG(data->fan[offset-1], \
289 FAN_DIV_FROM_REG(data->fan_status[offset-1]))); \ 289 FAN_DIV_FROM_REG(data->fan_status[offset-1]))); \
290} \ 290} \
291static ssize_t show_fan##offset##_min(struct device *dev, char *buf) \ 291static ssize_t show_fan##offset##_min(struct device *dev, struct device_attribute *attr, char *buf) \
292{ \ 292{ \
293 struct pc87360_data *data = pc87360_update_device(dev); \ 293 struct pc87360_data *data = pc87360_update_device(dev); \
294 return sprintf(buf, "%u\n", FAN_FROM_REG(data->fan_min[offset-1], \ 294 return sprintf(buf, "%u\n", FAN_FROM_REG(data->fan_min[offset-1], \
295 FAN_DIV_FROM_REG(data->fan_status[offset-1]))); \ 295 FAN_DIV_FROM_REG(data->fan_status[offset-1]))); \
296} \ 296} \
297static ssize_t show_fan##offset##_div(struct device *dev, char *buf) \ 297static ssize_t show_fan##offset##_div(struct device *dev, struct device_attribute *attr, char *buf) \
298{ \ 298{ \
299 struct pc87360_data *data = pc87360_update_device(dev); \ 299 struct pc87360_data *data = pc87360_update_device(dev); \
300 return sprintf(buf, "%u\n", \ 300 return sprintf(buf, "%u\n", \
301 FAN_DIV_FROM_REG(data->fan_status[offset-1])); \ 301 FAN_DIV_FROM_REG(data->fan_status[offset-1])); \
302} \ 302} \
303static ssize_t show_fan##offset##_status(struct device *dev, char *buf) \ 303static ssize_t show_fan##offset##_status(struct device *dev, struct device_attribute *attr, char *buf) \
304{ \ 304{ \
305 struct pc87360_data *data = pc87360_update_device(dev); \ 305 struct pc87360_data *data = pc87360_update_device(dev); \
306 return sprintf(buf, "%u\n", \ 306 return sprintf(buf, "%u\n", \
307 FAN_STATUS_FROM_REG(data->fan_status[offset-1])); \ 307 FAN_STATUS_FROM_REG(data->fan_status[offset-1])); \
308} \ 308} \
309static ssize_t set_fan##offset##_min(struct device *dev, const char *buf, \ 309static ssize_t set_fan##offset##_min(struct device *dev, struct device_attribute *attr, const char *buf, \
310 size_t count) \ 310 size_t count) \
311{ \ 311{ \
312 return set_fan_min(dev, buf, count, offset-1); \ 312 return set_fan_min(dev, buf, count, offset-1); \
@@ -324,7 +324,7 @@ show_and_set_fan(2)
324show_and_set_fan(3) 324show_and_set_fan(3)
325 325
326#define show_and_set_pwm(offset) \ 326#define show_and_set_pwm(offset) \
327static ssize_t show_pwm##offset(struct device *dev, char *buf) \ 327static ssize_t show_pwm##offset(struct device *dev, struct device_attribute *attr, char *buf) \
328{ \ 328{ \
329 struct pc87360_data *data = pc87360_update_device(dev); \ 329 struct pc87360_data *data = pc87360_update_device(dev); \
330 return sprintf(buf, "%u\n", \ 330 return sprintf(buf, "%u\n", \
@@ -332,7 +332,7 @@ static ssize_t show_pwm##offset(struct device *dev, char *buf) \
332 FAN_CONFIG_INVERT(data->fan_conf, \ 332 FAN_CONFIG_INVERT(data->fan_conf, \
333 offset-1))); \ 333 offset-1))); \
334} \ 334} \
335static ssize_t set_pwm##offset(struct device *dev, const char *buf, \ 335static ssize_t set_pwm##offset(struct device *dev, struct device_attribute *attr, const char *buf, \
336 size_t count) \ 336 size_t count) \
337{ \ 337{ \
338 struct i2c_client *client = to_i2c_client(dev); \ 338 struct i2c_client *client = to_i2c_client(dev); \
@@ -354,30 +354,30 @@ show_and_set_pwm(2)
354show_and_set_pwm(3) 354show_and_set_pwm(3)
355 355
356#define show_and_set_in(offset) \ 356#define show_and_set_in(offset) \
357static ssize_t show_in##offset##_input(struct device *dev, char *buf) \ 357static ssize_t show_in##offset##_input(struct device *dev, struct device_attribute *attr, char *buf) \
358{ \ 358{ \
359 struct pc87360_data *data = pc87360_update_device(dev); \ 359 struct pc87360_data *data = pc87360_update_device(dev); \
360 return sprintf(buf, "%u\n", IN_FROM_REG(data->in[offset], \ 360 return sprintf(buf, "%u\n", IN_FROM_REG(data->in[offset], \
361 data->in_vref)); \ 361 data->in_vref)); \
362} \ 362} \
363static ssize_t show_in##offset##_min(struct device *dev, char *buf) \ 363static ssize_t show_in##offset##_min(struct device *dev, struct device_attribute *attr, char *buf) \
364{ \ 364{ \
365 struct pc87360_data *data = pc87360_update_device(dev); \ 365 struct pc87360_data *data = pc87360_update_device(dev); \
366 return sprintf(buf, "%u\n", IN_FROM_REG(data->in_min[offset], \ 366 return sprintf(buf, "%u\n", IN_FROM_REG(data->in_min[offset], \
367 data->in_vref)); \ 367 data->in_vref)); \
368} \ 368} \
369static ssize_t show_in##offset##_max(struct device *dev, char *buf) \ 369static ssize_t show_in##offset##_max(struct device *dev, struct device_attribute *attr, char *buf) \
370{ \ 370{ \
371 struct pc87360_data *data = pc87360_update_device(dev); \ 371 struct pc87360_data *data = pc87360_update_device(dev); \
372 return sprintf(buf, "%u\n", IN_FROM_REG(data->in_max[offset], \ 372 return sprintf(buf, "%u\n", IN_FROM_REG(data->in_max[offset], \
373 data->in_vref)); \ 373 data->in_vref)); \
374} \ 374} \
375static ssize_t show_in##offset##_status(struct device *dev, char *buf) \ 375static ssize_t show_in##offset##_status(struct device *dev, struct device_attribute *attr, char *buf) \
376{ \ 376{ \
377 struct pc87360_data *data = pc87360_update_device(dev); \ 377 struct pc87360_data *data = pc87360_update_device(dev); \
378 return sprintf(buf, "%u\n", data->in_status[offset]); \ 378 return sprintf(buf, "%u\n", data->in_status[offset]); \
379} \ 379} \
380static ssize_t set_in##offset##_min(struct device *dev, const char *buf, \ 380static ssize_t set_in##offset##_min(struct device *dev, struct device_attribute *attr, const char *buf, \
381 size_t count) \ 381 size_t count) \
382{ \ 382{ \
383 struct i2c_client *client = to_i2c_client(dev); \ 383 struct i2c_client *client = to_i2c_client(dev); \
@@ -391,7 +391,7 @@ static ssize_t set_in##offset##_min(struct device *dev, const char *buf, \
391 up(&data->update_lock); \ 391 up(&data->update_lock); \
392 return count; \ 392 return count; \
393} \ 393} \
394static ssize_t set_in##offset##_max(struct device *dev, const char *buf, \ 394static ssize_t set_in##offset##_max(struct device *dev, struct device_attribute *attr, const char *buf, \
395 size_t count) \ 395 size_t count) \
396{ \ 396{ \
397 struct i2c_client *client = to_i2c_client(dev); \ 397 struct i2c_client *client = to_i2c_client(dev); \
@@ -427,36 +427,36 @@ show_and_set_in(9)
427show_and_set_in(10) 427show_and_set_in(10)
428 428
429#define show_and_set_therm(offset) \ 429#define show_and_set_therm(offset) \
430static ssize_t show_temp##offset##_input(struct device *dev, char *buf) \ 430static ssize_t show_temp##offset##_input(struct device *dev, struct device_attribute *attr, char *buf) \
431{ \ 431{ \
432 struct pc87360_data *data = pc87360_update_device(dev); \ 432 struct pc87360_data *data = pc87360_update_device(dev); \
433 return sprintf(buf, "%u\n", IN_FROM_REG(data->in[offset+7], \ 433 return sprintf(buf, "%u\n", IN_FROM_REG(data->in[offset+7], \
434 data->in_vref)); \ 434 data->in_vref)); \
435} \ 435} \
436static ssize_t show_temp##offset##_min(struct device *dev, char *buf) \ 436static ssize_t show_temp##offset##_min(struct device *dev, struct device_attribute *attr, char *buf) \
437{ \ 437{ \
438 struct pc87360_data *data = pc87360_update_device(dev); \ 438 struct pc87360_data *data = pc87360_update_device(dev); \
439 return sprintf(buf, "%u\n", IN_FROM_REG(data->in_min[offset+7], \ 439 return sprintf(buf, "%u\n", IN_FROM_REG(data->in_min[offset+7], \
440 data->in_vref)); \ 440 data->in_vref)); \
441} \ 441} \
442static ssize_t show_temp##offset##_max(struct device *dev, char *buf) \ 442static ssize_t show_temp##offset##_max(struct device *dev, struct device_attribute *attr, char *buf) \
443{ \ 443{ \
444 struct pc87360_data *data = pc87360_update_device(dev); \ 444 struct pc87360_data *data = pc87360_update_device(dev); \
445 return sprintf(buf, "%u\n", IN_FROM_REG(data->in_max[offset+7], \ 445 return sprintf(buf, "%u\n", IN_FROM_REG(data->in_max[offset+7], \
446 data->in_vref)); \ 446 data->in_vref)); \
447} \ 447} \
448static ssize_t show_temp##offset##_crit(struct device *dev, char *buf) \ 448static ssize_t show_temp##offset##_crit(struct device *dev, struct device_attribute *attr, char *buf) \
449{ \ 449{ \
450 struct pc87360_data *data = pc87360_update_device(dev); \ 450 struct pc87360_data *data = pc87360_update_device(dev); \
451 return sprintf(buf, "%u\n", IN_FROM_REG(data->in_crit[offset-4], \ 451 return sprintf(buf, "%u\n", IN_FROM_REG(data->in_crit[offset-4], \
452 data->in_vref)); \ 452 data->in_vref)); \
453} \ 453} \
454static ssize_t show_temp##offset##_status(struct device *dev, char *buf) \ 454static ssize_t show_temp##offset##_status(struct device *dev, struct device_attribute *attr, char *buf) \
455{ \ 455{ \
456 struct pc87360_data *data = pc87360_update_device(dev); \ 456 struct pc87360_data *data = pc87360_update_device(dev); \
457 return sprintf(buf, "%u\n", data->in_status[offset+7]); \ 457 return sprintf(buf, "%u\n", data->in_status[offset+7]); \
458} \ 458} \
459static ssize_t set_temp##offset##_min(struct device *dev, const char *buf, \ 459static ssize_t set_temp##offset##_min(struct device *dev, struct device_attribute *attr, const char *buf, \
460 size_t count) \ 460 size_t count) \
461{ \ 461{ \
462 struct i2c_client *client = to_i2c_client(dev); \ 462 struct i2c_client *client = to_i2c_client(dev); \
@@ -470,7 +470,7 @@ static ssize_t set_temp##offset##_min(struct device *dev, const char *buf, \
470 up(&data->update_lock); \ 470 up(&data->update_lock); \
471 return count; \ 471 return count; \
472} \ 472} \
473static ssize_t set_temp##offset##_max(struct device *dev, const char *buf, \ 473static ssize_t set_temp##offset##_max(struct device *dev, struct device_attribute *attr, const char *buf, \
474 size_t count) \ 474 size_t count) \
475{ \ 475{ \
476 struct i2c_client *client = to_i2c_client(dev); \ 476 struct i2c_client *client = to_i2c_client(dev); \
@@ -484,7 +484,7 @@ static ssize_t set_temp##offset##_max(struct device *dev, const char *buf, \
484 up(&data->update_lock); \ 484 up(&data->update_lock); \
485 return count; \ 485 return count; \
486} \ 486} \
487static ssize_t set_temp##offset##_crit(struct device *dev, const char *buf, \ 487static ssize_t set_temp##offset##_crit(struct device *dev, struct device_attribute *attr, const char *buf, \
488 size_t count) \ 488 size_t count) \
489{ \ 489{ \
490 struct i2c_client *client = to_i2c_client(dev); \ 490 struct i2c_client *client = to_i2c_client(dev); \
@@ -512,19 +512,19 @@ show_and_set_therm(4)
512show_and_set_therm(5) 512show_and_set_therm(5)
513show_and_set_therm(6) 513show_and_set_therm(6)
514 514
515static ssize_t show_vid(struct device *dev, char *buf) 515static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char *buf)
516{ 516{
517 struct pc87360_data *data = pc87360_update_device(dev); 517 struct pc87360_data *data = pc87360_update_device(dev);
518 return sprintf(buf, "%u\n", vid_from_reg(data->vid, data->vrm)); 518 return sprintf(buf, "%u\n", vid_from_reg(data->vid, data->vrm));
519} 519}
520static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL); 520static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL);
521 521
522static ssize_t show_vrm(struct device *dev, char *buf) 522static ssize_t show_vrm(struct device *dev, struct device_attribute *attr, char *buf)
523{ 523{
524 struct pc87360_data *data = pc87360_update_device(dev); 524 struct pc87360_data *data = pc87360_update_device(dev);
525 return sprintf(buf, "%u\n", data->vrm); 525 return sprintf(buf, "%u\n", data->vrm);
526} 526}
527static ssize_t set_vrm(struct device *dev, const char *buf, size_t count) 527static ssize_t set_vrm(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
528{ 528{
529 struct i2c_client *client = to_i2c_client(dev); 529 struct i2c_client *client = to_i2c_client(dev);
530 struct pc87360_data *data = i2c_get_clientdata(client); 530 struct pc87360_data *data = i2c_get_clientdata(client);
@@ -533,7 +533,7 @@ static ssize_t set_vrm(struct device *dev, const char *buf, size_t count)
533} 533}
534static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm, set_vrm); 534static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm, set_vrm);
535 535
536static ssize_t show_in_alarms(struct device *dev, char *buf) 536static ssize_t show_in_alarms(struct device *dev, struct device_attribute *attr, char *buf)
537{ 537{
538 struct pc87360_data *data = pc87360_update_device(dev); 538 struct pc87360_data *data = pc87360_update_device(dev);
539 return sprintf(buf, "%u\n", data->in_alarms); 539 return sprintf(buf, "%u\n", data->in_alarms);
@@ -541,32 +541,32 @@ static ssize_t show_in_alarms(struct device *dev, char *buf)
541static DEVICE_ATTR(alarms_in, S_IRUGO, show_in_alarms, NULL); 541static DEVICE_ATTR(alarms_in, S_IRUGO, show_in_alarms, NULL);
542 542
543#define show_and_set_temp(offset) \ 543#define show_and_set_temp(offset) \
544static ssize_t show_temp##offset##_input(struct device *dev, char *buf) \ 544static ssize_t show_temp##offset##_input(struct device *dev, struct device_attribute *attr, char *buf) \
545{ \ 545{ \
546 struct pc87360_data *data = pc87360_update_device(dev); \ 546 struct pc87360_data *data = pc87360_update_device(dev); \
547 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[offset-1])); \ 547 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[offset-1])); \
548} \ 548} \
549static ssize_t show_temp##offset##_min(struct device *dev, char *buf) \ 549static ssize_t show_temp##offset##_min(struct device *dev, struct device_attribute *attr, char *buf) \
550{ \ 550{ \
551 struct pc87360_data *data = pc87360_update_device(dev); \ 551 struct pc87360_data *data = pc87360_update_device(dev); \
552 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_min[offset-1])); \ 552 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_min[offset-1])); \
553} \ 553} \
554static ssize_t show_temp##offset##_max(struct device *dev, char *buf) \ 554static ssize_t show_temp##offset##_max(struct device *dev, struct device_attribute *attr, char *buf) \
555{ \ 555{ \
556 struct pc87360_data *data = pc87360_update_device(dev); \ 556 struct pc87360_data *data = pc87360_update_device(dev); \
557 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_max[offset-1])); \ 557 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_max[offset-1])); \
558}\ 558}\
559static ssize_t show_temp##offset##_crit(struct device *dev, char *buf) \ 559static ssize_t show_temp##offset##_crit(struct device *dev, struct device_attribute *attr, char *buf) \
560{ \ 560{ \
561 struct pc87360_data *data = pc87360_update_device(dev); \ 561 struct pc87360_data *data = pc87360_update_device(dev); \
562 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_crit[offset-1])); \ 562 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_crit[offset-1])); \
563}\ 563}\
564static ssize_t show_temp##offset##_status(struct device *dev, char *buf) \ 564static ssize_t show_temp##offset##_status(struct device *dev, struct device_attribute *attr, char *buf) \
565{ \ 565{ \
566 struct pc87360_data *data = pc87360_update_device(dev); \ 566 struct pc87360_data *data = pc87360_update_device(dev); \
567 return sprintf(buf, "%d\n", data->temp_status[offset-1]); \ 567 return sprintf(buf, "%d\n", data->temp_status[offset-1]); \
568}\ 568}\
569static ssize_t set_temp##offset##_min(struct device *dev, const char *buf, \ 569static ssize_t set_temp##offset##_min(struct device *dev, struct device_attribute *attr, const char *buf, \
570 size_t count) \ 570 size_t count) \
571{ \ 571{ \
572 struct i2c_client *client = to_i2c_client(dev); \ 572 struct i2c_client *client = to_i2c_client(dev); \
@@ -580,7 +580,7 @@ static ssize_t set_temp##offset##_min(struct device *dev, const char *buf, \
580 up(&data->update_lock); \ 580 up(&data->update_lock); \
581 return count; \ 581 return count; \
582} \ 582} \
583static ssize_t set_temp##offset##_max(struct device *dev, const char *buf, \ 583static ssize_t set_temp##offset##_max(struct device *dev, struct device_attribute *attr, const char *buf, \
584 size_t count) \ 584 size_t count) \
585{ \ 585{ \
586 struct i2c_client *client = to_i2c_client(dev); \ 586 struct i2c_client *client = to_i2c_client(dev); \
@@ -594,7 +594,7 @@ static ssize_t set_temp##offset##_max(struct device *dev, const char *buf, \
594 up(&data->update_lock); \ 594 up(&data->update_lock); \
595 return count; \ 595 return count; \
596} \ 596} \
597static ssize_t set_temp##offset##_crit(struct device *dev, const char *buf, \ 597static ssize_t set_temp##offset##_crit(struct device *dev, struct device_attribute *attr, const char *buf, \
598 size_t count) \ 598 size_t count) \
599{ \ 599{ \
600 struct i2c_client *client = to_i2c_client(dev); \ 600 struct i2c_client *client = to_i2c_client(dev); \
@@ -622,7 +622,7 @@ show_and_set_temp(1)
622show_and_set_temp(2) 622show_and_set_temp(2)
623show_and_set_temp(3) 623show_and_set_temp(3)
624 624
625static ssize_t show_temp_alarms(struct device *dev, char *buf) 625static ssize_t show_temp_alarms(struct device *dev, struct device_attribute *attr, char *buf)
626{ 626{
627 struct pc87360_data *data = pc87360_update_device(dev); 627 struct pc87360_data *data = pc87360_update_device(dev);
628 return sprintf(buf, "%u\n", data->temp_alarms); 628 return sprintf(buf, "%u\n", data->temp_alarms);
diff --git a/drivers/i2c/chips/pcf8574.c b/drivers/i2c/chips/pcf8574.c
index 48b4e22eaffe..4956e9effd75 100644
--- a/drivers/i2c/chips/pcf8574.c
+++ b/drivers/i2c/chips/pcf8574.c
@@ -76,7 +76,7 @@ static struct i2c_driver pcf8574_driver = {
76}; 76};
77 77
78/* following are the sysfs callback functions */ 78/* following are the sysfs callback functions */
79static ssize_t show_read(struct device *dev, char *buf) 79static ssize_t show_read(struct device *dev, struct device_attribute *attr, char *buf)
80{ 80{
81 struct i2c_client *client = to_i2c_client(dev); 81 struct i2c_client *client = to_i2c_client(dev);
82 struct pcf8574_data *data = i2c_get_clientdata(client); 82 struct pcf8574_data *data = i2c_get_clientdata(client);
@@ -86,13 +86,13 @@ static ssize_t show_read(struct device *dev, char *buf)
86 86
87static DEVICE_ATTR(read, S_IRUGO, show_read, NULL); 87static DEVICE_ATTR(read, S_IRUGO, show_read, NULL);
88 88
89static ssize_t show_write(struct device *dev, char *buf) 89static ssize_t show_write(struct device *dev, struct device_attribute *attr, char *buf)
90{ 90{
91 struct pcf8574_data *data = i2c_get_clientdata(to_i2c_client(dev)); 91 struct pcf8574_data *data = i2c_get_clientdata(to_i2c_client(dev));
92 return sprintf(buf, "%u\n", data->write); 92 return sprintf(buf, "%u\n", data->write);
93} 93}
94 94
95static ssize_t set_write(struct device *dev, const char *buf, 95static ssize_t set_write(struct device *dev, struct device_attribute *attr, const char *buf,
96 size_t count) 96 size_t count)
97{ 97{
98 struct i2c_client *client = to_i2c_client(dev); 98 struct i2c_client *client = to_i2c_client(dev);
diff --git a/drivers/i2c/chips/pcf8591.c b/drivers/i2c/chips/pcf8591.c
index b6b927d8b372..db812ade8564 100644
--- a/drivers/i2c/chips/pcf8591.c
+++ b/drivers/i2c/chips/pcf8591.c
@@ -100,7 +100,7 @@ static struct i2c_driver pcf8591_driver = {
100 100
101/* following are the sysfs callback functions */ 101/* following are the sysfs callback functions */
102#define show_in_channel(channel) \ 102#define show_in_channel(channel) \
103static ssize_t show_in##channel##_input(struct device *dev, char *buf) \ 103static ssize_t show_in##channel##_input(struct device *dev, struct device_attribute *attr, char *buf) \
104{ \ 104{ \
105 return sprintf(buf, "%d\n", pcf8591_read_channel(dev, channel));\ 105 return sprintf(buf, "%d\n", pcf8591_read_channel(dev, channel));\
106} \ 106} \
@@ -112,13 +112,13 @@ show_in_channel(1);
112show_in_channel(2); 112show_in_channel(2);
113show_in_channel(3); 113show_in_channel(3);
114 114
115static ssize_t show_out0_ouput(struct device *dev, char *buf) 115static ssize_t show_out0_ouput(struct device *dev, struct device_attribute *attr, char *buf)
116{ 116{
117 struct pcf8591_data *data = i2c_get_clientdata(to_i2c_client(dev)); 117 struct pcf8591_data *data = i2c_get_clientdata(to_i2c_client(dev));
118 return sprintf(buf, "%d\n", data->aout * 10); 118 return sprintf(buf, "%d\n", data->aout * 10);
119} 119}
120 120
121static ssize_t set_out0_output(struct device *dev, const char *buf, size_t count) 121static ssize_t set_out0_output(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
122{ 122{
123 unsigned int value; 123 unsigned int value;
124 struct i2c_client *client = to_i2c_client(dev); 124 struct i2c_client *client = to_i2c_client(dev);
@@ -134,13 +134,13 @@ static ssize_t set_out0_output(struct device *dev, const char *buf, size_t count
134static DEVICE_ATTR(out0_output, S_IWUSR | S_IRUGO, 134static DEVICE_ATTR(out0_output, S_IWUSR | S_IRUGO,
135 show_out0_ouput, set_out0_output); 135 show_out0_ouput, set_out0_output);
136 136
137static ssize_t show_out0_enable(struct device *dev, char *buf) 137static ssize_t show_out0_enable(struct device *dev, struct device_attribute *attr, char *buf)
138{ 138{
139 struct pcf8591_data *data = i2c_get_clientdata(to_i2c_client(dev)); 139 struct pcf8591_data *data = i2c_get_clientdata(to_i2c_client(dev));
140 return sprintf(buf, "%u\n", !(!(data->control & PCF8591_CONTROL_AOEF))); 140 return sprintf(buf, "%u\n", !(!(data->control & PCF8591_CONTROL_AOEF)));
141} 141}
142 142
143static ssize_t set_out0_enable(struct device *dev, const char *buf, size_t count) 143static ssize_t set_out0_enable(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
144{ 144{
145 struct i2c_client *client = to_i2c_client(dev); 145 struct i2c_client *client = to_i2c_client(dev);
146 struct pcf8591_data *data = i2c_get_clientdata(client); 146 struct pcf8591_data *data = i2c_get_clientdata(client);
diff --git a/drivers/i2c/chips/sis5595.c b/drivers/i2c/chips/sis5595.c
index 7ea84532df32..c6650727a27d 100644
--- a/drivers/i2c/chips/sis5595.c
+++ b/drivers/i2c/chips/sis5595.c
@@ -256,28 +256,28 @@ static ssize_t set_in_max(struct device *dev, const char *buf,
256 256
257#define show_in_offset(offset) \ 257#define show_in_offset(offset) \
258static ssize_t \ 258static ssize_t \
259 show_in##offset (struct device *dev, char *buf) \ 259 show_in##offset (struct device *dev, struct device_attribute *attr, char *buf) \
260{ \ 260{ \
261 return show_in(dev, buf, offset); \ 261 return show_in(dev, buf, offset); \
262} \ 262} \
263static DEVICE_ATTR(in##offset##_input, S_IRUGO, \ 263static DEVICE_ATTR(in##offset##_input, S_IRUGO, \
264 show_in##offset, NULL); \ 264 show_in##offset, NULL); \
265static ssize_t \ 265static ssize_t \
266 show_in##offset##_min (struct device *dev, char *buf) \ 266 show_in##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \
267{ \ 267{ \
268 return show_in_min(dev, buf, offset); \ 268 return show_in_min(dev, buf, offset); \
269} \ 269} \
270static ssize_t \ 270static ssize_t \
271 show_in##offset##_max (struct device *dev, char *buf) \ 271 show_in##offset##_max (struct device *dev, struct device_attribute *attr, char *buf) \
272{ \ 272{ \
273 return show_in_max(dev, buf, offset); \ 273 return show_in_max(dev, buf, offset); \
274} \ 274} \
275static ssize_t set_in##offset##_min (struct device *dev, \ 275static ssize_t set_in##offset##_min (struct device *dev, struct device_attribute *attr, \
276 const char *buf, size_t count) \ 276 const char *buf, size_t count) \
277{ \ 277{ \
278 return set_in_min(dev, buf, count, offset); \ 278 return set_in_min(dev, buf, count, offset); \
279} \ 279} \
280static ssize_t set_in##offset##_max (struct device *dev, \ 280static ssize_t set_in##offset##_max (struct device *dev, struct device_attribute *attr, \
281 const char *buf, size_t count) \ 281 const char *buf, size_t count) \
282{ \ 282{ \
283 return set_in_max(dev, buf, count, offset); \ 283 return set_in_max(dev, buf, count, offset); \
@@ -294,19 +294,19 @@ show_in_offset(3);
294show_in_offset(4); 294show_in_offset(4);
295 295
296/* Temperature */ 296/* Temperature */
297static ssize_t show_temp(struct device *dev, char *buf) 297static ssize_t show_temp(struct device *dev, struct device_attribute *attr, char *buf)
298{ 298{
299 struct sis5595_data *data = sis5595_update_device(dev); 299 struct sis5595_data *data = sis5595_update_device(dev);
300 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp)); 300 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp));
301} 301}
302 302
303static ssize_t show_temp_over(struct device *dev, char *buf) 303static ssize_t show_temp_over(struct device *dev, struct device_attribute *attr, char *buf)
304{ 304{
305 struct sis5595_data *data = sis5595_update_device(dev); 305 struct sis5595_data *data = sis5595_update_device(dev);
306 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_over)); 306 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_over));
307} 307}
308 308
309static ssize_t set_temp_over(struct device *dev, const char *buf, size_t count) 309static ssize_t set_temp_over(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
310{ 310{
311 struct i2c_client *client = to_i2c_client(dev); 311 struct i2c_client *client = to_i2c_client(dev);
312 struct sis5595_data *data = i2c_get_clientdata(client); 312 struct sis5595_data *data = i2c_get_clientdata(client);
@@ -319,13 +319,13 @@ static ssize_t set_temp_over(struct device *dev, const char *buf, size_t count)
319 return count; 319 return count;
320} 320}
321 321
322static ssize_t show_temp_hyst(struct device *dev, char *buf) 322static ssize_t show_temp_hyst(struct device *dev, struct device_attribute *attr, char *buf)
323{ 323{
324 struct sis5595_data *data = sis5595_update_device(dev); 324 struct sis5595_data *data = sis5595_update_device(dev);
325 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_hyst)); 325 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_hyst));
326} 326}
327 327
328static ssize_t set_temp_hyst(struct device *dev, const char *buf, size_t count) 328static ssize_t set_temp_hyst(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
329{ 329{
330 struct i2c_client *client = to_i2c_client(dev); 330 struct i2c_client *client = to_i2c_client(dev);
331 struct sis5595_data *data = i2c_get_clientdata(client); 331 struct sis5595_data *data = i2c_get_clientdata(client);
@@ -426,19 +426,19 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
426} 426}
427 427
428#define show_fan_offset(offset) \ 428#define show_fan_offset(offset) \
429static ssize_t show_fan_##offset (struct device *dev, char *buf) \ 429static ssize_t show_fan_##offset (struct device *dev, struct device_attribute *attr, char *buf) \
430{ \ 430{ \
431 return show_fan(dev, buf, offset - 1); \ 431 return show_fan(dev, buf, offset - 1); \
432} \ 432} \
433static ssize_t show_fan_##offset##_min (struct device *dev, char *buf) \ 433static ssize_t show_fan_##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \
434{ \ 434{ \
435 return show_fan_min(dev, buf, offset - 1); \ 435 return show_fan_min(dev, buf, offset - 1); \
436} \ 436} \
437static ssize_t show_fan_##offset##_div (struct device *dev, char *buf) \ 437static ssize_t show_fan_##offset##_div (struct device *dev, struct device_attribute *attr, char *buf) \
438{ \ 438{ \
439 return show_fan_div(dev, buf, offset - 1); \ 439 return show_fan_div(dev, buf, offset - 1); \
440} \ 440} \
441static ssize_t set_fan_##offset##_min (struct device *dev, \ 441static ssize_t set_fan_##offset##_min (struct device *dev, struct device_attribute *attr, \
442 const char *buf, size_t count) \ 442 const char *buf, size_t count) \
443{ \ 443{ \
444 return set_fan_min(dev, buf, count, offset - 1); \ 444 return set_fan_min(dev, buf, count, offset - 1); \
@@ -450,13 +450,13 @@ static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
450show_fan_offset(1); 450show_fan_offset(1);
451show_fan_offset(2); 451show_fan_offset(2);
452 452
453static ssize_t set_fan_1_div(struct device *dev, const char *buf, 453static ssize_t set_fan_1_div(struct device *dev, struct device_attribute *attr, const char *buf,
454 size_t count) 454 size_t count)
455{ 455{
456 return set_fan_div(dev, buf, count, 0) ; 456 return set_fan_div(dev, buf, count, 0) ;
457} 457}
458 458
459static ssize_t set_fan_2_div(struct device *dev, const char *buf, 459static ssize_t set_fan_2_div(struct device *dev, struct device_attribute *attr, const char *buf,
460 size_t count) 460 size_t count)
461{ 461{
462 return set_fan_div(dev, buf, count, 1) ; 462 return set_fan_div(dev, buf, count, 1) ;
@@ -467,7 +467,7 @@ static DEVICE_ATTR(fan2_div, S_IRUGO | S_IWUSR,
467 show_fan_2_div, set_fan_2_div); 467 show_fan_2_div, set_fan_2_div);
468 468
469/* Alarms */ 469/* Alarms */
470static ssize_t show_alarms(struct device *dev, char *buf) 470static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf)
471{ 471{
472 struct sis5595_data *data = sis5595_update_device(dev); 472 struct sis5595_data *data = sis5595_update_device(dev);
473 return sprintf(buf, "%d\n", data->alarms); 473 return sprintf(buf, "%d\n", data->alarms);
diff --git a/drivers/i2c/chips/smsc47b397.c b/drivers/i2c/chips/smsc47b397.c
index 1119c76791d9..251ac2659554 100644
--- a/drivers/i2c/chips/smsc47b397.c
+++ b/drivers/i2c/chips/smsc47b397.c
@@ -172,7 +172,7 @@ static ssize_t show_temp(struct device *dev, char *buf, int nr)
172} 172}
173 173
174#define sysfs_temp(num) \ 174#define sysfs_temp(num) \
175static ssize_t show_temp##num(struct device *dev, char *buf) \ 175static ssize_t show_temp##num(struct device *dev, struct device_attribute *attr, char *buf) \
176{ \ 176{ \
177 return show_temp(dev, buf, num-1); \ 177 return show_temp(dev, buf, num-1); \
178} \ 178} \
@@ -201,7 +201,7 @@ static ssize_t show_fan(struct device *dev, char *buf, int nr)
201} 201}
202 202
203#define sysfs_fan(num) \ 203#define sysfs_fan(num) \
204static ssize_t show_fan##num(struct device *dev, char *buf) \ 204static ssize_t show_fan##num(struct device *dev, struct device_attribute *attr, char *buf) \
205{ \ 205{ \
206 return show_fan(dev, buf, num-1); \ 206 return show_fan(dev, buf, num-1); \
207} \ 207} \
diff --git a/drivers/i2c/chips/smsc47m1.c b/drivers/i2c/chips/smsc47m1.c
index 0e12ca369413..13d6d4a8bc7d 100644
--- a/drivers/i2c/chips/smsc47m1.c
+++ b/drivers/i2c/chips/smsc47m1.c
@@ -184,7 +184,7 @@ static ssize_t get_pwm_en(struct device *dev, char *buf, int nr)
184 return sprintf(buf, "%d\n", PWM_EN_FROM_REG(data->pwm[nr])); 184 return sprintf(buf, "%d\n", PWM_EN_FROM_REG(data->pwm[nr]));
185} 185}
186 186
187static ssize_t get_alarms(struct device *dev, char *buf) 187static ssize_t get_alarms(struct device *dev, struct device_attribute *attr, char *buf)
188{ 188{
189 struct smsc47m1_data *data = smsc47m1_update_device(dev, 0); 189 struct smsc47m1_data *data = smsc47m1_update_device(dev, 0);
190 return sprintf(buf, "%d\n", data->alarms); 190 return sprintf(buf, "%d\n", data->alarms);
@@ -298,42 +298,42 @@ static ssize_t set_pwm_en(struct device *dev, const char *buf,
298} 298}
299 299
300#define fan_present(offset) \ 300#define fan_present(offset) \
301static ssize_t get_fan##offset (struct device *dev, char *buf) \ 301static ssize_t get_fan##offset (struct device *dev, struct device_attribute *attr, char *buf) \
302{ \ 302{ \
303 return get_fan(dev, buf, offset - 1); \ 303 return get_fan(dev, buf, offset - 1); \
304} \ 304} \
305static ssize_t get_fan##offset##_min (struct device *dev, char *buf) \ 305static ssize_t get_fan##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \
306{ \ 306{ \
307 return get_fan_min(dev, buf, offset - 1); \ 307 return get_fan_min(dev, buf, offset - 1); \
308} \ 308} \
309static ssize_t set_fan##offset##_min (struct device *dev, \ 309static ssize_t set_fan##offset##_min (struct device *dev, struct device_attribute *attr, \
310 const char *buf, size_t count) \ 310 const char *buf, size_t count) \
311{ \ 311{ \
312 return set_fan_min(dev, buf, count, offset - 1); \ 312 return set_fan_min(dev, buf, count, offset - 1); \
313} \ 313} \
314static ssize_t get_fan##offset##_div (struct device *dev, char *buf) \ 314static ssize_t get_fan##offset##_div (struct device *dev, struct device_attribute *attr, char *buf) \
315{ \ 315{ \
316 return get_fan_div(dev, buf, offset - 1); \ 316 return get_fan_div(dev, buf, offset - 1); \
317} \ 317} \
318static ssize_t set_fan##offset##_div (struct device *dev, \ 318static ssize_t set_fan##offset##_div (struct device *dev, struct device_attribute *attr, \
319 const char *buf, size_t count) \ 319 const char *buf, size_t count) \
320{ \ 320{ \
321 return set_fan_div(dev, buf, count, offset - 1); \ 321 return set_fan_div(dev, buf, count, offset - 1); \
322} \ 322} \
323static ssize_t get_pwm##offset (struct device *dev, char *buf) \ 323static ssize_t get_pwm##offset (struct device *dev, struct device_attribute *attr, char *buf) \
324{ \ 324{ \
325 return get_pwm(dev, buf, offset - 1); \ 325 return get_pwm(dev, buf, offset - 1); \
326} \ 326} \
327static ssize_t set_pwm##offset (struct device *dev, \ 327static ssize_t set_pwm##offset (struct device *dev, struct device_attribute *attr, \
328 const char *buf, size_t count) \ 328 const char *buf, size_t count) \
329{ \ 329{ \
330 return set_pwm(dev, buf, count, offset - 1); \ 330 return set_pwm(dev, buf, count, offset - 1); \
331} \ 331} \
332static ssize_t get_pwm##offset##_en (struct device *dev, char *buf) \ 332static ssize_t get_pwm##offset##_en (struct device *dev, struct device_attribute *attr, char *buf) \
333{ \ 333{ \
334 return get_pwm_en(dev, buf, offset - 1); \ 334 return get_pwm_en(dev, buf, offset - 1); \
335} \ 335} \
336static ssize_t set_pwm##offset##_en (struct device *dev, \ 336static ssize_t set_pwm##offset##_en (struct device *dev, struct device_attribute *attr, \
337 const char *buf, size_t count) \ 337 const char *buf, size_t count) \
338{ \ 338{ \
339 return set_pwm_en(dev, buf, count, offset - 1); \ 339 return set_pwm_en(dev, buf, count, offset - 1); \
diff --git a/drivers/i2c/chips/via686a.c b/drivers/i2c/chips/via686a.c
index 6614a59cecd4..fefc24a9251a 100644
--- a/drivers/i2c/chips/via686a.c
+++ b/drivers/i2c/chips/via686a.c
@@ -386,26 +386,26 @@ static ssize_t set_in_max(struct device *dev, const char *buf,
386} 386}
387#define show_in_offset(offset) \ 387#define show_in_offset(offset) \
388static ssize_t \ 388static ssize_t \
389 show_in##offset (struct device *dev, char *buf) \ 389 show_in##offset (struct device *dev, struct device_attribute *attr, char *buf) \
390{ \ 390{ \
391 return show_in(dev, buf, offset); \ 391 return show_in(dev, buf, offset); \
392} \ 392} \
393static ssize_t \ 393static ssize_t \
394 show_in##offset##_min (struct device *dev, char *buf) \ 394 show_in##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \
395{ \ 395{ \
396 return show_in_min(dev, buf, offset); \ 396 return show_in_min(dev, buf, offset); \
397} \ 397} \
398static ssize_t \ 398static ssize_t \
399 show_in##offset##_max (struct device *dev, char *buf) \ 399 show_in##offset##_max (struct device *dev, struct device_attribute *attr, char *buf) \
400{ \ 400{ \
401 return show_in_max(dev, buf, offset); \ 401 return show_in_max(dev, buf, offset); \
402} \ 402} \
403static ssize_t set_in##offset##_min (struct device *dev, \ 403static ssize_t set_in##offset##_min (struct device *dev, struct device_attribute *attr, \
404 const char *buf, size_t count) \ 404 const char *buf, size_t count) \
405{ \ 405{ \
406 return set_in_min(dev, buf, count, offset); \ 406 return set_in_min(dev, buf, count, offset); \
407} \ 407} \
408static ssize_t set_in##offset##_max (struct device *dev, \ 408static ssize_t set_in##offset##_max (struct device *dev, struct device_attribute *attr, \
409 const char *buf, size_t count) \ 409 const char *buf, size_t count) \
410{ \ 410{ \
411 return set_in_max(dev, buf, count, offset); \ 411 return set_in_max(dev, buf, count, offset); \
@@ -460,26 +460,26 @@ static ssize_t set_temp_hyst(struct device *dev, const char *buf,
460 return count; 460 return count;
461} 461}
462#define show_temp_offset(offset) \ 462#define show_temp_offset(offset) \
463static ssize_t show_temp_##offset (struct device *dev, char *buf) \ 463static ssize_t show_temp_##offset (struct device *dev, struct device_attribute *attr, char *buf) \
464{ \ 464{ \
465 return show_temp(dev, buf, offset - 1); \ 465 return show_temp(dev, buf, offset - 1); \
466} \ 466} \
467static ssize_t \ 467static ssize_t \
468show_temp_##offset##_over (struct device *dev, char *buf) \ 468show_temp_##offset##_over (struct device *dev, struct device_attribute *attr, char *buf) \
469{ \ 469{ \
470 return show_temp_over(dev, buf, offset - 1); \ 470 return show_temp_over(dev, buf, offset - 1); \
471} \ 471} \
472static ssize_t \ 472static ssize_t \
473show_temp_##offset##_hyst (struct device *dev, char *buf) \ 473show_temp_##offset##_hyst (struct device *dev, struct device_attribute *attr, char *buf) \
474{ \ 474{ \
475 return show_temp_hyst(dev, buf, offset - 1); \ 475 return show_temp_hyst(dev, buf, offset - 1); \
476} \ 476} \
477static ssize_t set_temp_##offset##_over (struct device *dev, \ 477static ssize_t set_temp_##offset##_over (struct device *dev, struct device_attribute *attr, \
478 const char *buf, size_t count) \ 478 const char *buf, size_t count) \
479{ \ 479{ \
480 return set_temp_over(dev, buf, count, offset - 1); \ 480 return set_temp_over(dev, buf, count, offset - 1); \
481} \ 481} \
482static ssize_t set_temp_##offset##_hyst (struct device *dev, \ 482static ssize_t set_temp_##offset##_hyst (struct device *dev, struct device_attribute *attr, \
483 const char *buf, size_t count) \ 483 const char *buf, size_t count) \
484{ \ 484{ \
485 return set_temp_hyst(dev, buf, count, offset - 1); \ 485 return set_temp_hyst(dev, buf, count, offset - 1); \
@@ -538,24 +538,24 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
538} 538}
539 539
540#define show_fan_offset(offset) \ 540#define show_fan_offset(offset) \
541static ssize_t show_fan_##offset (struct device *dev, char *buf) \ 541static ssize_t show_fan_##offset (struct device *dev, struct device_attribute *attr, char *buf) \
542{ \ 542{ \
543 return show_fan(dev, buf, offset - 1); \ 543 return show_fan(dev, buf, offset - 1); \
544} \ 544} \
545static ssize_t show_fan_##offset##_min (struct device *dev, char *buf) \ 545static ssize_t show_fan_##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \
546{ \ 546{ \
547 return show_fan_min(dev, buf, offset - 1); \ 547 return show_fan_min(dev, buf, offset - 1); \
548} \ 548} \
549static ssize_t show_fan_##offset##_div (struct device *dev, char *buf) \ 549static ssize_t show_fan_##offset##_div (struct device *dev, struct device_attribute *attr, char *buf) \
550{ \ 550{ \
551 return show_fan_div(dev, buf, offset - 1); \ 551 return show_fan_div(dev, buf, offset - 1); \
552} \ 552} \
553static ssize_t set_fan_##offset##_min (struct device *dev, \ 553static ssize_t set_fan_##offset##_min (struct device *dev, struct device_attribute *attr, \
554 const char *buf, size_t count) \ 554 const char *buf, size_t count) \
555{ \ 555{ \
556 return set_fan_min(dev, buf, count, offset - 1); \ 556 return set_fan_min(dev, buf, count, offset - 1); \
557} \ 557} \
558static ssize_t set_fan_##offset##_div (struct device *dev, \ 558static ssize_t set_fan_##offset##_div (struct device *dev, struct device_attribute *attr, \
559 const char *buf, size_t count) \ 559 const char *buf, size_t count) \
560{ \ 560{ \
561 return set_fan_div(dev, buf, count, offset - 1); \ 561 return set_fan_div(dev, buf, count, offset - 1); \
@@ -570,7 +570,7 @@ show_fan_offset(1);
570show_fan_offset(2); 570show_fan_offset(2);
571 571
572/* Alarms */ 572/* Alarms */
573static ssize_t show_alarms(struct device *dev, char *buf) { 573static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) {
574 struct via686a_data *data = via686a_update_device(dev); 574 struct via686a_data *data = via686a_update_device(dev);
575 return sprintf(buf,"%d\n", ALARMS_FROM_REG(data->alarms)); 575 return sprintf(buf,"%d\n", ALARMS_FROM_REG(data->alarms));
576} 576}
diff --git a/drivers/i2c/chips/w83627hf.c b/drivers/i2c/chips/w83627hf.c
index b1da5ed696d3..4f1bff572c1c 100644
--- a/drivers/i2c/chips/w83627hf.c
+++ b/drivers/i2c/chips/w83627hf.c
@@ -368,19 +368,19 @@ store_in_reg(MAX, max)
368 368
369#define sysfs_in_offset(offset) \ 369#define sysfs_in_offset(offset) \
370static ssize_t \ 370static ssize_t \
371show_regs_in_##offset (struct device *dev, char *buf) \ 371show_regs_in_##offset (struct device *dev, struct device_attribute *attr, char *buf) \
372{ \ 372{ \
373 return show_in(dev, buf, offset); \ 373 return show_in(dev, buf, offset); \
374} \ 374} \
375static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_regs_in_##offset, NULL); 375static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_regs_in_##offset, NULL);
376 376
377#define sysfs_in_reg_offset(reg, offset) \ 377#define sysfs_in_reg_offset(reg, offset) \
378static ssize_t show_regs_in_##reg##offset (struct device *dev, char *buf) \ 378static ssize_t show_regs_in_##reg##offset (struct device *dev, struct device_attribute *attr, char *buf) \
379{ \ 379{ \
380 return show_in_##reg (dev, buf, offset); \ 380 return show_in_##reg (dev, buf, offset); \
381} \ 381} \
382static ssize_t \ 382static ssize_t \
383store_regs_in_##reg##offset (struct device *dev, \ 383store_regs_in_##reg##offset (struct device *dev, struct device_attribute *attr, \
384 const char *buf, size_t count) \ 384 const char *buf, size_t count) \
385{ \ 385{ \
386 return store_in_##reg (dev, buf, count, offset); \ 386 return store_in_##reg (dev, buf, count, offset); \
@@ -419,25 +419,25 @@ static ssize_t show_in_0(struct w83627hf_data *data, char *buf, u8 reg)
419 return sprintf(buf,"%ld\n", in0); 419 return sprintf(buf,"%ld\n", in0);
420} 420}
421 421
422static ssize_t show_regs_in_0(struct device *dev, char *buf) 422static ssize_t show_regs_in_0(struct device *dev, struct device_attribute *attr, char *buf)
423{ 423{
424 struct w83627hf_data *data = w83627hf_update_device(dev); 424 struct w83627hf_data *data = w83627hf_update_device(dev);
425 return show_in_0(data, buf, data->in[0]); 425 return show_in_0(data, buf, data->in[0]);
426} 426}
427 427
428static ssize_t show_regs_in_min0(struct device *dev, char *buf) 428static ssize_t show_regs_in_min0(struct device *dev, struct device_attribute *attr, char *buf)
429{ 429{
430 struct w83627hf_data *data = w83627hf_update_device(dev); 430 struct w83627hf_data *data = w83627hf_update_device(dev);
431 return show_in_0(data, buf, data->in_min[0]); 431 return show_in_0(data, buf, data->in_min[0]);
432} 432}
433 433
434static ssize_t show_regs_in_max0(struct device *dev, char *buf) 434static ssize_t show_regs_in_max0(struct device *dev, struct device_attribute *attr, char *buf)
435{ 435{
436 struct w83627hf_data *data = w83627hf_update_device(dev); 436 struct w83627hf_data *data = w83627hf_update_device(dev);
437 return show_in_0(data, buf, data->in_max[0]); 437 return show_in_0(data, buf, data->in_max[0]);
438} 438}
439 439
440static ssize_t store_regs_in_min0(struct device *dev, 440static ssize_t store_regs_in_min0(struct device *dev, struct device_attribute *attr,
441 const char *buf, size_t count) 441 const char *buf, size_t count)
442{ 442{
443 struct i2c_client *client = to_i2c_client(dev); 443 struct i2c_client *client = to_i2c_client(dev);
@@ -462,7 +462,7 @@ static ssize_t store_regs_in_min0(struct device *dev,
462 return count; 462 return count;
463} 463}
464 464
465static ssize_t store_regs_in_max0(struct device *dev, 465static ssize_t store_regs_in_max0(struct device *dev, struct device_attribute *attr,
466 const char *buf, size_t count) 466 const char *buf, size_t count)
467{ 467{
468 struct i2c_client *client = to_i2c_client(dev); 468 struct i2c_client *client = to_i2c_client(dev);
@@ -531,19 +531,19 @@ store_fan_min(struct device *dev, const char *buf, size_t count, int nr)
531} 531}
532 532
533#define sysfs_fan_offset(offset) \ 533#define sysfs_fan_offset(offset) \
534static ssize_t show_regs_fan_##offset (struct device *dev, char *buf) \ 534static ssize_t show_regs_fan_##offset (struct device *dev, struct device_attribute *attr, char *buf) \
535{ \ 535{ \
536 return show_fan(dev, buf, offset); \ 536 return show_fan(dev, buf, offset); \
537} \ 537} \
538static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_regs_fan_##offset, NULL); 538static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_regs_fan_##offset, NULL);
539 539
540#define sysfs_fan_min_offset(offset) \ 540#define sysfs_fan_min_offset(offset) \
541static ssize_t show_regs_fan_min##offset (struct device *dev, char *buf) \ 541static ssize_t show_regs_fan_min##offset (struct device *dev, struct device_attribute *attr, char *buf) \
542{ \ 542{ \
543 return show_fan_min(dev, buf, offset); \ 543 return show_fan_min(dev, buf, offset); \
544} \ 544} \
545static ssize_t \ 545static ssize_t \
546store_regs_fan_min##offset (struct device *dev, const char *buf, size_t count) \ 546store_regs_fan_min##offset (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \
547{ \ 547{ \
548 return store_fan_min(dev, buf, count, offset); \ 548 return store_fan_min(dev, buf, count, offset); \
549} \ 549} \
@@ -608,19 +608,19 @@ store_temp_reg(HYST, max_hyst);
608 608
609#define sysfs_temp_offset(offset) \ 609#define sysfs_temp_offset(offset) \
610static ssize_t \ 610static ssize_t \
611show_regs_temp_##offset (struct device *dev, char *buf) \ 611show_regs_temp_##offset (struct device *dev, struct device_attribute *attr, char *buf) \
612{ \ 612{ \
613 return show_temp(dev, buf, offset); \ 613 return show_temp(dev, buf, offset); \
614} \ 614} \
615static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_regs_temp_##offset, NULL); 615static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_regs_temp_##offset, NULL);
616 616
617#define sysfs_temp_reg_offset(reg, offset) \ 617#define sysfs_temp_reg_offset(reg, offset) \
618static ssize_t show_regs_temp_##reg##offset (struct device *dev, char *buf) \ 618static ssize_t show_regs_temp_##reg##offset (struct device *dev, struct device_attribute *attr, char *buf) \
619{ \ 619{ \
620 return show_temp_##reg (dev, buf, offset); \ 620 return show_temp_##reg (dev, buf, offset); \
621} \ 621} \
622static ssize_t \ 622static ssize_t \
623store_regs_temp_##reg##offset (struct device *dev, \ 623store_regs_temp_##reg##offset (struct device *dev, struct device_attribute *attr, \
624 const char *buf, size_t count) \ 624 const char *buf, size_t count) \
625{ \ 625{ \
626 return store_temp_##reg (dev, buf, count, offset); \ 626 return store_temp_##reg (dev, buf, count, offset); \
@@ -645,7 +645,7 @@ device_create_file(&client->dev, &dev_attr_temp##offset##_max_hyst); \
645} while (0) 645} while (0)
646 646
647static ssize_t 647static ssize_t
648show_vid_reg(struct device *dev, char *buf) 648show_vid_reg(struct device *dev, struct device_attribute *attr, char *buf)
649{ 649{
650 struct w83627hf_data *data = w83627hf_update_device(dev); 650 struct w83627hf_data *data = w83627hf_update_device(dev);
651 return sprintf(buf, "%ld\n", (long) vid_from_reg(data->vid, data->vrm)); 651 return sprintf(buf, "%ld\n", (long) vid_from_reg(data->vid, data->vrm));
@@ -655,13 +655,13 @@ static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid_reg, NULL);
655device_create_file(&client->dev, &dev_attr_cpu0_vid) 655device_create_file(&client->dev, &dev_attr_cpu0_vid)
656 656
657static ssize_t 657static ssize_t
658show_vrm_reg(struct device *dev, char *buf) 658show_vrm_reg(struct device *dev, struct device_attribute *attr, char *buf)
659{ 659{
660 struct w83627hf_data *data = w83627hf_update_device(dev); 660 struct w83627hf_data *data = w83627hf_update_device(dev);
661 return sprintf(buf, "%ld\n", (long) data->vrm); 661 return sprintf(buf, "%ld\n", (long) data->vrm);
662} 662}
663static ssize_t 663static ssize_t
664store_vrm_reg(struct device *dev, const char *buf, size_t count) 664store_vrm_reg(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
665{ 665{
666 struct i2c_client *client = to_i2c_client(dev); 666 struct i2c_client *client = to_i2c_client(dev);
667 struct w83627hf_data *data = i2c_get_clientdata(client); 667 struct w83627hf_data *data = i2c_get_clientdata(client);
@@ -677,7 +677,7 @@ static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg);
677device_create_file(&client->dev, &dev_attr_vrm) 677device_create_file(&client->dev, &dev_attr_vrm)
678 678
679static ssize_t 679static ssize_t
680show_alarms_reg(struct device *dev, char *buf) 680show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf)
681{ 681{
682 struct w83627hf_data *data = w83627hf_update_device(dev); 682 struct w83627hf_data *data = w83627hf_update_device(dev);
683 return sprintf(buf, "%ld\n", (long) data->alarms); 683 return sprintf(buf, "%ld\n", (long) data->alarms);
@@ -687,7 +687,7 @@ static DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL);
687device_create_file(&client->dev, &dev_attr_alarms) 687device_create_file(&client->dev, &dev_attr_alarms)
688 688
689#define show_beep_reg(REG, reg) \ 689#define show_beep_reg(REG, reg) \
690static ssize_t show_beep_##reg (struct device *dev, char *buf) \ 690static ssize_t show_beep_##reg (struct device *dev, struct device_attribute *attr, char *buf) \
691{ \ 691{ \
692 struct w83627hf_data *data = w83627hf_update_device(dev); \ 692 struct w83627hf_data *data = w83627hf_update_device(dev); \
693 return sprintf(buf,"%ld\n", \ 693 return sprintf(buf,"%ld\n", \
@@ -732,12 +732,12 @@ store_beep_reg(struct device *dev, const char *buf, size_t count,
732} 732}
733 733
734#define sysfs_beep(REG, reg) \ 734#define sysfs_beep(REG, reg) \
735static ssize_t show_regs_beep_##reg (struct device *dev, char *buf) \ 735static ssize_t show_regs_beep_##reg (struct device *dev, struct device_attribute *attr, char *buf) \
736{ \ 736{ \
737 return show_beep_##reg(dev, buf); \ 737 return show_beep_##reg(dev, attr, buf); \
738} \ 738} \
739static ssize_t \ 739static ssize_t \
740store_regs_beep_##reg (struct device *dev, const char *buf, size_t count) \ 740store_regs_beep_##reg (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \
741{ \ 741{ \
742 return store_beep_reg(dev, buf, count, BEEP_##REG); \ 742 return store_beep_reg(dev, buf, count, BEEP_##REG); \
743} \ 743} \
@@ -801,12 +801,12 @@ store_fan_div_reg(struct device *dev, const char *buf, size_t count, int nr)
801} 801}
802 802
803#define sysfs_fan_div(offset) \ 803#define sysfs_fan_div(offset) \
804static ssize_t show_regs_fan_div_##offset (struct device *dev, char *buf) \ 804static ssize_t show_regs_fan_div_##offset (struct device *dev, struct device_attribute *attr, char *buf) \
805{ \ 805{ \
806 return show_fan_div_reg(dev, buf, offset); \ 806 return show_fan_div_reg(dev, buf, offset); \
807} \ 807} \
808static ssize_t \ 808static ssize_t \
809store_regs_fan_div_##offset (struct device *dev, \ 809store_regs_fan_div_##offset (struct device *dev, struct device_attribute *attr, \
810 const char *buf, size_t count) \ 810 const char *buf, size_t count) \
811{ \ 811{ \
812 return store_fan_div_reg(dev, buf, count, offset - 1); \ 812 return store_fan_div_reg(dev, buf, count, offset - 1); \
@@ -861,12 +861,12 @@ store_pwm_reg(struct device *dev, const char *buf, size_t count, int nr)
861} 861}
862 862
863#define sysfs_pwm(offset) \ 863#define sysfs_pwm(offset) \
864static ssize_t show_regs_pwm_##offset (struct device *dev, char *buf) \ 864static ssize_t show_regs_pwm_##offset (struct device *dev, struct device_attribute *attr, char *buf) \
865{ \ 865{ \
866 return show_pwm_reg(dev, buf, offset); \ 866 return show_pwm_reg(dev, buf, offset); \
867} \ 867} \
868static ssize_t \ 868static ssize_t \
869store_regs_pwm_##offset (struct device *dev, const char *buf, size_t count) \ 869store_regs_pwm_##offset (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \
870{ \ 870{ \
871 return store_pwm_reg(dev, buf, count, offset); \ 871 return store_pwm_reg(dev, buf, count, offset); \
872} \ 872} \
@@ -937,12 +937,12 @@ store_sensor_reg(struct device *dev, const char *buf, size_t count, int nr)
937} 937}
938 938
939#define sysfs_sensor(offset) \ 939#define sysfs_sensor(offset) \
940static ssize_t show_regs_sensor_##offset (struct device *dev, char *buf) \ 940static ssize_t show_regs_sensor_##offset (struct device *dev, struct device_attribute *attr, char *buf) \
941{ \ 941{ \
942 return show_sensor_reg(dev, buf, offset); \ 942 return show_sensor_reg(dev, buf, offset); \
943} \ 943} \
944static ssize_t \ 944static ssize_t \
945store_regs_sensor_##offset (struct device *dev, const char *buf, size_t count) \ 945store_regs_sensor_##offset (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \
946{ \ 946{ \
947 return store_sensor_reg(dev, buf, count, offset); \ 947 return store_sensor_reg(dev, buf, count, offset); \
948} \ 948} \
diff --git a/drivers/i2c/chips/w83781d.c b/drivers/i2c/chips/w83781d.c
index 4954e465c419..c3926d2d8ac6 100644
--- a/drivers/i2c/chips/w83781d.c
+++ b/drivers/i2c/chips/w83781d.c
@@ -309,18 +309,18 @@ store_in_reg(MAX, max);
309 309
310#define sysfs_in_offset(offset) \ 310#define sysfs_in_offset(offset) \
311static ssize_t \ 311static ssize_t \
312show_regs_in_##offset (struct device *dev, char *buf) \ 312show_regs_in_##offset (struct device *dev, struct device_attribute *attr, char *buf) \
313{ \ 313{ \
314 return show_in(dev, buf, offset); \ 314 return show_in(dev, buf, offset); \
315} \ 315} \
316static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_regs_in_##offset, NULL); 316static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_regs_in_##offset, NULL);
317 317
318#define sysfs_in_reg_offset(reg, offset) \ 318#define sysfs_in_reg_offset(reg, offset) \
319static ssize_t show_regs_in_##reg##offset (struct device *dev, char *buf) \ 319static ssize_t show_regs_in_##reg##offset (struct device *dev, struct device_attribute *attr, char *buf) \
320{ \ 320{ \
321 return show_in_##reg (dev, buf, offset); \ 321 return show_in_##reg (dev, buf, offset); \
322} \ 322} \
323static ssize_t store_regs_in_##reg##offset (struct device *dev, const char *buf, size_t count) \ 323static ssize_t store_regs_in_##reg##offset (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \
324{ \ 324{ \
325 return store_in_##reg (dev, buf, count, offset); \ 325 return store_in_##reg (dev, buf, count, offset); \
326} \ 326} \
@@ -378,18 +378,18 @@ store_fan_min(struct device *dev, const char *buf, size_t count, int nr)
378} 378}
379 379
380#define sysfs_fan_offset(offset) \ 380#define sysfs_fan_offset(offset) \
381static ssize_t show_regs_fan_##offset (struct device *dev, char *buf) \ 381static ssize_t show_regs_fan_##offset (struct device *dev, struct device_attribute *attr, char *buf) \
382{ \ 382{ \
383 return show_fan(dev, buf, offset); \ 383 return show_fan(dev, buf, offset); \
384} \ 384} \
385static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_regs_fan_##offset, NULL); 385static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_regs_fan_##offset, NULL);
386 386
387#define sysfs_fan_min_offset(offset) \ 387#define sysfs_fan_min_offset(offset) \
388static ssize_t show_regs_fan_min##offset (struct device *dev, char *buf) \ 388static ssize_t show_regs_fan_min##offset (struct device *dev, struct device_attribute *attr, char *buf) \
389{ \ 389{ \
390 return show_fan_min(dev, buf, offset); \ 390 return show_fan_min(dev, buf, offset); \
391} \ 391} \
392static ssize_t store_regs_fan_min##offset (struct device *dev, const char *buf, size_t count) \ 392static ssize_t store_regs_fan_min##offset (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \
393{ \ 393{ \
394 return store_fan_min(dev, buf, count, offset); \ 394 return store_fan_min(dev, buf, count, offset); \
395} \ 395} \
@@ -452,18 +452,18 @@ store_temp_reg(HYST, max_hyst);
452 452
453#define sysfs_temp_offset(offset) \ 453#define sysfs_temp_offset(offset) \
454static ssize_t \ 454static ssize_t \
455show_regs_temp_##offset (struct device *dev, char *buf) \ 455show_regs_temp_##offset (struct device *dev, struct device_attribute *attr, char *buf) \
456{ \ 456{ \
457 return show_temp(dev, buf, offset); \ 457 return show_temp(dev, buf, offset); \
458} \ 458} \
459static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_regs_temp_##offset, NULL); 459static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_regs_temp_##offset, NULL);
460 460
461#define sysfs_temp_reg_offset(reg, offset) \ 461#define sysfs_temp_reg_offset(reg, offset) \
462static ssize_t show_regs_temp_##reg##offset (struct device *dev, char *buf) \ 462static ssize_t show_regs_temp_##reg##offset (struct device *dev, struct device_attribute *attr, char *buf) \
463{ \ 463{ \
464 return show_temp_##reg (dev, buf, offset); \ 464 return show_temp_##reg (dev, buf, offset); \
465} \ 465} \
466static ssize_t store_regs_temp_##reg##offset (struct device *dev, const char *buf, size_t count) \ 466static ssize_t store_regs_temp_##reg##offset (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \
467{ \ 467{ \
468 return store_temp_##reg (dev, buf, count, offset); \ 468 return store_temp_##reg (dev, buf, count, offset); \
469} \ 469} \
@@ -486,7 +486,7 @@ device_create_file(&client->dev, &dev_attr_temp##offset##_max_hyst); \
486} while (0) 486} while (0)
487 487
488static ssize_t 488static ssize_t
489show_vid_reg(struct device *dev, char *buf) 489show_vid_reg(struct device *dev, struct device_attribute *attr, char *buf)
490{ 490{
491 struct w83781d_data *data = w83781d_update_device(dev); 491 struct w83781d_data *data = w83781d_update_device(dev);
492 return sprintf(buf, "%ld\n", (long) vid_from_reg(data->vid, data->vrm)); 492 return sprintf(buf, "%ld\n", (long) vid_from_reg(data->vid, data->vrm));
@@ -497,14 +497,14 @@ DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid_reg, NULL);
497#define device_create_file_vid(client) \ 497#define device_create_file_vid(client) \
498device_create_file(&client->dev, &dev_attr_cpu0_vid); 498device_create_file(&client->dev, &dev_attr_cpu0_vid);
499static ssize_t 499static ssize_t
500show_vrm_reg(struct device *dev, char *buf) 500show_vrm_reg(struct device *dev, struct device_attribute *attr, char *buf)
501{ 501{
502 struct w83781d_data *data = w83781d_update_device(dev); 502 struct w83781d_data *data = w83781d_update_device(dev);
503 return sprintf(buf, "%ld\n", (long) data->vrm); 503 return sprintf(buf, "%ld\n", (long) data->vrm);
504} 504}
505 505
506static ssize_t 506static ssize_t
507store_vrm_reg(struct device *dev, const char *buf, size_t count) 507store_vrm_reg(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
508{ 508{
509 struct i2c_client *client = to_i2c_client(dev); 509 struct i2c_client *client = to_i2c_client(dev);
510 struct w83781d_data *data = i2c_get_clientdata(client); 510 struct w83781d_data *data = i2c_get_clientdata(client);
@@ -521,7 +521,7 @@ DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg);
521#define device_create_file_vrm(client) \ 521#define device_create_file_vrm(client) \
522device_create_file(&client->dev, &dev_attr_vrm); 522device_create_file(&client->dev, &dev_attr_vrm);
523static ssize_t 523static ssize_t
524show_alarms_reg(struct device *dev, char *buf) 524show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf)
525{ 525{
526 struct w83781d_data *data = w83781d_update_device(dev); 526 struct w83781d_data *data = w83781d_update_device(dev);
527 return sprintf(buf, "%ld\n", (long) ALARMS_FROM_REG(data->alarms)); 527 return sprintf(buf, "%ld\n", (long) ALARMS_FROM_REG(data->alarms));
@@ -531,13 +531,13 @@ static
531DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL); 531DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL);
532#define device_create_file_alarms(client) \ 532#define device_create_file_alarms(client) \
533device_create_file(&client->dev, &dev_attr_alarms); 533device_create_file(&client->dev, &dev_attr_alarms);
534static ssize_t show_beep_mask (struct device *dev, char *buf) 534static ssize_t show_beep_mask (struct device *dev, struct device_attribute *attr, char *buf)
535{ 535{
536 struct w83781d_data *data = w83781d_update_device(dev); 536 struct w83781d_data *data = w83781d_update_device(dev);
537 return sprintf(buf, "%ld\n", 537 return sprintf(buf, "%ld\n",
538 (long)BEEP_MASK_FROM_REG(data->beep_mask, data->type)); 538 (long)BEEP_MASK_FROM_REG(data->beep_mask, data->type));
539} 539}
540static ssize_t show_beep_enable (struct device *dev, char *buf) 540static ssize_t show_beep_enable (struct device *dev, struct device_attribute *attr, char *buf)
541{ 541{
542 struct w83781d_data *data = w83781d_update_device(dev); 542 struct w83781d_data *data = w83781d_update_device(dev);
543 return sprintf(buf, "%ld\n", 543 return sprintf(buf, "%ld\n",
@@ -583,11 +583,11 @@ store_beep_reg(struct device *dev, const char *buf, size_t count,
583} 583}
584 584
585#define sysfs_beep(REG, reg) \ 585#define sysfs_beep(REG, reg) \
586static ssize_t show_regs_beep_##reg (struct device *dev, char *buf) \ 586static ssize_t show_regs_beep_##reg (struct device *dev, struct device_attribute *attr, char *buf) \
587{ \ 587{ \
588 return show_beep_##reg(dev, buf); \ 588 return show_beep_##reg(dev, attr, buf); \
589} \ 589} \
590static ssize_t store_regs_beep_##reg (struct device *dev, const char *buf, size_t count) \ 590static ssize_t store_regs_beep_##reg (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \
591{ \ 591{ \
592 return store_beep_reg(dev, buf, count, BEEP_##REG); \ 592 return store_beep_reg(dev, buf, count, BEEP_##REG); \
593} \ 593} \
@@ -653,11 +653,11 @@ store_fan_div_reg(struct device *dev, const char *buf, size_t count, int nr)
653} 653}
654 654
655#define sysfs_fan_div(offset) \ 655#define sysfs_fan_div(offset) \
656static ssize_t show_regs_fan_div_##offset (struct device *dev, char *buf) \ 656static ssize_t show_regs_fan_div_##offset (struct device *dev, struct device_attribute *attr, char *buf) \
657{ \ 657{ \
658 return show_fan_div_reg(dev, buf, offset); \ 658 return show_fan_div_reg(dev, buf, offset); \
659} \ 659} \
660static ssize_t store_regs_fan_div_##offset (struct device *dev, const char *buf, size_t count) \ 660static ssize_t store_regs_fan_div_##offset (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \
661{ \ 661{ \
662 return store_fan_div_reg(dev, buf, count, offset - 1); \ 662 return store_fan_div_reg(dev, buf, count, offset - 1); \
663} \ 663} \
@@ -737,11 +737,11 @@ store_pwmenable_reg(struct device *dev, const char *buf, size_t count, int nr)
737} 737}
738 738
739#define sysfs_pwm(offset) \ 739#define sysfs_pwm(offset) \
740static ssize_t show_regs_pwm_##offset (struct device *dev, char *buf) \ 740static ssize_t show_regs_pwm_##offset (struct device *dev, struct device_attribute *attr, char *buf) \
741{ \ 741{ \
742 return show_pwm_reg(dev, buf, offset); \ 742 return show_pwm_reg(dev, buf, offset); \
743} \ 743} \
744static ssize_t store_regs_pwm_##offset (struct device *dev, \ 744static ssize_t store_regs_pwm_##offset (struct device *dev, struct device_attribute *attr, \
745 const char *buf, size_t count) \ 745 const char *buf, size_t count) \
746{ \ 746{ \
747 return store_pwm_reg(dev, buf, count, offset); \ 747 return store_pwm_reg(dev, buf, count, offset); \
@@ -750,11 +750,11 @@ static DEVICE_ATTR(pwm##offset, S_IRUGO | S_IWUSR, \
750 show_regs_pwm_##offset, store_regs_pwm_##offset); 750 show_regs_pwm_##offset, store_regs_pwm_##offset);
751 751
752#define sysfs_pwmenable(offset) \ 752#define sysfs_pwmenable(offset) \
753static ssize_t show_regs_pwmenable_##offset (struct device *dev, char *buf) \ 753static ssize_t show_regs_pwmenable_##offset (struct device *dev, struct device_attribute *attr, char *buf) \
754{ \ 754{ \
755 return show_pwmenable_reg(dev, buf, offset); \ 755 return show_pwmenable_reg(dev, buf, offset); \
756} \ 756} \
757static ssize_t store_regs_pwmenable_##offset (struct device *dev, \ 757static ssize_t store_regs_pwmenable_##offset (struct device *dev, struct device_attribute *attr, \
758 const char *buf, size_t count) \ 758 const char *buf, size_t count) \
759{ \ 759{ \
760 return store_pwmenable_reg(dev, buf, count, offset); \ 760 return store_pwmenable_reg(dev, buf, count, offset); \
@@ -832,11 +832,11 @@ store_sensor_reg(struct device *dev, const char *buf, size_t count, int nr)
832} 832}
833 833
834#define sysfs_sensor(offset) \ 834#define sysfs_sensor(offset) \
835static ssize_t show_regs_sensor_##offset (struct device *dev, char *buf) \ 835static ssize_t show_regs_sensor_##offset (struct device *dev, struct device_attribute *attr, char *buf) \
836{ \ 836{ \
837 return show_sensor_reg(dev, buf, offset); \ 837 return show_sensor_reg(dev, buf, offset); \
838} \ 838} \
839static ssize_t store_regs_sensor_##offset (struct device *dev, const char *buf, size_t count) \ 839static ssize_t store_regs_sensor_##offset (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \
840{ \ 840{ \
841 return store_sensor_reg(dev, buf, count, offset); \ 841 return store_sensor_reg(dev, buf, count, offset); \
842} \ 842} \
diff --git a/drivers/i2c/chips/w83l785ts.c b/drivers/i2c/chips/w83l785ts.c
index 59bbc5881fa6..74d4b58e4237 100644
--- a/drivers/i2c/chips/w83l785ts.c
+++ b/drivers/i2c/chips/w83l785ts.c
@@ -118,13 +118,13 @@ struct w83l785ts_data {
118 * Sysfs stuff 118 * Sysfs stuff
119 */ 119 */
120 120
121static ssize_t show_temp(struct device *dev, char *buf) 121static ssize_t show_temp(struct device *dev, struct device_attribute *attr, char *buf)
122{ 122{
123 struct w83l785ts_data *data = w83l785ts_update_device(dev); 123 struct w83l785ts_data *data = w83l785ts_update_device(dev);
124 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp)); 124 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp));
125} 125}
126 126
127static ssize_t show_temp_over(struct device *dev, char *buf) 127static ssize_t show_temp_over(struct device *dev, struct device_attribute *attr, char *buf)
128{ 128{
129 struct w83l785ts_data *data = w83l785ts_update_device(dev); 129 struct w83l785ts_data *data = w83l785ts_update_device(dev);
130 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_over)); 130 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_over));
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 9011627d7eb0..a22e53badacb 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -103,7 +103,7 @@ static struct class i2c_adapter_class = {
103 .release = &i2c_adapter_class_dev_release, 103 .release = &i2c_adapter_class_dev_release,
104}; 104};
105 105
106static ssize_t show_adapter_name(struct device *dev, char *buf) 106static ssize_t show_adapter_name(struct device *dev, struct device_attribute *attr, char *buf)
107{ 107{
108 struct i2c_adapter *adap = dev_to_i2c_adapter(dev); 108 struct i2c_adapter *adap = dev_to_i2c_adapter(dev);
109 return sprintf(buf, "%s\n", adap->name); 109 return sprintf(buf, "%s\n", adap->name);
@@ -117,7 +117,7 @@ static void i2c_client_release(struct device *dev)
117 complete(&client->released); 117 complete(&client->released);
118} 118}
119 119
120static ssize_t show_client_name(struct device *dev, char *buf) 120static ssize_t show_client_name(struct device *dev, struct device_attribute *attr, char *buf)
121{ 121{
122 struct i2c_client *client = to_i2c_client(dev); 122 struct i2c_client *client = to_i2c_client(dev);
123 return sprintf(buf, "%s\n", client->name); 123 return sprintf(buf, "%s\n", client->name);
diff --git a/drivers/ieee1394/dv1394.c b/drivers/ieee1394/dv1394.c
index 68c7a5f07842..4538b0235ca3 100644
--- a/drivers/ieee1394/dv1394.c
+++ b/drivers/ieee1394/dv1394.c
@@ -2343,8 +2343,8 @@ static void dv1394_remove_host (struct hpsb_host *host)
2343 dv1394_un_init(video); 2343 dv1394_un_init(video);
2344 } while (video != NULL); 2344 } while (video != NULL);
2345 2345
2346 class_simple_device_remove(MKDEV( 2346 class_device_destroy(hpsb_protocol_class,
2347 IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_DV1394 * 16 + (id<<2))); 2347 MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_DV1394 * 16 + (id<<2)));
2348 devfs_remove("ieee1394/dv/host%d/NTSC", id); 2348 devfs_remove("ieee1394/dv/host%d/NTSC", id);
2349 devfs_remove("ieee1394/dv/host%d/PAL", id); 2349 devfs_remove("ieee1394/dv/host%d/PAL", id);
2350 devfs_remove("ieee1394/dv/host%d", id); 2350 devfs_remove("ieee1394/dv/host%d", id);
@@ -2361,7 +2361,7 @@ static void dv1394_add_host (struct hpsb_host *host)
2361 2361
2362 ohci = (struct ti_ohci *)host->hostdata; 2362 ohci = (struct ti_ohci *)host->hostdata;
2363 2363
2364 class_simple_device_add(hpsb_protocol_class, MKDEV( 2364 class_device_create(hpsb_protocol_class, MKDEV(
2365 IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_DV1394 * 16 + (id<<2)), 2365 IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_DV1394 * 16 + (id<<2)),
2366 NULL, "dv1394-%d", id); 2366 NULL, "dv1394-%d", id);
2367 devfs_mk_dir("ieee1394/dv/host%d", id); 2367 devfs_mk_dir("ieee1394/dv/host%d", id);
diff --git a/drivers/ieee1394/ieee1394_core.c b/drivers/ieee1394/ieee1394_core.c
index a294e45c77cd..2d9a9b74e687 100644
--- a/drivers/ieee1394/ieee1394_core.c
+++ b/drivers/ieee1394/ieee1394_core.c
@@ -67,7 +67,7 @@ MODULE_LICENSE("GPL");
67 67
68/* Some globals used */ 68/* Some globals used */
69const char *hpsb_speedto_str[] = { "S100", "S200", "S400", "S800", "S1600", "S3200" }; 69const char *hpsb_speedto_str[] = { "S100", "S200", "S400", "S800", "S1600", "S3200" };
70struct class_simple *hpsb_protocol_class; 70struct class *hpsb_protocol_class;
71 71
72#ifdef CONFIG_IEEE1394_VERBOSEDEBUG 72#ifdef CONFIG_IEEE1394_VERBOSEDEBUG
73static void dump_packet(const char *text, quadlet_t *data, int size) 73static void dump_packet(const char *text, quadlet_t *data, int size)
@@ -1121,7 +1121,7 @@ static int __init ieee1394_init(void)
1121 if (ret < 0) 1121 if (ret < 0)
1122 goto release_all_bus; 1122 goto release_all_bus;
1123 1123
1124 hpsb_protocol_class = class_simple_create(THIS_MODULE, "ieee1394_protocol"); 1124 hpsb_protocol_class = class_create(THIS_MODULE, "ieee1394_protocol");
1125 if (IS_ERR(hpsb_protocol_class)) { 1125 if (IS_ERR(hpsb_protocol_class)) {
1126 ret = PTR_ERR(hpsb_protocol_class); 1126 ret = PTR_ERR(hpsb_protocol_class);
1127 goto release_class_host; 1127 goto release_class_host;
@@ -1159,7 +1159,7 @@ static int __init ieee1394_init(void)
1159cleanup_csr: 1159cleanup_csr:
1160 cleanup_csr(); 1160 cleanup_csr();
1161release_class_protocol: 1161release_class_protocol:
1162 class_simple_destroy(hpsb_protocol_class); 1162 class_destroy(hpsb_protocol_class);
1163release_class_host: 1163release_class_host:
1164 class_unregister(&hpsb_host_class); 1164 class_unregister(&hpsb_host_class);
1165release_all_bus: 1165release_all_bus:
@@ -1189,7 +1189,7 @@ static void __exit ieee1394_cleanup(void)
1189 1189
1190 cleanup_csr(); 1190 cleanup_csr();
1191 1191
1192 class_simple_destroy(hpsb_protocol_class); 1192 class_destroy(hpsb_protocol_class);
1193 class_unregister(&hpsb_host_class); 1193 class_unregister(&hpsb_host_class);
1194 for (i = 0; fw_bus_attrs[i]; i++) 1194 for (i = 0; fw_bus_attrs[i]; i++)
1195 bus_remove_file(&ieee1394_bus_type, fw_bus_attrs[i]); 1195 bus_remove_file(&ieee1394_bus_type, fw_bus_attrs[i]);
diff --git a/drivers/ieee1394/ieee1394_core.h b/drivers/ieee1394/ieee1394_core.h
index c4b4408e2e05..73bd8efd2b6c 100644
--- a/drivers/ieee1394/ieee1394_core.h
+++ b/drivers/ieee1394/ieee1394_core.h
@@ -223,6 +223,7 @@ extern int hpsb_disable_irm;
223/* Our sysfs bus entry */ 223/* Our sysfs bus entry */
224extern struct bus_type ieee1394_bus_type; 224extern struct bus_type ieee1394_bus_type;
225extern struct class hpsb_host_class; 225extern struct class hpsb_host_class;
226extern struct class_simple *hpsb_protocol_class; 226extern struct class *hpsb_protocol_class;
227 227
228#endif /* _IEEE1394_CORE_H */ 228#endif /* _IEEE1394_CORE_H */
229
diff --git a/drivers/ieee1394/nodemgr.c b/drivers/ieee1394/nodemgr.c
index 83e66ed97ab5..32abb6dda888 100644
--- a/drivers/ieee1394/nodemgr.c
+++ b/drivers/ieee1394/nodemgr.c
@@ -220,7 +220,7 @@ struct device nodemgr_dev_template_host = {
220 220
221 221
222#define fw_attr(class, class_type, field, type, format_string) \ 222#define fw_attr(class, class_type, field, type, format_string) \
223static ssize_t fw_show_##class##_##field (struct device *dev, char *buf)\ 223static ssize_t fw_show_##class##_##field (struct device *dev, struct device_attribute *attr, char *buf)\
224{ \ 224{ \
225 class_type *class; \ 225 class_type *class; \
226 class = container_of(dev, class_type, device); \ 226 class = container_of(dev, class_type, device); \
@@ -232,7 +232,7 @@ static struct device_attribute dev_attr_##class##_##field = { \
232}; 232};
233 233
234#define fw_attr_td(class, class_type, td_kv) \ 234#define fw_attr_td(class, class_type, td_kv) \
235static ssize_t fw_show_##class##_##td_kv (struct device *dev, char *buf)\ 235static ssize_t fw_show_##class##_##td_kv (struct device *dev, struct device_attribute *attr, char *buf)\
236{ \ 236{ \
237 int len; \ 237 int len; \
238 class_type *class = container_of(dev, class_type, device); \ 238 class_type *class = container_of(dev, class_type, device); \
@@ -265,7 +265,7 @@ static struct driver_attribute driver_attr_drv_##field = { \
265}; 265};
266 266
267 267
268static ssize_t fw_show_ne_bus_options(struct device *dev, char *buf) 268static ssize_t fw_show_ne_bus_options(struct device *dev, struct device_attribute *attr, char *buf)
269{ 269{
270 struct node_entry *ne = container_of(dev, struct node_entry, device); 270 struct node_entry *ne = container_of(dev, struct node_entry, device);
271 271
@@ -281,7 +281,7 @@ static ssize_t fw_show_ne_bus_options(struct device *dev, char *buf)
281static DEVICE_ATTR(bus_options,S_IRUGO,fw_show_ne_bus_options,NULL); 281static DEVICE_ATTR(bus_options,S_IRUGO,fw_show_ne_bus_options,NULL);
282 282
283 283
284static ssize_t fw_show_ne_tlabels_free(struct device *dev, char *buf) 284static ssize_t fw_show_ne_tlabels_free(struct device *dev, struct device_attribute *attr, char *buf)
285{ 285{
286 struct node_entry *ne = container_of(dev, struct node_entry, device); 286 struct node_entry *ne = container_of(dev, struct node_entry, device);
287 return sprintf(buf, "%d\n", atomic_read(&ne->tpool->count.count) + 1); 287 return sprintf(buf, "%d\n", atomic_read(&ne->tpool->count.count) + 1);
@@ -289,7 +289,7 @@ static ssize_t fw_show_ne_tlabels_free(struct device *dev, char *buf)
289static DEVICE_ATTR(tlabels_free,S_IRUGO,fw_show_ne_tlabels_free,NULL); 289static DEVICE_ATTR(tlabels_free,S_IRUGO,fw_show_ne_tlabels_free,NULL);
290 290
291 291
292static ssize_t fw_show_ne_tlabels_allocations(struct device *dev, char *buf) 292static ssize_t fw_show_ne_tlabels_allocations(struct device *dev, struct device_attribute *attr, char *buf)
293{ 293{
294 struct node_entry *ne = container_of(dev, struct node_entry, device); 294 struct node_entry *ne = container_of(dev, struct node_entry, device);
295 return sprintf(buf, "%u\n", ne->tpool->allocations); 295 return sprintf(buf, "%u\n", ne->tpool->allocations);
@@ -297,7 +297,7 @@ static ssize_t fw_show_ne_tlabels_allocations(struct device *dev, char *buf)
297static DEVICE_ATTR(tlabels_allocations,S_IRUGO,fw_show_ne_tlabels_allocations,NULL); 297static DEVICE_ATTR(tlabels_allocations,S_IRUGO,fw_show_ne_tlabels_allocations,NULL);
298 298
299 299
300static ssize_t fw_show_ne_tlabels_mask(struct device *dev, char *buf) 300static ssize_t fw_show_ne_tlabels_mask(struct device *dev, struct device_attribute *attr, char *buf)
301{ 301{
302 struct node_entry *ne = container_of(dev, struct node_entry, device); 302 struct node_entry *ne = container_of(dev, struct node_entry, device);
303#if (BITS_PER_LONG <= 32) 303#if (BITS_PER_LONG <= 32)
@@ -309,7 +309,7 @@ static ssize_t fw_show_ne_tlabels_mask(struct device *dev, char *buf)
309static DEVICE_ATTR(tlabels_mask, S_IRUGO, fw_show_ne_tlabels_mask, NULL); 309static DEVICE_ATTR(tlabels_mask, S_IRUGO, fw_show_ne_tlabels_mask, NULL);
310 310
311 311
312static ssize_t fw_set_ignore_driver(struct device *dev, const char *buf, size_t count) 312static ssize_t fw_set_ignore_driver(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
313{ 313{
314 struct unit_directory *ud = container_of(dev, struct unit_directory, device); 314 struct unit_directory *ud = container_of(dev, struct unit_directory, device);
315 int state = simple_strtoul(buf, NULL, 10); 315 int state = simple_strtoul(buf, NULL, 10);
@@ -324,7 +324,7 @@ static ssize_t fw_set_ignore_driver(struct device *dev, const char *buf, size_t
324 324
325 return count; 325 return count;
326} 326}
327static ssize_t fw_get_ignore_driver(struct device *dev, char *buf) 327static ssize_t fw_get_ignore_driver(struct device *dev, struct device_attribute *attr, char *buf)
328{ 328{
329 struct unit_directory *ud = container_of(dev, struct unit_directory, device); 329 struct unit_directory *ud = container_of(dev, struct unit_directory, device);
330 330
@@ -695,14 +695,15 @@ static void nodemgr_remove_ne(struct node_entry *ne)
695 put_device(dev); 695 put_device(dev);
696} 696}
697 697
698static int __nodemgr_remove_host_dev(struct device *dev, void *data)
699{
700 nodemgr_remove_ne(container_of(dev, struct node_entry, device));
701 return 0;
702}
698 703
699static void nodemgr_remove_host_dev(struct device *dev) 704static void nodemgr_remove_host_dev(struct device *dev)
700{ 705{
701 struct device *ne_dev, *next; 706 device_for_each_child(dev, NULL, __nodemgr_remove_host_dev);
702
703 list_for_each_entry_safe(ne_dev, next, &dev->children, node)
704 nodemgr_remove_ne(container_of(ne_dev, struct node_entry, device));
705
706 sysfs_remove_link(&dev->kobj, "irm_id"); 707 sysfs_remove_link(&dev->kobj, "irm_id");
707 sysfs_remove_link(&dev->kobj, "busmgr_id"); 708 sysfs_remove_link(&dev->kobj, "busmgr_id");
708 sysfs_remove_link(&dev->kobj, "host_id"); 709 sysfs_remove_link(&dev->kobj, "host_id");
diff --git a/drivers/ieee1394/raw1394.c b/drivers/ieee1394/raw1394.c
index 6a08a8982ea8..7419af450bd1 100644
--- a/drivers/ieee1394/raw1394.c
+++ b/drivers/ieee1394/raw1394.c
@@ -2901,7 +2901,7 @@ static int __init init_raw1394(void)
2901 2901
2902 hpsb_register_highlevel(&raw1394_highlevel); 2902 hpsb_register_highlevel(&raw1394_highlevel);
2903 2903
2904 if (IS_ERR(class_simple_device_add(hpsb_protocol_class, MKDEV( 2904 if (IS_ERR(class_device_create(hpsb_protocol_class, MKDEV(
2905 IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16), 2905 IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16),
2906 NULL, RAW1394_DEVICE_NAME))) { 2906 NULL, RAW1394_DEVICE_NAME))) {
2907 ret = -EFAULT; 2907 ret = -EFAULT;
@@ -2934,8 +2934,8 @@ static int __init init_raw1394(void)
2934 2934
2935out_dev: 2935out_dev:
2936 devfs_remove(RAW1394_DEVICE_NAME); 2936 devfs_remove(RAW1394_DEVICE_NAME);
2937 class_simple_device_remove(MKDEV( 2937 class_device_destroy(hpsb_protocol_class,
2938 IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16)); 2938 MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16));
2939out_unreg: 2939out_unreg:
2940 hpsb_unregister_highlevel(&raw1394_highlevel); 2940 hpsb_unregister_highlevel(&raw1394_highlevel);
2941out: 2941out:
@@ -2944,8 +2944,8 @@ out:
2944 2944
2945static void __exit cleanup_raw1394(void) 2945static void __exit cleanup_raw1394(void)
2946{ 2946{
2947 class_simple_device_remove(MKDEV( 2947 class_device_destroy(hpsb_protocol_class,
2948 IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16)); 2948 MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16));
2949 cdev_del(&raw1394_cdev); 2949 cdev_del(&raw1394_cdev);
2950 devfs_remove(RAW1394_DEVICE_NAME); 2950 devfs_remove(RAW1394_DEVICE_NAME);
2951 hpsb_unregister_highlevel(&raw1394_highlevel); 2951 hpsb_unregister_highlevel(&raw1394_highlevel);
diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c
index 2bae300aad46..32368f3428ec 100644
--- a/drivers/ieee1394/sbp2.c
+++ b/drivers/ieee1394/sbp2.c
@@ -2648,7 +2648,7 @@ static const char *sbp2scsi_info (struct Scsi_Host *host)
2648 return "SCSI emulation for IEEE-1394 SBP-2 Devices"; 2648 return "SCSI emulation for IEEE-1394 SBP-2 Devices";
2649} 2649}
2650 2650
2651static ssize_t sbp2_sysfs_ieee1394_id_show(struct device *dev, char *buf) 2651static ssize_t sbp2_sysfs_ieee1394_id_show(struct device *dev, struct device_attribute *attr, char *buf)
2652{ 2652{
2653 struct scsi_device *sdev; 2653 struct scsi_device *sdev;
2654 struct scsi_id_instance_data *scsi_id; 2654 struct scsi_id_instance_data *scsi_id;
diff --git a/drivers/ieee1394/video1394.c b/drivers/ieee1394/video1394.c
index d68c4658f2fc..06759b36afea 100644
--- a/drivers/ieee1394/video1394.c
+++ b/drivers/ieee1394/video1394.c
@@ -1370,7 +1370,7 @@ static void video1394_add_host (struct hpsb_host *host)
1370 hpsb_set_hostinfo_key(&video1394_highlevel, host, ohci->host->id); 1370 hpsb_set_hostinfo_key(&video1394_highlevel, host, ohci->host->id);
1371 1371
1372 minor = IEEE1394_MINOR_BLOCK_VIDEO1394 * 16 + ohci->host->id; 1372 minor = IEEE1394_MINOR_BLOCK_VIDEO1394 * 16 + ohci->host->id;
1373 class_simple_device_add(hpsb_protocol_class, MKDEV( 1373 class_device_create(hpsb_protocol_class, MKDEV(
1374 IEEE1394_MAJOR, minor), 1374 IEEE1394_MAJOR, minor),
1375 NULL, "%s-%d", VIDEO1394_DRIVER_NAME, ohci->host->id); 1375 NULL, "%s-%d", VIDEO1394_DRIVER_NAME, ohci->host->id);
1376 devfs_mk_cdev(MKDEV(IEEE1394_MAJOR, minor), 1376 devfs_mk_cdev(MKDEV(IEEE1394_MAJOR, minor),
@@ -1384,7 +1384,7 @@ static void video1394_remove_host (struct hpsb_host *host)
1384 struct ti_ohci *ohci = hpsb_get_hostinfo(&video1394_highlevel, host); 1384 struct ti_ohci *ohci = hpsb_get_hostinfo(&video1394_highlevel, host);
1385 1385
1386 if (ohci) { 1386 if (ohci) {
1387 class_simple_device_remove(MKDEV(IEEE1394_MAJOR, 1387 class_device_destroy(hpsb_protocol_class, MKDEV(IEEE1394_MAJOR,
1388 IEEE1394_MINOR_BLOCK_VIDEO1394 * 16 + ohci->host->id)); 1388 IEEE1394_MINOR_BLOCK_VIDEO1394 * 16 + ohci->host->id));
1389 devfs_remove("%s/%d", VIDEO1394_DRIVER_NAME, ohci->host->id); 1389 devfs_remove("%s/%d", VIDEO1394_DRIVER_NAME, ohci->host->id);
1390 } 1390 }
diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
index 3a413f72ff6d..90d51b179abe 100644
--- a/drivers/infiniband/core/sysfs.c
+++ b/drivers/infiniband/core/sysfs.c
@@ -40,9 +40,7 @@ struct ib_port {
40 struct kobject kobj; 40 struct kobject kobj;
41 struct ib_device *ibdev; 41 struct ib_device *ibdev;
42 struct attribute_group gid_group; 42 struct attribute_group gid_group;
43 struct attribute **gid_attr;
44 struct attribute_group pkey_group; 43 struct attribute_group pkey_group;
45 struct attribute **pkey_attr;
46 u8 port_num; 44 u8 port_num;
47}; 45};
48 46
@@ -60,8 +58,9 @@ struct port_attribute port_attr_##_name = __ATTR(_name, _mode, _show, _store)
60struct port_attribute port_attr_##_name = __ATTR_RO(_name) 58struct port_attribute port_attr_##_name = __ATTR_RO(_name)
61 59
62struct port_table_attribute { 60struct port_table_attribute {
63 struct port_attribute attr; 61 struct port_attribute attr;
64 int index; 62 char name[8];
63 int index;
65}; 64};
66 65
67static ssize_t port_attr_show(struct kobject *kobj, 66static ssize_t port_attr_show(struct kobject *kobj,
@@ -72,7 +71,7 @@ static ssize_t port_attr_show(struct kobject *kobj,
72 struct ib_port *p = container_of(kobj, struct ib_port, kobj); 71 struct ib_port *p = container_of(kobj, struct ib_port, kobj);
73 72
74 if (!port_attr->show) 73 if (!port_attr->show)
75 return 0; 74 return -EIO;
76 75
77 return port_attr->show(p, port_attr, buf); 76 return port_attr->show(p, port_attr, buf);
78} 77}
@@ -398,17 +397,16 @@ static void ib_port_release(struct kobject *kobj)
398 struct attribute *a; 397 struct attribute *a;
399 int i; 398 int i;
400 399
401 for (i = 0; (a = p->gid_attr[i]); ++i) { 400 for (i = 0; (a = p->gid_group.attrs[i]); ++i)
402 kfree(a->name);
403 kfree(a); 401 kfree(a);
404 }
405 402
406 for (i = 0; (a = p->pkey_attr[i]); ++i) { 403 kfree(p->gid_group.attrs);
407 kfree(a->name); 404
405 for (i = 0; (a = p->pkey_group.attrs[i]); ++i)
408 kfree(a); 406 kfree(a);
409 }
410 407
411 kfree(p->gid_attr); 408 kfree(p->pkey_group.attrs);
409
412 kfree(p); 410 kfree(p);
413} 411}
414 412
@@ -449,58 +447,45 @@ static int ib_device_hotplug(struct class_device *cdev, char **envp,
449 return 0; 447 return 0;
450} 448}
451 449
452static int alloc_group(struct attribute ***attr, 450static struct attribute **
453 ssize_t (*show)(struct ib_port *, 451alloc_group_attrs(ssize_t (*show)(struct ib_port *,
454 struct port_attribute *, char *buf), 452 struct port_attribute *, char *buf),
455 int len) 453 int len)
456{ 454{
457 struct port_table_attribute ***tab_attr = 455 struct attribute **tab_attr;
458 (struct port_table_attribute ***) attr; 456 struct port_table_attribute *element;
459 int i; 457 int i;
460 int ret;
461
462 *tab_attr = kmalloc((1 + len) * sizeof *tab_attr, GFP_KERNEL);
463 if (!*tab_attr)
464 return -ENOMEM;
465 458
466 memset(*tab_attr, 0, (1 + len) * sizeof *tab_attr); 459 tab_attr = kcalloc(1 + len, sizeof(struct attribute *), GFP_KERNEL);
460 if (!tab_attr)
461 return NULL;
467 462
468 for (i = 0; i < len; ++i) { 463 for (i = 0; i < len; i++) {
469 (*tab_attr)[i] = kmalloc(sizeof *(*tab_attr)[i], GFP_KERNEL); 464 element = kcalloc(1, sizeof(struct port_table_attribute),
470 if (!(*tab_attr)[i]) { 465 GFP_KERNEL);
471 ret = -ENOMEM; 466 if (!element)
472 goto err; 467 goto err;
473 }
474 memset((*tab_attr)[i], 0, sizeof *(*tab_attr)[i]);
475 (*tab_attr)[i]->attr.attr.name = kmalloc(8, GFP_KERNEL);
476 if (!(*tab_attr)[i]->attr.attr.name) {
477 ret = -ENOMEM;
478 goto err;
479 }
480 468
481 if (snprintf((*tab_attr)[i]->attr.attr.name, 8, "%d", i) >= 8) { 469 if (snprintf(element->name, sizeof(element->name),
482 ret = -ENOMEM; 470 "%d", i) >= sizeof(element->name))
483 goto err; 471 goto err;
484 }
485 472
486 (*tab_attr)[i]->attr.attr.mode = S_IRUGO; 473 element->attr.attr.name = element->name;
487 (*tab_attr)[i]->attr.attr.owner = THIS_MODULE; 474 element->attr.attr.mode = S_IRUGO;
488 (*tab_attr)[i]->attr.show = show; 475 element->attr.attr.owner = THIS_MODULE;
489 (*tab_attr)[i]->index = i; 476 element->attr.show = show;
490 } 477 element->index = i;
491
492 return 0;
493 478
494err: 479 tab_attr[i] = &element->attr.attr;
495 for (i = 0; i < len; ++i) {
496 if ((*tab_attr)[i])
497 kfree((*tab_attr)[i]->attr.attr.name);
498 kfree((*tab_attr)[i]);
499 } 480 }
500 481
501 kfree(*tab_attr); 482 return tab_attr;
502 483
503 return ret; 484err:
485 while (--i >= 0)
486 kfree(tab_attr[i]);
487 kfree(tab_attr);
488 return NULL;
504} 489}
505 490
506static int add_port(struct ib_device *device, int port_num) 491static int add_port(struct ib_device *device, int port_num)
@@ -541,23 +526,20 @@ static int add_port(struct ib_device *device, int port_num)
541 if (ret) 526 if (ret)
542 goto err_put; 527 goto err_put;
543 528
544 ret = alloc_group(&p->gid_attr, show_port_gid, attr.gid_tbl_len);
545 if (ret)
546 goto err_remove_pma;
547
548 p->gid_group.name = "gids"; 529 p->gid_group.name = "gids";
549 p->gid_group.attrs = p->gid_attr; 530 p->gid_group.attrs = alloc_group_attrs(show_port_gid, attr.gid_tbl_len);
531 if (!p->gid_group.attrs)
532 goto err_remove_pma;
550 533
551 ret = sysfs_create_group(&p->kobj, &p->gid_group); 534 ret = sysfs_create_group(&p->kobj, &p->gid_group);
552 if (ret) 535 if (ret)
553 goto err_free_gid; 536 goto err_free_gid;
554 537
555 ret = alloc_group(&p->pkey_attr, show_port_pkey, attr.pkey_tbl_len);
556 if (ret)
557 goto err_remove_gid;
558
559 p->pkey_group.name = "pkeys"; 538 p->pkey_group.name = "pkeys";
560 p->pkey_group.attrs = p->pkey_attr; 539 p->pkey_group.attrs = alloc_group_attrs(show_port_pkey,
540 attr.pkey_tbl_len);
541 if (!p->pkey_group.attrs)
542 goto err_remove_gid;
561 543
562 ret = sysfs_create_group(&p->kobj, &p->pkey_group); 544 ret = sysfs_create_group(&p->kobj, &p->pkey_group);
563 if (ret) 545 if (ret)
@@ -568,23 +550,19 @@ static int add_port(struct ib_device *device, int port_num)
568 return 0; 550 return 0;
569 551
570err_free_pkey: 552err_free_pkey:
571 for (i = 0; i < attr.pkey_tbl_len; ++i) { 553 for (i = 0; i < attr.pkey_tbl_len; ++i)
572 kfree(p->pkey_attr[i]->name); 554 kfree(p->pkey_group.attrs[i]);
573 kfree(p->pkey_attr[i]);
574 }
575 555
576 kfree(p->pkey_attr); 556 kfree(p->pkey_group.attrs);
577 557
578err_remove_gid: 558err_remove_gid:
579 sysfs_remove_group(&p->kobj, &p->gid_group); 559 sysfs_remove_group(&p->kobj, &p->gid_group);
580 560
581err_free_gid: 561err_free_gid:
582 for (i = 0; i < attr.gid_tbl_len; ++i) { 562 for (i = 0; i < attr.gid_tbl_len; ++i)
583 kfree(p->gid_attr[i]->name); 563 kfree(p->gid_group.attrs[i]);
584 kfree(p->gid_attr[i]);
585 }
586 564
587 kfree(p->gid_attr); 565 kfree(p->gid_group.attrs);
588 566
589err_remove_pma: 567err_remove_pma:
590 sysfs_remove_group(&p->kobj, &pma_group); 568 sysfs_remove_group(&p->kobj, &pma_group);
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index 17552a29978b..556264b43425 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -431,9 +431,9 @@ static struct input_handle *evdev_connect(struct input_handler *handler, struct
431 431
432 devfs_mk_cdev(MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + minor), 432 devfs_mk_cdev(MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + minor),
433 S_IFCHR|S_IRUGO|S_IWUSR, "input/event%d", minor); 433 S_IFCHR|S_IRUGO|S_IWUSR, "input/event%d", minor);
434 class_simple_device_add(input_class, 434 class_device_create(input_class,
435 MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + minor), 435 MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + minor),
436 dev->dev, "event%d", minor); 436 dev->dev, "event%d", minor);
437 437
438 return &evdev->handle; 438 return &evdev->handle;
439} 439}
@@ -443,7 +443,8 @@ static void evdev_disconnect(struct input_handle *handle)
443 struct evdev *evdev = handle->private; 443 struct evdev *evdev = handle->private;
444 struct evdev_list *list; 444 struct evdev_list *list;
445 445
446 class_simple_device_remove(MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + evdev->minor)); 446 class_device_destroy(input_class,
447 MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + evdev->minor));
447 devfs_remove("input/event%d", evdev->minor); 448 devfs_remove("input/event%d", evdev->minor);
448 evdev->exist = 0; 449 evdev->exist = 0;
449 450
diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
index f20c3f23388b..9b8ff396e6f8 100644
--- a/drivers/input/gameport/gameport.c
+++ b/drivers/input/gameport/gameport.c
@@ -453,13 +453,13 @@ static int gameport_thread(void *nothing)
453 * Gameport port operations 453 * Gameport port operations
454 */ 454 */
455 455
456static ssize_t gameport_show_description(struct device *dev, char *buf) 456static ssize_t gameport_show_description(struct device *dev, struct device_attribute *attr, char *buf)
457{ 457{
458 struct gameport *gameport = to_gameport_port(dev); 458 struct gameport *gameport = to_gameport_port(dev);
459 return sprintf(buf, "%s\n", gameport->name); 459 return sprintf(buf, "%s\n", gameport->name);
460} 460}
461 461
462static ssize_t gameport_rebind_driver(struct device *dev, const char *buf, size_t count) 462static ssize_t gameport_rebind_driver(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
463{ 463{
464 struct gameport *gameport = to_gameport_port(dev); 464 struct gameport *gameport = to_gameport_port(dev);
465 struct device_driver *drv; 465 struct device_driver *drv;
diff --git a/drivers/input/input.c b/drivers/input/input.c
index 3385dd03abfc..83c77c990dda 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -702,13 +702,13 @@ static int __init input_proc_init(void)
702static inline int input_proc_init(void) { return 0; } 702static inline int input_proc_init(void) { return 0; }
703#endif 703#endif
704 704
705struct class_simple *input_class; 705struct class *input_class;
706 706
707static int __init input_init(void) 707static int __init input_init(void)
708{ 708{
709 int retval = -ENOMEM; 709 int retval = -ENOMEM;
710 710
711 input_class = class_simple_create(THIS_MODULE, "input"); 711 input_class = class_create(THIS_MODULE, "input");
712 if (IS_ERR(input_class)) 712 if (IS_ERR(input_class))
713 return PTR_ERR(input_class); 713 return PTR_ERR(input_class);
714 input_proc_init(); 714 input_proc_init();
@@ -718,7 +718,7 @@ static int __init input_init(void)
718 remove_proc_entry("devices", proc_bus_input_dir); 718 remove_proc_entry("devices", proc_bus_input_dir);
719 remove_proc_entry("handlers", proc_bus_input_dir); 719 remove_proc_entry("handlers", proc_bus_input_dir);
720 remove_proc_entry("input", proc_bus); 720 remove_proc_entry("input", proc_bus);
721 class_simple_destroy(input_class); 721 class_destroy(input_class);
722 return retval; 722 return retval;
723 } 723 }
724 724
@@ -728,7 +728,7 @@ static int __init input_init(void)
728 remove_proc_entry("handlers", proc_bus_input_dir); 728 remove_proc_entry("handlers", proc_bus_input_dir);
729 remove_proc_entry("input", proc_bus); 729 remove_proc_entry("input", proc_bus);
730 unregister_chrdev(INPUT_MAJOR, "input"); 730 unregister_chrdev(INPUT_MAJOR, "input");
731 class_simple_destroy(input_class); 731 class_destroy(input_class);
732 } 732 }
733 return retval; 733 return retval;
734} 734}
@@ -741,7 +741,7 @@ static void __exit input_exit(void)
741 741
742 devfs_remove("input"); 742 devfs_remove("input");
743 unregister_chrdev(INPUT_MAJOR, "input"); 743 unregister_chrdev(INPUT_MAJOR, "input");
744 class_simple_destroy(input_class); 744 class_destroy(input_class);
745} 745}
746 746
747subsys_initcall(input_init); 747subsys_initcall(input_init);
diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c
index 627d343dfba1..39775fc380c7 100644
--- a/drivers/input/joydev.c
+++ b/drivers/input/joydev.c
@@ -452,9 +452,9 @@ static struct input_handle *joydev_connect(struct input_handler *handler, struct
452 452
453 devfs_mk_cdev(MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE + minor), 453 devfs_mk_cdev(MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE + minor),
454 S_IFCHR|S_IRUGO|S_IWUSR, "input/js%d", minor); 454 S_IFCHR|S_IRUGO|S_IWUSR, "input/js%d", minor);
455 class_simple_device_add(input_class, 455 class_device_create(input_class,
456 MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE + minor), 456 MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE + minor),
457 dev->dev, "js%d", minor); 457 dev->dev, "js%d", minor);
458 458
459 return &joydev->handle; 459 return &joydev->handle;
460} 460}
@@ -464,7 +464,7 @@ static void joydev_disconnect(struct input_handle *handle)
464 struct joydev *joydev = handle->private; 464 struct joydev *joydev = handle->private;
465 struct joydev_list *list; 465 struct joydev_list *list;
466 466
467 class_simple_device_remove(MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE + joydev->minor)); 467 class_device_destroy(input_class, MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE + joydev->minor));
468 devfs_remove("input/js%d", joydev->minor); 468 devfs_remove("input/js%d", joydev->minor);
469 joydev->exist = 0; 469 joydev->exist = 0;
470 470
diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
index 48fdf1e517cf..82fad9a23ace 100644
--- a/drivers/input/keyboard/atkbd.c
+++ b/drivers/input/keyboard/atkbd.c
@@ -219,11 +219,11 @@ static ssize_t atkbd_attr_set_helper(struct device *dev, const char *buf, size_t
219#define ATKBD_DEFINE_ATTR(_name) \ 219#define ATKBD_DEFINE_ATTR(_name) \
220static ssize_t atkbd_show_##_name(struct atkbd *, char *); \ 220static ssize_t atkbd_show_##_name(struct atkbd *, char *); \
221static ssize_t atkbd_set_##_name(struct atkbd *, const char *, size_t); \ 221static ssize_t atkbd_set_##_name(struct atkbd *, const char *, size_t); \
222static ssize_t atkbd_do_show_##_name(struct device *d, char *b) \ 222static ssize_t atkbd_do_show_##_name(struct device *d, struct device_attribute *attr, char *b) \
223{ \ 223{ \
224 return atkbd_attr_show_helper(d, b, atkbd_show_##_name); \ 224 return atkbd_attr_show_helper(d, b, atkbd_show_##_name); \
225} \ 225} \
226static ssize_t atkbd_do_set_##_name(struct device *d, const char *b, size_t s) \ 226static ssize_t atkbd_do_set_##_name(struct device *d, struct device_attribute *attr, const char *b, size_t s) \
227{ \ 227{ \
228 return atkbd_attr_set_helper(d, b, s, atkbd_set_##_name); \ 228 return atkbd_attr_set_helper(d, b, s, atkbd_set_##_name); \
229} \ 229} \
diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
index bda5b065d03c..79e17a0c4664 100644
--- a/drivers/input/mouse/psmouse.h
+++ b/drivers/input/mouse/psmouse.h
@@ -91,11 +91,11 @@ ssize_t psmouse_attr_set_helper(struct device *dev, const char *buf, size_t coun
91#define PSMOUSE_DEFINE_ATTR(_name) \ 91#define PSMOUSE_DEFINE_ATTR(_name) \
92static ssize_t psmouse_attr_show_##_name(struct psmouse *, char *); \ 92static ssize_t psmouse_attr_show_##_name(struct psmouse *, char *); \
93static ssize_t psmouse_attr_set_##_name(struct psmouse *, const char *, size_t);\ 93static ssize_t psmouse_attr_set_##_name(struct psmouse *, const char *, size_t);\
94static ssize_t psmouse_do_show_##_name(struct device *d, char *b) \ 94static ssize_t psmouse_do_show_##_name(struct device *d, struct device_attribute *attr, char *b) \
95{ \ 95{ \
96 return psmouse_attr_show_helper(d, b, psmouse_attr_show_##_name); \ 96 return psmouse_attr_show_helper(d, b, psmouse_attr_show_##_name); \
97} \ 97} \
98static ssize_t psmouse_do_set_##_name(struct device *d, const char *b, size_t s)\ 98static ssize_t psmouse_do_set_##_name(struct device *d, struct device_attribute *attr, const char *b, size_t s)\
99{ \ 99{ \
100 return psmouse_attr_set_helper(d, b, s, psmouse_attr_set_##_name); \ 100 return psmouse_attr_set_helper(d, b, s, psmouse_attr_set_##_name); \
101} \ 101} \
diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
index 96fb9870834a..062848ac7e6b 100644
--- a/drivers/input/mousedev.c
+++ b/drivers/input/mousedev.c
@@ -647,9 +647,9 @@ static struct input_handle *mousedev_connect(struct input_handler *handler, stru
647 647
648 devfs_mk_cdev(MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + minor), 648 devfs_mk_cdev(MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + minor),
649 S_IFCHR|S_IRUGO|S_IWUSR, "input/mouse%d", minor); 649 S_IFCHR|S_IRUGO|S_IWUSR, "input/mouse%d", minor);
650 class_simple_device_add(input_class, 650 class_device_create(input_class,
651 MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + minor), 651 MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + minor),
652 dev->dev, "mouse%d", minor); 652 dev->dev, "mouse%d", minor);
653 653
654 return &mousedev->handle; 654 return &mousedev->handle;
655} 655}
@@ -659,7 +659,8 @@ static void mousedev_disconnect(struct input_handle *handle)
659 struct mousedev *mousedev = handle->private; 659 struct mousedev *mousedev = handle->private;
660 struct mousedev_list *list; 660 struct mousedev_list *list;
661 661
662 class_simple_device_remove(MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + mousedev->minor)); 662 class_device_destroy(input_class,
663 MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + mousedev->minor));
663 devfs_remove("input/mouse%d", mousedev->minor); 664 devfs_remove("input/mouse%d", mousedev->minor);
664 mousedev->exist = 0; 665 mousedev->exist = 0;
665 666
@@ -735,8 +736,8 @@ static int __init mousedev_init(void)
735 736
736 devfs_mk_cdev(MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + MOUSEDEV_MIX), 737 devfs_mk_cdev(MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + MOUSEDEV_MIX),
737 S_IFCHR|S_IRUGO|S_IWUSR, "input/mice"); 738 S_IFCHR|S_IRUGO|S_IWUSR, "input/mice");
738 class_simple_device_add(input_class, MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + MOUSEDEV_MIX), 739 class_device_create(input_class,
739 NULL, "mice"); 740 MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + MOUSEDEV_MIX), NULL, "mice");
740 741
741#ifdef CONFIG_INPUT_MOUSEDEV_PSAUX 742#ifdef CONFIG_INPUT_MOUSEDEV_PSAUX
742 if (!(psaux_registered = !misc_register(&psaux_mouse))) 743 if (!(psaux_registered = !misc_register(&psaux_mouse)))
@@ -755,7 +756,8 @@ static void __exit mousedev_exit(void)
755 misc_deregister(&psaux_mouse); 756 misc_deregister(&psaux_mouse);
756#endif 757#endif
757 devfs_remove("input/mice"); 758 devfs_remove("input/mice");
758 class_simple_device_remove(MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + MOUSEDEV_MIX)); 759 class_device_destroy(input_class,
760 MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + MOUSEDEV_MIX));
759 input_unregister_handler(&mousedev_handler); 761 input_unregister_handler(&mousedev_handler);
760} 762}
761 763
diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
index 0beacb77ee18..feab4970406e 100644
--- a/drivers/input/serio/serio.c
+++ b/drivers/input/serio/serio.c
@@ -358,31 +358,31 @@ static int serio_thread(void *nothing)
358 * Serio port operations 358 * Serio port operations
359 */ 359 */
360 360
361static ssize_t serio_show_description(struct device *dev, char *buf) 361static ssize_t serio_show_description(struct device *dev, struct device_attribute *attr, char *buf)
362{ 362{
363 struct serio *serio = to_serio_port(dev); 363 struct serio *serio = to_serio_port(dev);
364 return sprintf(buf, "%s\n", serio->name); 364 return sprintf(buf, "%s\n", serio->name);
365} 365}
366 366
367static ssize_t serio_show_id_type(struct device *dev, char *buf) 367static ssize_t serio_show_id_type(struct device *dev, struct device_attribute *attr, char *buf)
368{ 368{
369 struct serio *serio = to_serio_port(dev); 369 struct serio *serio = to_serio_port(dev);
370 return sprintf(buf, "%02x\n", serio->id.type); 370 return sprintf(buf, "%02x\n", serio->id.type);
371} 371}
372 372
373static ssize_t serio_show_id_proto(struct device *dev, char *buf) 373static ssize_t serio_show_id_proto(struct device *dev, struct device_attribute *attr, char *buf)
374{ 374{
375 struct serio *serio = to_serio_port(dev); 375 struct serio *serio = to_serio_port(dev);
376 return sprintf(buf, "%02x\n", serio->id.proto); 376 return sprintf(buf, "%02x\n", serio->id.proto);
377} 377}
378 378
379static ssize_t serio_show_id_id(struct device *dev, char *buf) 379static ssize_t serio_show_id_id(struct device *dev, struct device_attribute *attr, char *buf)
380{ 380{
381 struct serio *serio = to_serio_port(dev); 381 struct serio *serio = to_serio_port(dev);
382 return sprintf(buf, "%02x\n", serio->id.id); 382 return sprintf(buf, "%02x\n", serio->id.id);
383} 383}
384 384
385static ssize_t serio_show_id_extra(struct device *dev, char *buf) 385static ssize_t serio_show_id_extra(struct device *dev, struct device_attribute *attr, char *buf)
386{ 386{
387 struct serio *serio = to_serio_port(dev); 387 struct serio *serio = to_serio_port(dev);
388 return sprintf(buf, "%02x\n", serio->id.extra); 388 return sprintf(buf, "%02x\n", serio->id.extra);
@@ -406,7 +406,7 @@ static struct attribute_group serio_id_attr_group = {
406 .attrs = serio_device_id_attrs, 406 .attrs = serio_device_id_attrs,
407}; 407};
408 408
409static ssize_t serio_rebind_driver(struct device *dev, const char *buf, size_t count) 409static ssize_t serio_rebind_driver(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
410{ 410{
411 struct serio *serio = to_serio_port(dev); 411 struct serio *serio = to_serio_port(dev);
412 struct device_driver *drv; 412 struct device_driver *drv;
@@ -437,13 +437,13 @@ static ssize_t serio_rebind_driver(struct device *dev, const char *buf, size_t c
437 return retval; 437 return retval;
438} 438}
439 439
440static ssize_t serio_show_bind_mode(struct device *dev, char *buf) 440static ssize_t serio_show_bind_mode(struct device *dev, struct device_attribute *attr, char *buf)
441{ 441{
442 struct serio *serio = to_serio_port(dev); 442 struct serio *serio = to_serio_port(dev);
443 return sprintf(buf, "%s\n", serio->manual_bind ? "manual" : "auto"); 443 return sprintf(buf, "%s\n", serio->manual_bind ? "manual" : "auto");
444} 444}
445 445
446static ssize_t serio_set_bind_mode(struct device *dev, const char *buf, size_t count) 446static ssize_t serio_set_bind_mode(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
447{ 447{
448 struct serio *serio = to_serio_port(dev); 448 struct serio *serio = to_serio_port(dev);
449 int retval; 449 int retval;
diff --git a/drivers/input/tsdev.c b/drivers/input/tsdev.c
index d0afba85720b..50c63a155156 100644
--- a/drivers/input/tsdev.c
+++ b/drivers/input/tsdev.c
@@ -414,9 +414,9 @@ static struct input_handle *tsdev_connect(struct input_handler *handler,
414 S_IFCHR|S_IRUGO|S_IWUSR, "input/ts%d", minor); 414 S_IFCHR|S_IRUGO|S_IWUSR, "input/ts%d", minor);
415 devfs_mk_cdev(MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + minor + TSDEV_MINORS/2), 415 devfs_mk_cdev(MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + minor + TSDEV_MINORS/2),
416 S_IFCHR|S_IRUGO|S_IWUSR, "input/tsraw%d", minor); 416 S_IFCHR|S_IRUGO|S_IWUSR, "input/tsraw%d", minor);
417 class_simple_device_add(input_class, 417 class_device_create(input_class,
418 MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + minor), 418 MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + minor),
419 dev->dev, "ts%d", minor); 419 dev->dev, "ts%d", minor);
420 420
421 return &tsdev->handle; 421 return &tsdev->handle;
422} 422}
@@ -426,7 +426,8 @@ static void tsdev_disconnect(struct input_handle *handle)
426 struct tsdev *tsdev = handle->private; 426 struct tsdev *tsdev = handle->private;
427 struct tsdev_list *list; 427 struct tsdev_list *list;
428 428
429 class_simple_device_remove(MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + tsdev->minor)); 429 class_device_destroy(input_class,
430 MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + tsdev->minor));
430 devfs_remove("input/ts%d", tsdev->minor); 431 devfs_remove("input/ts%d", tsdev->minor);
431 devfs_remove("input/tsraw%d", tsdev->minor); 432 devfs_remove("input/tsraw%d", tsdev->minor);
432 tsdev->exist = 0; 433 tsdev->exist = 0;
diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
index 12dee8e9fbbe..04fb606b5ddd 100644
--- a/drivers/isdn/capi/capi.c
+++ b/drivers/isdn/capi/capi.c
@@ -58,7 +58,7 @@ MODULE_LICENSE("GPL");
58 58
59/* -------- driver information -------------------------------------- */ 59/* -------- driver information -------------------------------------- */
60 60
61static struct class_simple *capi_class; 61static struct class *capi_class;
62 62
63static int capi_major = 68; /* allocated */ 63static int capi_major = 68; /* allocated */
64#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE 64#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE
@@ -1499,20 +1499,20 @@ static int __init capi_init(void)
1499 return -EIO; 1499 return -EIO;
1500 } 1500 }
1501 1501
1502 capi_class = class_simple_create(THIS_MODULE, "capi"); 1502 capi_class = class_create(THIS_MODULE, "capi");
1503 if (IS_ERR(capi_class)) { 1503 if (IS_ERR(capi_class)) {
1504 unregister_chrdev(capi_major, "capi20"); 1504 unregister_chrdev(capi_major, "capi20");
1505 return PTR_ERR(capi_class); 1505 return PTR_ERR(capi_class);
1506 } 1506 }
1507 1507
1508 class_simple_device_add(capi_class, MKDEV(capi_major, 0), NULL, "capi"); 1508 class_device_create(capi_class, MKDEV(capi_major, 0), NULL, "capi");
1509 devfs_mk_cdev(MKDEV(capi_major, 0), S_IFCHR | S_IRUSR | S_IWUSR, 1509 devfs_mk_cdev(MKDEV(capi_major, 0), S_IFCHR | S_IRUSR | S_IWUSR,
1510 "isdn/capi20"); 1510 "isdn/capi20");
1511 1511
1512#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE 1512#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE
1513 if (capinc_tty_init() < 0) { 1513 if (capinc_tty_init() < 0) {
1514 class_simple_device_remove(MKDEV(capi_major, 0)); 1514 class_device_destroy(capi_class, MKDEV(capi_major, 0));
1515 class_simple_destroy(capi_class); 1515 class_destroy(capi_class);
1516 unregister_chrdev(capi_major, "capi20"); 1516 unregister_chrdev(capi_major, "capi20");
1517 return -ENOMEM; 1517 return -ENOMEM;
1518 } 1518 }
@@ -1539,8 +1539,8 @@ static void __exit capi_exit(void)
1539{ 1539{
1540 proc_exit(); 1540 proc_exit();
1541 1541
1542 class_simple_device_remove(MKDEV(capi_major, 0)); 1542 class_device_destroy(capi_class, MKDEV(capi_major, 0));
1543 class_simple_destroy(capi_class); 1543 class_destroy(capi_class);
1544 unregister_chrdev(capi_major, "capi20"); 1544 unregister_chrdev(capi_major, "capi20");
1545 devfs_remove("isdn/capi20"); 1545 devfs_remove("isdn/capi20");
1546 1546
diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c
index 7297c77f99cf..493e2afa191c 100644
--- a/drivers/macintosh/adb.c
+++ b/drivers/macintosh/adb.c
@@ -77,7 +77,7 @@ static struct adb_driver *adb_driver_list[] = {
77 NULL 77 NULL
78}; 78};
79 79
80static struct class_simple *adb_dev_class; 80static struct class *adb_dev_class;
81 81
82struct adb_driver *adb_controller; 82struct adb_driver *adb_controller;
83struct notifier_block *adb_client_list = NULL; 83struct notifier_block *adb_client_list = NULL;
@@ -902,9 +902,8 @@ adbdev_init(void)
902 902
903 devfs_mk_cdev(MKDEV(ADB_MAJOR, 0), S_IFCHR | S_IRUSR | S_IWUSR, "adb"); 903 devfs_mk_cdev(MKDEV(ADB_MAJOR, 0), S_IFCHR | S_IRUSR | S_IWUSR, "adb");
904 904
905 adb_dev_class = class_simple_create(THIS_MODULE, "adb"); 905 adb_dev_class = class_create(THIS_MODULE, "adb");
906 if (IS_ERR(adb_dev_class)) { 906 if (IS_ERR(adb_dev_class))
907 return; 907 return;
908 } 908 class_device_create(adb_dev_class, MKDEV(ADB_MAJOR, 0), NULL, "adb");
909 class_simple_device_add(adb_dev_class, MKDEV(ADB_MAJOR, 0), NULL, "adb");
910} 909}
diff --git a/drivers/macintosh/therm_adt746x.c b/drivers/macintosh/therm_adt746x.c
index d09308f30960..5ba190ce14a0 100644
--- a/drivers/macintosh/therm_adt746x.c
+++ b/drivers/macintosh/therm_adt746x.c
@@ -455,21 +455,22 @@ static int attach_one_thermostat(struct i2c_adapter *adapter, int addr,
455 * pass around to the attribute functions, so we don't really have 455 * pass around to the attribute functions, so we don't really have
456 * choice but implement a bunch of them... 456 * choice but implement a bunch of them...
457 * 457 *
458 * FIXME, it does now...
458 */ 459 */
459#define BUILD_SHOW_FUNC_INT(name, data) \ 460#define BUILD_SHOW_FUNC_INT(name, data) \
460static ssize_t show_##name(struct device *dev, char *buf) \ 461static ssize_t show_##name(struct device *dev, struct device_attribute *attr, char *buf) \
461{ \ 462{ \
462 return sprintf(buf, "%d\n", data); \ 463 return sprintf(buf, "%d\n", data); \
463} 464}
464 465
465#define BUILD_SHOW_FUNC_STR(name, data) \ 466#define BUILD_SHOW_FUNC_STR(name, data) \
466static ssize_t show_##name(struct device *dev, char *buf) \ 467static ssize_t show_##name(struct device *dev, struct device_attribute *attr, char *buf) \
467{ \ 468{ \
468 return sprintf(buf, "%s\n", data); \ 469 return sprintf(buf, "%s\n", data); \
469} 470}
470 471
471#define BUILD_SHOW_FUNC_FAN(name, data) \ 472#define BUILD_SHOW_FUNC_FAN(name, data) \
472static ssize_t show_##name(struct device *dev, char *buf) \ 473static ssize_t show_##name(struct device *dev, struct device_attribute *attr, char *buf) \
473{ \ 474{ \
474 return sprintf(buf, "%d (%d rpm)\n", \ 475 return sprintf(buf, "%d (%d rpm)\n", \
475 thermostat->last_speed[data], \ 476 thermostat->last_speed[data], \
@@ -478,7 +479,7 @@ static ssize_t show_##name(struct device *dev, char *buf) \
478} 479}
479 480
480#define BUILD_STORE_FUNC_DEG(name, data) \ 481#define BUILD_STORE_FUNC_DEG(name, data) \
481static ssize_t store_##name(struct device *dev, const char *buf, size_t n) \ 482static ssize_t store_##name(struct device *dev, struct device_attribute *attr, const char *buf, size_t n) \
482{ \ 483{ \
483 int val; \ 484 int val; \
484 int i; \ 485 int i; \
@@ -491,7 +492,7 @@ static ssize_t store_##name(struct device *dev, const char *buf, size_t n) \
491} 492}
492 493
493#define BUILD_STORE_FUNC_INT(name, data) \ 494#define BUILD_STORE_FUNC_INT(name, data) \
494static ssize_t store_##name(struct device *dev, const char *buf, size_t n) \ 495static ssize_t store_##name(struct device *dev, struct device_attribute *attr, const char *buf, size_t n) \
495{ \ 496{ \
496 u32 val; \ 497 u32 val; \
497 val = simple_strtoul(buf, NULL, 10); \ 498 val = simple_strtoul(buf, NULL, 10); \
diff --git a/drivers/macintosh/therm_pm72.c b/drivers/macintosh/therm_pm72.c
index 82336a5a5474..feb4e2413858 100644
--- a/drivers/macintosh/therm_pm72.c
+++ b/drivers/macintosh/therm_pm72.c
@@ -685,7 +685,7 @@ static void fetch_cpu_pumps_minmax(void)
685 * the input twice... I accept patches :) 685 * the input twice... I accept patches :)
686 */ 686 */
687#define BUILD_SHOW_FUNC_FIX(name, data) \ 687#define BUILD_SHOW_FUNC_FIX(name, data) \
688static ssize_t show_##name(struct device *dev, char *buf) \ 688static ssize_t show_##name(struct device *dev, struct device_attribute *attr, char *buf) \
689{ \ 689{ \
690 ssize_t r; \ 690 ssize_t r; \
691 down(&driver_lock); \ 691 down(&driver_lock); \
@@ -694,7 +694,7 @@ static ssize_t show_##name(struct device *dev, char *buf) \
694 return r; \ 694 return r; \
695} 695}
696#define BUILD_SHOW_FUNC_INT(name, data) \ 696#define BUILD_SHOW_FUNC_INT(name, data) \
697static ssize_t show_##name(struct device *dev, char *buf) \ 697static ssize_t show_##name(struct device *dev, struct device_attribute *attr, char *buf) \
698{ \ 698{ \
699 return sprintf(buf, "%d", data); \ 699 return sprintf(buf, "%d", data); \
700} 700}
diff --git a/drivers/macintosh/therm_windtunnel.c b/drivers/macintosh/therm_windtunnel.c
index c153699d0f84..0bdb47f08c2a 100644
--- a/drivers/macintosh/therm_windtunnel.c
+++ b/drivers/macintosh/therm_windtunnel.c
@@ -107,13 +107,13 @@ print_temp( const char *s, int temp )
107} 107}
108 108
109static ssize_t 109static ssize_t
110show_cpu_temperature( struct device *dev, char *buf ) 110show_cpu_temperature( struct device *dev, struct device_attribute *attr, char *buf )
111{ 111{
112 return sprintf(buf, "%d.%d\n", x.temp>>8, (x.temp & 255)*10/256 ); 112 return sprintf(buf, "%d.%d\n", x.temp>>8, (x.temp & 255)*10/256 );
113} 113}
114 114
115static ssize_t 115static ssize_t
116show_case_temperature( struct device *dev, char *buf ) 116show_case_temperature( struct device *dev, struct device_attribute *attr, char *buf )
117{ 117{
118 return sprintf(buf, "%d.%d\n", x.casetemp>>8, (x.casetemp & 255)*10/256 ); 118 return sprintf(buf, "%d.%d\n", x.casetemp>>8, (x.casetemp & 255)*10/256 );
119} 119}
diff --git a/drivers/mca/mca-bus.c b/drivers/mca/mca-bus.c
index ff9be67c2a15..09baa43b2599 100644
--- a/drivers/mca/mca-bus.c
+++ b/drivers/mca/mca-bus.c
@@ -69,7 +69,7 @@ struct bus_type mca_bus_type = {
69}; 69};
70EXPORT_SYMBOL (mca_bus_type); 70EXPORT_SYMBOL (mca_bus_type);
71 71
72static ssize_t mca_show_pos_id(struct device *dev, char *buf) 72static ssize_t mca_show_pos_id(struct device *dev, struct device_attribute *attr, char *buf)
73{ 73{
74 /* four digits, \n and trailing \0 */ 74 /* four digits, \n and trailing \0 */
75 struct mca_device *mca_dev = to_mca_device(dev); 75 struct mca_device *mca_dev = to_mca_device(dev);
@@ -81,7 +81,7 @@ static ssize_t mca_show_pos_id(struct device *dev, char *buf)
81 len = sprintf(buf, "none\n"); 81 len = sprintf(buf, "none\n");
82 return len; 82 return len;
83} 83}
84static ssize_t mca_show_pos(struct device *dev, char *buf) 84static ssize_t mca_show_pos(struct device *dev, struct device_attribute *attr, char *buf)
85{ 85{
86 /* enough for 8 two byte hex chars plus space and new line */ 86 /* enough for 8 two byte hex chars plus space and new line */
87 int j, len=0; 87 int j, len=0;
diff --git a/drivers/media/dvb/dvb-core/dvbdev.c b/drivers/media/dvb/dvb-core/dvbdev.c
index 9d9662f4b8e6..4b7adca3e286 100644
--- a/drivers/media/dvb/dvb-core/dvbdev.c
+++ b/drivers/media/dvb/dvb-core/dvbdev.c
@@ -56,8 +56,7 @@ static const char * const dnames[] = {
56#define nums2minor(num,type,id) ((num << 6) | (id << 4) | type) 56#define nums2minor(num,type,id) ((num << 6) | (id << 4) | type)
57#define MAX_DVB_MINORS (DVB_MAX_ADAPTERS*64) 57#define MAX_DVB_MINORS (DVB_MAX_ADAPTERS*64)
58 58
59struct class_simple *dvb_class; 59static struct class *dvb_class;
60EXPORT_SYMBOL(dvb_class);
61 60
62static struct dvb_device* dvbdev_find_device (int minor) 61static struct dvb_device* dvbdev_find_device (int minor)
63{ 62{
@@ -236,8 +235,8 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
236 S_IFCHR | S_IRUSR | S_IWUSR, 235 S_IFCHR | S_IRUSR | S_IWUSR,
237 "dvb/adapter%d/%s%d", adap->num, dnames[type], id); 236 "dvb/adapter%d/%s%d", adap->num, dnames[type], id);
238 237
239 class_simple_device_add(dvb_class, MKDEV(DVB_MAJOR, nums2minor(adap->num, type, id)), 238 class_device_create(dvb_class, MKDEV(DVB_MAJOR, nums2minor(adap->num, type, id)),
240 NULL, "dvb%d.%s%d", adap->num, dnames[type], id); 239 NULL, "dvb%d.%s%d", adap->num, dnames[type], id);
241 240
242 dprintk("DVB: register adapter%d/%s%d @ minor: %i (0x%02x)\n", 241 dprintk("DVB: register adapter%d/%s%d @ minor: %i (0x%02x)\n",
243 adap->num, dnames[type], id, nums2minor(adap->num, type, id), 242 adap->num, dnames[type], id, nums2minor(adap->num, type, id),
@@ -256,7 +255,7 @@ void dvb_unregister_device(struct dvb_device *dvbdev)
256 devfs_remove("dvb/adapter%d/%s%d", dvbdev->adapter->num, 255 devfs_remove("dvb/adapter%d/%s%d", dvbdev->adapter->num,
257 dnames[dvbdev->type], dvbdev->id); 256 dnames[dvbdev->type], dvbdev->id);
258 257
259 class_simple_device_remove(MKDEV(DVB_MAJOR, nums2minor(dvbdev->adapter->num, 258 class_device_destroy(dvb_class, MKDEV(DVB_MAJOR, nums2minor(dvbdev->adapter->num,
260 dvbdev->type, dvbdev->id))); 259 dvbdev->type, dvbdev->id)));
261 260
262 list_del (&dvbdev->list_head); 261 list_del (&dvbdev->list_head);
@@ -412,7 +411,7 @@ static int __init init_dvbdev(void)
412 411
413 devfs_mk_dir("dvb"); 412 devfs_mk_dir("dvb");
414 413
415 dvb_class = class_simple_create(THIS_MODULE, "dvb"); 414 dvb_class = class_create(THIS_MODULE, "dvb");
416 if (IS_ERR(dvb_class)) { 415 if (IS_ERR(dvb_class)) {
417 retval = PTR_ERR(dvb_class); 416 retval = PTR_ERR(dvb_class);
418 goto error; 417 goto error;
@@ -429,7 +428,7 @@ error:
429static void __exit exit_dvbdev(void) 428static void __exit exit_dvbdev(void)
430{ 429{
431 devfs_remove("dvb"); 430 devfs_remove("dvb");
432 class_simple_destroy(dvb_class); 431 class_destroy(dvb_class);
433 cdev_del(&dvb_device_cdev); 432 cdev_del(&dvb_device_cdev);
434 unregister_chrdev_region(MKDEV(DVB_MAJOR, 0), MAX_DVB_MINORS); 433 unregister_chrdev_region(MKDEV(DVB_MAJOR, 0), MAX_DVB_MINORS);
435} 434}
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
index 48ff314cdfbf..a0078ae5b9b8 100644
--- a/drivers/message/fusion/mptscsih.c
+++ b/drivers/message/fusion/mptscsih.c
@@ -2338,7 +2338,7 @@ slave_configure_exit:
2338} 2338}
2339 2339
2340ssize_t 2340ssize_t
2341mptscsih_store_queue_depth(struct device *dev, const char *buf, size_t count) 2341mptscsih_store_queue_depth(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
2342{ 2342{
2343 int depth; 2343 int depth;
2344 struct scsi_device *sdev = to_scsi_device(dev); 2344 struct scsi_device *sdev = to_scsi_device(dev);
diff --git a/drivers/message/fusion/mptscsih.h b/drivers/message/fusion/mptscsih.h
index 9f519836effa..d73aec33e16a 100644
--- a/drivers/message/fusion/mptscsih.h
+++ b/drivers/message/fusion/mptscsih.h
@@ -103,5 +103,5 @@ extern int mptscsih_taskmgmt_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_F
103extern int mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *r); 103extern int mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *r);
104extern int mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply); 104extern int mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply);
105extern int mptscsih_ioc_reset(MPT_ADAPTER *ioc, int post_reset); 105extern int mptscsih_ioc_reset(MPT_ADAPTER *ioc, int post_reset);
106extern ssize_t mptscsih_store_queue_depth(struct device *dev, const char *buf, size_t count); 106extern ssize_t mptscsih_store_queue_depth(struct device *dev, struct device_attribute *attr, const char *buf, size_t count);
107extern void mptscsih_timer_expired(unsigned long data); 107extern void mptscsih_timer_expired(unsigned long data);
diff --git a/drivers/mmc/mmc_sysfs.c b/drivers/mmc/mmc_sysfs.c
index 29a56e9cd5b3..5556cd3b5559 100644
--- a/drivers/mmc/mmc_sysfs.c
+++ b/drivers/mmc/mmc_sysfs.c
@@ -22,7 +22,7 @@
22#define to_mmc_driver(d) container_of(d, struct mmc_driver, drv) 22#define to_mmc_driver(d) container_of(d, struct mmc_driver, drv)
23 23
24#define MMC_ATTR(name, fmt, args...) \ 24#define MMC_ATTR(name, fmt, args...) \
25static ssize_t mmc_##name##_show (struct device *dev, char *buf) \ 25static ssize_t mmc_##name##_show (struct device *dev, struct device_attribute *attr, char *buf) \
26{ \ 26{ \
27 struct mmc_card *card = dev_to_mmc_card(dev); \ 27 struct mmc_card *card = dev_to_mmc_card(dev); \
28 return sprintf(buf, fmt, args); \ 28 return sprintf(buf, fmt, args); \
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c
index ad4b58af6b76..ab726ab43798 100644
--- a/drivers/net/ppp_generic.c
+++ b/drivers/net/ppp_generic.c
@@ -273,7 +273,7 @@ static int ppp_connect_channel(struct channel *pch, int unit);
273static int ppp_disconnect_channel(struct channel *pch); 273static int ppp_disconnect_channel(struct channel *pch);
274static void ppp_destroy_channel(struct channel *pch); 274static void ppp_destroy_channel(struct channel *pch);
275 275
276static struct class_simple *ppp_class; 276static struct class *ppp_class;
277 277
278/* Translates a PPP protocol number to a NP index (NP == network protocol) */ 278/* Translates a PPP protocol number to a NP index (NP == network protocol) */
279static inline int proto_to_npindex(int proto) 279static inline int proto_to_npindex(int proto)
@@ -858,12 +858,12 @@ static int __init ppp_init(void)
858 printk(KERN_INFO "PPP generic driver version " PPP_VERSION "\n"); 858 printk(KERN_INFO "PPP generic driver version " PPP_VERSION "\n");
859 err = register_chrdev(PPP_MAJOR, "ppp", &ppp_device_fops); 859 err = register_chrdev(PPP_MAJOR, "ppp", &ppp_device_fops);
860 if (!err) { 860 if (!err) {
861 ppp_class = class_simple_create(THIS_MODULE, "ppp"); 861 ppp_class = class_create(THIS_MODULE, "ppp");
862 if (IS_ERR(ppp_class)) { 862 if (IS_ERR(ppp_class)) {
863 err = PTR_ERR(ppp_class); 863 err = PTR_ERR(ppp_class);
864 goto out_chrdev; 864 goto out_chrdev;
865 } 865 }
866 class_simple_device_add(ppp_class, MKDEV(PPP_MAJOR, 0), NULL, "ppp"); 866 class_device_create(ppp_class, MKDEV(PPP_MAJOR, 0), NULL, "ppp");
867 err = devfs_mk_cdev(MKDEV(PPP_MAJOR, 0), 867 err = devfs_mk_cdev(MKDEV(PPP_MAJOR, 0),
868 S_IFCHR|S_IRUSR|S_IWUSR, "ppp"); 868 S_IFCHR|S_IRUSR|S_IWUSR, "ppp");
869 if (err) 869 if (err)
@@ -876,8 +876,8 @@ out:
876 return err; 876 return err;
877 877
878out_class: 878out_class:
879 class_simple_device_remove(MKDEV(PPP_MAJOR,0)); 879 class_device_destroy(ppp_class, MKDEV(PPP_MAJOR,0));
880 class_simple_destroy(ppp_class); 880 class_destroy(ppp_class);
881out_chrdev: 881out_chrdev:
882 unregister_chrdev(PPP_MAJOR, "ppp"); 882 unregister_chrdev(PPP_MAJOR, "ppp");
883 goto out; 883 goto out;
@@ -2654,8 +2654,8 @@ static void __exit ppp_cleanup(void)
2654 if (unregister_chrdev(PPP_MAJOR, "ppp") != 0) 2654 if (unregister_chrdev(PPP_MAJOR, "ppp") != 0)
2655 printk(KERN_ERR "PPP: failed to unregister PPP device\n"); 2655 printk(KERN_ERR "PPP: failed to unregister PPP device\n");
2656 devfs_remove("ppp"); 2656 devfs_remove("ppp");
2657 class_simple_device_remove(MKDEV(PPP_MAJOR, 0)); 2657 class_device_destroy(ppp_class, MKDEV(PPP_MAJOR, 0));
2658 class_simple_destroy(ppp_class); 2658 class_destroy(ppp_class);
2659} 2659}
2660 2660
2661/* 2661/*
diff --git a/drivers/net/wan/cosa.c b/drivers/net/wan/cosa.c
index 921a573372e9..7ff814fd65d0 100644
--- a/drivers/net/wan/cosa.c
+++ b/drivers/net/wan/cosa.c
@@ -235,7 +235,7 @@ static int dma[MAX_CARDS+1];
235static int irq[MAX_CARDS+1] = { -1, -1, -1, -1, -1, -1, 0, }; 235static int irq[MAX_CARDS+1] = { -1, -1, -1, -1, -1, -1, 0, };
236 236
237/* for class stuff*/ 237/* for class stuff*/
238static struct class_simple *cosa_class; 238static struct class *cosa_class;
239 239
240#ifdef MODULE 240#ifdef MODULE
241module_param_array(io, int, NULL, 0); 241module_param_array(io, int, NULL, 0);
@@ -394,19 +394,19 @@ static int __init cosa_init(void)
394 goto out; 394 goto out;
395 } 395 }
396 devfs_mk_dir("cosa"); 396 devfs_mk_dir("cosa");
397 cosa_class = class_simple_create(THIS_MODULE, "cosa"); 397 cosa_class = class_create(THIS_MODULE, "cosa");
398 if (IS_ERR(cosa_class)) { 398 if (IS_ERR(cosa_class)) {
399 err = PTR_ERR(cosa_class); 399 err = PTR_ERR(cosa_class);
400 goto out_chrdev; 400 goto out_chrdev;
401 } 401 }
402 for (i=0; i<nr_cards; i++) { 402 for (i=0; i<nr_cards; i++) {
403 class_simple_device_add(cosa_class, MKDEV(cosa_major, i), 403 class_device_create(cosa_class, MKDEV(cosa_major, i),
404 NULL, "cosa%d", i); 404 NULL, "cosa%d", i);
405 err = devfs_mk_cdev(MKDEV(cosa_major, i), 405 err = devfs_mk_cdev(MKDEV(cosa_major, i),
406 S_IFCHR|S_IRUSR|S_IWUSR, 406 S_IFCHR|S_IRUSR|S_IWUSR,
407 "cosa/%d", i); 407 "cosa/%d", i);
408 if (err) { 408 if (err) {
409 class_simple_device_remove(MKDEV(cosa_major, i)); 409 class_device_destroy(cosa_class, MKDEV(cosa_major, i));
410 goto out_chrdev; 410 goto out_chrdev;
411 } 411 }
412 } 412 }
@@ -427,10 +427,10 @@ static void __exit cosa_exit(void)
427 printk(KERN_INFO "Unloading the cosa module\n"); 427 printk(KERN_INFO "Unloading the cosa module\n");
428 428
429 for (i=0; i<nr_cards; i++) { 429 for (i=0; i<nr_cards; i++) {
430 class_simple_device_remove(MKDEV(cosa_major, i)); 430 class_device_destroy(cosa_class, MKDEV(cosa_major, i));
431 devfs_remove("cosa/%d", i); 431 devfs_remove("cosa/%d", i);
432 } 432 }
433 class_simple_destroy(cosa_class); 433 class_destroy(cosa_class);
434 devfs_remove("cosa"); 434 devfs_remove("cosa");
435 for (cosa=cosa_cards; nr_cards--; cosa++) { 435 for (cosa=cosa_cards; nr_cards--; cosa++) {
436 /* Clean up the per-channel data */ 436 /* Clean up the per-channel data */
diff --git a/drivers/pci/hotplug/cpqphp_sysfs.c b/drivers/pci/hotplug/cpqphp_sysfs.c
index 41c7971d06c5..4c11048ad51b 100644
--- a/drivers/pci/hotplug/cpqphp_sysfs.c
+++ b/drivers/pci/hotplug/cpqphp_sysfs.c
@@ -38,7 +38,7 @@
38 38
39/* A few routines that create sysfs entries for the hot plug controller */ 39/* A few routines that create sysfs entries for the hot plug controller */
40 40
41static ssize_t show_ctrl (struct device *dev, char *buf) 41static ssize_t show_ctrl (struct device *dev, struct device_attribute *attr, char *buf)
42{ 42{
43 struct pci_dev *pci_dev; 43 struct pci_dev *pci_dev;
44 struct controller *ctrl; 44 struct controller *ctrl;
@@ -82,7 +82,7 @@ static ssize_t show_ctrl (struct device *dev, char *buf)
82} 82}
83static DEVICE_ATTR (ctrl, S_IRUGO, show_ctrl, NULL); 83static DEVICE_ATTR (ctrl, S_IRUGO, show_ctrl, NULL);
84 84
85static ssize_t show_dev (struct device *dev, char *buf) 85static ssize_t show_dev (struct device *dev, struct device_attribute *attr, char *buf)
86{ 86{
87 struct pci_dev *pci_dev; 87 struct pci_dev *pci_dev;
88 struct controller *ctrl; 88 struct controller *ctrl;
diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
index c802f6270b89..c4282902cb52 100644
--- a/drivers/pci/hotplug/pci_hotplug_core.c
+++ b/drivers/pci/hotplug/pci_hotplug_core.c
@@ -73,7 +73,7 @@ static ssize_t hotplug_slot_attr_show(struct kobject *kobj,
73{ 73{
74 struct hotplug_slot *slot = to_hotplug_slot(kobj); 74 struct hotplug_slot *slot = to_hotplug_slot(kobj);
75 struct hotplug_slot_attribute *attribute = to_hotplug_attr(attr); 75 struct hotplug_slot_attribute *attribute = to_hotplug_attr(attr);
76 return attribute->show ? attribute->show(slot, buf) : 0; 76 return attribute->show ? attribute->show(slot, buf) : -EIO;
77} 77}
78 78
79static ssize_t hotplug_slot_attr_store(struct kobject *kobj, 79static ssize_t hotplug_slot_attr_store(struct kobject *kobj,
@@ -81,7 +81,7 @@ static ssize_t hotplug_slot_attr_store(struct kobject *kobj,
81{ 81{
82 struct hotplug_slot *slot = to_hotplug_slot(kobj); 82 struct hotplug_slot *slot = to_hotplug_slot(kobj);
83 struct hotplug_slot_attribute *attribute = to_hotplug_attr(attr); 83 struct hotplug_slot_attribute *attribute = to_hotplug_attr(attr);
84 return attribute->store ? attribute->store(slot, buf, len) : 0; 84 return attribute->store ? attribute->store(slot, buf, len) : -EIO;
85} 85}
86 86
87static struct sysfs_ops hotplug_slot_sysfs_ops = { 87static struct sysfs_ops hotplug_slot_sysfs_ops = {
diff --git a/drivers/pci/hotplug/rpadlpar_sysfs.c b/drivers/pci/hotplug/rpadlpar_sysfs.c
index 3285b822478d..752e6513c447 100644
--- a/drivers/pci/hotplug/rpadlpar_sysfs.c
+++ b/drivers/pci/hotplug/rpadlpar_sysfs.c
@@ -48,7 +48,7 @@ dlpar_attr_store(struct kobject * kobj, struct attribute * attr,
48 struct dlpar_io_attr *dlpar_attr = container_of(attr, 48 struct dlpar_io_attr *dlpar_attr = container_of(attr,
49 struct dlpar_io_attr, attr); 49 struct dlpar_io_attr, attr);
50 return dlpar_attr->store ? 50 return dlpar_attr->store ?
51 dlpar_attr->store(dlpar_attr, buf, nbytes) : 0; 51 dlpar_attr->store(dlpar_attr, buf, nbytes) : -EIO;
52} 52}
53 53
54static struct sysfs_ops dlpar_attr_sysfs_ops = { 54static struct sysfs_ops dlpar_attr_sysfs_ops = {
diff --git a/drivers/pci/hotplug/shpchp_sysfs.c b/drivers/pci/hotplug/shpchp_sysfs.c
index 9a1ee132d12c..c9445ebda5c7 100644
--- a/drivers/pci/hotplug/shpchp_sysfs.c
+++ b/drivers/pci/hotplug/shpchp_sysfs.c
@@ -38,7 +38,7 @@
38 38
39/* A few routines that create sysfs entries for the hot plug controller */ 39/* A few routines that create sysfs entries for the hot plug controller */
40 40
41static ssize_t show_ctrl (struct device *dev, char *buf) 41static ssize_t show_ctrl (struct device *dev, struct device_attribute *attr, char *buf)
42{ 42{
43 struct pci_dev *pci_dev; 43 struct pci_dev *pci_dev;
44 struct controller *ctrl; 44 struct controller *ctrl;
@@ -82,7 +82,7 @@ static ssize_t show_ctrl (struct device *dev, char *buf)
82} 82}
83static DEVICE_ATTR (ctrl, S_IRUGO, show_ctrl, NULL); 83static DEVICE_ATTR (ctrl, S_IRUGO, show_ctrl, NULL);
84 84
85static ssize_t show_dev (struct device *dev, char *buf) 85static ssize_t show_dev (struct device *dev, struct device_attribute *attr, char *buf)
86{ 86{
87 struct pci_dev *pci_dev; 87 struct pci_dev *pci_dev;
88 struct controller *ctrl; 88 struct controller *ctrl;
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index cf2cff7480f1..e65bf2b395aa 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -335,13 +335,14 @@ pci_driver_attr_show(struct kobject * kobj, struct attribute *attr, char *buf)
335{ 335{
336 struct device_driver *driver = kobj_to_pci_driver(kobj); 336 struct device_driver *driver = kobj_to_pci_driver(kobj);
337 struct driver_attribute *dattr = attr_to_driver_attribute(attr); 337 struct driver_attribute *dattr = attr_to_driver_attribute(attr);
338 ssize_t ret = 0; 338 ssize_t ret;
339 339
340 if (get_driver(driver)) { 340 if (!get_driver(driver))
341 if (dattr->show) 341 return -ENODEV;
342 ret = dattr->show(driver, buf); 342
343 put_driver(driver); 343 ret = dattr->show ? dattr->show(driver, buf) : -EIO;
344 } 344
345 put_driver(driver);
345 return ret; 346 return ret;
346} 347}
347 348
@@ -351,13 +352,14 @@ pci_driver_attr_store(struct kobject * kobj, struct attribute *attr,
351{ 352{
352 struct device_driver *driver = kobj_to_pci_driver(kobj); 353 struct device_driver *driver = kobj_to_pci_driver(kobj);
353 struct driver_attribute *dattr = attr_to_driver_attribute(attr); 354 struct driver_attribute *dattr = attr_to_driver_attribute(attr);
354 ssize_t ret = 0; 355 ssize_t ret;
355 356
356 if (get_driver(driver)) { 357 if (!get_driver(driver))
357 if (dattr->store) 358 return -ENODEV;
358 ret = dattr->store(driver, buf, count); 359
359 put_driver(driver); 360 ret = dattr->store ? dattr->store(driver, buf, count) : -EIO;
360 } 361
362 put_driver(driver);
361 return ret; 363 return ret;
362} 364}
363 365
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 6ca0061137a6..a15f94072a6f 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -29,7 +29,7 @@ static int sysfs_initialized; /* = 0 */
29/* show configuration fields */ 29/* show configuration fields */
30#define pci_config_attr(field, format_string) \ 30#define pci_config_attr(field, format_string) \
31static ssize_t \ 31static ssize_t \
32field##_show(struct device *dev, char *buf) \ 32field##_show(struct device *dev, struct device_attribute *attr, char *buf) \
33{ \ 33{ \
34 struct pci_dev *pdev; \ 34 struct pci_dev *pdev; \
35 \ 35 \
@@ -44,7 +44,7 @@ pci_config_attr(subsystem_device, "0x%04x\n");
44pci_config_attr(class, "0x%06x\n"); 44pci_config_attr(class, "0x%06x\n");
45pci_config_attr(irq, "%u\n"); 45pci_config_attr(irq, "%u\n");
46 46
47static ssize_t local_cpus_show(struct device *dev, char *buf) 47static ssize_t local_cpus_show(struct device *dev, struct device_attribute *attr, char *buf)
48{ 48{
49 cpumask_t mask = pcibus_to_cpumask(to_pci_dev(dev)->bus); 49 cpumask_t mask = pcibus_to_cpumask(to_pci_dev(dev)->bus);
50 int len = cpumask_scnprintf(buf, PAGE_SIZE-2, mask); 50 int len = cpumask_scnprintf(buf, PAGE_SIZE-2, mask);
@@ -54,7 +54,7 @@ static ssize_t local_cpus_show(struct device *dev, char *buf)
54 54
55/* show resources */ 55/* show resources */
56static ssize_t 56static ssize_t
57resource_show(struct device * dev, char * buf) 57resource_show(struct device * dev, struct device_attribute *attr, char * buf)
58{ 58{
59 struct pci_dev * pci_dev = to_pci_dev(dev); 59 struct pci_dev * pci_dev = to_pci_dev(dev);
60 char * str = buf; 60 char * str = buf;
@@ -73,7 +73,7 @@ resource_show(struct device * dev, char * buf)
73 return (str - buf); 73 return (str - buf);
74} 74}
75 75
76static ssize_t modalias_show(struct device *dev, char *buf) 76static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, char *buf)
77{ 77{
78 struct pci_dev *pci_dev = to_pci_dev(dev); 78 struct pci_dev *pci_dev = to_pci_dev(dev);
79 79
@@ -339,16 +339,17 @@ pci_create_resource_files(struct pci_dev *pdev)
339 if (!pci_resource_len(pdev, i)) 339 if (!pci_resource_len(pdev, i))
340 continue; 340 continue;
341 341
342 res_attr = kmalloc(sizeof(*res_attr) + 10, GFP_ATOMIC); 342 /* allocate attribute structure, piggyback attribute name */
343 res_attr = kcalloc(1, sizeof(*res_attr) + 10, GFP_ATOMIC);
343 if (res_attr) { 344 if (res_attr) {
344 memset(res_attr, 0, sizeof(*res_attr) + 10); 345 char *res_attr_name = (char *)(res_attr + 1);
346
345 pdev->res_attr[i] = res_attr; 347 pdev->res_attr[i] = res_attr;
346 /* Allocated above after the res_attr struct */ 348 sprintf(res_attr_name, "resource%d", i);
347 res_attr->attr.name = (char *)(res_attr + 1); 349 res_attr->attr.name = res_attr_name;
348 sprintf(res_attr->attr.name, "resource%d", i);
349 res_attr->size = pci_resource_len(pdev, i);
350 res_attr->attr.mode = S_IRUSR | S_IWUSR; 350 res_attr->attr.mode = S_IRUSR | S_IWUSR;
351 res_attr->attr.owner = THIS_MODULE; 351 res_attr->attr.owner = THIS_MODULE;
352 res_attr->size = pci_resource_len(pdev, i);
352 res_attr->mmap = pci_mmap_resource; 353 res_attr->mmap = pci_mmap_resource;
353 res_attr->private = &pdev->resource[i]; 354 res_attr->private = &pdev->resource[i];
354 sysfs_create_bin_file(&pdev->dev.kobj, res_attr); 355 sysfs_create_bin_file(&pdev->dev.kobj, res_attr);
diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c
index 576285765e98..f5c5f10a3d2f 100644
--- a/drivers/pci/pcie/portdrv_core.c
+++ b/drivers/pci/pcie/portdrv_core.c
@@ -232,19 +232,16 @@ static void pcie_device_init(struct pci_dev *parent, struct pcie_device *dev,
232 /* Initialize generic device interface */ 232 /* Initialize generic device interface */
233 device = &dev->device; 233 device = &dev->device;
234 memset(device, 0, sizeof(struct device)); 234 memset(device, 0, sizeof(struct device));
235 INIT_LIST_HEAD(&device->node);
236 INIT_LIST_HEAD(&device->children);
237 INIT_LIST_HEAD(&device->bus_list);
238 device->bus = &pcie_port_bus_type; 235 device->bus = &pcie_port_bus_type;
239 device->driver = NULL; 236 device->driver = NULL;
240 device->driver_data = NULL; 237 device->driver_data = NULL;
241 device->release = release_pcie_device; /* callback to free pcie dev */ 238 device->release = release_pcie_device; /* callback to free pcie dev */
242 sprintf(&device->bus_id[0], "pcie%02x", 239 sprintf(&device->bus_id[0], "pcie%02x",
243 get_descriptor_id(port_type, service_type)); 240 get_descriptor_id(port_type, service_type));
244 device->parent = &parent->dev; 241 device->parent = &parent->dev;
245} 242}
246 243
247static struct pcie_device* alloc_pcie_device(struct pci_dev *parent, 244static struct pcie_device* alloc_pcie_device(struct pci_dev *parent,
248 int port_type, int service_type, int irq, int irq_mode) 245 int port_type, int service_type, int irq, int irq_mode)
249{ 246{
250 struct pcie_device *device; 247 struct pcie_device *device;
@@ -270,9 +267,9 @@ int pcie_port_device_probe(struct pci_dev *dev)
270 pci_read_config_word(dev, pos + PCIE_CAPABILITIES_REG, &reg); 267 pci_read_config_word(dev, pos + PCIE_CAPABILITIES_REG, &reg);
271 type = (reg >> 4) & PORT_TYPE_MASK; 268 type = (reg >> 4) & PORT_TYPE_MASK;
272 if ( type == PCIE_RC_PORT || type == PCIE_SW_UPSTREAM_PORT || 269 if ( type == PCIE_RC_PORT || type == PCIE_SW_UPSTREAM_PORT ||
273 type == PCIE_SW_DOWNSTREAM_PORT ) 270 type == PCIE_SW_DOWNSTREAM_PORT )
274 return 0; 271 return 0;
275 272
276 return -ENODEV; 273 return -ENODEV;
277} 274}
278 275
@@ -283,8 +280,8 @@ int pcie_port_device_register(struct pci_dev *dev)
283 u16 reg16; 280 u16 reg16;
284 281
285 /* Get port type */ 282 /* Get port type */
286 pci_read_config_word(dev, 283 pci_read_config_word(dev,
287 pci_find_capability(dev, PCI_CAP_ID_EXP) + 284 pci_find_capability(dev, PCI_CAP_ID_EXP) +
288 PCIE_CAPABILITIES_REG, &reg16); 285 PCIE_CAPABILITIES_REG, &reg16);
289 type = (reg16 >> 4) & PORT_TYPE_MASK; 286 type = (reg16 >> 4) & PORT_TYPE_MASK;
290 287
@@ -299,11 +296,11 @@ int pcie_port_device_register(struct pci_dev *dev)
299 if (capabilities & (1 << i)) { 296 if (capabilities & (1 << i)) {
300 child = alloc_pcie_device( 297 child = alloc_pcie_device(
301 dev, /* parent */ 298 dev, /* parent */
302 type, /* port type */ 299 type, /* port type */
303 i, /* service type */ 300 i, /* service type */
304 vectors[i], /* irq */ 301 vectors[i], /* irq */
305 irq_mode /* interrupt mode */); 302 irq_mode /* interrupt mode */);
306 if (child) { 303 if (child) {
307 status = device_register(&child->device); 304 status = device_register(&child->device);
308 if (status) { 305 if (status) {
309 kfree(child); 306 kfree(child);
@@ -317,84 +314,78 @@ int pcie_port_device_register(struct pci_dev *dev)
317} 314}
318 315
319#ifdef CONFIG_PM 316#ifdef CONFIG_PM
320int pcie_port_device_suspend(struct pci_dev *dev, pm_message_t state) 317static int suspend_iter(struct device *dev, void *data)
321{ 318{
322 struct list_head *head, *tmp;
323 struct device *parent, *child;
324 struct device_driver *driver;
325 struct pcie_port_service_driver *service_driver; 319 struct pcie_port_service_driver *service_driver;
320 u32 state = (u32)data;
321
322 if ((dev->bus == &pcie_port_bus_type) &&
323 (dev->driver)) {
324 service_driver = to_service_driver(dev->driver);
325 if (service_driver->suspend)
326 service_driver->suspend(to_pcie_device(dev), state);
327 }
328 return 0;
329}
326 330
327 parent = &dev->dev; 331int pcie_port_device_suspend(struct pci_dev *dev, u32 state)
328 head = &parent->children; 332{
329 tmp = head->next; 333 device_for_each_child(&dev->dev, (void *)state, suspend_iter);
330 while (head != tmp) { 334 return 0;
331 child = container_of(tmp, struct device, node);
332 tmp = tmp->next;
333 if (child->bus != &pcie_port_bus_type)
334 continue;
335 driver = child->driver;
336 if (!driver)
337 continue;
338 service_driver = to_service_driver(driver);
339 if (service_driver->suspend)
340 service_driver->suspend(to_pcie_device(child), state);
341 }
342 return 0;
343} 335}
344 336
345int pcie_port_device_resume(struct pci_dev *dev) 337static int resume_iter(struct device *dev, void *data)
346{ 338{
347 struct list_head *head, *tmp;
348 struct device *parent, *child;
349 struct device_driver *driver;
350 struct pcie_port_service_driver *service_driver; 339 struct pcie_port_service_driver *service_driver;
351 340
352 parent = &dev->dev; 341 if ((dev->bus == &pcie_port_bus_type) &&
353 head = &parent->children; 342 (dev->driver)) {
354 tmp = head->next; 343 service_driver = to_service_driver(dev->driver);
355 while (head != tmp) { 344 if (service_driver->resume)
356 child = container_of(tmp, struct device, node); 345 service_driver->resume(to_pcie_device(dev));
357 tmp = tmp->next;
358 if (child->bus != &pcie_port_bus_type)
359 continue;
360 driver = child->driver;
361 if (!driver)
362 continue;
363 service_driver = to_service_driver(driver);
364 if (service_driver->resume)
365 service_driver->resume(to_pcie_device(child));
366 } 346 }
367 return 0; 347 return 0;
348}
368 349
350int pcie_port_device_resume(struct pci_dev *dev)
351{
352 device_for_each_child(&dev->dev, NULL, resume_iter);
353 return 0;
369} 354}
370#endif 355#endif
371 356
372void pcie_port_device_remove(struct pci_dev *dev) 357static int remove_iter(struct device *dev, void *data)
373{ 358{
374 struct list_head *head, *tmp;
375 struct device *parent, *child;
376 struct device_driver *driver;
377 struct pcie_port_service_driver *service_driver; 359 struct pcie_port_service_driver *service_driver;
378 int interrupt_mode = PCIE_PORT_INTx_MODE;
379 360
380 parent = &dev->dev; 361 if (dev->bus == &pcie_port_bus_type) {
381 head = &parent->children; 362 if (dev->driver) {
382 tmp = head->next; 363 service_driver = to_service_driver(dev->driver);
383 while (head != tmp) { 364 if (service_driver->remove)
384 child = container_of(tmp, struct device, node); 365 service_driver->remove(to_pcie_device(dev));
385 tmp = tmp->next;
386 if (child->bus != &pcie_port_bus_type)
387 continue;
388 driver = child->driver;
389 if (driver) {
390 service_driver = to_service_driver(driver);
391 if (service_driver->remove)
392 service_driver->remove(to_pcie_device(child));
393 } 366 }
394 interrupt_mode = (to_pcie_device(child))->interrupt_mode; 367 *(unsigned long*)data = (unsigned long)dev;
395 put_device(child); 368 return 1;
396 device_unregister(child);
397 } 369 }
370 return 0;
371}
372
373void pcie_port_device_remove(struct pci_dev *dev)
374{
375 struct device *device;
376 unsigned long device_addr;
377 int interrupt_mode = PCIE_PORT_INTx_MODE;
378 int status;
379
380 do {
381 status = device_for_each_child(&dev->dev, &device_addr, remove_iter);
382 if (status) {
383 device = (struct device*)device_addr;
384 interrupt_mode = (to_pcie_device(device))->interrupt_mode;
385 put_device(device);
386 device_unregister(device);
387 }
388 } while (status);
398 /* Switch to INTx by default if MSI enabled */ 389 /* Switch to INTx by default if MSI enabled */
399 if (interrupt_mode == PCIE_PORT_MSIX_MODE) 390 if (interrupt_mode == PCIE_PORT_MSIX_MODE)
400 pci_disable_msix(dev); 391 pci_disable_msix(dev);
@@ -423,7 +414,7 @@ int pcie_port_service_register(struct pcie_port_service_driver *new)
423 new->driver.resume = pcie_port_resume_service; 414 new->driver.resume = pcie_port_resume_service;
424 415
425 return driver_register(&new->driver); 416 return driver_register(&new->driver);
426} 417}
427 418
428void pcie_port_service_unregister(struct pcie_port_service_driver *new) 419void pcie_port_service_unregister(struct pcie_port_service_driver *new)
429{ 420{
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index c4ade288c5da..569e55feecfd 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -604,14 +604,14 @@ static int pcmcia_bus_match(struct device * dev, struct device_driver * drv) {
604/************************ per-device sysfs output ***************************/ 604/************************ per-device sysfs output ***************************/
605 605
606#define pcmcia_device_attr(field, test, format) \ 606#define pcmcia_device_attr(field, test, format) \
607static ssize_t field##_show (struct device *dev, char *buf) \ 607static ssize_t field##_show (struct device *dev, struct device_attribute *attr, char *buf) \
608{ \ 608{ \
609 struct pcmcia_device *p_dev = to_pcmcia_dev(dev); \ 609 struct pcmcia_device *p_dev = to_pcmcia_dev(dev); \
610 return p_dev->test ? sprintf (buf, format, p_dev->field) : -ENODEV; \ 610 return p_dev->test ? sprintf (buf, format, p_dev->field) : -ENODEV; \
611} 611}
612 612
613#define pcmcia_device_stringattr(name, field) \ 613#define pcmcia_device_stringattr(name, field) \
614static ssize_t name##_show (struct device *dev, char *buf) \ 614static ssize_t name##_show (struct device *dev, struct device_attribute *attr, char *buf) \
615{ \ 615{ \
616 struct pcmcia_device *p_dev = to_pcmcia_dev(dev); \ 616 struct pcmcia_device *p_dev = to_pcmcia_dev(dev); \
617 return p_dev->field ? sprintf (buf, "%s\n", p_dev->field) : -ENODEV; \ 617 return p_dev->field ? sprintf (buf, "%s\n", p_dev->field) : -ENODEV; \
diff --git a/drivers/pnp/card.c b/drivers/pnp/card.c
index 97eeecfaef1b..3252662958d3 100644
--- a/drivers/pnp/card.c
+++ b/drivers/pnp/card.c
@@ -140,7 +140,7 @@ static void pnp_release_card(struct device *dmdev)
140} 140}
141 141
142 142
143static ssize_t pnp_show_card_name(struct device *dmdev, char *buf) 143static ssize_t pnp_show_card_name(struct device *dmdev, struct device_attribute *attr, char *buf)
144{ 144{
145 char *str = buf; 145 char *str = buf;
146 struct pnp_card *card = to_pnp_card(dmdev); 146 struct pnp_card *card = to_pnp_card(dmdev);
@@ -150,7 +150,7 @@ static ssize_t pnp_show_card_name(struct device *dmdev, char *buf)
150 150
151static DEVICE_ATTR(name,S_IRUGO,pnp_show_card_name,NULL); 151static DEVICE_ATTR(name,S_IRUGO,pnp_show_card_name,NULL);
152 152
153static ssize_t pnp_show_card_ids(struct device *dmdev, char *buf) 153static ssize_t pnp_show_card_ids(struct device *dmdev, struct device_attribute *attr, char *buf)
154{ 154{
155 char *str = buf; 155 char *str = buf;
156 struct pnp_card *card = to_pnp_card(dmdev); 156 struct pnp_card *card = to_pnp_card(dmdev);
diff --git a/drivers/pnp/driver.c b/drivers/pnp/driver.c
index d64c1ca4fa76..1d037c2a82ac 100644
--- a/drivers/pnp/driver.c
+++ b/drivers/pnp/driver.c
@@ -160,10 +160,16 @@ struct bus_type pnp_bus_type = {
160}; 160};
161 161
162 162
163static int count_devices(struct device * dev, void * c)
164{
165 int * count = c;
166 (*count)++;
167 return 0;
168}
169
163int pnp_register_driver(struct pnp_driver *drv) 170int pnp_register_driver(struct pnp_driver *drv)
164{ 171{
165 int count; 172 int count;
166 struct list_head *pos;
167 173
168 pnp_dbg("the driver '%s' has been registered", drv->name); 174 pnp_dbg("the driver '%s' has been registered", drv->name);
169 175
@@ -177,9 +183,7 @@ int pnp_register_driver(struct pnp_driver *drv)
177 /* get the number of initial matches */ 183 /* get the number of initial matches */
178 if (count >= 0){ 184 if (count >= 0){
179 count = 0; 185 count = 0;
180 list_for_each(pos,&drv->driver.devices){ 186 driver_for_each_device(&drv->driver, NULL, &count, count_devices);
181 count++;
182 }
183 } 187 }
184 return count; 188 return count;
185} 189}
diff --git a/drivers/pnp/interface.c b/drivers/pnp/interface.c
index 53fac8ba5d5c..a2d8ce7fef9c 100644
--- a/drivers/pnp/interface.c
+++ b/drivers/pnp/interface.c
@@ -205,7 +205,7 @@ static void pnp_print_option(pnp_info_buffer_t *buffer, char *space,
205} 205}
206 206
207 207
208static ssize_t pnp_show_options(struct device *dmdev, char *buf) 208static ssize_t pnp_show_options(struct device *dmdev, struct device_attribute *attr, char *buf)
209{ 209{
210 struct pnp_dev *dev = to_pnp_dev(dmdev); 210 struct pnp_dev *dev = to_pnp_dev(dmdev);
211 struct pnp_option * independent = dev->independent; 211 struct pnp_option * independent = dev->independent;
@@ -236,7 +236,7 @@ static ssize_t pnp_show_options(struct device *dmdev, char *buf)
236static DEVICE_ATTR(options,S_IRUGO,pnp_show_options,NULL); 236static DEVICE_ATTR(options,S_IRUGO,pnp_show_options,NULL);
237 237
238 238
239static ssize_t pnp_show_current_resources(struct device *dmdev, char *buf) 239static ssize_t pnp_show_current_resources(struct device *dmdev, struct device_attribute *attr, char *buf)
240{ 240{
241 struct pnp_dev *dev = to_pnp_dev(dmdev); 241 struct pnp_dev *dev = to_pnp_dev(dmdev);
242 int i, ret; 242 int i, ret;
@@ -308,7 +308,7 @@ static ssize_t pnp_show_current_resources(struct device *dmdev, char *buf)
308extern struct semaphore pnp_res_mutex; 308extern struct semaphore pnp_res_mutex;
309 309
310static ssize_t 310static ssize_t
311pnp_set_current_resources(struct device * dmdev, const char * ubuf, size_t count) 311pnp_set_current_resources(struct device * dmdev, struct device_attribute *attr, const char * ubuf, size_t count)
312{ 312{
313 struct pnp_dev *dev = to_pnp_dev(dmdev); 313 struct pnp_dev *dev = to_pnp_dev(dmdev);
314 char *buf = (void *)ubuf; 314 char *buf = (void *)ubuf;
@@ -444,7 +444,7 @@ pnp_set_current_resources(struct device * dmdev, const char * ubuf, size_t count
444static DEVICE_ATTR(resources,S_IRUGO | S_IWUSR, 444static DEVICE_ATTR(resources,S_IRUGO | S_IWUSR,
445 pnp_show_current_resources,pnp_set_current_resources); 445 pnp_show_current_resources,pnp_set_current_resources);
446 446
447static ssize_t pnp_show_current_ids(struct device *dmdev, char *buf) 447static ssize_t pnp_show_current_ids(struct device *dmdev, struct device_attribute *attr, char *buf)
448{ 448{
449 char *str = buf; 449 char *str = buf;
450 struct pnp_dev *dev = to_pnp_dev(dmdev); 450 struct pnp_dev *dev = to_pnp_dev(dmdev);
diff --git a/drivers/s390/block/dasd_devmap.c b/drivers/s390/block/dasd_devmap.c
index 1aedc48e5f85..d948566bb24a 100644
--- a/drivers/s390/block/dasd_devmap.c
+++ b/drivers/s390/block/dasd_devmap.c
@@ -615,7 +615,7 @@ dasd_device_from_cdev(struct ccw_device *cdev)
615 * readonly controls the readonly status of a dasd 615 * readonly controls the readonly status of a dasd
616 */ 616 */
617static ssize_t 617static ssize_t
618dasd_ro_show(struct device *dev, char *buf) 618dasd_ro_show(struct device *dev, struct device_attribute *attr, char *buf)
619{ 619{
620 struct dasd_devmap *devmap; 620 struct dasd_devmap *devmap;
621 int ro_flag; 621 int ro_flag;
@@ -629,7 +629,7 @@ dasd_ro_show(struct device *dev, char *buf)
629} 629}
630 630
631static ssize_t 631static ssize_t
632dasd_ro_store(struct device *dev, const char *buf, size_t count) 632dasd_ro_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
633{ 633{
634 struct dasd_devmap *devmap; 634 struct dasd_devmap *devmap;
635 int ro_flag; 635 int ro_flag;
@@ -656,7 +656,7 @@ static DEVICE_ATTR(readonly, 0644, dasd_ro_show, dasd_ro_store);
656 * to talk to the device 656 * to talk to the device
657 */ 657 */
658static ssize_t 658static ssize_t
659dasd_use_diag_show(struct device *dev, char *buf) 659dasd_use_diag_show(struct device *dev, struct device_attribute *attr, char *buf)
660{ 660{
661 struct dasd_devmap *devmap; 661 struct dasd_devmap *devmap;
662 int use_diag; 662 int use_diag;
@@ -670,7 +670,7 @@ dasd_use_diag_show(struct device *dev, char *buf)
670} 670}
671 671
672static ssize_t 672static ssize_t
673dasd_use_diag_store(struct device *dev, const char *buf, size_t count) 673dasd_use_diag_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
674{ 674{
675 struct dasd_devmap *devmap; 675 struct dasd_devmap *devmap;
676 ssize_t rc; 676 ssize_t rc;
@@ -698,7 +698,7 @@ static
698DEVICE_ATTR(use_diag, 0644, dasd_use_diag_show, dasd_use_diag_store); 698DEVICE_ATTR(use_diag, 0644, dasd_use_diag_show, dasd_use_diag_store);
699 699
700static ssize_t 700static ssize_t
701dasd_discipline_show(struct device *dev, char *buf) 701dasd_discipline_show(struct device *dev, struct device_attribute *attr, char *buf)
702{ 702{
703 struct dasd_devmap *devmap; 703 struct dasd_devmap *devmap;
704 char *dname; 704 char *dname;
diff --git a/drivers/s390/block/dcssblk.c b/drivers/s390/block/dcssblk.c
index a66b17b65296..16ab8d363ac6 100644
--- a/drivers/s390/block/dcssblk.c
+++ b/drivers/s390/block/dcssblk.c
@@ -45,16 +45,16 @@ static struct block_device_operations dcssblk_devops = {
45 .release = dcssblk_release, 45 .release = dcssblk_release,
46}; 46};
47 47
48static ssize_t dcssblk_add_store(struct device * dev, const char * buf, 48static ssize_t dcssblk_add_store(struct device * dev, struct device_attribute *attr, const char * buf,
49 size_t count); 49 size_t count);
50static ssize_t dcssblk_remove_store(struct device * dev, const char * buf, 50static ssize_t dcssblk_remove_store(struct device * dev, struct device_attribute *attr, const char * buf,
51 size_t count); 51 size_t count);
52static ssize_t dcssblk_save_store(struct device * dev, const char * buf, 52static ssize_t dcssblk_save_store(struct device * dev, struct device_attribute *attr, const char * buf,
53 size_t count); 53 size_t count);
54static ssize_t dcssblk_save_show(struct device *dev, char *buf); 54static ssize_t dcssblk_save_show(struct device *dev, struct device_attribute *attr, char *buf);
55static ssize_t dcssblk_shared_store(struct device * dev, const char * buf, 55static ssize_t dcssblk_shared_store(struct device * dev, struct device_attribute *attr, const char * buf,
56 size_t count); 56 size_t count);
57static ssize_t dcssblk_shared_show(struct device *dev, char *buf); 57static ssize_t dcssblk_shared_show(struct device *dev, struct device_attribute *attr, char *buf);
58 58
59static DEVICE_ATTR(add, S_IWUSR, NULL, dcssblk_add_store); 59static DEVICE_ATTR(add, S_IWUSR, NULL, dcssblk_add_store);
60static DEVICE_ATTR(remove, S_IWUSR, NULL, dcssblk_remove_store); 60static DEVICE_ATTR(remove, S_IWUSR, NULL, dcssblk_remove_store);
@@ -195,7 +195,7 @@ dcssblk_segment_warn(int rc, char* seg_name)
195 * operation (show + store) 195 * operation (show + store)
196 */ 196 */
197static ssize_t 197static ssize_t
198dcssblk_shared_show(struct device *dev, char *buf) 198dcssblk_shared_show(struct device *dev, struct device_attribute *attr, char *buf)
199{ 199{
200 struct dcssblk_dev_info *dev_info; 200 struct dcssblk_dev_info *dev_info;
201 201
@@ -204,7 +204,7 @@ dcssblk_shared_show(struct device *dev, char *buf)
204} 204}
205 205
206static ssize_t 206static ssize_t
207dcssblk_shared_store(struct device *dev, const char *inbuf, size_t count) 207dcssblk_shared_store(struct device *dev, struct device_attribute *attr, const char *inbuf, size_t count)
208{ 208{
209 struct dcssblk_dev_info *dev_info; 209 struct dcssblk_dev_info *dev_info;
210 int rc; 210 int rc;
@@ -288,7 +288,7 @@ out:
288 * (show + store) 288 * (show + store)
289 */ 289 */
290static ssize_t 290static ssize_t
291dcssblk_save_show(struct device *dev, char *buf) 291dcssblk_save_show(struct device *dev, struct device_attribute *attr, char *buf)
292{ 292{
293 struct dcssblk_dev_info *dev_info; 293 struct dcssblk_dev_info *dev_info;
294 294
@@ -297,7 +297,7 @@ dcssblk_save_show(struct device *dev, char *buf)
297} 297}
298 298
299static ssize_t 299static ssize_t
300dcssblk_save_store(struct device *dev, const char *inbuf, size_t count) 300dcssblk_save_store(struct device *dev, struct device_attribute *attr, const char *inbuf, size_t count)
301{ 301{
302 struct dcssblk_dev_info *dev_info; 302 struct dcssblk_dev_info *dev_info;
303 303
@@ -343,7 +343,7 @@ dcssblk_save_store(struct device *dev, const char *inbuf, size_t count)
343 * device attribute for adding devices 343 * device attribute for adding devices
344 */ 344 */
345static ssize_t 345static ssize_t
346dcssblk_add_store(struct device *dev, const char *buf, size_t count) 346dcssblk_add_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
347{ 347{
348 int rc, i; 348 int rc, i;
349 struct dcssblk_dev_info *dev_info; 349 struct dcssblk_dev_info *dev_info;
@@ -517,7 +517,7 @@ out_nobuf:
517 * device attribute for removing devices 517 * device attribute for removing devices
518 */ 518 */
519static ssize_t 519static ssize_t
520dcssblk_remove_store(struct device *dev, const char *buf, size_t count) 520dcssblk_remove_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
521{ 521{
522 struct dcssblk_dev_info *dev_info; 522 struct dcssblk_dev_info *dev_info;
523 int rc, i; 523 int rc, i;
diff --git a/drivers/s390/char/raw3270.c b/drivers/s390/char/raw3270.c
index 8e16a9716686..d5eefeaba50c 100644
--- a/drivers/s390/char/raw3270.c
+++ b/drivers/s390/char/raw3270.c
@@ -1084,7 +1084,7 @@ raw3270_probe (struct ccw_device *cdev)
1084 * Additional attributes for a 3270 device 1084 * Additional attributes for a 3270 device
1085 */ 1085 */
1086static ssize_t 1086static ssize_t
1087raw3270_model_show(struct device *dev, char *buf) 1087raw3270_model_show(struct device *dev, struct device_attribute *attr, char *buf)
1088{ 1088{
1089 return snprintf(buf, PAGE_SIZE, "%i\n", 1089 return snprintf(buf, PAGE_SIZE, "%i\n",
1090 ((struct raw3270 *) dev->driver_data)->model); 1090 ((struct raw3270 *) dev->driver_data)->model);
@@ -1092,7 +1092,7 @@ raw3270_model_show(struct device *dev, char *buf)
1092static DEVICE_ATTR(model, 0444, raw3270_model_show, 0); 1092static DEVICE_ATTR(model, 0444, raw3270_model_show, 0);
1093 1093
1094static ssize_t 1094static ssize_t
1095raw3270_rows_show(struct device *dev, char *buf) 1095raw3270_rows_show(struct device *dev, struct device_attribute *attr, char *buf)
1096{ 1096{
1097 return snprintf(buf, PAGE_SIZE, "%i\n", 1097 return snprintf(buf, PAGE_SIZE, "%i\n",
1098 ((struct raw3270 *) dev->driver_data)->rows); 1098 ((struct raw3270 *) dev->driver_data)->rows);
@@ -1100,7 +1100,7 @@ raw3270_rows_show(struct device *dev, char *buf)
1100static DEVICE_ATTR(rows, 0444, raw3270_rows_show, 0); 1100static DEVICE_ATTR(rows, 0444, raw3270_rows_show, 0);
1101 1101
1102static ssize_t 1102static ssize_t
1103raw3270_columns_show(struct device *dev, char *buf) 1103raw3270_columns_show(struct device *dev, struct device_attribute *attr, char *buf)
1104{ 1104{
1105 return snprintf(buf, PAGE_SIZE, "%i\n", 1105 return snprintf(buf, PAGE_SIZE, "%i\n",
1106 ((struct raw3270 *) dev->driver_data)->cols); 1106 ((struct raw3270 *) dev->driver_data)->cols);
diff --git a/drivers/s390/char/tape_class.c b/drivers/s390/char/tape_class.c
index 0f8ffd4167ca..ed0cb1f15b4c 100644
--- a/drivers/s390/char/tape_class.c
+++ b/drivers/s390/char/tape_class.c
@@ -16,7 +16,7 @@ MODULE_DESCRIPTION(
16); 16);
17MODULE_LICENSE("GPL"); 17MODULE_LICENSE("GPL");
18 18
19struct class_simple *tape_class; 19static struct class *tape_class;
20 20
21/* 21/*
22 * Register a tape device and return a pointer to the cdev structure. 22 * Register a tape device and return a pointer to the cdev structure.
@@ -70,7 +70,7 @@ struct tape_class_device *register_tape_dev(
70 if (rc) 70 if (rc)
71 goto fail_with_cdev; 71 goto fail_with_cdev;
72 72
73 tcd->class_device = class_simple_device_add( 73 tcd->class_device = class_device_create(
74 tape_class, 74 tape_class,
75 tcd->char_device->dev, 75 tcd->char_device->dev,
76 device, 76 device,
@@ -101,7 +101,7 @@ void unregister_tape_dev(struct tape_class_device *tcd)
101 &tcd->class_device->dev->kobj, 101 &tcd->class_device->dev->kobj,
102 tcd->mode_name 102 tcd->mode_name
103 ); 103 );
104 class_simple_device_remove(tcd->char_device->dev); 104 class_device_destroy(tape_class, tcd->char_device->dev);
105 cdev_del(tcd->char_device); 105 cdev_del(tcd->char_device);
106 kfree(tcd); 106 kfree(tcd);
107 } 107 }
@@ -111,14 +111,14 @@ EXPORT_SYMBOL(unregister_tape_dev);
111 111
112static int __init tape_init(void) 112static int __init tape_init(void)
113{ 113{
114 tape_class = class_simple_create(THIS_MODULE, "tape390"); 114 tape_class = class_create(THIS_MODULE, "tape390");
115 115
116 return 0; 116 return 0;
117} 117}
118 118
119static void __exit tape_exit(void) 119static void __exit tape_exit(void)
120{ 120{
121 class_simple_destroy(tape_class); 121 class_destroy(tape_class);
122 tape_class = NULL; 122 tape_class = NULL;
123} 123}
124 124
diff --git a/drivers/s390/char/tape_core.c b/drivers/s390/char/tape_core.c
index e51046ab8adc..b4df4a515b12 100644
--- a/drivers/s390/char/tape_core.c
+++ b/drivers/s390/char/tape_core.c
@@ -107,7 +107,7 @@ busid_to_int(char *bus_id)
107 * replaced by a link to the cdev tree. 107 * replaced by a link to the cdev tree.
108 */ 108 */
109static ssize_t 109static ssize_t
110tape_medium_state_show(struct device *dev, char *buf) 110tape_medium_state_show(struct device *dev, struct device_attribute *attr, char *buf)
111{ 111{
112 struct tape_device *tdev; 112 struct tape_device *tdev;
113 113
@@ -119,7 +119,7 @@ static
119DEVICE_ATTR(medium_state, 0444, tape_medium_state_show, NULL); 119DEVICE_ATTR(medium_state, 0444, tape_medium_state_show, NULL);
120 120
121static ssize_t 121static ssize_t
122tape_first_minor_show(struct device *dev, char *buf) 122tape_first_minor_show(struct device *dev, struct device_attribute *attr, char *buf)
123{ 123{
124 struct tape_device *tdev; 124 struct tape_device *tdev;
125 125
@@ -131,7 +131,7 @@ static
131DEVICE_ATTR(first_minor, 0444, tape_first_minor_show, NULL); 131DEVICE_ATTR(first_minor, 0444, tape_first_minor_show, NULL);
132 132
133static ssize_t 133static ssize_t
134tape_state_show(struct device *dev, char *buf) 134tape_state_show(struct device *dev, struct device_attribute *attr, char *buf)
135{ 135{
136 struct tape_device *tdev; 136 struct tape_device *tdev;
137 137
@@ -144,7 +144,7 @@ static
144DEVICE_ATTR(state, 0444, tape_state_show, NULL); 144DEVICE_ATTR(state, 0444, tape_state_show, NULL);
145 145
146static ssize_t 146static ssize_t
147tape_operation_show(struct device *dev, char *buf) 147tape_operation_show(struct device *dev, struct device_attribute *attr, char *buf)
148{ 148{
149 struct tape_device *tdev; 149 struct tape_device *tdev;
150 ssize_t rc; 150 ssize_t rc;
@@ -171,7 +171,7 @@ static
171DEVICE_ATTR(operation, 0444, tape_operation_show, NULL); 171DEVICE_ATTR(operation, 0444, tape_operation_show, NULL);
172 172
173static ssize_t 173static ssize_t
174tape_blocksize_show(struct device *dev, char *buf) 174tape_blocksize_show(struct device *dev, struct device_attribute *attr, char *buf)
175{ 175{
176 struct tape_device *tdev; 176 struct tape_device *tdev;
177 177
diff --git a/drivers/s390/char/vmlogrdr.c b/drivers/s390/char/vmlogrdr.c
index edf50d2bd10b..f7717327d15e 100644
--- a/drivers/s390/char/vmlogrdr.c
+++ b/drivers/s390/char/vmlogrdr.c
@@ -548,7 +548,7 @@ vmlogrdr_read (struct file *filp, char *data, size_t count, loff_t * ppos)
548} 548}
549 549
550static ssize_t 550static ssize_t
551vmlogrdr_autopurge_store(struct device * dev, const char * buf, size_t count) { 551vmlogrdr_autopurge_store(struct device * dev, struct device_attribute *attr, const char * buf, size_t count) {
552 struct vmlogrdr_priv_t *priv = dev->driver_data; 552 struct vmlogrdr_priv_t *priv = dev->driver_data;
553 ssize_t ret = count; 553 ssize_t ret = count;
554 554
@@ -567,7 +567,7 @@ vmlogrdr_autopurge_store(struct device * dev, const char * buf, size_t count) {
567 567
568 568
569static ssize_t 569static ssize_t
570vmlogrdr_autopurge_show(struct device *dev, char *buf) { 570vmlogrdr_autopurge_show(struct device *dev, struct device_attribute *attr, char *buf) {
571 struct vmlogrdr_priv_t *priv = dev->driver_data; 571 struct vmlogrdr_priv_t *priv = dev->driver_data;
572 return sprintf(buf, "%u\n", priv->autopurge); 572 return sprintf(buf, "%u\n", priv->autopurge);
573} 573}
@@ -578,7 +578,7 @@ static DEVICE_ATTR(autopurge, 0644, vmlogrdr_autopurge_show,
578 578
579 579
580static ssize_t 580static ssize_t
581vmlogrdr_purge_store(struct device * dev, const char * buf, size_t count) { 581vmlogrdr_purge_store(struct device * dev, struct device_attribute *attr, const char * buf, size_t count) {
582 582
583 char cp_command[80]; 583 char cp_command[80];
584 char cp_response[80]; 584 char cp_response[80];
@@ -619,7 +619,7 @@ static DEVICE_ATTR(purge, 0200, NULL, vmlogrdr_purge_store);
619 619
620 620
621static ssize_t 621static ssize_t
622vmlogrdr_autorecording_store(struct device *dev, const char *buf, 622vmlogrdr_autorecording_store(struct device *dev, struct device_attribute *attr, const char *buf,
623 size_t count) { 623 size_t count) {
624 struct vmlogrdr_priv_t *priv = dev->driver_data; 624 struct vmlogrdr_priv_t *priv = dev->driver_data;
625 ssize_t ret = count; 625 ssize_t ret = count;
@@ -639,7 +639,7 @@ vmlogrdr_autorecording_store(struct device *dev, const char *buf,
639 639
640 640
641static ssize_t 641static ssize_t
642vmlogrdr_autorecording_show(struct device *dev, char *buf) { 642vmlogrdr_autorecording_show(struct device *dev, struct device_attribute *attr, char *buf) {
643 struct vmlogrdr_priv_t *priv = dev->driver_data; 643 struct vmlogrdr_priv_t *priv = dev->driver_data;
644 return sprintf(buf, "%u\n", priv->autorecording); 644 return sprintf(buf, "%u\n", priv->autorecording);
645} 645}
@@ -650,7 +650,7 @@ static DEVICE_ATTR(autorecording, 0644, vmlogrdr_autorecording_show,
650 650
651 651
652static ssize_t 652static ssize_t
653vmlogrdr_recording_store(struct device * dev, const char * buf, size_t count) { 653vmlogrdr_recording_store(struct device * dev, struct device_attribute *attr, const char * buf, size_t count) {
654 654
655 struct vmlogrdr_priv_t *priv = dev->driver_data; 655 struct vmlogrdr_priv_t *priv = dev->driver_data;
656 ssize_t ret; 656 ssize_t ret;
@@ -703,7 +703,7 @@ static struct attribute_group vmlogrdr_attr_group = {
703 .attrs = vmlogrdr_attrs, 703 .attrs = vmlogrdr_attrs,
704}; 704};
705 705
706static struct class_simple *vmlogrdr_class; 706static struct class *vmlogrdr_class;
707static struct device_driver vmlogrdr_driver = { 707static struct device_driver vmlogrdr_driver = {
708 .name = "vmlogrdr", 708 .name = "vmlogrdr",
709 .bus = &iucv_bus, 709 .bus = &iucv_bus,
@@ -727,7 +727,7 @@ vmlogrdr_register_driver(void) {
727 goto unregdriver; 727 goto unregdriver;
728 } 728 }
729 729
730 vmlogrdr_class = class_simple_create(THIS_MODULE, "vmlogrdr"); 730 vmlogrdr_class = class_create(THIS_MODULE, "vmlogrdr");
731 if (IS_ERR(vmlogrdr_class)) { 731 if (IS_ERR(vmlogrdr_class)) {
732 printk(KERN_ERR "vmlogrdr: failed to create class.\n"); 732 printk(KERN_ERR "vmlogrdr: failed to create class.\n");
733 ret=PTR_ERR(vmlogrdr_class); 733 ret=PTR_ERR(vmlogrdr_class);
@@ -746,7 +746,7 @@ unregdriver:
746 746
747static void 747static void
748vmlogrdr_unregister_driver(void) { 748vmlogrdr_unregister_driver(void) {
749 class_simple_destroy(vmlogrdr_class); 749 class_destroy(vmlogrdr_class);
750 vmlogrdr_class = NULL; 750 vmlogrdr_class = NULL;
751 driver_remove_file(&vmlogrdr_driver, &driver_attr_recording_status); 751 driver_remove_file(&vmlogrdr_driver, &driver_attr_recording_status);
752 driver_unregister(&vmlogrdr_driver); 752 driver_unregister(&vmlogrdr_driver);
@@ -786,7 +786,7 @@ vmlogrdr_register_device(struct vmlogrdr_priv_t *priv) {
786 device_unregister(dev); 786 device_unregister(dev);
787 return ret; 787 return ret;
788 } 788 }
789 priv->class_device = class_simple_device_add( 789 priv->class_device = class_device_create(
790 vmlogrdr_class, 790 vmlogrdr_class,
791 MKDEV(vmlogrdr_major, priv->minor_num), 791 MKDEV(vmlogrdr_major, priv->minor_num),
792 dev, 792 dev,
@@ -806,7 +806,7 @@ vmlogrdr_register_device(struct vmlogrdr_priv_t *priv) {
806 806
807static int 807static int
808vmlogrdr_unregister_device(struct vmlogrdr_priv_t *priv ) { 808vmlogrdr_unregister_device(struct vmlogrdr_priv_t *priv ) {
809 class_simple_device_remove(MKDEV(vmlogrdr_major, priv->minor_num)); 809 class_device_destroy(vmlogrdr_class, MKDEV(vmlogrdr_major, priv->minor_num));
810 if (priv->device != NULL) { 810 if (priv->device != NULL) {
811 sysfs_remove_group(&priv->device->kobj, &vmlogrdr_attr_group); 811 sysfs_remove_group(&priv->device->kobj, &vmlogrdr_attr_group);
812 device_unregister(priv->device); 812 device_unregister(priv->device);
diff --git a/drivers/s390/cio/ccwgroup.c b/drivers/s390/cio/ccwgroup.c
index 21a75ee28b80..306525acb9f8 100644
--- a/drivers/s390/cio/ccwgroup.c
+++ b/drivers/s390/cio/ccwgroup.c
@@ -77,7 +77,7 @@ __ccwgroup_remove_symlinks(struct ccwgroup_device *gdev)
77 * longer needed or accidentially created. Saves memory :) 77 * longer needed or accidentially created. Saves memory :)
78 */ 78 */
79static ssize_t 79static ssize_t
80ccwgroup_ungroup_store(struct device *dev, const char *buf, size_t count) 80ccwgroup_ungroup_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
81{ 81{
82 struct ccwgroup_device *gdev; 82 struct ccwgroup_device *gdev;
83 83
@@ -310,7 +310,7 @@ ccwgroup_set_offline(struct ccwgroup_device *gdev)
310} 310}
311 311
312static ssize_t 312static ssize_t
313ccwgroup_online_store (struct device *dev, const char *buf, size_t count) 313ccwgroup_online_store (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
314{ 314{
315 struct ccwgroup_device *gdev; 315 struct ccwgroup_device *gdev;
316 struct ccwgroup_driver *gdrv; 316 struct ccwgroup_driver *gdrv;
@@ -338,7 +338,7 @@ ccwgroup_online_store (struct device *dev, const char *buf, size_t count)
338} 338}
339 339
340static ssize_t 340static ssize_t
341ccwgroup_online_show (struct device *dev, char *buf) 341ccwgroup_online_show (struct device *dev, struct device_attribute *attr, char *buf)
342{ 342{
343 int online; 343 int online;
344 344
diff --git a/drivers/s390/cio/chsc.c b/drivers/s390/cio/chsc.c
index b35fe12e6bfc..b86f94ecd874 100644
--- a/drivers/s390/cio/chsc.c
+++ b/drivers/s390/cio/chsc.c
@@ -852,7 +852,7 @@ out:
852 * Files for the channel path entries. 852 * Files for the channel path entries.
853 */ 853 */
854static ssize_t 854static ssize_t
855chp_status_show(struct device *dev, char *buf) 855chp_status_show(struct device *dev, struct device_attribute *attr, char *buf)
856{ 856{
857 struct channel_path *chp = container_of(dev, struct channel_path, dev); 857 struct channel_path *chp = container_of(dev, struct channel_path, dev);
858 858
@@ -863,7 +863,7 @@ chp_status_show(struct device *dev, char *buf)
863} 863}
864 864
865static ssize_t 865static ssize_t
866chp_status_write(struct device *dev, const char *buf, size_t count) 866chp_status_write(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
867{ 867{
868 struct channel_path *cp = container_of(dev, struct channel_path, dev); 868 struct channel_path *cp = container_of(dev, struct channel_path, dev);
869 char cmd[10]; 869 char cmd[10];
@@ -888,7 +888,7 @@ chp_status_write(struct device *dev, const char *buf, size_t count)
888static DEVICE_ATTR(status, 0644, chp_status_show, chp_status_write); 888static DEVICE_ATTR(status, 0644, chp_status_show, chp_status_write);
889 889
890static ssize_t 890static ssize_t
891chp_type_show(struct device *dev, char *buf) 891chp_type_show(struct device *dev, struct device_attribute *attr, char *buf)
892{ 892{
893 struct channel_path *chp = container_of(dev, struct channel_path, dev); 893 struct channel_path *chp = container_of(dev, struct channel_path, dev);
894 894
diff --git a/drivers/s390/cio/cmf.c b/drivers/s390/cio/cmf.c
index 49def26ba383..8cc4f1a940dc 100644
--- a/drivers/s390/cio/cmf.c
+++ b/drivers/s390/cio/cmf.c
@@ -796,7 +796,7 @@ cmb_show_attr(struct device *dev, char *buf, enum cmb_index idx)
796} 796}
797 797
798static ssize_t 798static ssize_t
799cmb_show_avg_sample_interval(struct device *dev, char *buf) 799cmb_show_avg_sample_interval(struct device *dev, struct device_attribute *attr, char *buf)
800{ 800{
801 struct ccw_device *cdev; 801 struct ccw_device *cdev;
802 long interval; 802 long interval;
@@ -813,7 +813,7 @@ cmb_show_avg_sample_interval(struct device *dev, char *buf)
813} 813}
814 814
815static ssize_t 815static ssize_t
816cmb_show_avg_utilization(struct device *dev, char *buf) 816cmb_show_avg_utilization(struct device *dev, struct device_attribute *attr, char *buf)
817{ 817{
818 struct cmbdata data; 818 struct cmbdata data;
819 u64 utilization; 819 u64 utilization;
@@ -842,12 +842,12 @@ cmb_show_avg_utilization(struct device *dev, char *buf)
842} 842}
843 843
844#define cmf_attr(name) \ 844#define cmf_attr(name) \
845static ssize_t show_ ## name (struct device * dev, char * buf) \ 845static ssize_t show_ ## name (struct device * dev, struct device_attribute *attr, char * buf) \
846{ return cmb_show_attr((dev), buf, cmb_ ## name); } \ 846{ return cmb_show_attr((dev), buf, cmb_ ## name); } \
847static DEVICE_ATTR(name, 0444, show_ ## name, NULL); 847static DEVICE_ATTR(name, 0444, show_ ## name, NULL);
848 848
849#define cmf_attr_avg(name) \ 849#define cmf_attr_avg(name) \
850static ssize_t show_avg_ ## name (struct device * dev, char * buf) \ 850static ssize_t show_avg_ ## name (struct device * dev, struct device_attribute *attr, char * buf) \
851{ return cmb_show_attr((dev), buf, cmb_ ## name); } \ 851{ return cmb_show_attr((dev), buf, cmb_ ## name); } \
852static DEVICE_ATTR(avg_ ## name, 0444, show_avg_ ## name, NULL); 852static DEVICE_ATTR(avg_ ## name, 0444, show_avg_ ## name, NULL);
853 853
@@ -902,12 +902,12 @@ static struct attribute_group cmf_attr_group_ext = {
902 .attrs = cmf_attributes_ext, 902 .attrs = cmf_attributes_ext,
903}; 903};
904 904
905static ssize_t cmb_enable_show(struct device *dev, char *buf) 905static ssize_t cmb_enable_show(struct device *dev, struct device_attribute *attr, char *buf)
906{ 906{
907 return sprintf(buf, "%d\n", to_ccwdev(dev)->private->cmb ? 1 : 0); 907 return sprintf(buf, "%d\n", to_ccwdev(dev)->private->cmb ? 1 : 0);
908} 908}
909 909
910static ssize_t cmb_enable_store(struct device *dev, const char *buf, size_t c) 910static ssize_t cmb_enable_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t c)
911{ 911{
912 struct ccw_device *cdev; 912 struct ccw_device *cdev;
913 int ret; 913 int ret;
diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c
index df0325505e4e..809e1108a06e 100644
--- a/drivers/s390/cio/device.c
+++ b/drivers/s390/cio/device.c
@@ -204,7 +204,7 @@ module_exit(cleanup_ccw_bus_type);
204 * TODO: Split chpids and pimpampom up? Where is "in use" in the tree? 204 * TODO: Split chpids and pimpampom up? Where is "in use" in the tree?
205 */ 205 */
206static ssize_t 206static ssize_t
207chpids_show (struct device * dev, char * buf) 207chpids_show (struct device * dev, struct device_attribute *attr, char * buf)
208{ 208{
209 struct subchannel *sch = to_subchannel(dev); 209 struct subchannel *sch = to_subchannel(dev);
210 struct ssd_info *ssd = &sch->ssd_info; 210 struct ssd_info *ssd = &sch->ssd_info;
@@ -219,7 +219,7 @@ chpids_show (struct device * dev, char * buf)
219} 219}
220 220
221static ssize_t 221static ssize_t
222pimpampom_show (struct device * dev, char * buf) 222pimpampom_show (struct device * dev, struct device_attribute *attr, char * buf)
223{ 223{
224 struct subchannel *sch = to_subchannel(dev); 224 struct subchannel *sch = to_subchannel(dev);
225 struct pmcw *pmcw = &sch->schib.pmcw; 225 struct pmcw *pmcw = &sch->schib.pmcw;
@@ -229,7 +229,7 @@ pimpampom_show (struct device * dev, char * buf)
229} 229}
230 230
231static ssize_t 231static ssize_t
232devtype_show (struct device *dev, char *buf) 232devtype_show (struct device *dev, struct device_attribute *attr, char *buf)
233{ 233{
234 struct ccw_device *cdev = to_ccwdev(dev); 234 struct ccw_device *cdev = to_ccwdev(dev);
235 struct ccw_device_id *id = &(cdev->id); 235 struct ccw_device_id *id = &(cdev->id);
@@ -242,7 +242,7 @@ devtype_show (struct device *dev, char *buf)
242} 242}
243 243
244static ssize_t 244static ssize_t
245cutype_show (struct device *dev, char *buf) 245cutype_show (struct device *dev, struct device_attribute *attr, char *buf)
246{ 246{
247 struct ccw_device *cdev = to_ccwdev(dev); 247 struct ccw_device *cdev = to_ccwdev(dev);
248 struct ccw_device_id *id = &(cdev->id); 248 struct ccw_device_id *id = &(cdev->id);
@@ -252,7 +252,7 @@ cutype_show (struct device *dev, char *buf)
252} 252}
253 253
254static ssize_t 254static ssize_t
255online_show (struct device *dev, char *buf) 255online_show (struct device *dev, struct device_attribute *attr, char *buf)
256{ 256{
257 struct ccw_device *cdev = to_ccwdev(dev); 257 struct ccw_device *cdev = to_ccwdev(dev);
258 258
@@ -350,7 +350,7 @@ ccw_device_set_online(struct ccw_device *cdev)
350} 350}
351 351
352static ssize_t 352static ssize_t
353online_store (struct device *dev, const char *buf, size_t count) 353online_store (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
354{ 354{
355 struct ccw_device *cdev = to_ccwdev(dev); 355 struct ccw_device *cdev = to_ccwdev(dev);
356 int i, force, ret; 356 int i, force, ret;
@@ -422,7 +422,7 @@ online_store (struct device *dev, const char *buf, size_t count)
422} 422}
423 423
424static ssize_t 424static ssize_t
425available_show (struct device *dev, char *buf) 425available_show (struct device *dev, struct device_attribute *attr, char *buf)
426{ 426{
427 struct ccw_device *cdev = to_ccwdev(dev); 427 struct ccw_device *cdev = to_ccwdev(dev);
428 struct subchannel *sch; 428 struct subchannel *sch;
diff --git a/drivers/s390/net/claw.c b/drivers/s390/net/claw.c
index 06804d39a9c6..a99927d54ebb 100644
--- a/drivers/s390/net/claw.c
+++ b/drivers/s390/net/claw.c
@@ -241,20 +241,20 @@ static struct sk_buff *claw_pack_skb(struct claw_privbk *privptr);
241static void dumpit (char *buf, int len); 241static void dumpit (char *buf, int len);
242#endif 242#endif
243/* sysfs Functions */ 243/* sysfs Functions */
244static ssize_t claw_hname_show(struct device *dev, char *buf); 244static ssize_t claw_hname_show(struct device *dev, struct device_attribute *attr, char *buf);
245static ssize_t claw_hname_write(struct device *dev, 245static ssize_t claw_hname_write(struct device *dev, struct device_attribute *attr,
246 const char *buf, size_t count); 246 const char *buf, size_t count);
247static ssize_t claw_adname_show(struct device *dev, char *buf); 247static ssize_t claw_adname_show(struct device *dev, struct device_attribute *attr, char *buf);
248static ssize_t claw_adname_write(struct device *dev, 248static ssize_t claw_adname_write(struct device *dev, struct device_attribute *attr,
249 const char *buf, size_t count); 249 const char *buf, size_t count);
250static ssize_t claw_apname_show(struct device *dev, char *buf); 250static ssize_t claw_apname_show(struct device *dev, struct device_attribute *attr, char *buf);
251static ssize_t claw_apname_write(struct device *dev, 251static ssize_t claw_apname_write(struct device *dev, struct device_attribute *attr,
252 const char *buf, size_t count); 252 const char *buf, size_t count);
253static ssize_t claw_wbuff_show(struct device *dev, char *buf); 253static ssize_t claw_wbuff_show(struct device *dev, struct device_attribute *attr, char *buf);
254static ssize_t claw_wbuff_write(struct device *dev, 254static ssize_t claw_wbuff_write(struct device *dev, struct device_attribute *attr,
255 const char *buf, size_t count); 255 const char *buf, size_t count);
256static ssize_t claw_rbuff_show(struct device *dev, char *buf); 256static ssize_t claw_rbuff_show(struct device *dev, struct device_attribute *attr, char *buf);
257static ssize_t claw_rbuff_write(struct device *dev, 257static ssize_t claw_rbuff_write(struct device *dev, struct device_attribute *attr,
258 const char *buf, size_t count); 258 const char *buf, size_t count);
259static int claw_add_files(struct device *dev); 259static int claw_add_files(struct device *dev);
260static void claw_remove_files(struct device *dev); 260static void claw_remove_files(struct device *dev);
@@ -4149,7 +4149,7 @@ claw_remove_device(struct ccwgroup_device *cgdev)
4149 * sysfs attributes 4149 * sysfs attributes
4150 */ 4150 */
4151static ssize_t 4151static ssize_t
4152claw_hname_show(struct device *dev, char *buf) 4152claw_hname_show(struct device *dev, struct device_attribute *attr, char *buf)
4153{ 4153{
4154 struct claw_privbk *priv; 4154 struct claw_privbk *priv;
4155 struct claw_env * p_env; 4155 struct claw_env * p_env;
@@ -4162,7 +4162,7 @@ claw_hname_show(struct device *dev, char *buf)
4162} 4162}
4163 4163
4164static ssize_t 4164static ssize_t
4165claw_hname_write(struct device *dev, const char *buf, size_t count) 4165claw_hname_write(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
4166{ 4166{
4167 struct claw_privbk *priv; 4167 struct claw_privbk *priv;
4168 struct claw_env * p_env; 4168 struct claw_env * p_env;
@@ -4186,7 +4186,7 @@ claw_hname_write(struct device *dev, const char *buf, size_t count)
4186static DEVICE_ATTR(host_name, 0644, claw_hname_show, claw_hname_write); 4186static DEVICE_ATTR(host_name, 0644, claw_hname_show, claw_hname_write);
4187 4187
4188static ssize_t 4188static ssize_t
4189claw_adname_show(struct device *dev, char *buf) 4189claw_adname_show(struct device *dev, struct device_attribute *attr, char *buf)
4190{ 4190{
4191 struct claw_privbk *priv; 4191 struct claw_privbk *priv;
4192 struct claw_env * p_env; 4192 struct claw_env * p_env;
@@ -4199,7 +4199,7 @@ claw_adname_show(struct device *dev, char *buf)
4199} 4199}
4200 4200
4201static ssize_t 4201static ssize_t
4202claw_adname_write(struct device *dev, const char *buf, size_t count) 4202claw_adname_write(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
4203{ 4203{
4204 struct claw_privbk *priv; 4204 struct claw_privbk *priv;
4205 struct claw_env * p_env; 4205 struct claw_env * p_env;
@@ -4223,7 +4223,7 @@ claw_adname_write(struct device *dev, const char *buf, size_t count)
4223static DEVICE_ATTR(adapter_name, 0644, claw_adname_show, claw_adname_write); 4223static DEVICE_ATTR(adapter_name, 0644, claw_adname_show, claw_adname_write);
4224 4224
4225static ssize_t 4225static ssize_t
4226claw_apname_show(struct device *dev, char *buf) 4226claw_apname_show(struct device *dev, struct device_attribute *attr, char *buf)
4227{ 4227{
4228 struct claw_privbk *priv; 4228 struct claw_privbk *priv;
4229 struct claw_env * p_env; 4229 struct claw_env * p_env;
@@ -4237,7 +4237,7 @@ claw_apname_show(struct device *dev, char *buf)
4237} 4237}
4238 4238
4239static ssize_t 4239static ssize_t
4240claw_apname_write(struct device *dev, const char *buf, size_t count) 4240claw_apname_write(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
4241{ 4241{
4242 struct claw_privbk *priv; 4242 struct claw_privbk *priv;
4243 struct claw_env * p_env; 4243 struct claw_env * p_env;
@@ -4271,7 +4271,7 @@ claw_apname_write(struct device *dev, const char *buf, size_t count)
4271static DEVICE_ATTR(api_type, 0644, claw_apname_show, claw_apname_write); 4271static DEVICE_ATTR(api_type, 0644, claw_apname_show, claw_apname_write);
4272 4272
4273static ssize_t 4273static ssize_t
4274claw_wbuff_show(struct device *dev, char *buf) 4274claw_wbuff_show(struct device *dev, struct device_attribute *attr, char *buf)
4275{ 4275{
4276 struct claw_privbk *priv; 4276 struct claw_privbk *priv;
4277 struct claw_env * p_env; 4277 struct claw_env * p_env;
@@ -4284,7 +4284,7 @@ claw_wbuff_show(struct device *dev, char *buf)
4284} 4284}
4285 4285
4286static ssize_t 4286static ssize_t
4287claw_wbuff_write(struct device *dev, const char *buf, size_t count) 4287claw_wbuff_write(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
4288{ 4288{
4289 struct claw_privbk *priv; 4289 struct claw_privbk *priv;
4290 struct claw_env * p_env; 4290 struct claw_env * p_env;
@@ -4312,7 +4312,7 @@ claw_wbuff_write(struct device *dev, const char *buf, size_t count)
4312static DEVICE_ATTR(write_buffer, 0644, claw_wbuff_show, claw_wbuff_write); 4312static DEVICE_ATTR(write_buffer, 0644, claw_wbuff_show, claw_wbuff_write);
4313 4313
4314static ssize_t 4314static ssize_t
4315claw_rbuff_show(struct device *dev, char *buf) 4315claw_rbuff_show(struct device *dev, struct device_attribute *attr, char *buf)
4316{ 4316{
4317 struct claw_privbk *priv; 4317 struct claw_privbk *priv;
4318 struct claw_env * p_env; 4318 struct claw_env * p_env;
@@ -4325,7 +4325,7 @@ claw_rbuff_show(struct device *dev, char *buf)
4325} 4325}
4326 4326
4327static ssize_t 4327static ssize_t
4328claw_rbuff_write(struct device *dev, const char *buf, size_t count) 4328claw_rbuff_write(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
4329{ 4329{
4330 struct claw_privbk *priv; 4330 struct claw_privbk *priv;
4331 struct claw_env *p_env; 4331 struct claw_env *p_env;
diff --git a/drivers/s390/net/ctcmain.c b/drivers/s390/net/ctcmain.c
index ff3e95e07e89..96ca863eaff2 100644
--- a/drivers/s390/net/ctcmain.c
+++ b/drivers/s390/net/ctcmain.c
@@ -2469,7 +2469,7 @@ ctc_stats(struct net_device * dev)
2469 */ 2469 */
2470 2470
2471static ssize_t 2471static ssize_t
2472buffer_show(struct device *dev, char *buf) 2472buffer_show(struct device *dev, struct device_attribute *attr, char *buf)
2473{ 2473{
2474 struct ctc_priv *priv; 2474 struct ctc_priv *priv;
2475 2475
@@ -2481,7 +2481,7 @@ buffer_show(struct device *dev, char *buf)
2481} 2481}
2482 2482
2483static ssize_t 2483static ssize_t
2484buffer_write(struct device *dev, const char *buf, size_t count) 2484buffer_write(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
2485{ 2485{
2486 struct ctc_priv *priv; 2486 struct ctc_priv *priv;
2487 struct net_device *ndev; 2487 struct net_device *ndev;
@@ -2530,13 +2530,13 @@ einval:
2530} 2530}
2531 2531
2532static ssize_t 2532static ssize_t
2533loglevel_show(struct device *dev, char *buf) 2533loglevel_show(struct device *dev, struct device_attribute *attr, char *buf)
2534{ 2534{
2535 return sprintf(buf, "%d\n", loglevel); 2535 return sprintf(buf, "%d\n", loglevel);
2536} 2536}
2537 2537
2538static ssize_t 2538static ssize_t
2539loglevel_write(struct device *dev, const char *buf, size_t count) 2539loglevel_write(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
2540{ 2540{
2541 int ll1; 2541 int ll1;
2542 2542
@@ -2589,7 +2589,7 @@ ctc_print_statistics(struct ctc_priv *priv)
2589} 2589}
2590 2590
2591static ssize_t 2591static ssize_t
2592stats_show(struct device *dev, char *buf) 2592stats_show(struct device *dev, struct device_attribute *attr, char *buf)
2593{ 2593{
2594 struct ctc_priv *priv = dev->driver_data; 2594 struct ctc_priv *priv = dev->driver_data;
2595 if (!priv) 2595 if (!priv)
@@ -2599,7 +2599,7 @@ stats_show(struct device *dev, char *buf)
2599} 2599}
2600 2600
2601static ssize_t 2601static ssize_t
2602stats_write(struct device *dev, const char *buf, size_t count) 2602stats_write(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
2603{ 2603{
2604 struct ctc_priv *priv = dev->driver_data; 2604 struct ctc_priv *priv = dev->driver_data;
2605 if (!priv) 2605 if (!priv)
@@ -2654,7 +2654,7 @@ ctc_free_netdevice(struct net_device * dev, int free_dev)
2654} 2654}
2655 2655
2656static ssize_t 2656static ssize_t
2657ctc_proto_show(struct device *dev, char *buf) 2657ctc_proto_show(struct device *dev, struct device_attribute *attr, char *buf)
2658{ 2658{
2659 struct ctc_priv *priv; 2659 struct ctc_priv *priv;
2660 2660
@@ -2666,7 +2666,7 @@ ctc_proto_show(struct device *dev, char *buf)
2666} 2666}
2667 2667
2668static ssize_t 2668static ssize_t
2669ctc_proto_store(struct device *dev, const char *buf, size_t count) 2669ctc_proto_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
2670{ 2670{
2671 struct ctc_priv *priv; 2671 struct ctc_priv *priv;
2672 int value; 2672 int value;
@@ -2687,7 +2687,7 @@ ctc_proto_store(struct device *dev, const char *buf, size_t count)
2687 2687
2688 2688
2689static ssize_t 2689static ssize_t
2690ctc_type_show(struct device *dev, char *buf) 2690ctc_type_show(struct device *dev, struct device_attribute *attr, char *buf)
2691{ 2691{
2692 struct ccwgroup_device *cgdev; 2692 struct ccwgroup_device *cgdev;
2693 2693
diff --git a/drivers/s390/net/lcs.c b/drivers/s390/net/lcs.c
index cccfed248e70..ab086242d305 100644
--- a/drivers/s390/net/lcs.c
+++ b/drivers/s390/net/lcs.c
@@ -1984,7 +1984,7 @@ lcs_open_device(struct net_device *dev)
1984 * show function for portno called by cat or similar things 1984 * show function for portno called by cat or similar things
1985 */ 1985 */
1986static ssize_t 1986static ssize_t
1987lcs_portno_show (struct device *dev, char *buf) 1987lcs_portno_show (struct device *dev, struct device_attribute *attr, char *buf)
1988{ 1988{
1989 struct lcs_card *card; 1989 struct lcs_card *card;
1990 1990
@@ -2000,7 +2000,7 @@ lcs_portno_show (struct device *dev, char *buf)
2000 * store the value which is piped to file portno 2000 * store the value which is piped to file portno
2001 */ 2001 */
2002static ssize_t 2002static ssize_t
2003lcs_portno_store (struct device *dev, const char *buf, size_t count) 2003lcs_portno_store (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
2004{ 2004{
2005 struct lcs_card *card; 2005 struct lcs_card *card;
2006 int value; 2006 int value;
@@ -2021,7 +2021,7 @@ lcs_portno_store (struct device *dev, const char *buf, size_t count)
2021static DEVICE_ATTR(portno, 0644, lcs_portno_show, lcs_portno_store); 2021static DEVICE_ATTR(portno, 0644, lcs_portno_show, lcs_portno_store);
2022 2022
2023static ssize_t 2023static ssize_t
2024lcs_type_show(struct device *dev, char *buf) 2024lcs_type_show(struct device *dev, struct device_attribute *attr, char *buf)
2025{ 2025{
2026 struct ccwgroup_device *cgdev; 2026 struct ccwgroup_device *cgdev;
2027 2027
@@ -2035,7 +2035,7 @@ lcs_type_show(struct device *dev, char *buf)
2035static DEVICE_ATTR(type, 0444, lcs_type_show, NULL); 2035static DEVICE_ATTR(type, 0444, lcs_type_show, NULL);
2036 2036
2037static ssize_t 2037static ssize_t
2038lcs_timeout_show(struct device *dev, char *buf) 2038lcs_timeout_show(struct device *dev, struct device_attribute *attr, char *buf)
2039{ 2039{
2040 struct lcs_card *card; 2040 struct lcs_card *card;
2041 2041
@@ -2045,7 +2045,7 @@ lcs_timeout_show(struct device *dev, char *buf)
2045} 2045}
2046 2046
2047static ssize_t 2047static ssize_t
2048lcs_timeout_store (struct device *dev, const char *buf, size_t count) 2048lcs_timeout_store (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
2049{ 2049{
2050 struct lcs_card *card; 2050 struct lcs_card *card;
2051 int value; 2051 int value;
diff --git a/drivers/s390/net/netiucv.c b/drivers/s390/net/netiucv.c
index 16e8e69afb10..3fd4fb754b2d 100644
--- a/drivers/s390/net/netiucv.c
+++ b/drivers/s390/net/netiucv.c
@@ -1356,7 +1356,7 @@ netiucv_change_mtu (struct net_device * dev, int new_mtu)
1356 *****************************************************************************/ 1356 *****************************************************************************/
1357 1357
1358static ssize_t 1358static ssize_t
1359user_show (struct device *dev, char *buf) 1359user_show (struct device *dev, struct device_attribute *attr, char *buf)
1360{ 1360{
1361 struct netiucv_priv *priv = dev->driver_data; 1361 struct netiucv_priv *priv = dev->driver_data;
1362 1362
@@ -1365,7 +1365,7 @@ user_show (struct device *dev, char *buf)
1365} 1365}
1366 1366
1367static ssize_t 1367static ssize_t
1368user_write (struct device *dev, const char *buf, size_t count) 1368user_write (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1369{ 1369{
1370 struct netiucv_priv *priv = dev->driver_data; 1370 struct netiucv_priv *priv = dev->driver_data;
1371 struct net_device *ndev = priv->conn->netdev; 1371 struct net_device *ndev = priv->conn->netdev;
@@ -1422,7 +1422,7 @@ user_write (struct device *dev, const char *buf, size_t count)
1422static DEVICE_ATTR(user, 0644, user_show, user_write); 1422static DEVICE_ATTR(user, 0644, user_show, user_write);
1423 1423
1424static ssize_t 1424static ssize_t
1425buffer_show (struct device *dev, char *buf) 1425buffer_show (struct device *dev, struct device_attribute *attr, char *buf)
1426{ 1426{
1427 struct netiucv_priv *priv = dev->driver_data; 1427 struct netiucv_priv *priv = dev->driver_data;
1428 1428
@@ -1431,7 +1431,7 @@ buffer_show (struct device *dev, char *buf)
1431} 1431}
1432 1432
1433static ssize_t 1433static ssize_t
1434buffer_write (struct device *dev, const char *buf, size_t count) 1434buffer_write (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1435{ 1435{
1436 struct netiucv_priv *priv = dev->driver_data; 1436 struct netiucv_priv *priv = dev->driver_data;
1437 struct net_device *ndev = priv->conn->netdev; 1437 struct net_device *ndev = priv->conn->netdev;
@@ -1486,7 +1486,7 @@ buffer_write (struct device *dev, const char *buf, size_t count)
1486static DEVICE_ATTR(buffer, 0644, buffer_show, buffer_write); 1486static DEVICE_ATTR(buffer, 0644, buffer_show, buffer_write);
1487 1487
1488static ssize_t 1488static ssize_t
1489dev_fsm_show (struct device *dev, char *buf) 1489dev_fsm_show (struct device *dev, struct device_attribute *attr, char *buf)
1490{ 1490{
1491 struct netiucv_priv *priv = dev->driver_data; 1491 struct netiucv_priv *priv = dev->driver_data;
1492 1492
@@ -1497,7 +1497,7 @@ dev_fsm_show (struct device *dev, char *buf)
1497static DEVICE_ATTR(device_fsm_state, 0444, dev_fsm_show, NULL); 1497static DEVICE_ATTR(device_fsm_state, 0444, dev_fsm_show, NULL);
1498 1498
1499static ssize_t 1499static ssize_t
1500conn_fsm_show (struct device *dev, char *buf) 1500conn_fsm_show (struct device *dev, struct device_attribute *attr, char *buf)
1501{ 1501{
1502 struct netiucv_priv *priv = dev->driver_data; 1502 struct netiucv_priv *priv = dev->driver_data;
1503 1503
@@ -1508,7 +1508,7 @@ conn_fsm_show (struct device *dev, char *buf)
1508static DEVICE_ATTR(connection_fsm_state, 0444, conn_fsm_show, NULL); 1508static DEVICE_ATTR(connection_fsm_state, 0444, conn_fsm_show, NULL);
1509 1509
1510static ssize_t 1510static ssize_t
1511maxmulti_show (struct device *dev, char *buf) 1511maxmulti_show (struct device *dev, struct device_attribute *attr, char *buf)
1512{ 1512{
1513 struct netiucv_priv *priv = dev->driver_data; 1513 struct netiucv_priv *priv = dev->driver_data;
1514 1514
@@ -1517,7 +1517,7 @@ maxmulti_show (struct device *dev, char *buf)
1517} 1517}
1518 1518
1519static ssize_t 1519static ssize_t
1520maxmulti_write (struct device *dev, const char *buf, size_t count) 1520maxmulti_write (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1521{ 1521{
1522 struct netiucv_priv *priv = dev->driver_data; 1522 struct netiucv_priv *priv = dev->driver_data;
1523 1523
@@ -1529,7 +1529,7 @@ maxmulti_write (struct device *dev, const char *buf, size_t count)
1529static DEVICE_ATTR(max_tx_buffer_used, 0644, maxmulti_show, maxmulti_write); 1529static DEVICE_ATTR(max_tx_buffer_used, 0644, maxmulti_show, maxmulti_write);
1530 1530
1531static ssize_t 1531static ssize_t
1532maxcq_show (struct device *dev, char *buf) 1532maxcq_show (struct device *dev, struct device_attribute *attr, char *buf)
1533{ 1533{
1534 struct netiucv_priv *priv = dev->driver_data; 1534 struct netiucv_priv *priv = dev->driver_data;
1535 1535
@@ -1538,7 +1538,7 @@ maxcq_show (struct device *dev, char *buf)
1538} 1538}
1539 1539
1540static ssize_t 1540static ssize_t
1541maxcq_write (struct device *dev, const char *buf, size_t count) 1541maxcq_write (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1542{ 1542{
1543 struct netiucv_priv *priv = dev->driver_data; 1543 struct netiucv_priv *priv = dev->driver_data;
1544 1544
@@ -1550,7 +1550,7 @@ maxcq_write (struct device *dev, const char *buf, size_t count)
1550static DEVICE_ATTR(max_chained_skbs, 0644, maxcq_show, maxcq_write); 1550static DEVICE_ATTR(max_chained_skbs, 0644, maxcq_show, maxcq_write);
1551 1551
1552static ssize_t 1552static ssize_t
1553sdoio_show (struct device *dev, char *buf) 1553sdoio_show (struct device *dev, struct device_attribute *attr, char *buf)
1554{ 1554{
1555 struct netiucv_priv *priv = dev->driver_data; 1555 struct netiucv_priv *priv = dev->driver_data;
1556 1556
@@ -1559,7 +1559,7 @@ sdoio_show (struct device *dev, char *buf)
1559} 1559}
1560 1560
1561static ssize_t 1561static ssize_t
1562sdoio_write (struct device *dev, const char *buf, size_t count) 1562sdoio_write (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1563{ 1563{
1564 struct netiucv_priv *priv = dev->driver_data; 1564 struct netiucv_priv *priv = dev->driver_data;
1565 1565
@@ -1571,7 +1571,7 @@ sdoio_write (struct device *dev, const char *buf, size_t count)
1571static DEVICE_ATTR(tx_single_write_ops, 0644, sdoio_show, sdoio_write); 1571static DEVICE_ATTR(tx_single_write_ops, 0644, sdoio_show, sdoio_write);
1572 1572
1573static ssize_t 1573static ssize_t
1574mdoio_show (struct device *dev, char *buf) 1574mdoio_show (struct device *dev, struct device_attribute *attr, char *buf)
1575{ 1575{
1576 struct netiucv_priv *priv = dev->driver_data; 1576 struct netiucv_priv *priv = dev->driver_data;
1577 1577
@@ -1580,7 +1580,7 @@ mdoio_show (struct device *dev, char *buf)
1580} 1580}
1581 1581
1582static ssize_t 1582static ssize_t
1583mdoio_write (struct device *dev, const char *buf, size_t count) 1583mdoio_write (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1584{ 1584{
1585 struct netiucv_priv *priv = dev->driver_data; 1585 struct netiucv_priv *priv = dev->driver_data;
1586 1586
@@ -1592,7 +1592,7 @@ mdoio_write (struct device *dev, const char *buf, size_t count)
1592static DEVICE_ATTR(tx_multi_write_ops, 0644, mdoio_show, mdoio_write); 1592static DEVICE_ATTR(tx_multi_write_ops, 0644, mdoio_show, mdoio_write);
1593 1593
1594static ssize_t 1594static ssize_t
1595txlen_show (struct device *dev, char *buf) 1595txlen_show (struct device *dev, struct device_attribute *attr, char *buf)
1596{ 1596{
1597 struct netiucv_priv *priv = dev->driver_data; 1597 struct netiucv_priv *priv = dev->driver_data;
1598 1598
@@ -1601,7 +1601,7 @@ txlen_show (struct device *dev, char *buf)
1601} 1601}
1602 1602
1603static ssize_t 1603static ssize_t
1604txlen_write (struct device *dev, const char *buf, size_t count) 1604txlen_write (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1605{ 1605{
1606 struct netiucv_priv *priv = dev->driver_data; 1606 struct netiucv_priv *priv = dev->driver_data;
1607 1607
@@ -1613,7 +1613,7 @@ txlen_write (struct device *dev, const char *buf, size_t count)
1613static DEVICE_ATTR(netto_bytes, 0644, txlen_show, txlen_write); 1613static DEVICE_ATTR(netto_bytes, 0644, txlen_show, txlen_write);
1614 1614
1615static ssize_t 1615static ssize_t
1616txtime_show (struct device *dev, char *buf) 1616txtime_show (struct device *dev, struct device_attribute *attr, char *buf)
1617{ 1617{
1618 struct netiucv_priv *priv = dev->driver_data; 1618 struct netiucv_priv *priv = dev->driver_data;
1619 1619
@@ -1622,7 +1622,7 @@ txtime_show (struct device *dev, char *buf)
1622} 1622}
1623 1623
1624static ssize_t 1624static ssize_t
1625txtime_write (struct device *dev, const char *buf, size_t count) 1625txtime_write (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1626{ 1626{
1627 struct netiucv_priv *priv = dev->driver_data; 1627 struct netiucv_priv *priv = dev->driver_data;
1628 1628
@@ -1634,7 +1634,7 @@ txtime_write (struct device *dev, const char *buf, size_t count)
1634static DEVICE_ATTR(max_tx_io_time, 0644, txtime_show, txtime_write); 1634static DEVICE_ATTR(max_tx_io_time, 0644, txtime_show, txtime_write);
1635 1635
1636static ssize_t 1636static ssize_t
1637txpend_show (struct device *dev, char *buf) 1637txpend_show (struct device *dev, struct device_attribute *attr, char *buf)
1638{ 1638{
1639 struct netiucv_priv *priv = dev->driver_data; 1639 struct netiucv_priv *priv = dev->driver_data;
1640 1640
@@ -1643,7 +1643,7 @@ txpend_show (struct device *dev, char *buf)
1643} 1643}
1644 1644
1645static ssize_t 1645static ssize_t
1646txpend_write (struct device *dev, const char *buf, size_t count) 1646txpend_write (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1647{ 1647{
1648 struct netiucv_priv *priv = dev->driver_data; 1648 struct netiucv_priv *priv = dev->driver_data;
1649 1649
@@ -1655,7 +1655,7 @@ txpend_write (struct device *dev, const char *buf, size_t count)
1655static DEVICE_ATTR(tx_pending, 0644, txpend_show, txpend_write); 1655static DEVICE_ATTR(tx_pending, 0644, txpend_show, txpend_write);
1656 1656
1657static ssize_t 1657static ssize_t
1658txmpnd_show (struct device *dev, char *buf) 1658txmpnd_show (struct device *dev, struct device_attribute *attr, char *buf)
1659{ 1659{
1660 struct netiucv_priv *priv = dev->driver_data; 1660 struct netiucv_priv *priv = dev->driver_data;
1661 1661
@@ -1664,7 +1664,7 @@ txmpnd_show (struct device *dev, char *buf)
1664} 1664}
1665 1665
1666static ssize_t 1666static ssize_t
1667txmpnd_write (struct device *dev, const char *buf, size_t count) 1667txmpnd_write (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1668{ 1668{
1669 struct netiucv_priv *priv = dev->driver_data; 1669 struct netiucv_priv *priv = dev->driver_data;
1670 1670
diff --git a/drivers/s390/net/qeth_sys.c b/drivers/s390/net/qeth_sys.c
index 240348398211..98bedb0cb387 100644
--- a/drivers/s390/net/qeth_sys.c
+++ b/drivers/s390/net/qeth_sys.c
@@ -30,7 +30,7 @@ const char *VERSION_QETH_SYS_C = "$Revision: 1.51 $";
30//low/high watermark 30//low/high watermark
31 31
32static ssize_t 32static ssize_t
33qeth_dev_state_show(struct device *dev, char *buf) 33qeth_dev_state_show(struct device *dev, struct device_attribute *attr, char *buf)
34{ 34{
35 struct qeth_card *card = dev->driver_data; 35 struct qeth_card *card = dev->driver_data;
36 if (!card) 36 if (!card)
@@ -58,7 +58,7 @@ qeth_dev_state_show(struct device *dev, char *buf)
58static DEVICE_ATTR(state, 0444, qeth_dev_state_show, NULL); 58static DEVICE_ATTR(state, 0444, qeth_dev_state_show, NULL);
59 59
60static ssize_t 60static ssize_t
61qeth_dev_chpid_show(struct device *dev, char *buf) 61qeth_dev_chpid_show(struct device *dev, struct device_attribute *attr, char *buf)
62{ 62{
63 struct qeth_card *card = dev->driver_data; 63 struct qeth_card *card = dev->driver_data;
64 if (!card) 64 if (!card)
@@ -70,7 +70,7 @@ qeth_dev_chpid_show(struct device *dev, char *buf)
70static DEVICE_ATTR(chpid, 0444, qeth_dev_chpid_show, NULL); 70static DEVICE_ATTR(chpid, 0444, qeth_dev_chpid_show, NULL);
71 71
72static ssize_t 72static ssize_t
73qeth_dev_if_name_show(struct device *dev, char *buf) 73qeth_dev_if_name_show(struct device *dev, struct device_attribute *attr, char *buf)
74{ 74{
75 struct qeth_card *card = dev->driver_data; 75 struct qeth_card *card = dev->driver_data;
76 if (!card) 76 if (!card)
@@ -81,7 +81,7 @@ qeth_dev_if_name_show(struct device *dev, char *buf)
81static DEVICE_ATTR(if_name, 0444, qeth_dev_if_name_show, NULL); 81static DEVICE_ATTR(if_name, 0444, qeth_dev_if_name_show, NULL);
82 82
83static ssize_t 83static ssize_t
84qeth_dev_card_type_show(struct device *dev, char *buf) 84qeth_dev_card_type_show(struct device *dev, struct device_attribute *attr, char *buf)
85{ 85{
86 struct qeth_card *card = dev->driver_data; 86 struct qeth_card *card = dev->driver_data;
87 if (!card) 87 if (!card)
@@ -93,7 +93,7 @@ qeth_dev_card_type_show(struct device *dev, char *buf)
93static DEVICE_ATTR(card_type, 0444, qeth_dev_card_type_show, NULL); 93static DEVICE_ATTR(card_type, 0444, qeth_dev_card_type_show, NULL);
94 94
95static ssize_t 95static ssize_t
96qeth_dev_portno_show(struct device *dev, char *buf) 96qeth_dev_portno_show(struct device *dev, struct device_attribute *attr, char *buf)
97{ 97{
98 struct qeth_card *card = dev->driver_data; 98 struct qeth_card *card = dev->driver_data;
99 if (!card) 99 if (!card)
@@ -103,7 +103,7 @@ qeth_dev_portno_show(struct device *dev, char *buf)
103} 103}
104 104
105static ssize_t 105static ssize_t
106qeth_dev_portno_store(struct device *dev, const char *buf, size_t count) 106qeth_dev_portno_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
107{ 107{
108 struct qeth_card *card = dev->driver_data; 108 struct qeth_card *card = dev->driver_data;
109 char *tmp; 109 char *tmp;
@@ -129,7 +129,7 @@ qeth_dev_portno_store(struct device *dev, const char *buf, size_t count)
129static DEVICE_ATTR(portno, 0644, qeth_dev_portno_show, qeth_dev_portno_store); 129static DEVICE_ATTR(portno, 0644, qeth_dev_portno_show, qeth_dev_portno_store);
130 130
131static ssize_t 131static ssize_t
132qeth_dev_portname_show(struct device *dev, char *buf) 132qeth_dev_portname_show(struct device *dev, struct device_attribute *attr, char *buf)
133{ 133{
134 struct qeth_card *card = dev->driver_data; 134 struct qeth_card *card = dev->driver_data;
135 char portname[9] = {0, }; 135 char portname[9] = {0, };
@@ -146,7 +146,7 @@ qeth_dev_portname_show(struct device *dev, char *buf)
146} 146}
147 147
148static ssize_t 148static ssize_t
149qeth_dev_portname_store(struct device *dev, const char *buf, size_t count) 149qeth_dev_portname_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
150{ 150{
151 struct qeth_card *card = dev->driver_data; 151 struct qeth_card *card = dev->driver_data;
152 char *tmp; 152 char *tmp;
@@ -177,7 +177,7 @@ static DEVICE_ATTR(portname, 0644, qeth_dev_portname_show,
177 qeth_dev_portname_store); 177 qeth_dev_portname_store);
178 178
179static ssize_t 179static ssize_t
180qeth_dev_checksum_show(struct device *dev, char *buf) 180qeth_dev_checksum_show(struct device *dev, struct device_attribute *attr, char *buf)
181{ 181{
182 struct qeth_card *card = dev->driver_data; 182 struct qeth_card *card = dev->driver_data;
183 183
@@ -188,7 +188,7 @@ qeth_dev_checksum_show(struct device *dev, char *buf)
188} 188}
189 189
190static ssize_t 190static ssize_t
191qeth_dev_checksum_store(struct device *dev, const char *buf, size_t count) 191qeth_dev_checksum_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
192{ 192{
193 struct qeth_card *card = dev->driver_data; 193 struct qeth_card *card = dev->driver_data;
194 char *tmp; 194 char *tmp;
@@ -218,7 +218,7 @@ static DEVICE_ATTR(checksumming, 0644, qeth_dev_checksum_show,
218 qeth_dev_checksum_store); 218 qeth_dev_checksum_store);
219 219
220static ssize_t 220static ssize_t
221qeth_dev_prioqing_show(struct device *dev, char *buf) 221qeth_dev_prioqing_show(struct device *dev, struct device_attribute *attr, char *buf)
222{ 222{
223 struct qeth_card *card = dev->driver_data; 223 struct qeth_card *card = dev->driver_data;
224 224
@@ -237,7 +237,7 @@ qeth_dev_prioqing_show(struct device *dev, char *buf)
237} 237}
238 238
239static ssize_t 239static ssize_t
240qeth_dev_prioqing_store(struct device *dev, const char *buf, size_t count) 240qeth_dev_prioqing_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
241{ 241{
242 struct qeth_card *card = dev->driver_data; 242 struct qeth_card *card = dev->driver_data;
243 char *tmp; 243 char *tmp;
@@ -290,7 +290,7 @@ static DEVICE_ATTR(priority_queueing, 0644, qeth_dev_prioqing_show,
290 qeth_dev_prioqing_store); 290 qeth_dev_prioqing_store);
291 291
292static ssize_t 292static ssize_t
293qeth_dev_bufcnt_show(struct device *dev, char *buf) 293qeth_dev_bufcnt_show(struct device *dev, struct device_attribute *attr, char *buf)
294{ 294{
295 struct qeth_card *card = dev->driver_data; 295 struct qeth_card *card = dev->driver_data;
296 296
@@ -301,7 +301,7 @@ qeth_dev_bufcnt_show(struct device *dev, char *buf)
301} 301}
302 302
303static ssize_t 303static ssize_t
304qeth_dev_bufcnt_store(struct device *dev, const char *buf, size_t count) 304qeth_dev_bufcnt_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
305{ 305{
306 struct qeth_card *card = dev->driver_data; 306 struct qeth_card *card = dev->driver_data;
307 char *tmp; 307 char *tmp;
@@ -360,7 +360,7 @@ qeth_dev_route_show(struct qeth_card *card, struct qeth_routing_info *route,
360} 360}
361 361
362static ssize_t 362static ssize_t
363qeth_dev_route4_show(struct device *dev, char *buf) 363qeth_dev_route4_show(struct device *dev, struct device_attribute *attr, char *buf)
364{ 364{
365 struct qeth_card *card = dev->driver_data; 365 struct qeth_card *card = dev->driver_data;
366 366
@@ -410,7 +410,7 @@ qeth_dev_route_store(struct qeth_card *card, struct qeth_routing_info *route,
410} 410}
411 411
412static ssize_t 412static ssize_t
413qeth_dev_route4_store(struct device *dev, const char *buf, size_t count) 413qeth_dev_route4_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
414{ 414{
415 struct qeth_card *card = dev->driver_data; 415 struct qeth_card *card = dev->driver_data;
416 416
@@ -425,7 +425,7 @@ static DEVICE_ATTR(route4, 0644, qeth_dev_route4_show, qeth_dev_route4_store);
425 425
426#ifdef CONFIG_QETH_IPV6 426#ifdef CONFIG_QETH_IPV6
427static ssize_t 427static ssize_t
428qeth_dev_route6_show(struct device *dev, char *buf) 428qeth_dev_route6_show(struct device *dev, struct device_attribute *attr, char *buf)
429{ 429{
430 struct qeth_card *card = dev->driver_data; 430 struct qeth_card *card = dev->driver_data;
431 431
@@ -439,7 +439,7 @@ qeth_dev_route6_show(struct device *dev, char *buf)
439} 439}
440 440
441static ssize_t 441static ssize_t
442qeth_dev_route6_store(struct device *dev, const char *buf, size_t count) 442qeth_dev_route6_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
443{ 443{
444 struct qeth_card *card = dev->driver_data; 444 struct qeth_card *card = dev->driver_data;
445 445
@@ -461,7 +461,7 @@ static DEVICE_ATTR(route6, 0644, qeth_dev_route6_show, qeth_dev_route6_store);
461#endif 461#endif
462 462
463static ssize_t 463static ssize_t
464qeth_dev_add_hhlen_show(struct device *dev, char *buf) 464qeth_dev_add_hhlen_show(struct device *dev, struct device_attribute *attr, char *buf)
465{ 465{
466 struct qeth_card *card = dev->driver_data; 466 struct qeth_card *card = dev->driver_data;
467 467
@@ -472,7 +472,7 @@ qeth_dev_add_hhlen_show(struct device *dev, char *buf)
472} 472}
473 473
474static ssize_t 474static ssize_t
475qeth_dev_add_hhlen_store(struct device *dev, const char *buf, size_t count) 475qeth_dev_add_hhlen_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
476{ 476{
477 struct qeth_card *card = dev->driver_data; 477 struct qeth_card *card = dev->driver_data;
478 char *tmp; 478 char *tmp;
@@ -499,7 +499,7 @@ static DEVICE_ATTR(add_hhlen, 0644, qeth_dev_add_hhlen_show,
499 qeth_dev_add_hhlen_store); 499 qeth_dev_add_hhlen_store);
500 500
501static ssize_t 501static ssize_t
502qeth_dev_fake_ll_show(struct device *dev, char *buf) 502qeth_dev_fake_ll_show(struct device *dev, struct device_attribute *attr, char *buf)
503{ 503{
504 struct qeth_card *card = dev->driver_data; 504 struct qeth_card *card = dev->driver_data;
505 505
@@ -510,7 +510,7 @@ qeth_dev_fake_ll_show(struct device *dev, char *buf)
510} 510}
511 511
512static ssize_t 512static ssize_t
513qeth_dev_fake_ll_store(struct device *dev, const char *buf, size_t count) 513qeth_dev_fake_ll_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
514{ 514{
515 struct qeth_card *card = dev->driver_data; 515 struct qeth_card *card = dev->driver_data;
516 char *tmp; 516 char *tmp;
@@ -536,7 +536,7 @@ static DEVICE_ATTR(fake_ll, 0644, qeth_dev_fake_ll_show,
536 qeth_dev_fake_ll_store); 536 qeth_dev_fake_ll_store);
537 537
538static ssize_t 538static ssize_t
539qeth_dev_fake_broadcast_show(struct device *dev, char *buf) 539qeth_dev_fake_broadcast_show(struct device *dev, struct device_attribute *attr, char *buf)
540{ 540{
541 struct qeth_card *card = dev->driver_data; 541 struct qeth_card *card = dev->driver_data;
542 542
@@ -547,7 +547,7 @@ qeth_dev_fake_broadcast_show(struct device *dev, char *buf)
547} 547}
548 548
549static ssize_t 549static ssize_t
550qeth_dev_fake_broadcast_store(struct device *dev, const char *buf, size_t count) 550qeth_dev_fake_broadcast_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
551{ 551{
552 struct qeth_card *card = dev->driver_data; 552 struct qeth_card *card = dev->driver_data;
553 char *tmp; 553 char *tmp;
@@ -574,7 +574,7 @@ static DEVICE_ATTR(fake_broadcast, 0644, qeth_dev_fake_broadcast_show,
574 qeth_dev_fake_broadcast_store); 574 qeth_dev_fake_broadcast_store);
575 575
576static ssize_t 576static ssize_t
577qeth_dev_recover_store(struct device *dev, const char *buf, size_t count) 577qeth_dev_recover_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
578{ 578{
579 struct qeth_card *card = dev->driver_data; 579 struct qeth_card *card = dev->driver_data;
580 char *tmp; 580 char *tmp;
@@ -596,7 +596,7 @@ qeth_dev_recover_store(struct device *dev, const char *buf, size_t count)
596static DEVICE_ATTR(recover, 0200, NULL, qeth_dev_recover_store); 596static DEVICE_ATTR(recover, 0200, NULL, qeth_dev_recover_store);
597 597
598static ssize_t 598static ssize_t
599qeth_dev_broadcast_mode_show(struct device *dev, char *buf) 599qeth_dev_broadcast_mode_show(struct device *dev, struct device_attribute *attr, char *buf)
600{ 600{
601 struct qeth_card *card = dev->driver_data; 601 struct qeth_card *card = dev->driver_data;
602 602
@@ -613,7 +613,7 @@ qeth_dev_broadcast_mode_show(struct device *dev, char *buf)
613} 613}
614 614
615static ssize_t 615static ssize_t
616qeth_dev_broadcast_mode_store(struct device *dev, const char *buf, size_t count) 616qeth_dev_broadcast_mode_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
617{ 617{
618 struct qeth_card *card = dev->driver_data; 618 struct qeth_card *card = dev->driver_data;
619 char *tmp; 619 char *tmp;
@@ -651,7 +651,7 @@ static DEVICE_ATTR(broadcast_mode, 0644, qeth_dev_broadcast_mode_show,
651 qeth_dev_broadcast_mode_store); 651 qeth_dev_broadcast_mode_store);
652 652
653static ssize_t 653static ssize_t
654qeth_dev_canonical_macaddr_show(struct device *dev, char *buf) 654qeth_dev_canonical_macaddr_show(struct device *dev, struct device_attribute *attr, char *buf)
655{ 655{
656 struct qeth_card *card = dev->driver_data; 656 struct qeth_card *card = dev->driver_data;
657 657
@@ -667,7 +667,7 @@ qeth_dev_canonical_macaddr_show(struct device *dev, char *buf)
667} 667}
668 668
669static ssize_t 669static ssize_t
670qeth_dev_canonical_macaddr_store(struct device *dev, const char *buf, 670qeth_dev_canonical_macaddr_store(struct device *dev, struct device_attribute *attr, const char *buf,
671 size_t count) 671 size_t count)
672{ 672{
673 struct qeth_card *card = dev->driver_data; 673 struct qeth_card *card = dev->driver_data;
@@ -703,7 +703,7 @@ static DEVICE_ATTR(canonical_macaddr, 0644, qeth_dev_canonical_macaddr_show,
703 qeth_dev_canonical_macaddr_store); 703 qeth_dev_canonical_macaddr_store);
704 704
705static ssize_t 705static ssize_t
706qeth_dev_layer2_show(struct device *dev, char *buf) 706qeth_dev_layer2_show(struct device *dev, struct device_attribute *attr, char *buf)
707{ 707{
708 struct qeth_card *card = dev->driver_data; 708 struct qeth_card *card = dev->driver_data;
709 709
@@ -714,7 +714,7 @@ qeth_dev_layer2_show(struct device *dev, char *buf)
714} 714}
715 715
716static ssize_t 716static ssize_t
717qeth_dev_layer2_store(struct device *dev, const char *buf, size_t count) 717qeth_dev_layer2_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
718{ 718{
719 struct qeth_card *card = dev->driver_data; 719 struct qeth_card *card = dev->driver_data;
720 char *tmp; 720 char *tmp;
@@ -742,7 +742,7 @@ static DEVICE_ATTR(layer2, 0644, qeth_dev_layer2_show,
742 qeth_dev_layer2_store); 742 qeth_dev_layer2_store);
743 743
744static ssize_t 744static ssize_t
745qeth_dev_large_send_show(struct device *dev, char *buf) 745qeth_dev_large_send_show(struct device *dev, struct device_attribute *attr, char *buf)
746{ 746{
747 struct qeth_card *card = dev->driver_data; 747 struct qeth_card *card = dev->driver_data;
748 748
@@ -762,7 +762,7 @@ qeth_dev_large_send_show(struct device *dev, char *buf)
762} 762}
763 763
764static ssize_t 764static ssize_t
765qeth_dev_large_send_store(struct device *dev, const char *buf, size_t count) 765qeth_dev_large_send_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
766{ 766{
767 struct qeth_card *card = dev->driver_data; 767 struct qeth_card *card = dev->driver_data;
768 enum qeth_large_send_types type; 768 enum qeth_large_send_types type;
@@ -832,7 +832,7 @@ qeth_dev_blkt_store(struct qeth_card *card, const char *buf, size_t count,
832} 832}
833 833
834static ssize_t 834static ssize_t
835qeth_dev_blkt_total_show(struct device *dev, char *buf) 835qeth_dev_blkt_total_show(struct device *dev, struct device_attribute *attr, char *buf)
836{ 836{
837 struct qeth_card *card = dev->driver_data; 837 struct qeth_card *card = dev->driver_data;
838 838
@@ -841,7 +841,7 @@ qeth_dev_blkt_total_show(struct device *dev, char *buf)
841 841
842 842
843static ssize_t 843static ssize_t
844qeth_dev_blkt_total_store(struct device *dev, const char *buf, size_t count) 844qeth_dev_blkt_total_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
845{ 845{
846 struct qeth_card *card = dev->driver_data; 846 struct qeth_card *card = dev->driver_data;
847 847
@@ -855,7 +855,7 @@ static DEVICE_ATTR(total, 0644, qeth_dev_blkt_total_show,
855 qeth_dev_blkt_total_store); 855 qeth_dev_blkt_total_store);
856 856
857static ssize_t 857static ssize_t
858qeth_dev_blkt_inter_show(struct device *dev, char *buf) 858qeth_dev_blkt_inter_show(struct device *dev, struct device_attribute *attr, char *buf)
859{ 859{
860 struct qeth_card *card = dev->driver_data; 860 struct qeth_card *card = dev->driver_data;
861 861
@@ -864,7 +864,7 @@ qeth_dev_blkt_inter_show(struct device *dev, char *buf)
864 864
865 865
866static ssize_t 866static ssize_t
867qeth_dev_blkt_inter_store(struct device *dev, const char *buf, size_t count) 867qeth_dev_blkt_inter_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
868{ 868{
869 struct qeth_card *card = dev->driver_data; 869 struct qeth_card *card = dev->driver_data;
870 870
@@ -876,7 +876,7 @@ static DEVICE_ATTR(inter, 0644, qeth_dev_blkt_inter_show,
876 qeth_dev_blkt_inter_store); 876 qeth_dev_blkt_inter_store);
877 877
878static ssize_t 878static ssize_t
879qeth_dev_blkt_inter_jumbo_show(struct device *dev, char *buf) 879qeth_dev_blkt_inter_jumbo_show(struct device *dev, struct device_attribute *attr, char *buf)
880{ 880{
881 struct qeth_card *card = dev->driver_data; 881 struct qeth_card *card = dev->driver_data;
882 882
@@ -886,7 +886,7 @@ qeth_dev_blkt_inter_jumbo_show(struct device *dev, char *buf)
886 886
887 887
888static ssize_t 888static ssize_t
889qeth_dev_blkt_inter_jumbo_store(struct device *dev, const char *buf, size_t count) 889qeth_dev_blkt_inter_jumbo_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
890{ 890{
891 struct qeth_card *card = dev->driver_data; 891 struct qeth_card *card = dev->driver_data;
892 892
@@ -956,7 +956,7 @@ qeth_check_layer2(struct qeth_card *card)
956 956
957 957
958static ssize_t 958static ssize_t
959qeth_dev_ipato_enable_show(struct device *dev, char *buf) 959qeth_dev_ipato_enable_show(struct device *dev, struct device_attribute *attr, char *buf)
960{ 960{
961 struct qeth_card *card = dev->driver_data; 961 struct qeth_card *card = dev->driver_data;
962 962
@@ -969,7 +969,7 @@ qeth_dev_ipato_enable_show(struct device *dev, char *buf)
969} 969}
970 970
971static ssize_t 971static ssize_t
972qeth_dev_ipato_enable_store(struct device *dev, const char *buf, size_t count) 972qeth_dev_ipato_enable_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
973{ 973{
974 struct qeth_card *card = dev->driver_data; 974 struct qeth_card *card = dev->driver_data;
975 char *tmp; 975 char *tmp;
@@ -1004,7 +1004,7 @@ static QETH_DEVICE_ATTR(ipato_enable, enable, 0644,
1004 qeth_dev_ipato_enable_store); 1004 qeth_dev_ipato_enable_store);
1005 1005
1006static ssize_t 1006static ssize_t
1007qeth_dev_ipato_invert4_show(struct device *dev, char *buf) 1007qeth_dev_ipato_invert4_show(struct device *dev, struct device_attribute *attr, char *buf)
1008{ 1008{
1009 struct qeth_card *card = dev->driver_data; 1009 struct qeth_card *card = dev->driver_data;
1010 1010
@@ -1018,7 +1018,7 @@ qeth_dev_ipato_invert4_show(struct device *dev, char *buf)
1018} 1018}
1019 1019
1020static ssize_t 1020static ssize_t
1021qeth_dev_ipato_invert4_store(struct device *dev, const char *buf, size_t count) 1021qeth_dev_ipato_invert4_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1022{ 1022{
1023 struct qeth_card *card = dev->driver_data; 1023 struct qeth_card *card = dev->driver_data;
1024 char *tmp; 1024 char *tmp;
@@ -1084,7 +1084,7 @@ qeth_dev_ipato_add_show(char *buf, struct qeth_card *card,
1084} 1084}
1085 1085
1086static ssize_t 1086static ssize_t
1087qeth_dev_ipato_add4_show(struct device *dev, char *buf) 1087qeth_dev_ipato_add4_show(struct device *dev, struct device_attribute *attr, char *buf)
1088{ 1088{
1089 struct qeth_card *card = dev->driver_data; 1089 struct qeth_card *card = dev->driver_data;
1090 1090
@@ -1153,7 +1153,7 @@ qeth_dev_ipato_add_store(const char *buf, size_t count,
1153} 1153}
1154 1154
1155static ssize_t 1155static ssize_t
1156qeth_dev_ipato_add4_store(struct device *dev, const char *buf, size_t count) 1156qeth_dev_ipato_add4_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1157{ 1157{
1158 struct qeth_card *card = dev->driver_data; 1158 struct qeth_card *card = dev->driver_data;
1159 1159
@@ -1186,7 +1186,7 @@ qeth_dev_ipato_del_store(const char *buf, size_t count,
1186} 1186}
1187 1187
1188static ssize_t 1188static ssize_t
1189qeth_dev_ipato_del4_store(struct device *dev, const char *buf, size_t count) 1189qeth_dev_ipato_del4_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1190{ 1190{
1191 struct qeth_card *card = dev->driver_data; 1191 struct qeth_card *card = dev->driver_data;
1192 1192
@@ -1201,7 +1201,7 @@ static QETH_DEVICE_ATTR(ipato_del4, del4, 0200, NULL,
1201 1201
1202#ifdef CONFIG_QETH_IPV6 1202#ifdef CONFIG_QETH_IPV6
1203static ssize_t 1203static ssize_t
1204qeth_dev_ipato_invert6_show(struct device *dev, char *buf) 1204qeth_dev_ipato_invert6_show(struct device *dev, struct device_attribute *attr, char *buf)
1205{ 1205{
1206 struct qeth_card *card = dev->driver_data; 1206 struct qeth_card *card = dev->driver_data;
1207 1207
@@ -1215,7 +1215,7 @@ qeth_dev_ipato_invert6_show(struct device *dev, char *buf)
1215} 1215}
1216 1216
1217static ssize_t 1217static ssize_t
1218qeth_dev_ipato_invert6_store(struct device *dev, const char *buf, size_t count) 1218qeth_dev_ipato_invert6_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1219{ 1219{
1220 struct qeth_card *card = dev->driver_data; 1220 struct qeth_card *card = dev->driver_data;
1221 char *tmp; 1221 char *tmp;
@@ -1247,7 +1247,7 @@ static QETH_DEVICE_ATTR(ipato_invert6, invert6, 0644,
1247 1247
1248 1248
1249static ssize_t 1249static ssize_t
1250qeth_dev_ipato_add6_show(struct device *dev, char *buf) 1250qeth_dev_ipato_add6_show(struct device *dev, struct device_attribute *attr, char *buf)
1251{ 1251{
1252 struct qeth_card *card = dev->driver_data; 1252 struct qeth_card *card = dev->driver_data;
1253 1253
@@ -1258,7 +1258,7 @@ qeth_dev_ipato_add6_show(struct device *dev, char *buf)
1258} 1258}
1259 1259
1260static ssize_t 1260static ssize_t
1261qeth_dev_ipato_add6_store(struct device *dev, const char *buf, size_t count) 1261qeth_dev_ipato_add6_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1262{ 1262{
1263 struct qeth_card *card = dev->driver_data; 1263 struct qeth_card *card = dev->driver_data;
1264 1264
@@ -1273,7 +1273,7 @@ static QETH_DEVICE_ATTR(ipato_add6, add6, 0644,
1273 qeth_dev_ipato_add6_store); 1273 qeth_dev_ipato_add6_store);
1274 1274
1275static ssize_t 1275static ssize_t
1276qeth_dev_ipato_del6_store(struct device *dev, const char *buf, size_t count) 1276qeth_dev_ipato_del6_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1277{ 1277{
1278 struct qeth_card *card = dev->driver_data; 1278 struct qeth_card *card = dev->driver_data;
1279 1279
@@ -1341,7 +1341,7 @@ qeth_dev_vipa_add_show(char *buf, struct qeth_card *card,
1341} 1341}
1342 1342
1343static ssize_t 1343static ssize_t
1344qeth_dev_vipa_add4_show(struct device *dev, char *buf) 1344qeth_dev_vipa_add4_show(struct device *dev, struct device_attribute *attr, char *buf)
1345{ 1345{
1346 struct qeth_card *card = dev->driver_data; 1346 struct qeth_card *card = dev->driver_data;
1347 1347
@@ -1381,7 +1381,7 @@ qeth_dev_vipa_add_store(const char *buf, size_t count,
1381} 1381}
1382 1382
1383static ssize_t 1383static ssize_t
1384qeth_dev_vipa_add4_store(struct device *dev, const char *buf, size_t count) 1384qeth_dev_vipa_add4_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1385{ 1385{
1386 struct qeth_card *card = dev->driver_data; 1386 struct qeth_card *card = dev->driver_data;
1387 1387
@@ -1413,7 +1413,7 @@ qeth_dev_vipa_del_store(const char *buf, size_t count,
1413} 1413}
1414 1414
1415static ssize_t 1415static ssize_t
1416qeth_dev_vipa_del4_store(struct device *dev, const char *buf, size_t count) 1416qeth_dev_vipa_del4_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1417{ 1417{
1418 struct qeth_card *card = dev->driver_data; 1418 struct qeth_card *card = dev->driver_data;
1419 1419
@@ -1428,7 +1428,7 @@ static QETH_DEVICE_ATTR(vipa_del4, del4, 0200, NULL,
1428 1428
1429#ifdef CONFIG_QETH_IPV6 1429#ifdef CONFIG_QETH_IPV6
1430static ssize_t 1430static ssize_t
1431qeth_dev_vipa_add6_show(struct device *dev, char *buf) 1431qeth_dev_vipa_add6_show(struct device *dev, struct device_attribute *attr, char *buf)
1432{ 1432{
1433 struct qeth_card *card = dev->driver_data; 1433 struct qeth_card *card = dev->driver_data;
1434 1434
@@ -1439,7 +1439,7 @@ qeth_dev_vipa_add6_show(struct device *dev, char *buf)
1439} 1439}
1440 1440
1441static ssize_t 1441static ssize_t
1442qeth_dev_vipa_add6_store(struct device *dev, const char *buf, size_t count) 1442qeth_dev_vipa_add6_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1443{ 1443{
1444 struct qeth_card *card = dev->driver_data; 1444 struct qeth_card *card = dev->driver_data;
1445 1445
@@ -1454,7 +1454,7 @@ static QETH_DEVICE_ATTR(vipa_add6, add6, 0644,
1454 qeth_dev_vipa_add6_store); 1454 qeth_dev_vipa_add6_store);
1455 1455
1456static ssize_t 1456static ssize_t
1457qeth_dev_vipa_del6_store(struct device *dev, const char *buf, size_t count) 1457qeth_dev_vipa_del6_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1458{ 1458{
1459 struct qeth_card *card = dev->driver_data; 1459 struct qeth_card *card = dev->driver_data;
1460 1460
@@ -1522,7 +1522,7 @@ qeth_dev_rxip_add_show(char *buf, struct qeth_card *card,
1522} 1522}
1523 1523
1524static ssize_t 1524static ssize_t
1525qeth_dev_rxip_add4_show(struct device *dev, char *buf) 1525qeth_dev_rxip_add4_show(struct device *dev, struct device_attribute *attr, char *buf)
1526{ 1526{
1527 struct qeth_card *card = dev->driver_data; 1527 struct qeth_card *card = dev->driver_data;
1528 1528
@@ -1562,7 +1562,7 @@ qeth_dev_rxip_add_store(const char *buf, size_t count,
1562} 1562}
1563 1563
1564static ssize_t 1564static ssize_t
1565qeth_dev_rxip_add4_store(struct device *dev, const char *buf, size_t count) 1565qeth_dev_rxip_add4_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1566{ 1566{
1567 struct qeth_card *card = dev->driver_data; 1567 struct qeth_card *card = dev->driver_data;
1568 1568
@@ -1594,7 +1594,7 @@ qeth_dev_rxip_del_store(const char *buf, size_t count,
1594} 1594}
1595 1595
1596static ssize_t 1596static ssize_t
1597qeth_dev_rxip_del4_store(struct device *dev, const char *buf, size_t count) 1597qeth_dev_rxip_del4_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1598{ 1598{
1599 struct qeth_card *card = dev->driver_data; 1599 struct qeth_card *card = dev->driver_data;
1600 1600
@@ -1609,7 +1609,7 @@ static QETH_DEVICE_ATTR(rxip_del4, del4, 0200, NULL,
1609 1609
1610#ifdef CONFIG_QETH_IPV6 1610#ifdef CONFIG_QETH_IPV6
1611static ssize_t 1611static ssize_t
1612qeth_dev_rxip_add6_show(struct device *dev, char *buf) 1612qeth_dev_rxip_add6_show(struct device *dev, struct device_attribute *attr, char *buf)
1613{ 1613{
1614 struct qeth_card *card = dev->driver_data; 1614 struct qeth_card *card = dev->driver_data;
1615 1615
@@ -1620,7 +1620,7 @@ qeth_dev_rxip_add6_show(struct device *dev, char *buf)
1620} 1620}
1621 1621
1622static ssize_t 1622static ssize_t
1623qeth_dev_rxip_add6_store(struct device *dev, const char *buf, size_t count) 1623qeth_dev_rxip_add6_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1624{ 1624{
1625 struct qeth_card *card = dev->driver_data; 1625 struct qeth_card *card = dev->driver_data;
1626 1626
@@ -1635,7 +1635,7 @@ static QETH_DEVICE_ATTR(rxip_add6, add6, 0644,
1635 qeth_dev_rxip_add6_store); 1635 qeth_dev_rxip_add6_store);
1636 1636
1637static ssize_t 1637static ssize_t
1638qeth_dev_rxip_del6_store(struct device *dev, const char *buf, size_t count) 1638qeth_dev_rxip_del6_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1639{ 1639{
1640 struct qeth_card *card = dev->driver_data; 1640 struct qeth_card *card = dev->driver_data;
1641 1641
diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c
index 6965992ddbbf..b61d309352c3 100644
--- a/drivers/s390/scsi/zfcp_scsi.c
+++ b/drivers/s390/scsi/zfcp_scsi.c
@@ -924,7 +924,7 @@ struct fc_function_template zfcp_transport_functions = {
924 * Generates attribute for a unit. 924 * Generates attribute for a unit.
925 */ 925 */
926#define ZFCP_DEFINE_SCSI_ATTR(_name, _format, _value) \ 926#define ZFCP_DEFINE_SCSI_ATTR(_name, _format, _value) \
927static ssize_t zfcp_sysfs_scsi_##_name##_show(struct device *dev, \ 927static ssize_t zfcp_sysfs_scsi_##_name##_show(struct device *dev, struct device_attribute *attr, \
928 char *buf) \ 928 char *buf) \
929{ \ 929{ \
930 struct scsi_device *sdev; \ 930 struct scsi_device *sdev; \
diff --git a/drivers/s390/scsi/zfcp_sysfs_adapter.c b/drivers/s390/scsi/zfcp_sysfs_adapter.c
index 23e2dca55bb8..e7345a74800a 100644
--- a/drivers/s390/scsi/zfcp_sysfs_adapter.c
+++ b/drivers/s390/scsi/zfcp_sysfs_adapter.c
@@ -50,7 +50,7 @@ static const char fc_topologies[5][25] = {
50 * Generates attributes for an adapter. 50 * Generates attributes for an adapter.
51 */ 51 */
52#define ZFCP_DEFINE_ADAPTER_ATTR(_name, _format, _value) \ 52#define ZFCP_DEFINE_ADAPTER_ATTR(_name, _format, _value) \
53static ssize_t zfcp_sysfs_adapter_##_name##_show(struct device *dev, \ 53static ssize_t zfcp_sysfs_adapter_##_name##_show(struct device *dev, struct device_attribute *attr, \
54 char *buf) \ 54 char *buf) \
55{ \ 55{ \
56 struct zfcp_adapter *adapter; \ 56 struct zfcp_adapter *adapter; \
@@ -90,7 +90,7 @@ ZFCP_DEFINE_ADAPTER_ATTR(in_recovery, "%d\n", atomic_test_mask
90 * Store function of the "port_add" attribute of an adapter. 90 * Store function of the "port_add" attribute of an adapter.
91 */ 91 */
92static ssize_t 92static ssize_t
93zfcp_sysfs_port_add_store(struct device *dev, const char *buf, size_t count) 93zfcp_sysfs_port_add_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
94{ 94{
95 wwn_t wwpn; 95 wwn_t wwpn;
96 char *endp; 96 char *endp;
@@ -135,7 +135,7 @@ static DEVICE_ATTR(port_add, S_IWUSR, NULL, zfcp_sysfs_port_add_store);
135 * Store function of the "port_remove" attribute of an adapter. 135 * Store function of the "port_remove" attribute of an adapter.
136 */ 136 */
137static ssize_t 137static ssize_t
138zfcp_sysfs_port_remove_store(struct device *dev, const char *buf, size_t count) 138zfcp_sysfs_port_remove_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
139{ 139{
140 struct zfcp_adapter *adapter; 140 struct zfcp_adapter *adapter;
141 struct zfcp_port *port; 141 struct zfcp_port *port;
@@ -196,7 +196,7 @@ static DEVICE_ATTR(port_remove, S_IWUSR, NULL, zfcp_sysfs_port_remove_store);
196 * started for the belonging adapter. 196 * started for the belonging adapter.
197 */ 197 */
198static ssize_t 198static ssize_t
199zfcp_sysfs_adapter_failed_store(struct device *dev, 199zfcp_sysfs_adapter_failed_store(struct device *dev, struct device_attribute *attr,
200 const char *buf, size_t count) 200 const char *buf, size_t count)
201{ 201{
202 struct zfcp_adapter *adapter; 202 struct zfcp_adapter *adapter;
@@ -236,7 +236,7 @@ zfcp_sysfs_adapter_failed_store(struct device *dev,
236 * "0" if adapter is working, otherwise "1". 236 * "0" if adapter is working, otherwise "1".
237 */ 237 */
238static ssize_t 238static ssize_t
239zfcp_sysfs_adapter_failed_show(struct device *dev, char *buf) 239zfcp_sysfs_adapter_failed_show(struct device *dev, struct device_attribute *attr, char *buf)
240{ 240{
241 struct zfcp_adapter *adapter; 241 struct zfcp_adapter *adapter;
242 242
diff --git a/drivers/s390/scsi/zfcp_sysfs_port.c b/drivers/s390/scsi/zfcp_sysfs_port.c
index 6aafb2abb4b5..7a84c7d474d9 100644
--- a/drivers/s390/scsi/zfcp_sysfs_port.c
+++ b/drivers/s390/scsi/zfcp_sysfs_port.c
@@ -53,7 +53,7 @@ zfcp_sysfs_port_release(struct device *dev)
53 * Generates attributes for a port. 53 * Generates attributes for a port.
54 */ 54 */
55#define ZFCP_DEFINE_PORT_ATTR(_name, _format, _value) \ 55#define ZFCP_DEFINE_PORT_ATTR(_name, _format, _value) \
56static ssize_t zfcp_sysfs_port_##_name##_show(struct device *dev, \ 56static ssize_t zfcp_sysfs_port_##_name##_show(struct device *dev, struct device_attribute *attr, \
57 char *buf) \ 57 char *buf) \
58{ \ 58{ \
59 struct zfcp_port *port; \ 59 struct zfcp_port *port; \
@@ -82,7 +82,7 @@ ZFCP_DEFINE_PORT_ATTR(access_denied, "%d\n", atomic_test_mask
82 * Store function of the "unit_add" attribute of a port. 82 * Store function of the "unit_add" attribute of a port.
83 */ 83 */
84static ssize_t 84static ssize_t
85zfcp_sysfs_unit_add_store(struct device *dev, const char *buf, size_t count) 85zfcp_sysfs_unit_add_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
86{ 86{
87 fcp_lun_t fcp_lun; 87 fcp_lun_t fcp_lun;
88 char *endp; 88 char *endp;
@@ -125,7 +125,7 @@ static DEVICE_ATTR(unit_add, S_IWUSR, NULL, zfcp_sysfs_unit_add_store);
125 * @count: number of bytes in buffer 125 * @count: number of bytes in buffer
126 */ 126 */
127static ssize_t 127static ssize_t
128zfcp_sysfs_unit_remove_store(struct device *dev, const char *buf, size_t count) 128zfcp_sysfs_unit_remove_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
129{ 129{
130 struct zfcp_port *port; 130 struct zfcp_port *port;
131 struct zfcp_unit *unit; 131 struct zfcp_unit *unit;
@@ -186,7 +186,7 @@ static DEVICE_ATTR(unit_remove, S_IWUSR, NULL, zfcp_sysfs_unit_remove_store);
186 * started for the belonging port. 186 * started for the belonging port.
187 */ 187 */
188static ssize_t 188static ssize_t
189zfcp_sysfs_port_failed_store(struct device *dev, const char *buf, size_t count) 189zfcp_sysfs_port_failed_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
190{ 190{
191 struct zfcp_port *port; 191 struct zfcp_port *port;
192 unsigned int val; 192 unsigned int val;
@@ -224,7 +224,7 @@ zfcp_sysfs_port_failed_store(struct device *dev, const char *buf, size_t count)
224 * "0" if port is working, otherwise "1". 224 * "0" if port is working, otherwise "1".
225 */ 225 */
226static ssize_t 226static ssize_t
227zfcp_sysfs_port_failed_show(struct device *dev, char *buf) 227zfcp_sysfs_port_failed_show(struct device *dev, struct device_attribute *attr, char *buf)
228{ 228{
229 struct zfcp_port *port; 229 struct zfcp_port *port;
230 230
diff --git a/drivers/s390/scsi/zfcp_sysfs_unit.c b/drivers/s390/scsi/zfcp_sysfs_unit.c
index 87c0b461831f..0556642c9e1d 100644
--- a/drivers/s390/scsi/zfcp_sysfs_unit.c
+++ b/drivers/s390/scsi/zfcp_sysfs_unit.c
@@ -53,7 +53,7 @@ zfcp_sysfs_unit_release(struct device *dev)
53 * Generates attribute for a unit. 53 * Generates attribute for a unit.
54 */ 54 */
55#define ZFCP_DEFINE_UNIT_ATTR(_name, _format, _value) \ 55#define ZFCP_DEFINE_UNIT_ATTR(_name, _format, _value) \
56static ssize_t zfcp_sysfs_unit_##_name##_show(struct device *dev, \ 56static ssize_t zfcp_sysfs_unit_##_name##_show(struct device *dev, struct device_attribute *attr, \
57 char *buf) \ 57 char *buf) \
58{ \ 58{ \
59 struct zfcp_unit *unit; \ 59 struct zfcp_unit *unit; \
@@ -86,7 +86,7 @@ ZFCP_DEFINE_UNIT_ATTR(access_readonly, "%d\n", atomic_test_mask
86 * started for the belonging unit. 86 * started for the belonging unit.
87 */ 87 */
88static ssize_t 88static ssize_t
89zfcp_sysfs_unit_failed_store(struct device *dev, const char *buf, size_t count) 89zfcp_sysfs_unit_failed_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
90{ 90{
91 struct zfcp_unit *unit; 91 struct zfcp_unit *unit;
92 unsigned int val; 92 unsigned int val;
@@ -123,7 +123,7 @@ zfcp_sysfs_unit_failed_store(struct device *dev, const char *buf, size_t count)
123 * "0" if unit is working, otherwise "1". 123 * "0" if unit is working, otherwise "1".
124 */ 124 */
125static ssize_t 125static ssize_t
126zfcp_sysfs_unit_failed_show(struct device *dev, char *buf) 126zfcp_sysfs_unit_failed_show(struct device *dev, struct device_attribute *attr, char *buf)
127{ 127{
128 struct zfcp_unit *unit; 128 struct zfcp_unit *unit;
129 129
diff --git a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c
index d151af9a6f15..a7620fc368e7 100644
--- a/drivers/scsi/53c700.c
+++ b/drivers/scsi/53c700.c
@@ -2125,7 +2125,7 @@ static int NCR_700_change_queue_type(struct scsi_device *SDp, int tag_type)
2125} 2125}
2126 2126
2127static ssize_t 2127static ssize_t
2128NCR_700_show_active_tags(struct device *dev, char *buf) 2128NCR_700_show_active_tags(struct device *dev, struct device_attribute *attr, char *buf)
2129{ 2129{
2130 struct scsi_device *SDp = to_scsi_device(dev); 2130 struct scsi_device *SDp = to_scsi_device(dev);
2131 2131
diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c
index c4eaaad2c69b..5f526dd0aaa1 100644
--- a/drivers/scsi/aic7xxx/aic79xx_osm.c
+++ b/drivers/scsi/aic7xxx/aic79xx_osm.c
@@ -941,7 +941,7 @@ ahd_linux_queue(Scsi_Cmnd * cmd, void (*scsi_done) (Scsi_Cmnd *))
941 */ 941 */
942 cmd->scsi_done = scsi_done; 942 cmd->scsi_done = scsi_done;
943 943
944 ahd_lock(ahd, &flags); 944 ahd_midlayer_entrypoint_lock(ahd, &flags);
945 945
946 /* 946 /*
947 * Close the race of a command that was in the process of 947 * Close the race of a command that was in the process of
@@ -955,7 +955,7 @@ ahd_linux_queue(Scsi_Cmnd * cmd, void (*scsi_done) (Scsi_Cmnd *))
955 ahd_cmd_set_transaction_status(cmd, CAM_REQUEUE_REQ); 955 ahd_cmd_set_transaction_status(cmd, CAM_REQUEUE_REQ);
956 ahd_linux_queue_cmd_complete(ahd, cmd); 956 ahd_linux_queue_cmd_complete(ahd, cmd);
957 ahd_schedule_completeq(ahd); 957 ahd_schedule_completeq(ahd);
958 ahd_unlock(ahd, &flags); 958 ahd_midlayer_entrypoint_unlock(ahd, &flags);
959 return (0); 959 return (0);
960 } 960 }
961 dev = ahd_linux_get_device(ahd, cmd->device->channel, 961 dev = ahd_linux_get_device(ahd, cmd->device->channel,
@@ -965,7 +965,7 @@ ahd_linux_queue(Scsi_Cmnd * cmd, void (*scsi_done) (Scsi_Cmnd *))
965 ahd_cmd_set_transaction_status(cmd, CAM_RESRC_UNAVAIL); 965 ahd_cmd_set_transaction_status(cmd, CAM_RESRC_UNAVAIL);
966 ahd_linux_queue_cmd_complete(ahd, cmd); 966 ahd_linux_queue_cmd_complete(ahd, cmd);
967 ahd_schedule_completeq(ahd); 967 ahd_schedule_completeq(ahd);
968 ahd_unlock(ahd, &flags); 968 ahd_midlayer_entrypoint_unlock(ahd, &flags);
969 printf("%s: aic79xx_linux_queue - Unable to allocate device!\n", 969 printf("%s: aic79xx_linux_queue - Unable to allocate device!\n",
970 ahd_name(ahd)); 970 ahd_name(ahd));
971 return (0); 971 return (0);
@@ -979,7 +979,7 @@ ahd_linux_queue(Scsi_Cmnd * cmd, void (*scsi_done) (Scsi_Cmnd *))
979 dev->flags |= AHD_DEV_ON_RUN_LIST; 979 dev->flags |= AHD_DEV_ON_RUN_LIST;
980 ahd_linux_run_device_queues(ahd); 980 ahd_linux_run_device_queues(ahd);
981 } 981 }
982 ahd_unlock(ahd, &flags); 982 ahd_midlayer_entrypoint_unlock(ahd, &flags);
983 return (0); 983 return (0);
984} 984}
985 985
diff --git a/drivers/scsi/arm/eesox.c b/drivers/scsi/arm/eesox.c
index 78b7e543471b..ce711f166cfb 100644
--- a/drivers/scsi/arm/eesox.c
+++ b/drivers/scsi/arm/eesox.c
@@ -466,7 +466,7 @@ int eesoxscsi_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_
466 return pos; 466 return pos;
467} 467}
468 468
469static ssize_t eesoxscsi_show_term(struct device *dev, char *buf) 469static ssize_t eesoxscsi_show_term(struct device *dev, struct device_attribute *attr, char *buf)
470{ 470{
471 struct expansion_card *ec = ECARD_DEV(dev); 471 struct expansion_card *ec = ECARD_DEV(dev);
472 struct Scsi_Host *host = ecard_get_drvdata(ec); 472 struct Scsi_Host *host = ecard_get_drvdata(ec);
@@ -475,7 +475,7 @@ static ssize_t eesoxscsi_show_term(struct device *dev, char *buf)
475 return sprintf(buf, "%d\n", info->control & EESOX_TERM_ENABLE ? 1 : 0); 475 return sprintf(buf, "%d\n", info->control & EESOX_TERM_ENABLE ? 1 : 0);
476} 476}
477 477
478static ssize_t eesoxscsi_store_term(struct device *dev, const char *buf, size_t len) 478static ssize_t eesoxscsi_store_term(struct device *dev, struct device_attribute *attr, const char *buf, size_t len)
479{ 479{
480 struct expansion_card *ec = ECARD_DEV(dev); 480 struct expansion_card *ec = ECARD_DEV(dev);
481 struct Scsi_Host *host = ecard_get_drvdata(ec); 481 struct Scsi_Host *host = ecard_get_drvdata(ec);
diff --git a/drivers/scsi/arm/powertec.c b/drivers/scsi/arm/powertec.c
index 54f23be6460f..abda216113f1 100644
--- a/drivers/scsi/arm/powertec.c
+++ b/drivers/scsi/arm/powertec.c
@@ -269,7 +269,7 @@ int powertecscsi_proc_info(struct Scsi_Host *host, char *buffer, char **start, o
269 return pos; 269 return pos;
270} 270}
271 271
272static ssize_t powertecscsi_show_term(struct device *dev, char *buf) 272static ssize_t powertecscsi_show_term(struct device *dev, struct device_attribute *attr, char *buf)
273{ 273{
274 struct expansion_card *ec = ECARD_DEV(dev); 274 struct expansion_card *ec = ECARD_DEV(dev);
275 struct Scsi_Host *host = ecard_get_drvdata(ec); 275 struct Scsi_Host *host = ecard_get_drvdata(ec);
@@ -279,7 +279,7 @@ static ssize_t powertecscsi_show_term(struct device *dev, char *buf)
279} 279}
280 280
281static ssize_t 281static ssize_t
282powertecscsi_store_term(struct device *dev, const char *buf, size_t len) 282powertecscsi_store_term(struct device *dev, struct device_attribute *attr, const char *buf, size_t len)
283{ 283{
284 struct expansion_card *ec = ECARD_DEV(dev); 284 struct expansion_card *ec = ECARD_DEV(dev);
285 struct Scsi_Host *host = ecard_get_drvdata(ec); 285 struct Scsi_Host *host = ecard_get_drvdata(ec);
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index 17b106b79f72..80d022625c82 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -2716,7 +2716,7 @@ static int ipr_change_queue_type(struct scsi_device *sdev, int tag_type)
2716 * Return value: 2716 * Return value:
2717 * number of bytes printed to buffer 2717 * number of bytes printed to buffer
2718 **/ 2718 **/
2719static ssize_t ipr_show_adapter_handle(struct device *dev, char *buf) 2719static ssize_t ipr_show_adapter_handle(struct device *dev, struct device_attribute *attr, char *buf)
2720{ 2720{
2721 struct scsi_device *sdev = to_scsi_device(dev); 2721 struct scsi_device *sdev = to_scsi_device(dev);
2722 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)sdev->host->hostdata; 2722 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)sdev->host->hostdata;
diff --git a/drivers/scsi/megaraid/megaraid_mbox.c b/drivers/scsi/megaraid/megaraid_mbox.c
index 057ed45b54b2..cbe430246276 100644
--- a/drivers/scsi/megaraid/megaraid_mbox.c
+++ b/drivers/scsi/megaraid/megaraid_mbox.c
@@ -124,7 +124,7 @@ static irqreturn_t megaraid_isr(int, void *, struct pt_regs *);
124static void megaraid_mbox_dpc(unsigned long); 124static void megaraid_mbox_dpc(unsigned long);
125 125
126static ssize_t megaraid_sysfs_show_app_hndl(struct class_device *, char *); 126static ssize_t megaraid_sysfs_show_app_hndl(struct class_device *, char *);
127static ssize_t megaraid_sysfs_show_ldnum(struct device *, char *); 127static ssize_t megaraid_sysfs_show_ldnum(struct device *, struct device_attribute *attr, char *);
128 128
129static int megaraid_cmm_register(adapter_t *); 129static int megaraid_cmm_register(adapter_t *);
130static int megaraid_cmm_unregister(adapter_t *); 130static int megaraid_cmm_unregister(adapter_t *);
@@ -4145,7 +4145,7 @@ megaraid_sysfs_show_app_hndl(struct class_device *cdev, char *buf)
4145 * @param buf : buffer to send data to 4145 * @param buf : buffer to send data to
4146 */ 4146 */
4147static ssize_t 4147static ssize_t
4148megaraid_sysfs_show_ldnum(struct device *dev, char *buf) 4148megaraid_sysfs_show_ldnum(struct device *dev, struct device_attribute *attr, char *buf)
4149{ 4149{
4150 struct scsi_device *sdev = to_scsi_device(dev); 4150 struct scsi_device *sdev = to_scsi_device(dev);
4151 adapter_t *adapter = (adapter_t *)SCSIHOST2ADAP(sdev->host); 4151 adapter_t *adapter = (adapter_t *)SCSIHOST2ADAP(sdev->host);
diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c
index c585c7bef247..89a4a0615c22 100644
--- a/drivers/scsi/osst.c
+++ b/drivers/scsi/osst.c
@@ -5608,13 +5608,13 @@ static ssize_t osst_filemark_cnt_show(struct class_device *class_dev, char *buf)
5608 5608
5609CLASS_DEVICE_ATTR(file_count, S_IRUGO, osst_filemark_cnt_show, NULL); 5609CLASS_DEVICE_ATTR(file_count, S_IRUGO, osst_filemark_cnt_show, NULL);
5610 5610
5611static struct class_simple * osst_sysfs_class; 5611static struct class *osst_sysfs_class;
5612 5612
5613static int osst_sysfs_valid = 0; 5613static int osst_sysfs_valid = 0;
5614 5614
5615static void osst_sysfs_init(void) 5615static void osst_sysfs_init(void)
5616{ 5616{
5617 osst_sysfs_class = class_simple_create(THIS_MODULE, "onstream_tape"); 5617 osst_sysfs_class = class_create(THIS_MODULE, "onstream_tape");
5618 if ( IS_ERR(osst_sysfs_class) ) 5618 if ( IS_ERR(osst_sysfs_class) )
5619 printk(KERN_WARNING "osst :W: Unable to register sysfs class\n"); 5619 printk(KERN_WARNING "osst :W: Unable to register sysfs class\n");
5620 else 5620 else
@@ -5627,7 +5627,7 @@ static void osst_sysfs_add(dev_t dev, struct device *device, struct osst_tape *
5627 5627
5628 if (!osst_sysfs_valid) return; 5628 if (!osst_sysfs_valid) return;
5629 5629
5630 osst_class_member = class_simple_device_add(osst_sysfs_class, dev, device, "%s", name); 5630 osst_class_member = class_device_create(osst_sysfs_class, dev, device, "%s", name);
5631 if (IS_ERR(osst_class_member)) { 5631 if (IS_ERR(osst_class_member)) {
5632 printk(KERN_WARNING "osst :W: Unable to add sysfs class member %s\n", name); 5632 printk(KERN_WARNING "osst :W: Unable to add sysfs class member %s\n", name);
5633 return; 5633 return;
@@ -5645,13 +5645,13 @@ static void osst_sysfs_destroy(dev_t dev)
5645{ 5645{
5646 if (!osst_sysfs_valid) return; 5646 if (!osst_sysfs_valid) return;
5647 5647
5648 class_simple_device_remove(dev); 5648 class_device_destroy(osst_sysfs_class, dev);
5649} 5649}
5650 5650
5651static void osst_sysfs_cleanup(void) 5651static void osst_sysfs_cleanup(void)
5652{ 5652{
5653 if (osst_sysfs_valid) { 5653 if (osst_sysfs_valid) {
5654 class_simple_destroy(osst_sysfs_class); 5654 class_destroy(osst_sysfs_class);
5655 osst_sysfs_valid = 0; 5655 osst_sysfs_valid = 0;
5656 } 5656 }
5657} 5657}
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index e75ee4671ee3..93b41100a6d8 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -230,7 +230,7 @@ void scsi_sysfs_unregister(void)
230 */ 230 */
231#define sdev_show_function(field, format_string) \ 231#define sdev_show_function(field, format_string) \
232static ssize_t \ 232static ssize_t \
233sdev_show_##field (struct device *dev, char *buf) \ 233sdev_show_##field (struct device *dev, struct device_attribute *attr, char *buf) \
234{ \ 234{ \
235 struct scsi_device *sdev; \ 235 struct scsi_device *sdev; \
236 sdev = to_scsi_device(dev); \ 236 sdev = to_scsi_device(dev); \
@@ -254,7 +254,7 @@ static DEVICE_ATTR(field, S_IRUGO, sdev_show_##field, NULL);
254 sdev_show_function(field, format_string) \ 254 sdev_show_function(field, format_string) \
255 \ 255 \
256static ssize_t \ 256static ssize_t \
257sdev_store_##field (struct device *dev, const char *buf, size_t count) \ 257sdev_store_##field (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \
258{ \ 258{ \
259 struct scsi_device *sdev; \ 259 struct scsi_device *sdev; \
260 sdev = to_scsi_device(dev); \ 260 sdev = to_scsi_device(dev); \
@@ -274,7 +274,7 @@ static DEVICE_ATTR(field, S_IRUGO | S_IWUSR, sdev_show_##field, sdev_store_##fie
274 sdev_show_function(field, "%d\n") \ 274 sdev_show_function(field, "%d\n") \
275 \ 275 \
276static ssize_t \ 276static ssize_t \
277sdev_store_##field (struct device *dev, const char *buf, size_t count) \ 277sdev_store_##field (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \
278{ \ 278{ \
279 int ret; \ 279 int ret; \
280 struct scsi_device *sdev; \ 280 struct scsi_device *sdev; \
@@ -317,7 +317,7 @@ sdev_rd_attr (model, "%.16s\n");
317sdev_rd_attr (rev, "%.4s\n"); 317sdev_rd_attr (rev, "%.4s\n");
318 318
319static ssize_t 319static ssize_t
320sdev_show_timeout (struct device *dev, char *buf) 320sdev_show_timeout (struct device *dev, struct device_attribute *attr, char *buf)
321{ 321{
322 struct scsi_device *sdev; 322 struct scsi_device *sdev;
323 sdev = to_scsi_device(dev); 323 sdev = to_scsi_device(dev);
@@ -325,7 +325,7 @@ sdev_show_timeout (struct device *dev, char *buf)
325} 325}
326 326
327static ssize_t 327static ssize_t
328sdev_store_timeout (struct device *dev, const char *buf, size_t count) 328sdev_store_timeout (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
329{ 329{
330 struct scsi_device *sdev; 330 struct scsi_device *sdev;
331 int timeout; 331 int timeout;
@@ -337,14 +337,14 @@ sdev_store_timeout (struct device *dev, const char *buf, size_t count)
337static DEVICE_ATTR(timeout, S_IRUGO | S_IWUSR, sdev_show_timeout, sdev_store_timeout); 337static DEVICE_ATTR(timeout, S_IRUGO | S_IWUSR, sdev_show_timeout, sdev_store_timeout);
338 338
339static ssize_t 339static ssize_t
340store_rescan_field (struct device *dev, const char *buf, size_t count) 340store_rescan_field (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
341{ 341{
342 scsi_rescan_device(dev); 342 scsi_rescan_device(dev);
343 return count; 343 return count;
344} 344}
345static DEVICE_ATTR(rescan, S_IWUSR, NULL, store_rescan_field); 345static DEVICE_ATTR(rescan, S_IWUSR, NULL, store_rescan_field);
346 346
347static ssize_t sdev_store_delete(struct device *dev, const char *buf, 347static ssize_t sdev_store_delete(struct device *dev, struct device_attribute *attr, const char *buf,
348 size_t count) 348 size_t count)
349{ 349{
350 scsi_remove_device(to_scsi_device(dev)); 350 scsi_remove_device(to_scsi_device(dev));
@@ -353,7 +353,7 @@ static ssize_t sdev_store_delete(struct device *dev, const char *buf,
353static DEVICE_ATTR(delete, S_IWUSR, NULL, sdev_store_delete); 353static DEVICE_ATTR(delete, S_IWUSR, NULL, sdev_store_delete);
354 354
355static ssize_t 355static ssize_t
356store_state_field(struct device *dev, const char *buf, size_t count) 356store_state_field(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
357{ 357{
358 int i; 358 int i;
359 struct scsi_device *sdev = to_scsi_device(dev); 359 struct scsi_device *sdev = to_scsi_device(dev);
@@ -376,7 +376,7 @@ store_state_field(struct device *dev, const char *buf, size_t count)
376} 376}
377 377
378static ssize_t 378static ssize_t
379show_state_field(struct device *dev, char *buf) 379show_state_field(struct device *dev, struct device_attribute *attr, char *buf)
380{ 380{
381 struct scsi_device *sdev = to_scsi_device(dev); 381 struct scsi_device *sdev = to_scsi_device(dev);
382 const char *name = scsi_device_state_name(sdev->sdev_state); 382 const char *name = scsi_device_state_name(sdev->sdev_state);
@@ -390,7 +390,7 @@ show_state_field(struct device *dev, char *buf)
390static DEVICE_ATTR(state, S_IRUGO | S_IWUSR, show_state_field, store_state_field); 390static DEVICE_ATTR(state, S_IRUGO | S_IWUSR, show_state_field, store_state_field);
391 391
392static ssize_t 392static ssize_t
393show_queue_type_field(struct device *dev, char *buf) 393show_queue_type_field(struct device *dev, struct device_attribute *attr, char *buf)
394{ 394{
395 struct scsi_device *sdev = to_scsi_device(dev); 395 struct scsi_device *sdev = to_scsi_device(dev);
396 const char *name = "none"; 396 const char *name = "none";
@@ -406,7 +406,7 @@ show_queue_type_field(struct device *dev, char *buf)
406static DEVICE_ATTR(queue_type, S_IRUGO, show_queue_type_field, NULL); 406static DEVICE_ATTR(queue_type, S_IRUGO, show_queue_type_field, NULL);
407 407
408static ssize_t 408static ssize_t
409show_iostat_counterbits(struct device *dev, char *buf) 409show_iostat_counterbits(struct device *dev, struct device_attribute *attr, char *buf)
410{ 410{
411 return snprintf(buf, 20, "%d\n", (int)sizeof(atomic_t) * 8); 411 return snprintf(buf, 20, "%d\n", (int)sizeof(atomic_t) * 8);
412} 412}
@@ -415,7 +415,7 @@ static DEVICE_ATTR(iocounterbits, S_IRUGO, show_iostat_counterbits, NULL);
415 415
416#define show_sdev_iostat(field) \ 416#define show_sdev_iostat(field) \
417static ssize_t \ 417static ssize_t \
418show_iostat_##field(struct device *dev, char *buf) \ 418show_iostat_##field(struct device *dev, struct device_attribute *attr, char *buf) \
419{ \ 419{ \
420 struct scsi_device *sdev = to_scsi_device(dev); \ 420 struct scsi_device *sdev = to_scsi_device(dev); \
421 unsigned long long count = atomic_read(&sdev->field); \ 421 unsigned long long count = atomic_read(&sdev->field); \
@@ -449,7 +449,7 @@ static struct device_attribute *scsi_sysfs_sdev_attrs[] = {
449 NULL 449 NULL
450}; 450};
451 451
452static ssize_t sdev_store_queue_depth_rw(struct device *dev, const char *buf, 452static ssize_t sdev_store_queue_depth_rw(struct device *dev, struct device_attribute *attr, const char *buf,
453 size_t count) 453 size_t count)
454{ 454{
455 int depth, retval; 455 int depth, retval;
@@ -475,7 +475,7 @@ static struct device_attribute sdev_attr_queue_depth_rw =
475 __ATTR(queue_depth, S_IRUGO | S_IWUSR, sdev_show_queue_depth, 475 __ATTR(queue_depth, S_IRUGO | S_IWUSR, sdev_show_queue_depth,
476 sdev_store_queue_depth_rw); 476 sdev_store_queue_depth_rw);
477 477
478static ssize_t sdev_store_queue_type_rw(struct device *dev, const char *buf, 478static ssize_t sdev_store_queue_type_rw(struct device *dev, struct device_attribute *attr, const char *buf,
479 size_t count) 479 size_t count)
480{ 480{
481 struct scsi_device *sdev = to_scsi_device(dev); 481 struct scsi_device *sdev = to_scsi_device(dev);
@@ -669,6 +669,13 @@ void __scsi_remove_target(struct scsi_target *starget)
669 scsi_target_reap(starget); 669 scsi_target_reap(starget);
670} 670}
671 671
672static int __remove_child (struct device * dev, void * data)
673{
674 if (scsi_is_target_device(dev))
675 __scsi_remove_target(to_scsi_target(dev));
676 return 0;
677}
678
672/** 679/**
673 * scsi_remove_target - try to remove a target and all its devices 680 * scsi_remove_target - try to remove a target and all its devices
674 * @dev: generic starget or parent of generic stargets to be removed 681 * @dev: generic starget or parent of generic stargets to be removed
@@ -679,7 +686,7 @@ void __scsi_remove_target(struct scsi_target *starget)
679 */ 686 */
680void scsi_remove_target(struct device *dev) 687void scsi_remove_target(struct device *dev)
681{ 688{
682 struct device *rdev, *idev, *next; 689 struct device *rdev;
683 690
684 if (scsi_is_target_device(dev)) { 691 if (scsi_is_target_device(dev)) {
685 __scsi_remove_target(to_scsi_target(dev)); 692 __scsi_remove_target(to_scsi_target(dev));
@@ -687,10 +694,7 @@ void scsi_remove_target(struct device *dev)
687 } 694 }
688 695
689 rdev = get_device(dev); 696 rdev = get_device(dev);
690 list_for_each_entry_safe(idev, next, &dev->children, node) { 697 device_for_each_child(dev, NULL, __remove_child);
691 if (scsi_is_target_device(idev))
692 __scsi_remove_target(to_scsi_target(idev));
693 }
694 put_device(rdev); 698 put_device(rdev);
695} 699}
696EXPORT_SYMBOL(scsi_remove_target); 700EXPORT_SYMBOL(scsi_remove_target);
diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c
index c87ae469d707..2918b9600db7 100644
--- a/drivers/scsi/scsi_transport_spi.c
+++ b/drivers/scsi/scsi_transport_spi.c
@@ -348,17 +348,21 @@ spi_transport_rd_attr(rd_strm, "%d\n");
348spi_transport_rd_attr(rti, "%d\n"); 348spi_transport_rd_attr(rti, "%d\n");
349spi_transport_rd_attr(pcomp_en, "%d\n"); 349spi_transport_rd_attr(pcomp_en, "%d\n");
350 350
351/* we only care about the first child device so we return 1 */
352static int child_iter(struct device *dev, void *data)
353{
354 struct scsi_device *sdev = to_scsi_device(dev);
355
356 spi_dv_device(sdev);
357 return 1;
358}
359
351static ssize_t 360static ssize_t
352store_spi_revalidate(struct class_device *cdev, const char *buf, size_t count) 361store_spi_revalidate(struct class_device *cdev, const char *buf, size_t count)
353{ 362{
354 struct scsi_target *starget = transport_class_to_starget(cdev); 363 struct scsi_target *starget = transport_class_to_starget(cdev);
355 364
356 /* FIXME: we're relying on an awful lot of device internals 365 device_for_each_child(&starget->dev, NULL, child_iter);
357 * here. We really need a function to get the first available
358 * child */
359 struct device *dev = container_of(starget->dev.children.next, struct device, node);
360 struct scsi_device *sdev = to_scsi_device(dev);
361 spi_dv_device(sdev);
362 return count; 366 return count;
363} 367}
364static CLASS_DEVICE_ATTR(revalidate, S_IWUSR, NULL, store_spi_revalidate); 368static CLASS_DEVICE_ATTR(revalidate, S_IWUSR, NULL, store_spi_revalidate);
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 3d1d7bff38ed..51292f269ce5 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -1430,7 +1430,7 @@ static struct file_operations sg_fops = {
1430 .fasync = sg_fasync, 1430 .fasync = sg_fasync,
1431}; 1431};
1432 1432
1433static struct class_simple * sg_sysfs_class; 1433static struct class *sg_sysfs_class;
1434 1434
1435static int sg_sysfs_valid = 0; 1435static int sg_sysfs_valid = 0;
1436 1436
@@ -1551,13 +1551,13 @@ sg_add(struct class_device *cl_dev)
1551 if (sg_sysfs_valid) { 1551 if (sg_sysfs_valid) {
1552 struct class_device * sg_class_member; 1552 struct class_device * sg_class_member;
1553 1553
1554 sg_class_member = class_simple_device_add(sg_sysfs_class, 1554 sg_class_member = class_device_create(sg_sysfs_class,
1555 MKDEV(SCSI_GENERIC_MAJOR, k), 1555 MKDEV(SCSI_GENERIC_MAJOR, k),
1556 cl_dev->dev, "%s", 1556 cl_dev->dev, "%s",
1557 disk->disk_name); 1557 disk->disk_name);
1558 if (IS_ERR(sg_class_member)) 1558 if (IS_ERR(sg_class_member))
1559 printk(KERN_WARNING "sg_add: " 1559 printk(KERN_WARNING "sg_add: "
1560 "class_simple_device_add failed\n"); 1560 "class_device_create failed\n");
1561 class_set_devdata(sg_class_member, sdp); 1561 class_set_devdata(sg_class_member, sdp);
1562 error = sysfs_create_link(&scsidp->sdev_gendev.kobj, 1562 error = sysfs_create_link(&scsidp->sdev_gendev.kobj,
1563 &sg_class_member->kobj, "generic"); 1563 &sg_class_member->kobj, "generic");
@@ -1636,7 +1636,7 @@ sg_remove(struct class_device *cl_dev)
1636 1636
1637 if (sdp) { 1637 if (sdp) {
1638 sysfs_remove_link(&scsidp->sdev_gendev.kobj, "generic"); 1638 sysfs_remove_link(&scsidp->sdev_gendev.kobj, "generic");
1639 class_simple_device_remove(MKDEV(SCSI_GENERIC_MAJOR, k)); 1639 class_device_destroy(sg_sysfs_class, MKDEV(SCSI_GENERIC_MAJOR, k));
1640 cdev_del(sdp->cdev); 1640 cdev_del(sdp->cdev);
1641 sdp->cdev = NULL; 1641 sdp->cdev = NULL;
1642 devfs_remove("%s/generic", scsidp->devfs_name); 1642 devfs_remove("%s/generic", scsidp->devfs_name);
@@ -1677,7 +1677,7 @@ init_sg(void)
1677 SG_MAX_DEVS, "sg"); 1677 SG_MAX_DEVS, "sg");
1678 if (rc) 1678 if (rc)
1679 return rc; 1679 return rc;
1680 sg_sysfs_class = class_simple_create(THIS_MODULE, "scsi_generic"); 1680 sg_sysfs_class = class_create(THIS_MODULE, "scsi_generic");
1681 if ( IS_ERR(sg_sysfs_class) ) { 1681 if ( IS_ERR(sg_sysfs_class) ) {
1682 rc = PTR_ERR(sg_sysfs_class); 1682 rc = PTR_ERR(sg_sysfs_class);
1683 goto err_out; 1683 goto err_out;
@@ -1690,7 +1690,7 @@ init_sg(void)
1690#endif /* CONFIG_SCSI_PROC_FS */ 1690#endif /* CONFIG_SCSI_PROC_FS */
1691 return 0; 1691 return 0;
1692 } 1692 }
1693 class_simple_destroy(sg_sysfs_class); 1693 class_destroy(sg_sysfs_class);
1694err_out: 1694err_out:
1695 unregister_chrdev_region(MKDEV(SCSI_GENERIC_MAJOR, 0), SG_MAX_DEVS); 1695 unregister_chrdev_region(MKDEV(SCSI_GENERIC_MAJOR, 0), SG_MAX_DEVS);
1696 return rc; 1696 return rc;
@@ -1703,7 +1703,7 @@ exit_sg(void)
1703 sg_proc_cleanup(); 1703 sg_proc_cleanup();
1704#endif /* CONFIG_SCSI_PROC_FS */ 1704#endif /* CONFIG_SCSI_PROC_FS */
1705 scsi_unregister_interface(&sg_interface); 1705 scsi_unregister_interface(&sg_interface);
1706 class_simple_destroy(sg_sysfs_class); 1706 class_destroy(sg_sysfs_class);
1707 sg_sysfs_valid = 0; 1707 sg_sysfs_valid = 0;
1708 unregister_chrdev_region(MKDEV(SCSI_GENERIC_MAJOR, 0), 1708 unregister_chrdev_region(MKDEV(SCSI_GENERIC_MAJOR, 0),
1709 SG_MAX_DEVS); 1709 SG_MAX_DEVS);
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index 03b902c20e09..0291a8fb654d 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -84,7 +84,7 @@ static int try_wdio = 1;
84static int st_dev_max; 84static int st_dev_max;
85static int st_nr_dev; 85static int st_nr_dev;
86 86
87static struct class_simple *st_sysfs_class; 87static struct class *st_sysfs_class;
88 88
89MODULE_AUTHOR("Kai Makisara"); 89MODULE_AUTHOR("Kai Makisara");
90MODULE_DESCRIPTION("SCSI Tape Driver"); 90MODULE_DESCRIPTION("SCSI Tape Driver");
@@ -4024,8 +4024,9 @@ out_free_tape:
4024 if (STm->cdevs[j]) { 4024 if (STm->cdevs[j]) {
4025 if (cdev == STm->cdevs[j]) 4025 if (cdev == STm->cdevs[j])
4026 cdev = NULL; 4026 cdev = NULL;
4027 class_simple_device_remove(MKDEV(SCSI_TAPE_MAJOR, 4027 class_device_destroy(st_sysfs_class,
4028 TAPE_MINOR(i, mode, j))); 4028 MKDEV(SCSI_TAPE_MAJOR,
4029 TAPE_MINOR(i, mode, j)));
4029 cdev_del(STm->cdevs[j]); 4030 cdev_del(STm->cdevs[j]);
4030 } 4031 }
4031 } 4032 }
@@ -4068,8 +4069,9 @@ static int st_remove(struct device *dev)
4068 devfs_remove("%s/mt%s", SDp->devfs_name, st_formats[j]); 4069 devfs_remove("%s/mt%s", SDp->devfs_name, st_formats[j]);
4069 devfs_remove("%s/mt%sn", SDp->devfs_name, st_formats[j]); 4070 devfs_remove("%s/mt%sn", SDp->devfs_name, st_formats[j]);
4070 for (j=0; j < 2; j++) { 4071 for (j=0; j < 2; j++) {
4071 class_simple_device_remove(MKDEV(SCSI_TAPE_MAJOR, 4072 class_device_destroy(st_sysfs_class,
4072 TAPE_MINOR(i, mode, j))); 4073 MKDEV(SCSI_TAPE_MAJOR,
4074 TAPE_MINOR(i, mode, j)));
4073 cdev_del(tpnt->modes[mode].cdevs[j]); 4075 cdev_del(tpnt->modes[mode].cdevs[j]);
4074 tpnt->modes[mode].cdevs[j] = NULL; 4076 tpnt->modes[mode].cdevs[j] = NULL;
4075 } 4077 }
@@ -4134,7 +4136,7 @@ static int __init init_st(void)
4134 "st: Version %s, fixed bufsize %d, s/g segs %d\n", 4136 "st: Version %s, fixed bufsize %d, s/g segs %d\n",
4135 verstr, st_fixed_buffer_size, st_max_sg_segs); 4137 verstr, st_fixed_buffer_size, st_max_sg_segs);
4136 4138
4137 st_sysfs_class = class_simple_create(THIS_MODULE, "scsi_tape"); 4139 st_sysfs_class = class_create(THIS_MODULE, "scsi_tape");
4138 if (IS_ERR(st_sysfs_class)) { 4140 if (IS_ERR(st_sysfs_class)) {
4139 st_sysfs_class = NULL; 4141 st_sysfs_class = NULL;
4140 printk(KERN_ERR "Unable create sysfs class for SCSI tapes\n"); 4142 printk(KERN_ERR "Unable create sysfs class for SCSI tapes\n");
@@ -4148,7 +4150,7 @@ static int __init init_st(void)
4148 return 0; 4150 return 0;
4149 } 4151 }
4150 if (st_sysfs_class) 4152 if (st_sysfs_class)
4151 class_simple_destroy(st_sysfs_class); 4153 class_destroy(st_sysfs_class);
4152 unregister_chrdev_region(MKDEV(SCSI_TAPE_MAJOR, 0), 4154 unregister_chrdev_region(MKDEV(SCSI_TAPE_MAJOR, 0),
4153 4155
4154 ST_MAX_TAPE_ENTRIES); 4156 ST_MAX_TAPE_ENTRIES);
@@ -4161,7 +4163,7 @@ static int __init init_st(void)
4161static void __exit exit_st(void) 4163static void __exit exit_st(void)
4162{ 4164{
4163 if (st_sysfs_class) 4165 if (st_sysfs_class)
4164 class_simple_destroy(st_sysfs_class); 4166 class_destroy(st_sysfs_class);
4165 st_sysfs_class = NULL; 4167 st_sysfs_class = NULL;
4166 do_remove_driverfs_files(); 4168 do_remove_driverfs_files();
4167 scsi_unregister_driver(&st_template.gendrv); 4169 scsi_unregister_driver(&st_template.gendrv);
@@ -4284,12 +4286,12 @@ static void do_create_class_files(struct scsi_tape *STp, int dev_num, int mode)
4284 snprintf(name, 10, "%s%s%s", rew ? "n" : "", 4286 snprintf(name, 10, "%s%s%s", rew ? "n" : "",
4285 STp->disk->disk_name, st_formats[i]); 4287 STp->disk->disk_name, st_formats[i]);
4286 st_class_member = 4288 st_class_member =
4287 class_simple_device_add(st_sysfs_class, 4289 class_device_create(st_sysfs_class,
4288 MKDEV(SCSI_TAPE_MAJOR, 4290 MKDEV(SCSI_TAPE_MAJOR,
4289 TAPE_MINOR(dev_num, mode, rew)), 4291 TAPE_MINOR(dev_num, mode, rew)),
4290 &STp->device->sdev_gendev, "%s", name); 4292 &STp->device->sdev_gendev, "%s", name);
4291 if (IS_ERR(st_class_member)) { 4293 if (IS_ERR(st_class_member)) {
4292 printk(KERN_WARNING "st%d: class_simple_device_add failed\n", 4294 printk(KERN_WARNING "st%d: class_device_create failed\n",
4293 dev_num); 4295 dev_num);
4294 goto out; 4296 goto out;
4295 } 4297 }
diff --git a/drivers/sh/superhyway/superhyway-sysfs.c b/drivers/sh/superhyway/superhyway-sysfs.c
index 39ab6a12da76..dc119ce68e3e 100644
--- a/drivers/sh/superhyway/superhyway-sysfs.c
+++ b/drivers/sh/superhyway/superhyway-sysfs.c
@@ -15,7 +15,7 @@
15#include <linux/superhyway.h> 15#include <linux/superhyway.h>
16 16
17#define superhyway_ro_attr(name, fmt, field) \ 17#define superhyway_ro_attr(name, fmt, field) \
18static ssize_t name##_show(struct device *dev, char *buf) \ 18static ssize_t name##_show(struct device *dev, struct device_attribute *attr, char *buf) \
19{ \ 19{ \
20 struct superhyway_device *s = to_superhyway_device(dev); \ 20 struct superhyway_device *s = to_superhyway_device(dev); \
21 return sprintf(buf, fmt, s->field); \ 21 return sprintf(buf, fmt, s->field); \
diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
index ef0b35731ff0..83e815d3cd52 100644
--- a/drivers/usb/core/devices.c
+++ b/drivers/usb/core/devices.c
@@ -239,7 +239,7 @@ static char *usb_dump_interface_descriptor(char *start, char *end,
239 int setno) 239 int setno)
240{ 240{
241 const struct usb_interface_descriptor *desc = &intfc->altsetting[setno].desc; 241 const struct usb_interface_descriptor *desc = &intfc->altsetting[setno].desc;
242 char *driver_name = ""; 242 const char *driver_name = "";
243 243
244 if (start > end) 244 if (start > end)
245 return start; 245 return start;
diff --git a/drivers/usb/core/file.c b/drivers/usb/core/file.c
index 38ed2220c9fc..65ca131cc44c 100644
--- a/drivers/usb/core/file.c
+++ b/drivers/usb/core/file.c
@@ -68,7 +68,7 @@ static struct file_operations usb_fops = {
68 .open = usb_open, 68 .open = usb_open,
69}; 69};
70 70
71static struct class_simple *usb_class; 71static struct class *usb_class;
72 72
73int usb_major_init(void) 73int usb_major_init(void)
74{ 74{
@@ -80,9 +80,10 @@ int usb_major_init(void)
80 goto out; 80 goto out;
81 } 81 }
82 82
83 usb_class = class_simple_create(THIS_MODULE, "usb"); 83 usb_class = class_create(THIS_MODULE, "usb");
84 if (IS_ERR(usb_class)) { 84 if (IS_ERR(usb_class)) {
85 err("class_simple_create failed for usb devices"); 85 error = PTR_ERR(usb_class);
86 err("class_create failed for usb devices");
86 unregister_chrdev(USB_MAJOR, "usb"); 87 unregister_chrdev(USB_MAJOR, "usb");
87 goto out; 88 goto out;
88 } 89 }
@@ -95,7 +96,7 @@ out:
95 96
96void usb_major_cleanup(void) 97void usb_major_cleanup(void)
97{ 98{
98 class_simple_destroy(usb_class); 99 class_destroy(usb_class);
99 devfs_remove("usb"); 100 devfs_remove("usb");
100 unregister_chrdev(USB_MAJOR, "usb"); 101 unregister_chrdev(USB_MAJOR, "usb");
101} 102}
@@ -171,7 +172,7 @@ int usb_register_dev(struct usb_interface *intf,
171 ++temp; 172 ++temp;
172 else 173 else
173 temp = name; 174 temp = name;
174 intf->class_dev = class_simple_device_add(usb_class, MKDEV(USB_MAJOR, minor), &intf->dev, "%s", temp); 175 intf->class_dev = class_device_create(usb_class, MKDEV(USB_MAJOR, minor), &intf->dev, "%s", temp);
175 if (IS_ERR(intf->class_dev)) { 176 if (IS_ERR(intf->class_dev)) {
176 spin_lock (&minor_lock); 177 spin_lock (&minor_lock);
177 usb_minors[intf->minor] = NULL; 178 usb_minors[intf->minor] = NULL;
@@ -220,7 +221,7 @@ void usb_deregister_dev(struct usb_interface *intf,
220 221
221 snprintf(name, BUS_ID_SIZE, class_driver->name, intf->minor - minor_base); 222 snprintf(name, BUS_ID_SIZE, class_driver->name, intf->minor - minor_base);
222 devfs_remove (name); 223 devfs_remove (name);
223 class_simple_device_remove(MKDEV(USB_MAJOR, intf->minor)); 224 class_device_destroy(usb_class, MKDEV(USB_MAJOR, intf->minor));
224 intf->class_dev = NULL; 225 intf->class_dev = NULL;
225 intf->minor = -1; 226 intf->minor = -1;
226} 227}
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 266e9e06a9f5..d041782e0c8b 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -651,50 +651,45 @@ static int usb_rh_urb_dequeue (struct usb_hcd *hcd, struct urb *urb)
651/*-------------------------------------------------------------------------*/ 651/*-------------------------------------------------------------------------*/
652 652
653/* exported only within usbcore */ 653/* exported only within usbcore */
654struct usb_bus *usb_bus_get (struct usb_bus *bus) 654struct usb_bus *usb_bus_get(struct usb_bus *bus)
655{ 655{
656 struct class_device *tmp; 656 if (bus)
657 kref_get(&bus->kref);
658 return bus;
659}
657 660
658 if (!bus) 661static void usb_host_release(struct kref *kref)
659 return NULL; 662{
663 struct usb_bus *bus = container_of(kref, struct usb_bus, kref);
660 664
661 tmp = class_device_get(&bus->class_dev); 665 if (bus->release)
662 if (tmp) 666 bus->release(bus);
663 return to_usb_bus(tmp);
664 else
665 return NULL;
666} 667}
667 668
668/* exported only within usbcore */ 669/* exported only within usbcore */
669void usb_bus_put (struct usb_bus *bus) 670void usb_bus_put(struct usb_bus *bus)
670{ 671{
671 if (bus) 672 if (bus)
672 class_device_put(&bus->class_dev); 673 kref_put(&bus->kref, usb_host_release);
673} 674}
674 675
675/*-------------------------------------------------------------------------*/ 676/*-------------------------------------------------------------------------*/
676 677
677static void usb_host_release(struct class_device *class_dev) 678static struct class *usb_host_class;
678{
679 struct usb_bus *bus = to_usb_bus(class_dev);
680
681 if (bus->release)
682 bus->release(bus);
683}
684
685static struct class usb_host_class = {
686 .name = "usb_host",
687 .release = &usb_host_release,
688};
689 679
690int usb_host_init(void) 680int usb_host_init(void)
691{ 681{
692 return class_register(&usb_host_class); 682 int retval = 0;
683
684 usb_host_class = class_create(THIS_MODULE, "usb_host");
685 if (IS_ERR(usb_host_class))
686 retval = PTR_ERR(usb_host_class);
687 return retval;
693} 688}
694 689
695void usb_host_cleanup(void) 690void usb_host_cleanup(void)
696{ 691{
697 class_unregister(&usb_host_class); 692 class_destroy(usb_host_class);
698} 693}
699 694
700/** 695/**
@@ -719,8 +714,7 @@ static void usb_bus_init (struct usb_bus *bus)
719 714
720 INIT_LIST_HEAD (&bus->bus_list); 715 INIT_LIST_HEAD (&bus->bus_list);
721 716
722 class_device_initialize(&bus->class_dev); 717 kref_init(&bus->kref);
723 bus->class_dev.class = &usb_host_class;
724} 718}
725 719
726/** 720/**
@@ -761,7 +755,6 @@ struct usb_bus *usb_alloc_bus (struct usb_operations *op)
761static int usb_register_bus(struct usb_bus *bus) 755static int usb_register_bus(struct usb_bus *bus)
762{ 756{
763 int busnum; 757 int busnum;
764 int retval;
765 758
766 down (&usb_bus_list_lock); 759 down (&usb_bus_list_lock);
767 busnum = find_next_zero_bit (busmap.busmap, USB_MAXBUS, 1); 760 busnum = find_next_zero_bit (busmap.busmap, USB_MAXBUS, 1);
@@ -774,15 +767,15 @@ static int usb_register_bus(struct usb_bus *bus)
774 return -E2BIG; 767 return -E2BIG;
775 } 768 }
776 769
777 snprintf(bus->class_dev.class_id, BUS_ID_SIZE, "usb%d", busnum); 770 bus->class_dev = class_device_create(usb_host_class, MKDEV(0,0), bus->controller, "usb%d", busnum);
778 bus->class_dev.dev = bus->controller; 771 if (IS_ERR(bus->class_dev)) {
779 retval = class_device_add(&bus->class_dev);
780 if (retval) {
781 clear_bit(busnum, busmap.busmap); 772 clear_bit(busnum, busmap.busmap);
782 up(&usb_bus_list_lock); 773 up(&usb_bus_list_lock);
783 return retval; 774 return PTR_ERR(bus->class_dev);
784 } 775 }
785 776
777 class_set_devdata(bus->class_dev, bus);
778
786 /* Add it to the local list of buses */ 779 /* Add it to the local list of buses */
787 list_add (&bus->bus_list, &usb_bus_list); 780 list_add (&bus->bus_list, &usb_bus_list);
788 up (&usb_bus_list_lock); 781 up (&usb_bus_list_lock);
@@ -820,7 +813,7 @@ static void usb_deregister_bus (struct usb_bus *bus)
820 813
821 clear_bit (bus->busnum, busmap.busmap); 814 clear_bit (bus->busnum, busmap.busmap);
822 815
823 class_device_del(&bus->class_dev); 816 class_device_unregister(bus->class_dev);
824} 817}
825 818
826/** 819/**
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
index 4d0c9e65cd03..740cb4c668df 100644
--- a/drivers/usb/core/sysfs.c
+++ b/drivers/usb/core/sysfs.c
@@ -24,7 +24,7 @@
24 24
25/* Active configuration fields */ 25/* Active configuration fields */
26#define usb_actconfig_show(field, multiplier, format_string) \ 26#define usb_actconfig_show(field, multiplier, format_string) \
27static ssize_t show_##field (struct device *dev, char *buf) \ 27static ssize_t show_##field (struct device *dev, struct device_attribute *attr, char *buf) \
28{ \ 28{ \
29 struct usb_device *udev; \ 29 struct usb_device *udev; \
30 struct usb_host_config *actconfig; \ 30 struct usb_host_config *actconfig; \
@@ -46,7 +46,7 @@ usb_actconfig_attr (bNumInterfaces, 1, "%2d\n")
46usb_actconfig_attr (bmAttributes, 1, "%2x\n") 46usb_actconfig_attr (bmAttributes, 1, "%2x\n")
47usb_actconfig_attr (bMaxPower, 2, "%3dmA\n") 47usb_actconfig_attr (bMaxPower, 2, "%3dmA\n")
48 48
49static ssize_t show_configuration_string(struct device *dev, char *buf) 49static ssize_t show_configuration_string(struct device *dev, struct device_attribute *attr, char *buf)
50{ 50{
51 struct usb_device *udev; 51 struct usb_device *udev;
52 struct usb_host_config *actconfig; 52 struct usb_host_config *actconfig;
@@ -69,7 +69,7 @@ static DEVICE_ATTR(configuration, S_IRUGO, show_configuration_string, NULL);
69usb_actconfig_show(bConfigurationValue, 1, "%u\n"); 69usb_actconfig_show(bConfigurationValue, 1, "%u\n");
70 70
71static ssize_t 71static ssize_t
72set_bConfigurationValue (struct device *dev, const char *buf, size_t count) 72set_bConfigurationValue (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
73{ 73{
74 struct usb_device *udev = udev = to_usb_device (dev); 74 struct usb_device *udev = udev = to_usb_device (dev);
75 int config, value; 75 int config, value;
@@ -87,7 +87,7 @@ static DEVICE_ATTR(bConfigurationValue, S_IRUGO | S_IWUSR,
87 87
88/* String fields */ 88/* String fields */
89#define usb_string_attr(name) \ 89#define usb_string_attr(name) \
90static ssize_t show_##name(struct device *dev, char *buf) \ 90static ssize_t show_##name(struct device *dev, struct device_attribute *attr, char *buf) \
91{ \ 91{ \
92 struct usb_device *udev; \ 92 struct usb_device *udev; \
93 int len; \ 93 int len; \
@@ -107,7 +107,7 @@ usb_string_attr(manufacturer);
107usb_string_attr(serial); 107usb_string_attr(serial);
108 108
109static ssize_t 109static ssize_t
110show_speed (struct device *dev, char *buf) 110show_speed (struct device *dev, struct device_attribute *attr, char *buf)
111{ 111{
112 struct usb_device *udev; 112 struct usb_device *udev;
113 char *speed; 113 char *speed;
@@ -133,7 +133,7 @@ show_speed (struct device *dev, char *buf)
133static DEVICE_ATTR(speed, S_IRUGO, show_speed, NULL); 133static DEVICE_ATTR(speed, S_IRUGO, show_speed, NULL);
134 134
135static ssize_t 135static ssize_t
136show_devnum (struct device *dev, char *buf) 136show_devnum (struct device *dev, struct device_attribute *attr, char *buf)
137{ 137{
138 struct usb_device *udev; 138 struct usb_device *udev;
139 139
@@ -143,7 +143,7 @@ show_devnum (struct device *dev, char *buf)
143static DEVICE_ATTR(devnum, S_IRUGO, show_devnum, NULL); 143static DEVICE_ATTR(devnum, S_IRUGO, show_devnum, NULL);
144 144
145static ssize_t 145static ssize_t
146show_version (struct device *dev, char *buf) 146show_version (struct device *dev, struct device_attribute *attr, char *buf)
147{ 147{
148 struct usb_device *udev; 148 struct usb_device *udev;
149 u16 bcdUSB; 149 u16 bcdUSB;
@@ -155,7 +155,7 @@ show_version (struct device *dev, char *buf)
155static DEVICE_ATTR(version, S_IRUGO, show_version, NULL); 155static DEVICE_ATTR(version, S_IRUGO, show_version, NULL);
156 156
157static ssize_t 157static ssize_t
158show_maxchild (struct device *dev, char *buf) 158show_maxchild (struct device *dev, struct device_attribute *attr, char *buf)
159{ 159{
160 struct usb_device *udev; 160 struct usb_device *udev;
161 161
@@ -167,7 +167,7 @@ static DEVICE_ATTR(maxchild, S_IRUGO, show_maxchild, NULL);
167/* Descriptor fields */ 167/* Descriptor fields */
168#define usb_descriptor_attr_le16(field, format_string) \ 168#define usb_descriptor_attr_le16(field, format_string) \
169static ssize_t \ 169static ssize_t \
170show_##field (struct device *dev, char *buf) \ 170show_##field (struct device *dev, struct device_attribute *attr, char *buf) \
171{ \ 171{ \
172 struct usb_device *udev; \ 172 struct usb_device *udev; \
173 \ 173 \
@@ -183,7 +183,7 @@ usb_descriptor_attr_le16(bcdDevice, "%04x\n")
183 183
184#define usb_descriptor_attr(field, format_string) \ 184#define usb_descriptor_attr(field, format_string) \
185static ssize_t \ 185static ssize_t \
186show_##field (struct device *dev, char *buf) \ 186show_##field (struct device *dev, struct device_attribute *attr, char *buf) \
187{ \ 187{ \
188 struct usb_device *udev; \ 188 struct usb_device *udev; \
189 \ 189 \
@@ -254,7 +254,7 @@ void usb_remove_sysfs_dev_files (struct usb_device *udev)
254/* Interface fields */ 254/* Interface fields */
255#define usb_intf_attr(field, format_string) \ 255#define usb_intf_attr(field, format_string) \
256static ssize_t \ 256static ssize_t \
257show_##field (struct device *dev, char *buf) \ 257show_##field (struct device *dev, struct device_attribute *attr, char *buf) \
258{ \ 258{ \
259 struct usb_interface *intf = to_usb_interface (dev); \ 259 struct usb_interface *intf = to_usb_interface (dev); \
260 \ 260 \
@@ -269,7 +269,7 @@ usb_intf_attr (bInterfaceClass, "%02x\n")
269usb_intf_attr (bInterfaceSubClass, "%02x\n") 269usb_intf_attr (bInterfaceSubClass, "%02x\n")
270usb_intf_attr (bInterfaceProtocol, "%02x\n") 270usb_intf_attr (bInterfaceProtocol, "%02x\n")
271 271
272static ssize_t show_interface_string(struct device *dev, char *buf) 272static ssize_t show_interface_string(struct device *dev, struct device_attribute *attr, char *buf)
273{ 273{
274 struct usb_interface *intf; 274 struct usb_interface *intf;
275 struct usb_device *udev; 275 struct usb_device *udev;
@@ -286,7 +286,7 @@ static ssize_t show_interface_string(struct device *dev, char *buf)
286} 286}
287static DEVICE_ATTR(interface, S_IRUGO, show_interface_string, NULL); 287static DEVICE_ATTR(interface, S_IRUGO, show_interface_string, NULL);
288 288
289static ssize_t show_modalias(struct device *dev, char *buf) 289static ssize_t show_modalias(struct device *dev, struct device_attribute *attr, char *buf)
290{ 290{
291 struct usb_interface *intf; 291 struct usb_interface *intf;
292 struct usb_device *udev; 292 struct usb_device *udev;
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 25cf7e9eccfa..a3c42203213a 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -293,7 +293,7 @@ int usb_driver_claim_interface(struct usb_driver *driver,
293 /* if interface was already added, bind now; else let 293 /* if interface was already added, bind now; else let
294 * the future device_add() bind it, bypassing probe() 294 * the future device_add() bind it, bypassing probe()
295 */ 295 */
296 if (!list_empty (&dev->bus_list)) 296 if (klist_node_attached(&dev->knode_bus))
297 device_bind_driver(dev); 297 device_bind_driver(dev);
298 298
299 return 0; 299 return 0;
@@ -322,9 +322,15 @@ void usb_driver_release_interface(struct usb_driver *driver,
322 if (!dev->driver || dev->driver != &driver->driver) 322 if (!dev->driver || dev->driver != &driver->driver)
323 return; 323 return;
324 324
325 /* don't disconnect from disconnect(), or before dev_add() */ 325 /* don't release from within disconnect() */
326 if (!list_empty (&dev->driver_list) && !list_empty (&dev->bus_list)) 326 if (iface->condition != USB_INTERFACE_BOUND)
327 return;
328
329 /* release only after device_add() */
330 if (klist_node_attached(&dev->knode_bus)) {
331 iface->condition = USB_INTERFACE_UNBINDING;
327 device_release_driver(dev); 332 device_release_driver(dev);
333 }
328 334
329 dev->driver = NULL; 335 dev->driver = NULL;
330 usb_set_intfdata(iface, NULL); 336 usb_set_intfdata(iface, NULL);
@@ -462,6 +468,25 @@ usb_match_id(struct usb_interface *interface, const struct usb_device_id *id)
462 return NULL; 468 return NULL;
463} 469}
464 470
471
472static int __find_interface(struct device * dev, void * data)
473{
474 struct usb_interface ** ret = (struct usb_interface **)data;
475 struct usb_interface * intf = *ret;
476 int *minor = (int *)data;
477
478 /* can't look at usb devices, only interfaces */
479 if (dev->driver == &usb_generic_driver)
480 return 0;
481
482 intf = to_usb_interface(dev);
483 if (intf->minor != -1 && intf->minor == *minor) {
484 *ret = intf;
485 return 1;
486 }
487 return 0;
488}
489
465/** 490/**
466 * usb_find_interface - find usb_interface pointer for driver and device 491 * usb_find_interface - find usb_interface pointer for driver and device
467 * @drv: the driver whose current configuration is considered 492 * @drv: the driver whose current configuration is considered
@@ -473,26 +498,12 @@ usb_match_id(struct usb_interface *interface, const struct usb_device_id *id)
473 */ 498 */
474struct usb_interface *usb_find_interface(struct usb_driver *drv, int minor) 499struct usb_interface *usb_find_interface(struct usb_driver *drv, int minor)
475{ 500{
476 struct list_head *entry; 501 struct usb_interface *intf = (struct usb_interface *)(long)minor;
477 struct device *dev; 502 int ret;
478 struct usb_interface *intf;
479 503
480 list_for_each(entry, &drv->driver.devices) { 504 ret = driver_for_each_device(&drv->driver, NULL, &intf, __find_interface);
481 dev = container_of(entry, struct device, driver_list);
482
483 /* can't look at usb devices, only interfaces */
484 if (dev->driver == &usb_generic_driver)
485 continue;
486
487 intf = to_usb_interface(dev);
488 if (intf->minor == -1)
489 continue;
490 if (intf->minor == minor)
491 return intf;
492 }
493 505
494 /* no device found that matches */ 506 return ret ? intf : NULL;
495 return NULL;
496} 507}
497 508
498static int usb_device_match (struct device *dev, struct device_driver *drv) 509static int usb_device_match (struct device *dev, struct device_driver *drv)
diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c
index 8ef8a9cd9ac4..c039d2fbe7ab 100644
--- a/drivers/usb/gadget/dummy_hcd.c
+++ b/drivers/usb/gadget/dummy_hcd.c
@@ -633,7 +633,7 @@ static const struct usb_gadget_ops dummy_ops = {
633 633
634/* "function" sysfs attribute */ 634/* "function" sysfs attribute */
635static ssize_t 635static ssize_t
636show_function (struct device *dev, char *buf) 636show_function (struct device *dev, struct device_attribute *attr, char *buf)
637{ 637{
638 struct dummy *dum = gadget_dev_to_dummy (dev); 638 struct dummy *dum = gadget_dev_to_dummy (dev);
639 639
@@ -1600,7 +1600,7 @@ show_urb (char *buf, size_t size, struct urb *urb)
1600} 1600}
1601 1601
1602static ssize_t 1602static ssize_t
1603show_urbs (struct device *dev, char *buf) 1603show_urbs (struct device *dev, struct device_attribute *attr, char *buf)
1604{ 1604{
1605 struct usb_hcd *hcd = dev_get_drvdata (dev); 1605 struct usb_hcd *hcd = dev_get_drvdata (dev);
1606 struct dummy *dum = hcd_to_dummy (hcd); 1606 struct dummy *dum = hcd_to_dummy (hcd);
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c
index 4857f0e4ef44..037a7f163822 100644
--- a/drivers/usb/gadget/file_storage.c
+++ b/drivers/usb/gadget/file_storage.c
@@ -3554,14 +3554,14 @@ static void close_all_backing_files(struct fsg_dev *fsg)
3554} 3554}
3555 3555
3556 3556
3557static ssize_t show_ro(struct device *dev, char *buf) 3557static ssize_t show_ro(struct device *dev, struct device_attribute *attr, char *buf)
3558{ 3558{
3559 struct lun *curlun = dev_to_lun(dev); 3559 struct lun *curlun = dev_to_lun(dev);
3560 3560
3561 return sprintf(buf, "%d\n", curlun->ro); 3561 return sprintf(buf, "%d\n", curlun->ro);
3562} 3562}
3563 3563
3564static ssize_t show_file(struct device *dev, char *buf) 3564static ssize_t show_file(struct device *dev, struct device_attribute *attr, char *buf)
3565{ 3565{
3566 struct lun *curlun = dev_to_lun(dev); 3566 struct lun *curlun = dev_to_lun(dev);
3567 struct fsg_dev *fsg = (struct fsg_dev *) dev_get_drvdata(dev); 3567 struct fsg_dev *fsg = (struct fsg_dev *) dev_get_drvdata(dev);
@@ -3589,7 +3589,7 @@ static ssize_t show_file(struct device *dev, char *buf)
3589} 3589}
3590 3590
3591 3591
3592static ssize_t store_ro(struct device *dev, const char *buf, size_t count) 3592static ssize_t store_ro(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
3593{ 3593{
3594 ssize_t rc = count; 3594 ssize_t rc = count;
3595 struct lun *curlun = dev_to_lun(dev); 3595 struct lun *curlun = dev_to_lun(dev);
@@ -3613,7 +3613,7 @@ static ssize_t store_ro(struct device *dev, const char *buf, size_t count)
3613 return rc; 3613 return rc;
3614} 3614}
3615 3615
3616static ssize_t store_file(struct device *dev, const char *buf, size_t count) 3616static ssize_t store_file(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
3617{ 3617{
3618 struct lun *curlun = dev_to_lun(dev); 3618 struct lun *curlun = dev_to_lun(dev);
3619 struct fsg_dev *fsg = (struct fsg_dev *) dev_get_drvdata(dev); 3619 struct fsg_dev *fsg = (struct fsg_dev *) dev_get_drvdata(dev);
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index e5457f2026cc..e47e398daeb5 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -1469,7 +1469,7 @@ static const struct usb_gadget_ops net2280_ops = {
1469 1469
1470/* "function" sysfs attribute */ 1470/* "function" sysfs attribute */
1471static ssize_t 1471static ssize_t
1472show_function (struct device *_dev, char *buf) 1472show_function (struct device *_dev, struct device_attribute *attr, char *buf)
1473{ 1473{
1474 struct net2280 *dev = dev_get_drvdata (_dev); 1474 struct net2280 *dev = dev_get_drvdata (_dev);
1475 1475
@@ -1482,7 +1482,7 @@ show_function (struct device *_dev, char *buf)
1482static DEVICE_ATTR (function, S_IRUGO, show_function, NULL); 1482static DEVICE_ATTR (function, S_IRUGO, show_function, NULL);
1483 1483
1484static ssize_t 1484static ssize_t
1485show_registers (struct device *_dev, char *buf) 1485show_registers (struct device *_dev, struct device_attribute *attr, char *buf)
1486{ 1486{
1487 struct net2280 *dev; 1487 struct net2280 *dev;
1488 char *next; 1488 char *next;
@@ -1637,7 +1637,7 @@ show_registers (struct device *_dev, char *buf)
1637static DEVICE_ATTR (registers, S_IRUGO, show_registers, NULL); 1637static DEVICE_ATTR (registers, S_IRUGO, show_registers, NULL);
1638 1638
1639static ssize_t 1639static ssize_t
1640show_queues (struct device *_dev, char *buf) 1640show_queues (struct device *_dev, struct device_attribute *attr, char *buf)
1641{ 1641{
1642 struct net2280 *dev; 1642 struct net2280 *dev;
1643 char *next; 1643 char *next;
diff --git a/drivers/usb/gadget/pxa2xx_udc.c b/drivers/usb/gadget/pxa2xx_udc.c
index 6390c5726d81..b8b4524ed746 100644
--- a/drivers/usb/gadget/pxa2xx_udc.c
+++ b/drivers/usb/gadget/pxa2xx_udc.c
@@ -1429,7 +1429,7 @@ done:
1429 1429
1430/* "function" sysfs attribute */ 1430/* "function" sysfs attribute */
1431static ssize_t 1431static ssize_t
1432show_function (struct device *_dev, char *buf) 1432show_function (struct device *_dev, struct device_attribute *attr, char *buf)
1433{ 1433{
1434 struct pxa2xx_udc *dev = dev_get_drvdata (_dev); 1434 struct pxa2xx_udc *dev = dev_get_drvdata (_dev);
1435 1435
diff --git a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c
index 9b347d765383..2ff11d53567b 100644
--- a/drivers/usb/host/ehci-dbg.c
+++ b/drivers/usb/host/ehci-dbg.c
@@ -450,7 +450,7 @@ show_async (struct class_device *class_dev, char *buf)
450 450
451 *buf = 0; 451 *buf = 0;
452 452
453 bus = to_usb_bus(class_dev); 453 bus = class_get_devdata(class_dev);
454 hcd = bus->hcpriv; 454 hcd = bus->hcpriv;
455 ehci = hcd_to_ehci (hcd); 455 ehci = hcd_to_ehci (hcd);
456 next = buf; 456 next = buf;
@@ -496,7 +496,7 @@ show_periodic (struct class_device *class_dev, char *buf)
496 return 0; 496 return 0;
497 seen_count = 0; 497 seen_count = 0;
498 498
499 bus = to_usb_bus(class_dev); 499 bus = class_get_devdata(class_dev);
500 hcd = bus->hcpriv; 500 hcd = bus->hcpriv;
501 ehci = hcd_to_ehci (hcd); 501 ehci = hcd_to_ehci (hcd);
502 next = buf; 502 next = buf;
@@ -633,7 +633,7 @@ show_registers (struct class_device *class_dev, char *buf)
633 static char fmt [] = "%*s\n"; 633 static char fmt [] = "%*s\n";
634 static char label [] = ""; 634 static char label [] = "";
635 635
636 bus = to_usb_bus(class_dev); 636 bus = class_get_devdata(class_dev);
637 hcd = bus->hcpriv; 637 hcd = bus->hcpriv;
638 ehci = hcd_to_ehci (hcd); 638 ehci = hcd_to_ehci (hcd);
639 next = buf; 639 next = buf;
@@ -735,7 +735,7 @@ static CLASS_DEVICE_ATTR (registers, S_IRUGO, show_registers, NULL);
735 735
736static inline void create_debug_files (struct ehci_hcd *ehci) 736static inline void create_debug_files (struct ehci_hcd *ehci)
737{ 737{
738 struct class_device *cldev = &ehci_to_hcd(ehci)->self.class_dev; 738 struct class_device *cldev = ehci_to_hcd(ehci)->self.class_dev;
739 739
740 class_device_create_file(cldev, &class_device_attr_async); 740 class_device_create_file(cldev, &class_device_attr_async);
741 class_device_create_file(cldev, &class_device_attr_periodic); 741 class_device_create_file(cldev, &class_device_attr_periodic);
@@ -744,7 +744,7 @@ static inline void create_debug_files (struct ehci_hcd *ehci)
744 744
745static inline void remove_debug_files (struct ehci_hcd *ehci) 745static inline void remove_debug_files (struct ehci_hcd *ehci)
746{ 746{
747 struct class_device *cldev = &ehci_to_hcd(ehci)->self.class_dev; 747 struct class_device *cldev = ehci_to_hcd(ehci)->self.class_dev;
748 748
749 class_device_remove_file(cldev, &class_device_attr_async); 749 class_device_remove_file(cldev, &class_device_attr_async);
750 class_device_remove_file(cldev, &class_device_attr_periodic); 750 class_device_remove_file(cldev, &class_device_attr_periodic);
diff --git a/drivers/usb/host/ohci-dbg.c b/drivers/usb/host/ohci-dbg.c
index 62f53a213808..c58408c95c3d 100644
--- a/drivers/usb/host/ohci-dbg.c
+++ b/drivers/usb/host/ohci-dbg.c
@@ -481,7 +481,7 @@ show_async (struct class_device *class_dev, char *buf)
481 size_t temp; 481 size_t temp;
482 unsigned long flags; 482 unsigned long flags;
483 483
484 bus = to_usb_bus(class_dev); 484 bus = class_get_devdata(class_dev);
485 hcd = bus->hcpriv; 485 hcd = bus->hcpriv;
486 ohci = hcd_to_ohci(hcd); 486 ohci = hcd_to_ohci(hcd);
487 487
@@ -514,7 +514,7 @@ show_periodic (struct class_device *class_dev, char *buf)
514 return 0; 514 return 0;
515 seen_count = 0; 515 seen_count = 0;
516 516
517 bus = to_usb_bus(class_dev); 517 bus = class_get_devdata(class_dev);
518 hcd = bus->hcpriv; 518 hcd = bus->hcpriv;
519 ohci = hcd_to_ohci(hcd); 519 ohci = hcd_to_ohci(hcd);
520 next = buf; 520 next = buf;
@@ -611,7 +611,7 @@ show_registers (struct class_device *class_dev, char *buf)
611 char *next; 611 char *next;
612 u32 rdata; 612 u32 rdata;
613 613
614 bus = to_usb_bus(class_dev); 614 bus = class_get_devdata(class_dev);
615 hcd = bus->hcpriv; 615 hcd = bus->hcpriv;
616 ohci = hcd_to_ohci(hcd); 616 ohci = hcd_to_ohci(hcd);
617 regs = ohci->regs; 617 regs = ohci->regs;
@@ -684,7 +684,7 @@ static CLASS_DEVICE_ATTR (registers, S_IRUGO, show_registers, NULL);
684 684
685static inline void create_debug_files (struct ohci_hcd *ohci) 685static inline void create_debug_files (struct ohci_hcd *ohci)
686{ 686{
687 struct class_device *cldev = &ohci_to_hcd(ohci)->self.class_dev; 687 struct class_device *cldev = ohci_to_hcd(ohci)->self.class_dev;
688 688
689 class_device_create_file(cldev, &class_device_attr_async); 689 class_device_create_file(cldev, &class_device_attr_async);
690 class_device_create_file(cldev, &class_device_attr_periodic); 690 class_device_create_file(cldev, &class_device_attr_periodic);
@@ -694,7 +694,7 @@ static inline void create_debug_files (struct ohci_hcd *ohci)
694 694
695static inline void remove_debug_files (struct ohci_hcd *ohci) 695static inline void remove_debug_files (struct ohci_hcd *ohci)
696{ 696{
697 struct class_device *cldev = &ohci_to_hcd(ohci)->self.class_dev; 697 struct class_device *cldev = ohci_to_hcd(ohci)->self.class_dev;
698 698
699 class_device_remove_file(cldev, &class_device_attr_async); 699 class_device_remove_file(cldev, &class_device_attr_async);
700 class_device_remove_file(cldev, &class_device_attr_periodic); 700 class_device_remove_file(cldev, &class_device_attr_periodic);
diff --git a/drivers/usb/input/aiptek.c b/drivers/usb/input/aiptek.c
index 94ce2a9ad50f..e991f7ed7330 100644
--- a/drivers/usb/input/aiptek.c
+++ b/drivers/usb/input/aiptek.c
@@ -1025,7 +1025,7 @@ static int aiptek_program_tablet(struct aiptek *aiptek)
1025/*********************************************************************** 1025/***********************************************************************
1026 * support the 'size' file -- display support 1026 * support the 'size' file -- display support
1027 */ 1027 */
1028static ssize_t show_tabletSize(struct device *dev, char *buf) 1028static ssize_t show_tabletSize(struct device *dev, struct device_attribute *attr, char *buf)
1029{ 1029{
1030 struct aiptek *aiptek = dev_get_drvdata(dev); 1030 struct aiptek *aiptek = dev_get_drvdata(dev);
1031 1031
@@ -1048,7 +1048,7 @@ static DEVICE_ATTR(size, S_IRUGO, show_tabletSize, NULL);
1048/*********************************************************************** 1048/***********************************************************************
1049 * support routines for the 'product_id' file 1049 * support routines for the 'product_id' file
1050 */ 1050 */
1051static ssize_t show_tabletProductId(struct device *dev, char *buf) 1051static ssize_t show_tabletProductId(struct device *dev, struct device_attribute *attr, char *buf)
1052{ 1052{
1053 struct aiptek *aiptek = dev_get_drvdata(dev); 1053 struct aiptek *aiptek = dev_get_drvdata(dev);
1054 1054
@@ -1064,7 +1064,7 @@ static DEVICE_ATTR(product_id, S_IRUGO, show_tabletProductId, NULL);
1064/*********************************************************************** 1064/***********************************************************************
1065 * support routines for the 'vendor_id' file 1065 * support routines for the 'vendor_id' file
1066 */ 1066 */
1067static ssize_t show_tabletVendorId(struct device *dev, char *buf) 1067static ssize_t show_tabletVendorId(struct device *dev, struct device_attribute *attr, char *buf)
1068{ 1068{
1069 struct aiptek *aiptek = dev_get_drvdata(dev); 1069 struct aiptek *aiptek = dev_get_drvdata(dev);
1070 1070
@@ -1079,7 +1079,7 @@ static DEVICE_ATTR(vendor_id, S_IRUGO, show_tabletVendorId, NULL);
1079/*********************************************************************** 1079/***********************************************************************
1080 * support routines for the 'vendor' file 1080 * support routines for the 'vendor' file
1081 */ 1081 */
1082static ssize_t show_tabletManufacturer(struct device *dev, char *buf) 1082static ssize_t show_tabletManufacturer(struct device *dev, struct device_attribute *attr, char *buf)
1083{ 1083{
1084 struct aiptek *aiptek = dev_get_drvdata(dev); 1084 struct aiptek *aiptek = dev_get_drvdata(dev);
1085 int retval; 1085 int retval;
@@ -1096,7 +1096,7 @@ static DEVICE_ATTR(vendor, S_IRUGO, show_tabletManufacturer, NULL);
1096/*********************************************************************** 1096/***********************************************************************
1097 * support routines for the 'product' file 1097 * support routines for the 'product' file
1098 */ 1098 */
1099static ssize_t show_tabletProduct(struct device *dev, char *buf) 1099static ssize_t show_tabletProduct(struct device *dev, struct device_attribute *attr, char *buf)
1100{ 1100{
1101 struct aiptek *aiptek = dev_get_drvdata(dev); 1101 struct aiptek *aiptek = dev_get_drvdata(dev);
1102 int retval; 1102 int retval;
@@ -1114,7 +1114,7 @@ static DEVICE_ATTR(product, S_IRUGO, show_tabletProduct, NULL);
1114 * support routines for the 'pointer_mode' file. Note that this file 1114 * support routines for the 'pointer_mode' file. Note that this file
1115 * both displays current setting and allows reprogramming. 1115 * both displays current setting and allows reprogramming.
1116 */ 1116 */
1117static ssize_t show_tabletPointerMode(struct device *dev, char *buf) 1117static ssize_t show_tabletPointerMode(struct device *dev, struct device_attribute *attr, char *buf)
1118{ 1118{
1119 struct aiptek *aiptek = dev_get_drvdata(dev); 1119 struct aiptek *aiptek = dev_get_drvdata(dev);
1120 char *s; 1120 char *s;
@@ -1143,7 +1143,7 @@ static ssize_t show_tabletPointerMode(struct device *dev, char *buf)
1143} 1143}
1144 1144
1145static ssize_t 1145static ssize_t
1146store_tabletPointerMode(struct device *dev, const char *buf, size_t count) 1146store_tabletPointerMode(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1147{ 1147{
1148 struct aiptek *aiptek = dev_get_drvdata(dev); 1148 struct aiptek *aiptek = dev_get_drvdata(dev);
1149 if (aiptek == NULL) 1149 if (aiptek == NULL)
@@ -1168,7 +1168,7 @@ static DEVICE_ATTR(pointer_mode,
1168 * support routines for the 'coordinate_mode' file. Note that this file 1168 * support routines for the 'coordinate_mode' file. Note that this file
1169 * both displays current setting and allows reprogramming. 1169 * both displays current setting and allows reprogramming.
1170 */ 1170 */
1171static ssize_t show_tabletCoordinateMode(struct device *dev, char *buf) 1171static ssize_t show_tabletCoordinateMode(struct device *dev, struct device_attribute *attr, char *buf)
1172{ 1172{
1173 struct aiptek *aiptek = dev_get_drvdata(dev); 1173 struct aiptek *aiptek = dev_get_drvdata(dev);
1174 char *s; 1174 char *s;
@@ -1193,7 +1193,7 @@ static ssize_t show_tabletCoordinateMode(struct device *dev, char *buf)
1193} 1193}
1194 1194
1195static ssize_t 1195static ssize_t
1196store_tabletCoordinateMode(struct device *dev, const char *buf, size_t count) 1196store_tabletCoordinateMode(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1197{ 1197{
1198 struct aiptek *aiptek = dev_get_drvdata(dev); 1198 struct aiptek *aiptek = dev_get_drvdata(dev);
1199 if (aiptek == NULL) 1199 if (aiptek == NULL)
@@ -1217,7 +1217,7 @@ static DEVICE_ATTR(coordinate_mode,
1217 * support routines for the 'tool_mode' file. Note that this file 1217 * support routines for the 'tool_mode' file. Note that this file
1218 * both displays current setting and allows reprogramming. 1218 * both displays current setting and allows reprogramming.
1219 */ 1219 */
1220static ssize_t show_tabletToolMode(struct device *dev, char *buf) 1220static ssize_t show_tabletToolMode(struct device *dev, struct device_attribute *attr, char *buf)
1221{ 1221{
1222 struct aiptek *aiptek = dev_get_drvdata(dev); 1222 struct aiptek *aiptek = dev_get_drvdata(dev);
1223 char *s; 1223 char *s;
@@ -1262,7 +1262,7 @@ static ssize_t show_tabletToolMode(struct device *dev, char *buf)
1262} 1262}
1263 1263
1264static ssize_t 1264static ssize_t
1265store_tabletToolMode(struct device *dev, const char *buf, size_t count) 1265store_tabletToolMode(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1266{ 1266{
1267 struct aiptek *aiptek = dev_get_drvdata(dev); 1267 struct aiptek *aiptek = dev_get_drvdata(dev);
1268 if (aiptek == NULL) 1268 if (aiptek == NULL)
@@ -1295,7 +1295,7 @@ static DEVICE_ATTR(tool_mode,
1295 * support routines for the 'xtilt' file. Note that this file 1295 * support routines for the 'xtilt' file. Note that this file
1296 * both displays current setting and allows reprogramming. 1296 * both displays current setting and allows reprogramming.
1297 */ 1297 */
1298static ssize_t show_tabletXtilt(struct device *dev, char *buf) 1298static ssize_t show_tabletXtilt(struct device *dev, struct device_attribute *attr, char *buf)
1299{ 1299{
1300 struct aiptek *aiptek = dev_get_drvdata(dev); 1300 struct aiptek *aiptek = dev_get_drvdata(dev);
1301 1301
@@ -1311,7 +1311,7 @@ static ssize_t show_tabletXtilt(struct device *dev, char *buf)
1311} 1311}
1312 1312
1313static ssize_t 1313static ssize_t
1314store_tabletXtilt(struct device *dev, const char *buf, size_t count) 1314store_tabletXtilt(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1315{ 1315{
1316 struct aiptek *aiptek = dev_get_drvdata(dev); 1316 struct aiptek *aiptek = dev_get_drvdata(dev);
1317 int x; 1317 int x;
@@ -1337,7 +1337,7 @@ static DEVICE_ATTR(xtilt,
1337 * support routines for the 'ytilt' file. Note that this file 1337 * support routines for the 'ytilt' file. Note that this file
1338 * both displays current setting and allows reprogramming. 1338 * both displays current setting and allows reprogramming.
1339 */ 1339 */
1340static ssize_t show_tabletYtilt(struct device *dev, char *buf) 1340static ssize_t show_tabletYtilt(struct device *dev, struct device_attribute *attr, char *buf)
1341{ 1341{
1342 struct aiptek *aiptek = dev_get_drvdata(dev); 1342 struct aiptek *aiptek = dev_get_drvdata(dev);
1343 1343
@@ -1353,7 +1353,7 @@ static ssize_t show_tabletYtilt(struct device *dev, char *buf)
1353} 1353}
1354 1354
1355static ssize_t 1355static ssize_t
1356store_tabletYtilt(struct device *dev, const char *buf, size_t count) 1356store_tabletYtilt(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1357{ 1357{
1358 struct aiptek *aiptek = dev_get_drvdata(dev); 1358 struct aiptek *aiptek = dev_get_drvdata(dev);
1359 int y; 1359 int y;
@@ -1379,7 +1379,7 @@ static DEVICE_ATTR(ytilt,
1379 * support routines for the 'jitter' file. Note that this file 1379 * support routines for the 'jitter' file. Note that this file
1380 * both displays current setting and allows reprogramming. 1380 * both displays current setting and allows reprogramming.
1381 */ 1381 */
1382static ssize_t show_tabletJitterDelay(struct device *dev, char *buf) 1382static ssize_t show_tabletJitterDelay(struct device *dev, struct device_attribute *attr, char *buf)
1383{ 1383{
1384 struct aiptek *aiptek = dev_get_drvdata(dev); 1384 struct aiptek *aiptek = dev_get_drvdata(dev);
1385 1385
@@ -1390,7 +1390,7 @@ static ssize_t show_tabletJitterDelay(struct device *dev, char *buf)
1390} 1390}
1391 1391
1392static ssize_t 1392static ssize_t
1393store_tabletJitterDelay(struct device *dev, const char *buf, size_t count) 1393store_tabletJitterDelay(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1394{ 1394{
1395 struct aiptek *aiptek = dev_get_drvdata(dev); 1395 struct aiptek *aiptek = dev_get_drvdata(dev);
1396 1396
@@ -1409,7 +1409,7 @@ static DEVICE_ATTR(jitter,
1409 * support routines for the 'delay' file. Note that this file 1409 * support routines for the 'delay' file. Note that this file
1410 * both displays current setting and allows reprogramming. 1410 * both displays current setting and allows reprogramming.
1411 */ 1411 */
1412static ssize_t show_tabletProgrammableDelay(struct device *dev, char *buf) 1412static ssize_t show_tabletProgrammableDelay(struct device *dev, struct device_attribute *attr, char *buf)
1413{ 1413{
1414 struct aiptek *aiptek = dev_get_drvdata(dev); 1414 struct aiptek *aiptek = dev_get_drvdata(dev);
1415 1415
@@ -1421,7 +1421,7 @@ static ssize_t show_tabletProgrammableDelay(struct device *dev, char *buf)
1421} 1421}
1422 1422
1423static ssize_t 1423static ssize_t
1424store_tabletProgrammableDelay(struct device *dev, const char *buf, size_t count) 1424store_tabletProgrammableDelay(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1425{ 1425{
1426 struct aiptek *aiptek = dev_get_drvdata(dev); 1426 struct aiptek *aiptek = dev_get_drvdata(dev);
1427 1427
@@ -1440,7 +1440,7 @@ static DEVICE_ATTR(delay,
1440 * support routines for the 'input_path' file. Note that this file 1440 * support routines for the 'input_path' file. Note that this file
1441 * only displays current setting. 1441 * only displays current setting.
1442 */ 1442 */
1443static ssize_t show_tabletInputDevice(struct device *dev, char *buf) 1443static ssize_t show_tabletInputDevice(struct device *dev, struct device_attribute *attr, char *buf)
1444{ 1444{
1445 struct aiptek *aiptek = dev_get_drvdata(dev); 1445 struct aiptek *aiptek = dev_get_drvdata(dev);
1446 1446
@@ -1457,7 +1457,7 @@ static DEVICE_ATTR(input_path, S_IRUGO, show_tabletInputDevice, NULL);
1457 * support routines for the 'event_count' file. Note that this file 1457 * support routines for the 'event_count' file. Note that this file
1458 * only displays current setting. 1458 * only displays current setting.
1459 */ 1459 */
1460static ssize_t show_tabletEventsReceived(struct device *dev, char *buf) 1460static ssize_t show_tabletEventsReceived(struct device *dev, struct device_attribute *attr, char *buf)
1461{ 1461{
1462 struct aiptek *aiptek = dev_get_drvdata(dev); 1462 struct aiptek *aiptek = dev_get_drvdata(dev);
1463 1463
@@ -1473,7 +1473,7 @@ static DEVICE_ATTR(event_count, S_IRUGO, show_tabletEventsReceived, NULL);
1473 * support routines for the 'diagnostic' file. Note that this file 1473 * support routines for the 'diagnostic' file. Note that this file
1474 * only displays current setting. 1474 * only displays current setting.
1475 */ 1475 */
1476static ssize_t show_tabletDiagnosticMessage(struct device *dev, char *buf) 1476static ssize_t show_tabletDiagnosticMessage(struct device *dev, struct device_attribute *attr, char *buf)
1477{ 1477{
1478 struct aiptek *aiptek = dev_get_drvdata(dev); 1478 struct aiptek *aiptek = dev_get_drvdata(dev);
1479 char *retMsg; 1479 char *retMsg;
@@ -1515,7 +1515,7 @@ static DEVICE_ATTR(diagnostic, S_IRUGO, show_tabletDiagnosticMessage, NULL);
1515 * support routines for the 'stylus_upper' file. Note that this file 1515 * support routines for the 'stylus_upper' file. Note that this file
1516 * both displays current setting and allows for setting changing. 1516 * both displays current setting and allows for setting changing.
1517 */ 1517 */
1518static ssize_t show_tabletStylusUpper(struct device *dev, char *buf) 1518static ssize_t show_tabletStylusUpper(struct device *dev, struct device_attribute *attr, char *buf)
1519{ 1519{
1520 struct aiptek *aiptek = dev_get_drvdata(dev); 1520 struct aiptek *aiptek = dev_get_drvdata(dev);
1521 char *s; 1521 char *s;
@@ -1540,7 +1540,7 @@ static ssize_t show_tabletStylusUpper(struct device *dev, char *buf)
1540} 1540}
1541 1541
1542static ssize_t 1542static ssize_t
1543store_tabletStylusUpper(struct device *dev, const char *buf, size_t count) 1543store_tabletStylusUpper(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1544{ 1544{
1545 struct aiptek *aiptek = dev_get_drvdata(dev); 1545 struct aiptek *aiptek = dev_get_drvdata(dev);
1546 1546
@@ -1565,7 +1565,7 @@ static DEVICE_ATTR(stylus_upper,
1565 * support routines for the 'stylus_lower' file. Note that this file 1565 * support routines for the 'stylus_lower' file. Note that this file
1566 * both displays current setting and allows for setting changing. 1566 * both displays current setting and allows for setting changing.
1567 */ 1567 */
1568static ssize_t show_tabletStylusLower(struct device *dev, char *buf) 1568static ssize_t show_tabletStylusLower(struct device *dev, struct device_attribute *attr, char *buf)
1569{ 1569{
1570 struct aiptek *aiptek = dev_get_drvdata(dev); 1570 struct aiptek *aiptek = dev_get_drvdata(dev);
1571 char *s; 1571 char *s;
@@ -1590,7 +1590,7 @@ static ssize_t show_tabletStylusLower(struct device *dev, char *buf)
1590} 1590}
1591 1591
1592static ssize_t 1592static ssize_t
1593store_tabletStylusLower(struct device *dev, const char *buf, size_t count) 1593store_tabletStylusLower(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1594{ 1594{
1595 struct aiptek *aiptek = dev_get_drvdata(dev); 1595 struct aiptek *aiptek = dev_get_drvdata(dev);
1596 1596
@@ -1615,7 +1615,7 @@ static DEVICE_ATTR(stylus_lower,
1615 * support routines for the 'mouse_left' file. Note that this file 1615 * support routines for the 'mouse_left' file. Note that this file
1616 * both displays current setting and allows for setting changing. 1616 * both displays current setting and allows for setting changing.
1617 */ 1617 */
1618static ssize_t show_tabletMouseLeft(struct device *dev, char *buf) 1618static ssize_t show_tabletMouseLeft(struct device *dev, struct device_attribute *attr, char *buf)
1619{ 1619{
1620 struct aiptek *aiptek = dev_get_drvdata(dev); 1620 struct aiptek *aiptek = dev_get_drvdata(dev);
1621 char *s; 1621 char *s;
@@ -1644,7 +1644,7 @@ static ssize_t show_tabletMouseLeft(struct device *dev, char *buf)
1644} 1644}
1645 1645
1646static ssize_t 1646static ssize_t
1647store_tabletMouseLeft(struct device *dev, const char *buf, size_t count) 1647store_tabletMouseLeft(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1648{ 1648{
1649 struct aiptek *aiptek = dev_get_drvdata(dev); 1649 struct aiptek *aiptek = dev_get_drvdata(dev);
1650 1650
@@ -1669,7 +1669,7 @@ static DEVICE_ATTR(mouse_left,
1669 * support routines for the 'mouse_middle' file. Note that this file 1669 * support routines for the 'mouse_middle' file. Note that this file
1670 * both displays current setting and allows for setting changing. 1670 * both displays current setting and allows for setting changing.
1671 */ 1671 */
1672static ssize_t show_tabletMouseMiddle(struct device *dev, char *buf) 1672static ssize_t show_tabletMouseMiddle(struct device *dev, struct device_attribute *attr, char *buf)
1673{ 1673{
1674 struct aiptek *aiptek = dev_get_drvdata(dev); 1674 struct aiptek *aiptek = dev_get_drvdata(dev);
1675 char *s; 1675 char *s;
@@ -1698,7 +1698,7 @@ static ssize_t show_tabletMouseMiddle(struct device *dev, char *buf)
1698} 1698}
1699 1699
1700static ssize_t 1700static ssize_t
1701store_tabletMouseMiddle(struct device *dev, const char *buf, size_t count) 1701store_tabletMouseMiddle(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1702{ 1702{
1703 struct aiptek *aiptek = dev_get_drvdata(dev); 1703 struct aiptek *aiptek = dev_get_drvdata(dev);
1704 1704
@@ -1725,7 +1725,7 @@ static DEVICE_ATTR(mouse_middle,
1725 * support routines for the 'mouse_right' file. Note that this file 1725 * support routines for the 'mouse_right' file. Note that this file
1726 * both displays current setting and allows for setting changing. 1726 * both displays current setting and allows for setting changing.
1727 */ 1727 */
1728static ssize_t show_tabletMouseRight(struct device *dev, char *buf) 1728static ssize_t show_tabletMouseRight(struct device *dev, struct device_attribute *attr, char *buf)
1729{ 1729{
1730 struct aiptek *aiptek = dev_get_drvdata(dev); 1730 struct aiptek *aiptek = dev_get_drvdata(dev);
1731 char *s; 1731 char *s;
@@ -1754,7 +1754,7 @@ static ssize_t show_tabletMouseRight(struct device *dev, char *buf)
1754} 1754}
1755 1755
1756static ssize_t 1756static ssize_t
1757store_tabletMouseRight(struct device *dev, const char *buf, size_t count) 1757store_tabletMouseRight(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1758{ 1758{
1759 struct aiptek *aiptek = dev_get_drvdata(dev); 1759 struct aiptek *aiptek = dev_get_drvdata(dev);
1760 1760
@@ -1780,7 +1780,7 @@ static DEVICE_ATTR(mouse_right,
1780 * support routines for the 'wheel' file. Note that this file 1780 * support routines for the 'wheel' file. Note that this file
1781 * both displays current setting and allows for setting changing. 1781 * both displays current setting and allows for setting changing.
1782 */ 1782 */
1783static ssize_t show_tabletWheel(struct device *dev, char *buf) 1783static ssize_t show_tabletWheel(struct device *dev, struct device_attribute *attr, char *buf)
1784{ 1784{
1785 struct aiptek *aiptek = dev_get_drvdata(dev); 1785 struct aiptek *aiptek = dev_get_drvdata(dev);
1786 1786
@@ -1796,7 +1796,7 @@ static ssize_t show_tabletWheel(struct device *dev, char *buf)
1796} 1796}
1797 1797
1798static ssize_t 1798static ssize_t
1799store_tabletWheel(struct device *dev, const char *buf, size_t count) 1799store_tabletWheel(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1800{ 1800{
1801 struct aiptek *aiptek = dev_get_drvdata(dev); 1801 struct aiptek *aiptek = dev_get_drvdata(dev);
1802 1802
@@ -1814,7 +1814,7 @@ static DEVICE_ATTR(wheel,
1814 * support routines for the 'execute' file. Note that this file 1814 * support routines for the 'execute' file. Note that this file
1815 * both displays current setting and allows for setting changing. 1815 * both displays current setting and allows for setting changing.
1816 */ 1816 */
1817static ssize_t show_tabletExecute(struct device *dev, char *buf) 1817static ssize_t show_tabletExecute(struct device *dev, struct device_attribute *attr, char *buf)
1818{ 1818{
1819 struct aiptek *aiptek = dev_get_drvdata(dev); 1819 struct aiptek *aiptek = dev_get_drvdata(dev);
1820 1820
@@ -1829,7 +1829,7 @@ static ssize_t show_tabletExecute(struct device *dev, char *buf)
1829} 1829}
1830 1830
1831static ssize_t 1831static ssize_t
1832store_tabletExecute(struct device *dev, const char *buf, size_t count) 1832store_tabletExecute(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
1833{ 1833{
1834 struct aiptek *aiptek = dev_get_drvdata(dev); 1834 struct aiptek *aiptek = dev_get_drvdata(dev);
1835 1835
@@ -1855,7 +1855,7 @@ static DEVICE_ATTR(execute,
1855 * support routines for the 'odm_code' file. Note that this file 1855 * support routines for the 'odm_code' file. Note that this file
1856 * only displays current setting. 1856 * only displays current setting.
1857 */ 1857 */
1858static ssize_t show_tabletODMCode(struct device *dev, char *buf) 1858static ssize_t show_tabletODMCode(struct device *dev, struct device_attribute *attr, char *buf)
1859{ 1859{
1860 struct aiptek *aiptek = dev_get_drvdata(dev); 1860 struct aiptek *aiptek = dev_get_drvdata(dev);
1861 1861
@@ -1871,7 +1871,7 @@ static DEVICE_ATTR(odm_code, S_IRUGO, show_tabletODMCode, NULL);
1871 * support routines for the 'model_code' file. Note that this file 1871 * support routines for the 'model_code' file. Note that this file
1872 * only displays current setting. 1872 * only displays current setting.
1873 */ 1873 */
1874static ssize_t show_tabletModelCode(struct device *dev, char *buf) 1874static ssize_t show_tabletModelCode(struct device *dev, struct device_attribute *attr, char *buf)
1875{ 1875{
1876 struct aiptek *aiptek = dev_get_drvdata(dev); 1876 struct aiptek *aiptek = dev_get_drvdata(dev);
1877 1877
@@ -1887,7 +1887,7 @@ static DEVICE_ATTR(model_code, S_IRUGO, show_tabletModelCode, NULL);
1887 * support routines for the 'firmware_code' file. Note that this file 1887 * support routines for the 'firmware_code' file. Note that this file
1888 * only displays current setting. 1888 * only displays current setting.
1889 */ 1889 */
1890static ssize_t show_firmwareCode(struct device *dev, char *buf) 1890static ssize_t show_firmwareCode(struct device *dev, struct device_attribute *attr, char *buf)
1891{ 1891{
1892 struct aiptek *aiptek = dev_get_drvdata(dev); 1892 struct aiptek *aiptek = dev_get_drvdata(dev);
1893 1893
diff --git a/drivers/usb/misc/cytherm.c b/drivers/usb/misc/cytherm.c
index 626e2b05f719..b33044d56a1e 100644
--- a/drivers/usb/misc/cytherm.c
+++ b/drivers/usb/misc/cytherm.c
@@ -85,7 +85,7 @@ static int vendor_command(struct usb_device *dev, unsigned char request,
85#define BRIGHTNESS 0x2c /* RAM location for brightness value */ 85#define BRIGHTNESS 0x2c /* RAM location for brightness value */
86#define BRIGHTNESS_SEM 0x2b /* RAM location for brightness semaphore */ 86#define BRIGHTNESS_SEM 0x2b /* RAM location for brightness semaphore */
87 87
88static ssize_t show_brightness(struct device *dev, char *buf) 88static ssize_t show_brightness(struct device *dev, struct device_attribute *attr, char *buf)
89{ 89{
90 struct usb_interface *intf = to_usb_interface(dev); 90 struct usb_interface *intf = to_usb_interface(dev);
91 struct usb_cytherm *cytherm = usb_get_intfdata(intf); 91 struct usb_cytherm *cytherm = usb_get_intfdata(intf);
@@ -93,7 +93,7 @@ static ssize_t show_brightness(struct device *dev, char *buf)
93 return sprintf(buf, "%i", cytherm->brightness); 93 return sprintf(buf, "%i", cytherm->brightness);
94} 94}
95 95
96static ssize_t set_brightness(struct device *dev, const char *buf, 96static ssize_t set_brightness(struct device *dev, struct device_attribute *attr, const char *buf,
97 size_t count) 97 size_t count)
98{ 98{
99 struct usb_interface *intf = to_usb_interface(dev); 99 struct usb_interface *intf = to_usb_interface(dev);
@@ -138,7 +138,7 @@ static DEVICE_ATTR(brightness, S_IRUGO | S_IWUSR | S_IWGRP,
138#define TEMP 0x33 /* RAM location for temperature */ 138#define TEMP 0x33 /* RAM location for temperature */
139#define SIGN 0x34 /* RAM location for temperature sign */ 139#define SIGN 0x34 /* RAM location for temperature sign */
140 140
141static ssize_t show_temp(struct device *dev, char *buf) 141static ssize_t show_temp(struct device *dev, struct device_attribute *attr, char *buf)
142{ 142{
143 143
144 struct usb_interface *intf = to_usb_interface(dev); 144 struct usb_interface *intf = to_usb_interface(dev);
@@ -174,7 +174,7 @@ static ssize_t show_temp(struct device *dev, char *buf)
174} 174}
175 175
176 176
177static ssize_t set_temp(struct device *dev, const char *buf, size_t count) 177static ssize_t set_temp(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
178{ 178{
179 return count; 179 return count;
180} 180}
@@ -184,7 +184,7 @@ static DEVICE_ATTR(temp, S_IRUGO, show_temp, set_temp);
184 184
185#define BUTTON 0x7a 185#define BUTTON 0x7a
186 186
187static ssize_t show_button(struct device *dev, char *buf) 187static ssize_t show_button(struct device *dev, struct device_attribute *attr, char *buf)
188{ 188{
189 189
190 struct usb_interface *intf = to_usb_interface(dev); 190 struct usb_interface *intf = to_usb_interface(dev);
@@ -215,7 +215,7 @@ static ssize_t show_button(struct device *dev, char *buf)
215} 215}
216 216
217 217
218static ssize_t set_button(struct device *dev, const char *buf, size_t count) 218static ssize_t set_button(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
219{ 219{
220 return count; 220 return count;
221} 221}
@@ -223,7 +223,7 @@ static ssize_t set_button(struct device *dev, const char *buf, size_t count)
223static DEVICE_ATTR(button, S_IRUGO, show_button, set_button); 223static DEVICE_ATTR(button, S_IRUGO, show_button, set_button);
224 224
225 225
226static ssize_t show_port0(struct device *dev, char *buf) 226static ssize_t show_port0(struct device *dev, struct device_attribute *attr, char *buf)
227{ 227{
228 struct usb_interface *intf = to_usb_interface(dev); 228 struct usb_interface *intf = to_usb_interface(dev);
229 struct usb_cytherm *cytherm = usb_get_intfdata(intf); 229 struct usb_cytherm *cytherm = usb_get_intfdata(intf);
@@ -249,7 +249,7 @@ static ssize_t show_port0(struct device *dev, char *buf)
249} 249}
250 250
251 251
252static ssize_t set_port0(struct device *dev, const char *buf, size_t count) 252static ssize_t set_port0(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
253{ 253{
254 struct usb_interface *intf = to_usb_interface(dev); 254 struct usb_interface *intf = to_usb_interface(dev);
255 struct usb_cytherm *cytherm = usb_get_intfdata(intf); 255 struct usb_cytherm *cytherm = usb_get_intfdata(intf);
@@ -283,7 +283,7 @@ static ssize_t set_port0(struct device *dev, const char *buf, size_t count)
283 283
284static DEVICE_ATTR(port0, S_IRUGO | S_IWUSR | S_IWGRP, show_port0, set_port0); 284static DEVICE_ATTR(port0, S_IRUGO | S_IWUSR | S_IWGRP, show_port0, set_port0);
285 285
286static ssize_t show_port1(struct device *dev, char *buf) 286static ssize_t show_port1(struct device *dev, struct device_attribute *attr, char *buf)
287{ 287{
288 struct usb_interface *intf = to_usb_interface(dev); 288 struct usb_interface *intf = to_usb_interface(dev);
289 struct usb_cytherm *cytherm = usb_get_intfdata(intf); 289 struct usb_cytherm *cytherm = usb_get_intfdata(intf);
@@ -309,7 +309,7 @@ static ssize_t show_port1(struct device *dev, char *buf)
309} 309}
310 310
311 311
312static ssize_t set_port1(struct device *dev, const char *buf, size_t count) 312static ssize_t set_port1(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
313{ 313{
314 struct usb_interface *intf = to_usb_interface(dev); 314 struct usb_interface *intf = to_usb_interface(dev);
315 struct usb_cytherm *cytherm = usb_get_intfdata(intf); 315 struct usb_cytherm *cytherm = usb_get_intfdata(intf);
diff --git a/drivers/usb/misc/phidgetkit.c b/drivers/usb/misc/phidgetkit.c
index ddbf8e992368..067a81486921 100644
--- a/drivers/usb/misc/phidgetkit.c
+++ b/drivers/usb/misc/phidgetkit.c
@@ -173,7 +173,7 @@ exit:
173} 173}
174 174
175#define set_lcd_line(number) \ 175#define set_lcd_line(number) \
176static ssize_t lcd_line_##number(struct device *dev, const char *buf, size_t count) \ 176static ssize_t lcd_line_##number(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \
177{ \ 177{ \
178 struct usb_interface *intf = to_usb_interface(dev); \ 178 struct usb_interface *intf = to_usb_interface(dev); \
179 struct phidget_interfacekit *kit = usb_get_intfdata(intf); \ 179 struct phidget_interfacekit *kit = usb_get_intfdata(intf); \
@@ -184,7 +184,7 @@ static DEVICE_ATTR(lcd_line_##number, S_IWUGO, NULL, lcd_line_##number);
184set_lcd_line(1); 184set_lcd_line(1);
185set_lcd_line(2); 185set_lcd_line(2);
186 186
187static ssize_t set_backlight(struct device *dev, const char *buf, size_t count) 187static ssize_t set_backlight(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
188{ 188{
189 struct usb_interface *intf = to_usb_interface(dev); 189 struct usb_interface *intf = to_usb_interface(dev);
190 struct phidget_interfacekit *kit = usb_get_intfdata(intf); 190 struct phidget_interfacekit *kit = usb_get_intfdata(intf);
@@ -232,7 +232,7 @@ static void remove_lcd_files(struct phidget_interfacekit *kit)
232 } 232 }
233} 233}
234 234
235static ssize_t enable_lcd_files(struct device *dev, const char *buf, size_t count) 235static ssize_t enable_lcd_files(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
236{ 236{
237 struct usb_interface *intf = to_usb_interface(dev); 237 struct usb_interface *intf = to_usb_interface(dev);
238 struct phidget_interfacekit *kit = usb_get_intfdata(intf); 238 struct phidget_interfacekit *kit = usb_get_intfdata(intf);
@@ -307,7 +307,7 @@ resubmit:
307} 307}
308 308
309#define show_set_output(value) \ 309#define show_set_output(value) \
310static ssize_t set_output##value(struct device *dev, const char *buf, \ 310static ssize_t set_output##value(struct device *dev, struct device_attribute *attr, const char *buf, \
311 size_t count) \ 311 size_t count) \
312{ \ 312{ \
313 struct usb_interface *intf = to_usb_interface(dev); \ 313 struct usb_interface *intf = to_usb_interface(dev); \
@@ -324,7 +324,7 @@ static ssize_t set_output##value(struct device *dev, const char *buf, \
324 return retval ? retval : count; \ 324 return retval ? retval : count; \
325} \ 325} \
326 \ 326 \
327static ssize_t show_output##value(struct device *dev, char *buf) \ 327static ssize_t show_output##value(struct device *dev, struct device_attribute *attr, char *buf) \
328{ \ 328{ \
329 struct usb_interface *intf = to_usb_interface(dev); \ 329 struct usb_interface *intf = to_usb_interface(dev); \
330 struct phidget_interfacekit *kit = usb_get_intfdata(intf); \ 330 struct phidget_interfacekit *kit = usb_get_intfdata(intf); \
@@ -343,7 +343,7 @@ show_set_output(7);
343show_set_output(8); /* should be MAX_INTERFACES - 1 */ 343show_set_output(8); /* should be MAX_INTERFACES - 1 */
344 344
345#define show_input(value) \ 345#define show_input(value) \
346static ssize_t show_input##value(struct device *dev, char *buf) \ 346static ssize_t show_input##value(struct device *dev, struct device_attribute *attr, char *buf) \
347{ \ 347{ \
348 struct usb_interface *intf = to_usb_interface(dev); \ 348 struct usb_interface *intf = to_usb_interface(dev); \
349 struct phidget_interfacekit *kit = usb_get_intfdata(intf); \ 349 struct phidget_interfacekit *kit = usb_get_intfdata(intf); \
@@ -362,7 +362,7 @@ show_input(7);
362show_input(8); /* should be MAX_INTERFACES - 1 */ 362show_input(8); /* should be MAX_INTERFACES - 1 */
363 363
364#define show_sensor(value) \ 364#define show_sensor(value) \
365static ssize_t show_sensor##value(struct device *dev, char *buf) \ 365static ssize_t show_sensor##value(struct device *dev, struct device_attribute *attr, char *buf) \
366{ \ 366{ \
367 struct usb_interface *intf = to_usb_interface(dev); \ 367 struct usb_interface *intf = to_usb_interface(dev); \
368 struct phidget_interfacekit *kit = usb_get_intfdata(intf); \ 368 struct phidget_interfacekit *kit = usb_get_intfdata(intf); \
diff --git a/drivers/usb/misc/phidgetservo.c b/drivers/usb/misc/phidgetservo.c
index 4bd291502a3c..b84eda631ab5 100644
--- a/drivers/usb/misc/phidgetservo.c
+++ b/drivers/usb/misc/phidgetservo.c
@@ -207,7 +207,7 @@ change_position_v20(struct phidget_servo *servo, int servo_no, int degrees,
207} 207}
208 208
209#define show_set(value) \ 209#define show_set(value) \
210static ssize_t set_servo##value (struct device *dev, \ 210static ssize_t set_servo##value (struct device *dev, struct device_attribute *attr, \
211 const char *buf, size_t count) \ 211 const char *buf, size_t count) \
212{ \ 212{ \
213 int degrees, minutes, retval; \ 213 int degrees, minutes, retval; \
@@ -233,7 +233,7 @@ static ssize_t set_servo##value (struct device *dev, \
233 return retval < 0 ? retval : count; \ 233 return retval < 0 ? retval : count; \
234} \ 234} \
235 \ 235 \
236static ssize_t show_servo##value (struct device *dev, char *buf) \ 236static ssize_t show_servo##value (struct device *dev, struct device_attribute *attr, char *buf) \
237{ \ 237{ \
238 struct usb_interface *intf = to_usb_interface (dev); \ 238 struct usb_interface *intf = to_usb_interface (dev); \
239 struct phidget_servo *servo = usb_get_intfdata (intf); \ 239 struct phidget_servo *servo = usb_get_intfdata (intf); \
diff --git a/drivers/usb/misc/usbled.c b/drivers/usb/misc/usbled.c
index ee329d5e1c5e..f6ba4c788dbc 100644
--- a/drivers/usb/misc/usbled.c
+++ b/drivers/usb/misc/usbled.c
@@ -81,14 +81,14 @@ static void change_color(struct usb_led *led)
81} 81}
82 82
83#define show_set(value) \ 83#define show_set(value) \
84static ssize_t show_##value(struct device *dev, char *buf) \ 84static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \
85{ \ 85{ \
86 struct usb_interface *intf = to_usb_interface(dev); \ 86 struct usb_interface *intf = to_usb_interface(dev); \
87 struct usb_led *led = usb_get_intfdata(intf); \ 87 struct usb_led *led = usb_get_intfdata(intf); \
88 \ 88 \
89 return sprintf(buf, "%d\n", led->value); \ 89 return sprintf(buf, "%d\n", led->value); \
90} \ 90} \
91static ssize_t set_##value(struct device *dev, const char *buf, size_t count) \ 91static ssize_t set_##value(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \
92{ \ 92{ \
93 struct usb_interface *intf = to_usb_interface(dev); \ 93 struct usb_interface *intf = to_usb_interface(dev); \
94 struct usb_led *led = usb_get_intfdata(intf); \ 94 struct usb_led *led = usb_get_intfdata(intf); \
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 3bfcc7b9f861..d882fa3ad19a 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -1218,7 +1218,7 @@ check_and_exit:
1218 * *************************************************************************** 1218 * ***************************************************************************
1219 */ 1219 */
1220 1220
1221static ssize_t show_latency_timer(struct device *dev, char *buf) 1221static ssize_t show_latency_timer(struct device *dev, struct device_attribute *attr, char *buf)
1222{ 1222{
1223 struct usb_serial_port *port = to_usb_serial_port(dev); 1223 struct usb_serial_port *port = to_usb_serial_port(dev);
1224 struct ftdi_private *priv = usb_get_serial_port_data(port); 1224 struct ftdi_private *priv = usb_get_serial_port_data(port);
@@ -1245,7 +1245,7 @@ static ssize_t show_latency_timer(struct device *dev, char *buf)
1245} 1245}
1246 1246
1247/* Write a new value of the latency timer, in units of milliseconds. */ 1247/* Write a new value of the latency timer, in units of milliseconds. */
1248static ssize_t store_latency_timer(struct device *dev, const char *valbuf, 1248static ssize_t store_latency_timer(struct device *dev, struct device_attribute *attr, const char *valbuf,
1249 size_t count) 1249 size_t count)
1250{ 1250{
1251 struct usb_serial_port *port = to_usb_serial_port(dev); 1251 struct usb_serial_port *port = to_usb_serial_port(dev);
@@ -1276,7 +1276,7 @@ static ssize_t store_latency_timer(struct device *dev, const char *valbuf,
1276 1276
1277/* Write an event character directly to the FTDI register. The ASCII 1277/* Write an event character directly to the FTDI register. The ASCII
1278 value is in the low 8 bits, with the enable bit in the 9th bit. */ 1278 value is in the low 8 bits, with the enable bit in the 9th bit. */
1279static ssize_t store_event_char(struct device *dev, const char *valbuf, 1279static ssize_t store_event_char(struct device *dev, struct device_attribute *attr, const char *valbuf,
1280 size_t count) 1280 size_t count)
1281{ 1281{
1282 struct usb_serial_port *port = to_usb_serial_port(dev); 1282 struct usb_serial_port *port = to_usb_serial_port(dev);
diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
index 1035b248eff4..e43eddc3d44b 100644
--- a/drivers/usb/storage/scsiglue.c
+++ b/drivers/usb/storage/scsiglue.c
@@ -398,7 +398,7 @@ US_DO_ALL_FLAGS
398 ***********************************************************************/ 398 ***********************************************************************/
399 399
400/* Output routine for the sysfs max_sectors file */ 400/* Output routine for the sysfs max_sectors file */
401static ssize_t show_max_sectors(struct device *dev, char *buf) 401static ssize_t show_max_sectors(struct device *dev, struct device_attribute *attr, char *buf)
402{ 402{
403 struct scsi_device *sdev = to_scsi_device(dev); 403 struct scsi_device *sdev = to_scsi_device(dev);
404 404
@@ -406,7 +406,7 @@ static ssize_t show_max_sectors(struct device *dev, char *buf)
406} 406}
407 407
408/* Input routine for the sysfs max_sectors file */ 408/* Input routine for the sysfs max_sectors file */
409static ssize_t store_max_sectors(struct device *dev, const char *buf, 409static ssize_t store_max_sectors(struct device *dev, struct device_attribute *attr, const char *buf,
410 size_t count) 410 size_t count)
411{ 411{
412 struct scsi_device *sdev = to_scsi_device(dev); 412 struct scsi_device *sdev = to_scsi_device(dev);
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index 7705070191d9..8cef020d1801 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -1040,7 +1040,7 @@ static struct file_operations fb_fops = {
1040#endif 1040#endif
1041}; 1041};
1042 1042
1043static struct class_simple *fb_class; 1043static struct class *fb_class;
1044 1044
1045/** 1045/**
1046 * register_framebuffer - registers a frame buffer device 1046 * register_framebuffer - registers a frame buffer device
@@ -1066,7 +1066,7 @@ register_framebuffer(struct fb_info *fb_info)
1066 break; 1066 break;
1067 fb_info->node = i; 1067 fb_info->node = i;
1068 1068
1069 fb_info->class_device = class_simple_device_add(fb_class, MKDEV(FB_MAJOR, i), 1069 fb_info->class_device = class_device_create(fb_class, MKDEV(FB_MAJOR, i),
1070 fb_info->device, "fb%d", i); 1070 fb_info->device, "fb%d", i);
1071 if (IS_ERR(fb_info->class_device)) { 1071 if (IS_ERR(fb_info->class_device)) {
1072 /* Not fatal */ 1072 /* Not fatal */
@@ -1134,7 +1134,7 @@ unregister_framebuffer(struct fb_info *fb_info)
1134 registered_fb[i]=NULL; 1134 registered_fb[i]=NULL;
1135 num_registered_fb--; 1135 num_registered_fb--;
1136 fb_cleanup_class_device(fb_info); 1136 fb_cleanup_class_device(fb_info);
1137 class_simple_device_remove(MKDEV(FB_MAJOR, i)); 1137 class_device_destroy(fb_class, MKDEV(FB_MAJOR, i));
1138 return 0; 1138 return 0;
1139} 1139}
1140 1140
@@ -1197,7 +1197,7 @@ fbmem_init(void)
1197 if (register_chrdev(FB_MAJOR,"fb",&fb_fops)) 1197 if (register_chrdev(FB_MAJOR,"fb",&fb_fops))
1198 printk("unable to get major %d for fb devs\n", FB_MAJOR); 1198 printk("unable to get major %d for fb devs\n", FB_MAJOR);
1199 1199
1200 fb_class = class_simple_create(THIS_MODULE, "graphics"); 1200 fb_class = class_create(THIS_MODULE, "graphics");
1201 if (IS_ERR(fb_class)) { 1201 if (IS_ERR(fb_class)) {
1202 printk(KERN_WARNING "Unable to create fb class; errno = %ld\n", PTR_ERR(fb_class)); 1202 printk(KERN_WARNING "Unable to create fb class; errno = %ld\n", PTR_ERR(fb_class));
1203 fb_class = NULL; 1203 fb_class = NULL;
@@ -1210,7 +1210,7 @@ module_init(fbmem_init);
1210static void __exit 1210static void __exit
1211fbmem_exit(void) 1211fbmem_exit(void)
1212{ 1212{
1213 class_simple_destroy(fb_class); 1213 class_destroy(fb_class);
1214} 1214}
1215 1215
1216module_exit(fbmem_exit); 1216module_exit(fbmem_exit);
diff --git a/drivers/video/gbefb.c b/drivers/video/gbefb.c
index 2a023282d7a3..d3c1922cb13a 100644
--- a/drivers/video/gbefb.c
+++ b/drivers/video/gbefb.c
@@ -1045,14 +1045,14 @@ static struct fb_ops gbefb_ops = {
1045 * sysfs 1045 * sysfs
1046 */ 1046 */
1047 1047
1048static ssize_t gbefb_show_memsize(struct device *dev, char *buf) 1048static ssize_t gbefb_show_memsize(struct device *dev, struct device_attribute *attr, char *buf)
1049{ 1049{
1050 return snprintf(buf, PAGE_SIZE, "%d\n", gbe_mem_size); 1050 return snprintf(buf, PAGE_SIZE, "%d\n", gbe_mem_size);
1051} 1051}
1052 1052
1053static DEVICE_ATTR(size, S_IRUGO, gbefb_show_memsize, NULL); 1053static DEVICE_ATTR(size, S_IRUGO, gbefb_show_memsize, NULL);
1054 1054
1055static ssize_t gbefb_show_rev(struct device *device, char *buf) 1055static ssize_t gbefb_show_rev(struct device *device, struct device_attribute *attr, char *buf)
1056{ 1056{
1057 return snprintf(buf, PAGE_SIZE, "%d\n", gbe_revision); 1057 return snprintf(buf, PAGE_SIZE, "%d\n", gbe_revision);
1058} 1058}
diff --git a/drivers/video/w100fb.c b/drivers/video/w100fb.c
index 58cd2ad84afb..adcda697ea60 100644
--- a/drivers/video/w100fb.c
+++ b/drivers/video/w100fb.c
@@ -101,7 +101,7 @@ static void(*w100fb_ssp_send)(u8 adrs, u8 data);
101 * Sysfs functions 101 * Sysfs functions
102 */ 102 */
103 103
104static ssize_t rotation_show(struct device *dev, char *buf) 104static ssize_t rotation_show(struct device *dev, struct device_attribute *attr, char *buf)
105{ 105{
106 struct fb_info *info = dev_get_drvdata(dev); 106 struct fb_info *info = dev_get_drvdata(dev);
107 struct w100fb_par *par=info->par; 107 struct w100fb_par *par=info->par;
@@ -109,7 +109,7 @@ static ssize_t rotation_show(struct device *dev, char *buf)
109 return sprintf(buf, "%d\n",par->rotation_flag); 109 return sprintf(buf, "%d\n",par->rotation_flag);
110} 110}
111 111
112static ssize_t rotation_store(struct device *dev, const char *buf, size_t count) 112static ssize_t rotation_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
113{ 113{
114 unsigned int rotate; 114 unsigned int rotate;
115 struct fb_info *info = dev_get_drvdata(dev); 115 struct fb_info *info = dev_get_drvdata(dev);
@@ -134,7 +134,7 @@ static ssize_t rotation_store(struct device *dev, const char *buf, size_t count)
134 134
135static DEVICE_ATTR(rotation, 0644, rotation_show, rotation_store); 135static DEVICE_ATTR(rotation, 0644, rotation_show, rotation_store);
136 136
137static ssize_t w100fb_reg_read(struct device *dev, const char *buf, size_t count) 137static ssize_t w100fb_reg_read(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
138{ 138{
139 unsigned long param; 139 unsigned long param;
140 unsigned long regs; 140 unsigned long regs;
@@ -146,7 +146,7 @@ static ssize_t w100fb_reg_read(struct device *dev, const char *buf, size_t count
146 146
147static DEVICE_ATTR(reg_read, 0200, NULL, w100fb_reg_read); 147static DEVICE_ATTR(reg_read, 0200, NULL, w100fb_reg_read);
148 148
149static ssize_t w100fb_reg_write(struct device *dev, const char *buf, size_t count) 149static ssize_t w100fb_reg_write(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
150{ 150{
151 unsigned long regs; 151 unsigned long regs;
152 unsigned long param; 152 unsigned long param;
@@ -163,7 +163,7 @@ static ssize_t w100fb_reg_write(struct device *dev, const char *buf, size_t coun
163static DEVICE_ATTR(reg_write, 0200, NULL, w100fb_reg_write); 163static DEVICE_ATTR(reg_write, 0200, NULL, w100fb_reg_write);
164 164
165 165
166static ssize_t fastsysclk_show(struct device *dev, char *buf) 166static ssize_t fastsysclk_show(struct device *dev, struct device_attribute *attr, char *buf)
167{ 167{
168 struct fb_info *info = dev_get_drvdata(dev); 168 struct fb_info *info = dev_get_drvdata(dev);
169 struct w100fb_par *par=info->par; 169 struct w100fb_par *par=info->par;
@@ -171,7 +171,7 @@ static ssize_t fastsysclk_show(struct device *dev, char *buf)
171 return sprintf(buf, "%d\n",par->fastsysclk_mode); 171 return sprintf(buf, "%d\n",par->fastsysclk_mode);
172} 172}
173 173
174static ssize_t fastsysclk_store(struct device *dev, const char *buf, size_t count) 174static ssize_t fastsysclk_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
175{ 175{
176 int param; 176 int param;
177 struct fb_info *info = dev_get_drvdata(dev); 177 struct fb_info *info = dev_get_drvdata(dev);
diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index 8d7821899cc1..24a192e3b8b4 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -88,7 +88,7 @@ static void w1_slave_release(struct device *dev)
88 complete(&sl->dev_released); 88 complete(&sl->dev_released);
89} 89}
90 90
91static ssize_t w1_default_read_name(struct device *dev, char *buf) 91static ssize_t w1_default_read_name(struct device *dev, struct device_attribute *attr, char *buf)
92{ 92{
93 return sprintf(buf, "No family registered.\n"); 93 return sprintf(buf, "No family registered.\n");
94} 94}
@@ -137,7 +137,7 @@ static struct device_attribute w1_slave_attribute_val = {
137 .show = &w1_default_read_name, 137 .show = &w1_default_read_name,
138}; 138};
139 139
140static ssize_t w1_master_attribute_show_name(struct device *dev, char *buf) 140static ssize_t w1_master_attribute_show_name(struct device *dev, struct device_attribute *attr, char *buf)
141{ 141{
142 struct w1_master *md = container_of (dev, struct w1_master, dev); 142 struct w1_master *md = container_of (dev, struct w1_master, dev);
143 ssize_t count; 143 ssize_t count;
@@ -152,7 +152,7 @@ static ssize_t w1_master_attribute_show_name(struct device *dev, char *buf)
152 return count; 152 return count;
153} 153}
154 154
155static ssize_t w1_master_attribute_show_pointer(struct device *dev, char *buf) 155static ssize_t w1_master_attribute_show_pointer(struct device *dev, struct device_attribute *attr, char *buf)
156{ 156{
157 struct w1_master *md = container_of(dev, struct w1_master, dev); 157 struct w1_master *md = container_of(dev, struct w1_master, dev);
158 ssize_t count; 158 ssize_t count;
@@ -166,14 +166,14 @@ static ssize_t w1_master_attribute_show_pointer(struct device *dev, char *buf)
166 return count; 166 return count;
167} 167}
168 168
169static ssize_t w1_master_attribute_show_timeout(struct device *dev, char *buf) 169static ssize_t w1_master_attribute_show_timeout(struct device *dev, struct device_attribute *attr, char *buf)
170{ 170{
171 ssize_t count; 171 ssize_t count;
172 count = sprintf(buf, "%d\n", w1_timeout); 172 count = sprintf(buf, "%d\n", w1_timeout);
173 return count; 173 return count;
174} 174}
175 175
176static ssize_t w1_master_attribute_show_max_slave_count(struct device *dev, char *buf) 176static ssize_t w1_master_attribute_show_max_slave_count(struct device *dev, struct device_attribute *attr, char *buf)
177{ 177{
178 struct w1_master *md = container_of(dev, struct w1_master, dev); 178 struct w1_master *md = container_of(dev, struct w1_master, dev);
179 ssize_t count; 179 ssize_t count;
@@ -187,7 +187,7 @@ static ssize_t w1_master_attribute_show_max_slave_count(struct device *dev, char
187 return count; 187 return count;
188} 188}
189 189
190static ssize_t w1_master_attribute_show_attempts(struct device *dev, char *buf) 190static ssize_t w1_master_attribute_show_attempts(struct device *dev, struct device_attribute *attr, char *buf)
191{ 191{
192 struct w1_master *md = container_of(dev, struct w1_master, dev); 192 struct w1_master *md = container_of(dev, struct w1_master, dev);
193 ssize_t count; 193 ssize_t count;
@@ -201,7 +201,7 @@ static ssize_t w1_master_attribute_show_attempts(struct device *dev, char *buf)
201 return count; 201 return count;
202} 202}
203 203
204static ssize_t w1_master_attribute_show_slave_count(struct device *dev, char *buf) 204static ssize_t w1_master_attribute_show_slave_count(struct device *dev, struct device_attribute *attr, char *buf)
205{ 205{
206 struct w1_master *md = container_of(dev, struct w1_master, dev); 206 struct w1_master *md = container_of(dev, struct w1_master, dev);
207 ssize_t count; 207 ssize_t count;
@@ -215,7 +215,7 @@ static ssize_t w1_master_attribute_show_slave_count(struct device *dev, char *bu
215 return count; 215 return count;
216} 216}
217 217
218static ssize_t w1_master_attribute_show_slaves(struct device *dev, char *buf) 218static ssize_t w1_master_attribute_show_slaves(struct device *dev, struct device_attribute *attr, char *buf)
219 219
220{ 220{
221 struct w1_master *md = container_of(dev, struct w1_master, dev); 221 struct w1_master *md = container_of(dev, struct w1_master, dev);
diff --git a/drivers/w1/w1_family.h b/drivers/w1/w1_family.h
index 03a2de7a601f..07fa49412a90 100644
--- a/drivers/w1/w1_family.h
+++ b/drivers/w1/w1_family.h
@@ -34,10 +34,10 @@
34 34
35struct w1_family_ops 35struct w1_family_ops
36{ 36{
37 ssize_t (* rname)(struct device *, char *); 37 ssize_t (* rname)(struct device *, struct device_attribute *, char *);
38 ssize_t (* rbin)(struct kobject *, char *, loff_t, size_t); 38 ssize_t (* rbin)(struct kobject *, char *, loff_t, size_t);
39 39
40 ssize_t (* rval)(struct device *, char *); 40 ssize_t (* rval)(struct device *, struct device_attribute *, char *);
41 unsigned char rvalname[MAXNAMELEN]; 41 unsigned char rvalname[MAXNAMELEN];
42}; 42};
43 43
diff --git a/drivers/w1/w1_smem.c b/drivers/w1/w1_smem.c
index a54e425217a0..674eb75a9bad 100644
--- a/drivers/w1/w1_smem.c
+++ b/drivers/w1/w1_smem.c
@@ -36,8 +36,8 @@ MODULE_LICENSE("GPL");
36MODULE_AUTHOR("Evgeniy Polyakov <johnpol@2ka.mipt.ru>"); 36MODULE_AUTHOR("Evgeniy Polyakov <johnpol@2ka.mipt.ru>");
37MODULE_DESCRIPTION("Driver for 1-wire Dallas network protocol, 64bit memory family."); 37MODULE_DESCRIPTION("Driver for 1-wire Dallas network protocol, 64bit memory family.");
38 38
39static ssize_t w1_smem_read_name(struct device *, char *); 39static ssize_t w1_smem_read_name(struct device *, struct device_attribute *attr, char *);
40static ssize_t w1_smem_read_val(struct device *, char *); 40static ssize_t w1_smem_read_val(struct device *, struct device_attribute *attr, char *);
41static ssize_t w1_smem_read_bin(struct kobject *, char *, loff_t, size_t); 41static ssize_t w1_smem_read_bin(struct kobject *, char *, loff_t, size_t);
42 42
43static struct w1_family_ops w1_smem_fops = { 43static struct w1_family_ops w1_smem_fops = {
@@ -47,14 +47,14 @@ static struct w1_family_ops w1_smem_fops = {
47 .rvalname = "id", 47 .rvalname = "id",
48}; 48};
49 49
50static ssize_t w1_smem_read_name(struct device *dev, char *buf) 50static ssize_t w1_smem_read_name(struct device *dev, struct device_attribute *attr, char *buf)
51{ 51{
52 struct w1_slave *sl = container_of(dev, struct w1_slave, dev); 52 struct w1_slave *sl = container_of(dev, struct w1_slave, dev);
53 53
54 return sprintf(buf, "%s\n", sl->name); 54 return sprintf(buf, "%s\n", sl->name);
55} 55}
56 56
57static ssize_t w1_smem_read_val(struct device *dev, char *buf) 57static ssize_t w1_smem_read_val(struct device *dev, struct device_attribute *attr, char *buf)
58{ 58{
59 struct w1_slave *sl = container_of(dev, struct w1_slave, dev); 59 struct w1_slave *sl = container_of(dev, struct w1_slave, dev);
60 int i; 60 int i;
diff --git a/drivers/w1/w1_therm.c b/drivers/w1/w1_therm.c
index 0b1817890503..70310f7a722e 100644
--- a/drivers/w1/w1_therm.c
+++ b/drivers/w1/w1_therm.c
@@ -42,8 +42,8 @@ static u8 bad_roms[][9] = {
42 {} 42 {}
43 }; 43 };
44 44
45static ssize_t w1_therm_read_name(struct device *, char *); 45static ssize_t w1_therm_read_name(struct device *, struct device_attribute *attr, char *);
46static ssize_t w1_therm_read_temp(struct device *, char *); 46static ssize_t w1_therm_read_temp(struct device *, struct device_attribute *attr, char *);
47static ssize_t w1_therm_read_bin(struct kobject *, char *, loff_t, size_t); 47static ssize_t w1_therm_read_bin(struct kobject *, char *, loff_t, size_t);
48 48
49static struct w1_family_ops w1_therm_fops = { 49static struct w1_family_ops w1_therm_fops = {
@@ -53,7 +53,7 @@ static struct w1_family_ops w1_therm_fops = {
53 .rvalname = "temp1_input", 53 .rvalname = "temp1_input",
54}; 54};
55 55
56static ssize_t w1_therm_read_name(struct device *dev, char *buf) 56static ssize_t w1_therm_read_name(struct device *dev, struct device_attribute *attr, char *buf)
57{ 57{
58 struct w1_slave *sl = container_of(dev, struct w1_slave, dev); 58 struct w1_slave *sl = container_of(dev, struct w1_slave, dev);
59 59
@@ -77,7 +77,7 @@ static inline int w1_convert_temp(u8 rom[9])
77 return t; 77 return t;
78} 78}
79 79
80static ssize_t w1_therm_read_temp(struct device *dev, char *buf) 80static ssize_t w1_therm_read_temp(struct device *dev, struct device_attribute *attr, char *buf)
81{ 81{
82 struct w1_slave *sl = container_of(dev, struct w1_slave, dev); 82 struct w1_slave *sl = container_of(dev, struct w1_slave, dev);
83 83
diff --git a/drivers/zorro/zorro-sysfs.c b/drivers/zorro/zorro-sysfs.c
index dad03fc33a44..04ca8840acf1 100644
--- a/drivers/zorro/zorro-sysfs.c
+++ b/drivers/zorro/zorro-sysfs.c
@@ -21,7 +21,7 @@
21/* show configuration fields */ 21/* show configuration fields */
22#define zorro_config_attr(name, field, format_string) \ 22#define zorro_config_attr(name, field, format_string) \
23static ssize_t \ 23static ssize_t \
24show_##name(struct device *dev, char *buf) \ 24show_##name(struct device *dev, struct device_attribute *attr, char *buf) \
25{ \ 25{ \
26 struct zorro_dev *z; \ 26 struct zorro_dev *z; \
27 \ 27 \
@@ -36,7 +36,7 @@ zorro_config_attr(serial, rom.er_SerialNumber, "0x%08x\n");
36zorro_config_attr(slotaddr, slotaddr, "0x%04x\n"); 36zorro_config_attr(slotaddr, slotaddr, "0x%04x\n");
37zorro_config_attr(slotsize, slotsize, "0x%04x\n"); 37zorro_config_attr(slotsize, slotsize, "0x%04x\n");
38 38
39static ssize_t zorro_show_resource(struct device *dev, char *buf) 39static ssize_t zorro_show_resource(struct device *dev, struct device_attribute *attr, char *buf)
40{ 40{
41 struct zorro_dev *z = to_zorro_dev(dev); 41 struct zorro_dev *z = to_zorro_dev(dev);
42 42
diff --git a/fs/Kconfig b/fs/Kconfig
index 6a4ad4bb7a54..178e27494b74 100644
--- a/fs/Kconfig
+++ b/fs/Kconfig
@@ -741,56 +741,6 @@ config SYSFS
741 741
742 Designers of embedded systems may wish to say N here to conserve space. 742 Designers of embedded systems may wish to say N here to conserve space.
743 743
744config DEVFS_FS
745 bool "/dev file system support (OBSOLETE)"
746 depends on EXPERIMENTAL
747 help
748 This is support for devfs, a virtual file system (like /proc) which
749 provides the file system interface to device drivers, normally found
750 in /dev. Devfs does not depend on major and minor number
751 allocations. Device drivers register entries in /dev which then
752 appear automatically, which means that the system administrator does
753 not have to create character and block special device files in the
754 /dev directory using the mknod command (or MAKEDEV script) anymore.
755
756 This is work in progress. If you want to use this, you *must* read
757 the material in <file:Documentation/filesystems/devfs/>, especially
758 the file README there.
759
760 Note that devfs no longer manages /dev/pts! If you are using UNIX98
761 ptys, you will also need to mount the /dev/pts filesystem (devpts).
762
763 Note that devfs has been obsoleted by udev,
764 <http://www.kernel.org/pub/linux/utils/kernel/hotplug/>.
765 It has been stripped down to a bare minimum and is only provided for
766 legacy installations that use its naming scheme which is
767 unfortunately different from the names normal Linux installations
768 use.
769
770 If unsure, say N.
771
772config DEVFS_MOUNT
773 bool "Automatically mount at boot"
774 depends on DEVFS_FS
775 help
776 This option appears if you have CONFIG_DEVFS_FS enabled. Setting
777 this to 'Y' will make the kernel automatically mount devfs onto /dev
778 when the system is booted, before the init thread is started.
779 You can override this with the "devfs=nomount" boot option.
780
781 If unsure, say N.
782
783config DEVFS_DEBUG
784 bool "Debug devfs"
785 depends on DEVFS_FS
786 help
787 If you say Y here, then the /dev file system code will generate
788 debugging messages. See the file
789 <file:Documentation/filesystems/devfs/boot-options> for more
790 details.
791
792 If unsure, say N.
793
794config DEVPTS_FS_XATTR 744config DEVPTS_FS_XATTR
795 bool "/dev/pts Extended Attributes" 745 bool "/dev/pts Extended Attributes"
796 depends on UNIX98_PTYS 746 depends on UNIX98_PTYS
diff --git a/fs/coda/psdev.c b/fs/coda/psdev.c
index ef001a9313e6..3d1cce3653b8 100644
--- a/fs/coda/psdev.c
+++ b/fs/coda/psdev.c
@@ -61,7 +61,7 @@ unsigned long coda_timeout = 30; /* .. secs, then signals will dequeue */
61 61
62 62
63struct venus_comm coda_comms[MAX_CODADEVS]; 63struct venus_comm coda_comms[MAX_CODADEVS];
64static struct class_simple *coda_psdev_class; 64static struct class *coda_psdev_class;
65 65
66/* 66/*
67 * Device operations 67 * Device operations
@@ -363,14 +363,14 @@ static int init_coda_psdev(void)
363 CODA_PSDEV_MAJOR); 363 CODA_PSDEV_MAJOR);
364 return -EIO; 364 return -EIO;
365 } 365 }
366 coda_psdev_class = class_simple_create(THIS_MODULE, "coda"); 366 coda_psdev_class = class_create(THIS_MODULE, "coda");
367 if (IS_ERR(coda_psdev_class)) { 367 if (IS_ERR(coda_psdev_class)) {
368 err = PTR_ERR(coda_psdev_class); 368 err = PTR_ERR(coda_psdev_class);
369 goto out_chrdev; 369 goto out_chrdev;
370 } 370 }
371 devfs_mk_dir ("coda"); 371 devfs_mk_dir ("coda");
372 for (i = 0; i < MAX_CODADEVS; i++) { 372 for (i = 0; i < MAX_CODADEVS; i++) {
373 class_simple_device_add(coda_psdev_class, MKDEV(CODA_PSDEV_MAJOR,i), 373 class_device_create(coda_psdev_class, MKDEV(CODA_PSDEV_MAJOR,i),
374 NULL, "cfs%d", i); 374 NULL, "cfs%d", i);
375 err = devfs_mk_cdev(MKDEV(CODA_PSDEV_MAJOR, i), 375 err = devfs_mk_cdev(MKDEV(CODA_PSDEV_MAJOR, i),
376 S_IFCHR|S_IRUSR|S_IWUSR, "coda/%d", i); 376 S_IFCHR|S_IRUSR|S_IWUSR, "coda/%d", i);
@@ -382,8 +382,8 @@ static int init_coda_psdev(void)
382 382
383out_class: 383out_class:
384 for (i = 0; i < MAX_CODADEVS; i++) 384 for (i = 0; i < MAX_CODADEVS; i++)
385 class_simple_device_remove(MKDEV(CODA_PSDEV_MAJOR, i)); 385 class_device_destroy(coda_psdev_class, MKDEV(CODA_PSDEV_MAJOR, i));
386 class_simple_destroy(coda_psdev_class); 386 class_destroy(coda_psdev_class);
387out_chrdev: 387out_chrdev:
388 unregister_chrdev(CODA_PSDEV_MAJOR, "coda"); 388 unregister_chrdev(CODA_PSDEV_MAJOR, "coda");
389out: 389out:
@@ -425,10 +425,10 @@ static int __init init_coda(void)
425 return 0; 425 return 0;
426out: 426out:
427 for (i = 0; i < MAX_CODADEVS; i++) { 427 for (i = 0; i < MAX_CODADEVS; i++) {
428 class_simple_device_remove(MKDEV(CODA_PSDEV_MAJOR, i)); 428 class_device_destroy(coda_psdev_class, MKDEV(CODA_PSDEV_MAJOR, i));
429 devfs_remove("coda/%d", i); 429 devfs_remove("coda/%d", i);
430 } 430 }
431 class_simple_destroy(coda_psdev_class); 431 class_destroy(coda_psdev_class);
432 devfs_remove("coda"); 432 devfs_remove("coda");
433 unregister_chrdev(CODA_PSDEV_MAJOR, "coda"); 433 unregister_chrdev(CODA_PSDEV_MAJOR, "coda");
434 coda_sysctl_clean(); 434 coda_sysctl_clean();
@@ -447,10 +447,10 @@ static void __exit exit_coda(void)
447 printk("coda: failed to unregister filesystem\n"); 447 printk("coda: failed to unregister filesystem\n");
448 } 448 }
449 for (i = 0; i < MAX_CODADEVS; i++) { 449 for (i = 0; i < MAX_CODADEVS; i++) {
450 class_simple_device_remove(MKDEV(CODA_PSDEV_MAJOR, i)); 450 class_device_destroy(coda_psdev_class, MKDEV(CODA_PSDEV_MAJOR, i));
451 devfs_remove("coda/%d", i); 451 devfs_remove("coda/%d", i);
452 } 452 }
453 class_simple_destroy(coda_psdev_class); 453 class_destroy(coda_psdev_class);
454 devfs_remove("coda"); 454 devfs_remove("coda");
455 unregister_chrdev(CODA_PSDEV_MAJOR, "coda"); 455 unregister_chrdev(CODA_PSDEV_MAJOR, "coda");
456 coda_sysctl_clean(); 456 coda_sysctl_clean();
diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c
index 548556ff2506..efc97d9b7860 100644
--- a/fs/debugfs/file.c
+++ b/fs/debugfs/file.c
@@ -45,44 +45,15 @@ struct file_operations debugfs_file_operations = {
45 .open = default_open, 45 .open = default_open,
46}; 46};
47 47
48#define simple_type(type, format, temptype, strtolfn) \ 48static void debugfs_u8_set(void *data, u64 val)
49static ssize_t read_file_##type(struct file *file, char __user *user_buf, \ 49{
50 size_t count, loff_t *ppos) \ 50 *(u8 *)data = val;
51{ \ 51}
52 char buf[32]; \ 52static u64 debugfs_u8_get(void *data)
53 type *val = file->private_data; \ 53{
54 \ 54 return *(u8 *)data;
55 snprintf(buf, sizeof(buf), format "\n", *val); \ 55}
56 return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf));\ 56DEFINE_SIMPLE_ATTRIBUTE(fops_u8, debugfs_u8_get, debugfs_u8_set, "%llu\n");
57} \
58static ssize_t write_file_##type(struct file *file, const char __user *user_buf,\
59 size_t count, loff_t *ppos) \
60{ \
61 char *endp; \
62 char buf[32]; \
63 int buf_size; \
64 type *val = file->private_data; \
65 temptype tmp; \
66 \
67 memset(buf, 0x00, sizeof(buf)); \
68 buf_size = min(count, (sizeof(buf)-1)); \
69 if (copy_from_user(buf, user_buf, buf_size)) \
70 return -EFAULT; \
71 \
72 tmp = strtolfn(buf, &endp, 0); \
73 if ((endp == buf) || ((type)tmp != tmp)) \
74 return -EINVAL; \
75 *val = tmp; \
76 return count; \
77} \
78static struct file_operations fops_##type = { \
79 .read = read_file_##type, \
80 .write = write_file_##type, \
81 .open = default_open, \
82};
83simple_type(u8, "%c", unsigned long, simple_strtoul);
84simple_type(u16, "%hi", unsigned long, simple_strtoul);
85simple_type(u32, "%i", unsigned long, simple_strtoul);
86 57
87/** 58/**
88 * debugfs_create_u8 - create a file in the debugfs filesystem that is used to read and write a unsigned 8 bit value. 59 * debugfs_create_u8 - create a file in the debugfs filesystem that is used to read and write a unsigned 8 bit value.
@@ -116,6 +87,16 @@ struct dentry *debugfs_create_u8(const char *name, mode_t mode,
116} 87}
117EXPORT_SYMBOL_GPL(debugfs_create_u8); 88EXPORT_SYMBOL_GPL(debugfs_create_u8);
118 89
90static void debugfs_u16_set(void *data, u64 val)
91{
92 *(u16 *)data = val;
93}
94static u64 debugfs_u16_get(void *data)
95{
96 return *(u16 *)data;
97}
98DEFINE_SIMPLE_ATTRIBUTE(fops_u16, debugfs_u16_get, debugfs_u16_set, "%llu\n");
99
119/** 100/**
120 * debugfs_create_u16 - create a file in the debugfs filesystem that is used to read and write a unsigned 8 bit value. 101 * debugfs_create_u16 - create a file in the debugfs filesystem that is used to read and write a unsigned 8 bit value.
121 * 102 *
@@ -148,6 +129,16 @@ struct dentry *debugfs_create_u16(const char *name, mode_t mode,
148} 129}
149EXPORT_SYMBOL_GPL(debugfs_create_u16); 130EXPORT_SYMBOL_GPL(debugfs_create_u16);
150 131
132static void debugfs_u32_set(void *data, u64 val)
133{
134 *(u32 *)data = val;
135}
136static u64 debugfs_u32_get(void *data)
137{
138 return *(u32 *)data;
139}
140DEFINE_SIMPLE_ATTRIBUTE(fops_u32, debugfs_u32_get, debugfs_u32_set, "%llu\n");
141
151/** 142/**
152 * debugfs_create_u32 - create a file in the debugfs filesystem that is used to read and write a unsigned 8 bit value. 143 * debugfs_create_u32 - create a file in the debugfs filesystem that is used to read and write a unsigned 8 bit value.
153 * 144 *
diff --git a/fs/jfs/acl.c b/fs/jfs/acl.c
index 8d2a9ab981d4..30a2bf9eeda5 100644
--- a/fs/jfs/acl.c
+++ b/fs/jfs/acl.c
@@ -70,8 +70,7 @@ static struct posix_acl *jfs_get_acl(struct inode *inode, int type)
70 if (!IS_ERR(acl)) 70 if (!IS_ERR(acl))
71 *p_acl = posix_acl_dup(acl); 71 *p_acl = posix_acl_dup(acl);
72 } 72 }
73 if (value) 73 kfree(value);
74 kfree(value);
75 return acl; 74 return acl;
76} 75}
77 76
@@ -112,8 +111,7 @@ static int jfs_set_acl(struct inode *inode, int type, struct posix_acl *acl)
112 } 111 }
113 rc = __jfs_setxattr(inode, ea_name, value, size, 0); 112 rc = __jfs_setxattr(inode, ea_name, value, size, 0);
114out: 113out:
115 if (value) 114 kfree(value);
116 kfree(value);
117 115
118 if (!rc) { 116 if (!rc) {
119 if (*p_acl && (*p_acl != JFS_ACL_NOT_CACHED)) 117 if (*p_acl && (*p_acl != JFS_ACL_NOT_CACHED))
diff --git a/fs/jfs/file.c b/fs/jfs/file.c
index a87b06fa8ff8..c2c19c9ed9a4 100644
--- a/fs/jfs/file.c
+++ b/fs/jfs/file.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Copyright (c) International Business Machines Corp., 2000-2002 2 * Copyright (C) International Business Machines Corp., 2000-2002
3 * Portions Copyright (c) Christoph Hellwig, 2001-2002 3 * Portions Copyright (C) Christoph Hellwig, 2001-2002
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
@@ -19,16 +19,13 @@
19 19
20#include <linux/fs.h> 20#include <linux/fs.h>
21#include "jfs_incore.h" 21#include "jfs_incore.h"
22#include "jfs_inode.h"
22#include "jfs_dmap.h" 23#include "jfs_dmap.h"
23#include "jfs_txnmgr.h" 24#include "jfs_txnmgr.h"
24#include "jfs_xattr.h" 25#include "jfs_xattr.h"
25#include "jfs_acl.h" 26#include "jfs_acl.h"
26#include "jfs_debug.h" 27#include "jfs_debug.h"
27 28
28
29extern int jfs_commit_inode(struct inode *, int);
30extern void jfs_truncate(struct inode *);
31
32int jfs_fsync(struct file *file, struct dentry *dentry, int datasync) 29int jfs_fsync(struct file *file, struct dentry *dentry, int datasync)
33{ 30{
34 struct inode *inode = dentry->d_inode; 31 struct inode *inode = dentry->d_inode;
diff --git a/fs/jfs/inode.c b/fs/jfs/inode.c
index 24a689179af2..2137138c59b0 100644
--- a/fs/jfs/inode.c
+++ b/fs/jfs/inode.c
@@ -23,6 +23,7 @@
23#include <linux/pagemap.h> 23#include <linux/pagemap.h>
24#include <linux/quotaops.h> 24#include <linux/quotaops.h>
25#include "jfs_incore.h" 25#include "jfs_incore.h"
26#include "jfs_inode.h"
26#include "jfs_filsys.h" 27#include "jfs_filsys.h"
27#include "jfs_imap.h" 28#include "jfs_imap.h"
28#include "jfs_extent.h" 29#include "jfs_extent.h"
@@ -30,14 +31,6 @@
30#include "jfs_debug.h" 31#include "jfs_debug.h"
31 32
32 33
33extern struct inode_operations jfs_dir_inode_operations;
34extern struct inode_operations jfs_file_inode_operations;
35extern struct inode_operations jfs_symlink_inode_operations;
36extern struct file_operations jfs_dir_operations;
37extern struct file_operations jfs_file_operations;
38struct address_space_operations jfs_aops;
39extern int freeZeroLink(struct inode *);
40
41void jfs_read_inode(struct inode *inode) 34void jfs_read_inode(struct inode *inode)
42{ 35{
43 if (diRead(inode)) { 36 if (diRead(inode)) {
@@ -136,7 +129,7 @@ void jfs_delete_inode(struct inode *inode)
136 jfs_info("In jfs_delete_inode, inode = 0x%p", inode); 129 jfs_info("In jfs_delete_inode, inode = 0x%p", inode);
137 130
138 if (test_cflag(COMMIT_Freewmap, inode)) 131 if (test_cflag(COMMIT_Freewmap, inode))
139 freeZeroLink(inode); 132 jfs_free_zero_link(inode);
140 133
141 diFree(inode); 134 diFree(inode);
142 135
diff --git a/fs/jfs/jfs_debug.c b/fs/jfs/jfs_debug.c
index 91a0a889ebc5..4caea6b43b92 100644
--- a/fs/jfs/jfs_debug.c
+++ b/fs/jfs/jfs_debug.c
@@ -58,8 +58,6 @@ void dump_mem(char *label, void *data, int length)
58 58
59static struct proc_dir_entry *base; 59static struct proc_dir_entry *base;
60#ifdef CONFIG_JFS_DEBUG 60#ifdef CONFIG_JFS_DEBUG
61extern read_proc_t jfs_txanchor_read;
62
63static int loglevel_read(char *page, char **start, off_t off, 61static int loglevel_read(char *page, char **start, off_t off,
64 int count, int *eof, void *data) 62 int count, int *eof, void *data)
65{ 63{
@@ -97,14 +95,6 @@ static int loglevel_write(struct file *file, const char __user *buffer,
97} 95}
98#endif 96#endif
99 97
100
101#ifdef CONFIG_JFS_STATISTICS
102extern read_proc_t jfs_lmstats_read;
103extern read_proc_t jfs_txstats_read;
104extern read_proc_t jfs_xtstat_read;
105extern read_proc_t jfs_mpstat_read;
106#endif
107
108static struct { 98static struct {
109 const char *name; 99 const char *name;
110 read_proc_t *read_fn; 100 read_proc_t *read_fn;
diff --git a/fs/jfs/jfs_debug.h b/fs/jfs/jfs_debug.h
index a38079ae1e00..ddffbbd4d955 100644
--- a/fs/jfs/jfs_debug.h
+++ b/fs/jfs/jfs_debug.h
@@ -1,6 +1,6 @@
1/* 1/*
2 * Copyright (c) International Business Machines Corp., 2000-2002 2 * Copyright (C) International Business Machines Corp., 2000-2002
3 * Portions Copyright (c) Christoph Hellwig, 2001-2002 3 * Portions Copyright (C) Christoph Hellwig, 2001-2002
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
@@ -31,7 +31,9 @@
31 * CONFIG_JFS_DEBUG or CONFIG_JFS_STATISTICS is defined 31 * CONFIG_JFS_DEBUG or CONFIG_JFS_STATISTICS is defined
32 */ 32 */
33#if defined(CONFIG_PROC_FS) && (defined(CONFIG_JFS_DEBUG) || defined(CONFIG_JFS_STATISTICS)) 33#if defined(CONFIG_PROC_FS) && (defined(CONFIG_JFS_DEBUG) || defined(CONFIG_JFS_STATISTICS))
34 #define PROC_FS_JFS 34#define PROC_FS_JFS
35extern void jfs_proc_init(void);
36extern void jfs_proc_clean(void);
35#endif 37#endif
36 38
37/* 39/*
@@ -65,8 +67,8 @@
65 67
66extern int jfsloglevel; 68extern int jfsloglevel;
67 69
68/* dump memory contents */
69extern void dump_mem(char *label, void *data, int length); 70extern void dump_mem(char *label, void *data, int length);
71extern int jfs_txanchor_read(char *, char **, off_t, int, int *, void *);
70 72
71/* information message: e.g., configuration, major event */ 73/* information message: e.g., configuration, major event */
72#define jfs_info(fmt, arg...) do { \ 74#define jfs_info(fmt, arg...) do { \
@@ -110,6 +112,11 @@ extern void dump_mem(char *label, void *data, int length);
110 * ---------- 112 * ----------
111 */ 113 */
112#ifdef CONFIG_JFS_STATISTICS 114#ifdef CONFIG_JFS_STATISTICS
115extern int jfs_lmstats_read(char *, char **, off_t, int, int *, void *);
116extern int jfs_txstats_read(char *, char **, off_t, int, int *, void *);
117extern int jfs_mpstat_read(char *, char **, off_t, int, int *, void *);
118extern int jfs_xtstat_read(char *, char **, off_t, int, int *, void *);
119
113#define INCREMENT(x) ((x)++) 120#define INCREMENT(x) ((x)++)
114#define DECREMENT(x) ((x)--) 121#define DECREMENT(x) ((x)--)
115#define HIGHWATERMARK(x,y) ((x) = max((x), (y))) 122#define HIGHWATERMARK(x,y) ((x) = max((x), (y)))
diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c
index 69007fd546ef..cced2fed9d0f 100644
--- a/fs/jfs/jfs_dmap.c
+++ b/fs/jfs/jfs_dmap.c
@@ -272,7 +272,6 @@ int dbMount(struct inode *ipbmap)
272int dbUnmount(struct inode *ipbmap, int mounterror) 272int dbUnmount(struct inode *ipbmap, int mounterror)
273{ 273{
274 struct bmap *bmp = JFS_SBI(ipbmap->i_sb)->bmap; 274 struct bmap *bmp = JFS_SBI(ipbmap->i_sb)->bmap;
275 int i;
276 275
277 if (!(mounterror || isReadOnly(ipbmap))) 276 if (!(mounterror || isReadOnly(ipbmap)))
278 dbSync(ipbmap); 277 dbSync(ipbmap);
@@ -282,14 +281,6 @@ int dbUnmount(struct inode *ipbmap, int mounterror)
282 */ 281 */
283 truncate_inode_pages(ipbmap->i_mapping, 0); 282 truncate_inode_pages(ipbmap->i_mapping, 0);
284 283
285 /*
286 * Sanity Check
287 */
288 for (i = 0; i < bmp->db_numag; i++)
289 if (atomic_read(&bmp->db_active[i]))
290 printk(KERN_ERR "dbUnmount: db_active[%d] = %d\n",
291 i, atomic_read(&bmp->db_active[i]));
292
293 /* free the memory for the in-memory bmap. */ 284 /* free the memory for the in-memory bmap. */
294 kfree(bmp); 285 kfree(bmp);
295 286
diff --git a/fs/jfs/jfs_dtree.c b/fs/jfs/jfs_dtree.c
index ac41f72d6d50..8676aee3ae48 100644
--- a/fs/jfs/jfs_dtree.c
+++ b/fs/jfs/jfs_dtree.c
@@ -2931,6 +2931,9 @@ static void add_missing_indices(struct inode *inode, s64 bn)
2931 ASSERT(p->header.flag & BT_LEAF); 2931 ASSERT(p->header.flag & BT_LEAF);
2932 2932
2933 tlck = txLock(tid, inode, mp, tlckDTREE | tlckENTRY); 2933 tlck = txLock(tid, inode, mp, tlckDTREE | tlckENTRY);
2934 if (BT_IS_ROOT(mp))
2935 tlck->type |= tlckBTROOT;
2936
2934 dtlck = (struct dt_lock *) &tlck->lock; 2937 dtlck = (struct dt_lock *) &tlck->lock;
2935 2938
2936 stbl = DT_GETSTBL(p); 2939 stbl = DT_GETSTBL(p);
diff --git a/fs/jfs/jfs_extent.c b/fs/jfs/jfs_extent.c
index 1953acb79266..4879603daa1c 100644
--- a/fs/jfs/jfs_extent.c
+++ b/fs/jfs/jfs_extent.c
@@ -19,6 +19,7 @@
19#include <linux/fs.h> 19#include <linux/fs.h>
20#include <linux/quotaops.h> 20#include <linux/quotaops.h>
21#include "jfs_incore.h" 21#include "jfs_incore.h"
22#include "jfs_inode.h"
22#include "jfs_superblock.h" 23#include "jfs_superblock.h"
23#include "jfs_dmap.h" 24#include "jfs_dmap.h"
24#include "jfs_extent.h" 25#include "jfs_extent.h"
@@ -33,12 +34,6 @@ static int extBrealloc(struct inode *, s64, s64, s64 *, s64 *);
33#endif 34#endif
34static s64 extRoundDown(s64 nb); 35static s64 extRoundDown(s64 nb);
35 36
36/*
37 * external references
38 */
39extern int jfs_commit_inode(struct inode *, int);
40
41
42#define DPD(a) (printk("(a): %d\n",(a))) 37#define DPD(a) (printk("(a): %d\n",(a)))
43#define DPC(a) (printk("(a): %c\n",(a))) 38#define DPC(a) (printk("(a): %c\n",(a)))
44#define DPL1(a) \ 39#define DPL1(a) \
diff --git a/fs/jfs/jfs_imap.c b/fs/jfs/jfs_imap.c
index 7acff2ce3c80..971af2977eff 100644
--- a/fs/jfs/jfs_imap.c
+++ b/fs/jfs/jfs_imap.c
@@ -47,6 +47,7 @@
47#include <linux/quotaops.h> 47#include <linux/quotaops.h>
48 48
49#include "jfs_incore.h" 49#include "jfs_incore.h"
50#include "jfs_inode.h"
50#include "jfs_filsys.h" 51#include "jfs_filsys.h"
51#include "jfs_dinode.h" 52#include "jfs_dinode.h"
52#include "jfs_dmap.h" 53#include "jfs_dmap.h"
@@ -69,11 +70,6 @@
69#define AG_UNLOCK(imap,agno) up(&imap->im_aglock[agno]) 70#define AG_UNLOCK(imap,agno) up(&imap->im_aglock[agno])
70 71
71/* 72/*
72 * external references
73 */
74extern struct address_space_operations jfs_aops;
75
76/*
77 * forward references 73 * forward references
78 */ 74 */
79static int diAllocAG(struct inomap *, int, boolean_t, struct inode *); 75static int diAllocAG(struct inomap *, int, boolean_t, struct inode *);
diff --git a/fs/jfs/jfs_inode.c b/fs/jfs/jfs_inode.c
index 84f2459b2191..2af5efbfd06f 100644
--- a/fs/jfs/jfs_inode.c
+++ b/fs/jfs/jfs_inode.c
@@ -19,6 +19,7 @@
19#include <linux/fs.h> 19#include <linux/fs.h>
20#include <linux/quotaops.h> 20#include <linux/quotaops.h>
21#include "jfs_incore.h" 21#include "jfs_incore.h"
22#include "jfs_inode.h"
22#include "jfs_filsys.h" 23#include "jfs_filsys.h"
23#include "jfs_imap.h" 24#include "jfs_imap.h"
24#include "jfs_dinode.h" 25#include "jfs_dinode.h"
diff --git a/fs/jfs/jfs_inode.h b/fs/jfs/jfs_inode.h
index 3df91fbfe781..b54bac576cb3 100644
--- a/fs/jfs/jfs_inode.h
+++ b/fs/jfs/jfs_inode.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) International Business Machines Corp., 2000-2001 2 * Copyright (C) International Business Machines Corp., 2000-2001
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by 5 * it under the terms of the GNU General Public License as published by
@@ -19,5 +19,22 @@
19#define _H_JFS_INODE 19#define _H_JFS_INODE
20 20
21extern struct inode *ialloc(struct inode *, umode_t); 21extern struct inode *ialloc(struct inode *, umode_t);
22extern int jfs_fsync(struct file *, struct dentry *, int);
23extern void jfs_read_inode(struct inode *);
24extern int jfs_commit_inode(struct inode *, int);
25extern int jfs_write_inode(struct inode*, int);
26extern void jfs_delete_inode(struct inode *);
27extern void jfs_dirty_inode(struct inode *);
28extern void jfs_truncate(struct inode *);
29extern void jfs_truncate_nolock(struct inode *, loff_t);
30extern void jfs_free_zero_link(struct inode *);
31extern struct dentry *jfs_get_parent(struct dentry *dentry);
22 32
33extern struct address_space_operations jfs_aops;
34extern struct inode_operations jfs_dir_inode_operations;
35extern struct file_operations jfs_dir_operations;
36extern struct inode_operations jfs_file_inode_operations;
37extern struct file_operations jfs_file_operations;
38extern struct inode_operations jfs_symlink_inode_operations;
39extern struct dentry_operations jfs_ci_dentry_operations;
23#endif /* _H_JFS_INODE */ 40#endif /* _H_JFS_INODE */
diff --git a/fs/jfs/jfs_logmgr.c b/fs/jfs/jfs_logmgr.c
index dfa1200daa61..7c8387ed4192 100644
--- a/fs/jfs/jfs_logmgr.c
+++ b/fs/jfs/jfs_logmgr.c
@@ -71,6 +71,7 @@
71#include "jfs_incore.h" 71#include "jfs_incore.h"
72#include "jfs_filsys.h" 72#include "jfs_filsys.h"
73#include "jfs_metapage.h" 73#include "jfs_metapage.h"
74#include "jfs_superblock.h"
74#include "jfs_txnmgr.h" 75#include "jfs_txnmgr.h"
75#include "jfs_debug.h" 76#include "jfs_debug.h"
76 77
@@ -167,14 +168,6 @@ static struct jfs_log *dummy_log = NULL;
167static DECLARE_MUTEX(jfs_log_sem); 168static DECLARE_MUTEX(jfs_log_sem);
168 169
169/* 170/*
170 * external references
171 */
172extern void txLazyUnlock(struct tblock * tblk);
173extern int jfs_stop_threads;
174extern struct completion jfsIOwait;
175extern int jfs_tlocks_low;
176
177/*
178 * forward references 171 * forward references
179 */ 172 */
180static int lmWriteRecord(struct jfs_log * log, struct tblock * tblk, 173static int lmWriteRecord(struct jfs_log * log, struct tblock * tblk,
@@ -1624,6 +1617,8 @@ void jfs_flush_journal(struct jfs_log *log, int wait)
1624 } 1617 }
1625 } 1618 }
1626 assert(list_empty(&log->cqueue)); 1619 assert(list_empty(&log->cqueue));
1620
1621#ifdef CONFIG_JFS_DEBUG
1627 if (!list_empty(&log->synclist)) { 1622 if (!list_empty(&log->synclist)) {
1628 struct logsyncblk *lp; 1623 struct logsyncblk *lp;
1629 1624
@@ -1638,9 +1633,8 @@ void jfs_flush_journal(struct jfs_log *log, int wait)
1638 dump_mem("orphan tblock", lp, 1633 dump_mem("orphan tblock", lp,
1639 sizeof(struct tblock)); 1634 sizeof(struct tblock));
1640 } 1635 }
1641// current->state = TASK_INTERRUPTIBLE;
1642// schedule();
1643 } 1636 }
1637#endif
1644 //assert(list_empty(&log->synclist)); 1638 //assert(list_empty(&log->synclist));
1645 clear_bit(log_FLUSH, &log->flag); 1639 clear_bit(log_FLUSH, &log->flag);
1646} 1640}
diff --git a/fs/jfs/jfs_logmgr.h b/fs/jfs/jfs_logmgr.h
index 51291fbc420c..747114cd38b8 100644
--- a/fs/jfs/jfs_logmgr.h
+++ b/fs/jfs/jfs_logmgr.h
@@ -507,6 +507,8 @@ extern int lmLogClose(struct super_block *sb);
507extern int lmLogShutdown(struct jfs_log * log); 507extern int lmLogShutdown(struct jfs_log * log);
508extern int lmLogInit(struct jfs_log * log); 508extern int lmLogInit(struct jfs_log * log);
509extern int lmLogFormat(struct jfs_log *log, s64 logAddress, int logSize); 509extern int lmLogFormat(struct jfs_log *log, s64 logAddress, int logSize);
510extern int lmGroupCommit(struct jfs_log *, struct tblock *);
511extern int jfsIOWait(void *);
510extern void jfs_flush_journal(struct jfs_log * log, int wait); 512extern void jfs_flush_journal(struct jfs_log * log, int wait);
511extern void jfs_syncpt(struct jfs_log *log); 513extern void jfs_syncpt(struct jfs_log *log);
512 514
diff --git a/fs/jfs/jfs_metapage.c b/fs/jfs/jfs_metapage.c
index 41bf078dce05..6c5485d16c39 100644
--- a/fs/jfs/jfs_metapage.c
+++ b/fs/jfs/jfs_metapage.c
@@ -198,7 +198,7 @@ static void init_once(void *foo, kmem_cache_t *cachep, unsigned long flags)
198 } 198 }
199} 199}
200 200
201static inline struct metapage *alloc_metapage(int gfp_mask) 201static inline struct metapage *alloc_metapage(unsigned int gfp_mask)
202{ 202{
203 return mempool_alloc(metapage_mempool, gfp_mask); 203 return mempool_alloc(metapage_mempool, gfp_mask);
204} 204}
@@ -726,12 +726,12 @@ void force_metapage(struct metapage *mp)
726 page_cache_release(page); 726 page_cache_release(page);
727} 727}
728 728
729extern void hold_metapage(struct metapage *mp) 729void hold_metapage(struct metapage *mp)
730{ 730{
731 lock_page(mp->page); 731 lock_page(mp->page);
732} 732}
733 733
734extern void put_metapage(struct metapage *mp) 734void put_metapage(struct metapage *mp)
735{ 735{
736 if (mp->count || mp->nohomeok) { 736 if (mp->count || mp->nohomeok) {
737 /* Someone else will release this */ 737 /* Someone else will release this */
diff --git a/fs/jfs/jfs_metapage.h b/fs/jfs/jfs_metapage.h
index 991e9fb84c75..f0b7d3282b07 100644
--- a/fs/jfs/jfs_metapage.h
+++ b/fs/jfs/jfs_metapage.h
@@ -1,6 +1,6 @@
1/* 1/*
2 * Copyright (c) International Business Machines Corp., 2000-2002 2 * Copyright (C) International Business Machines Corp., 2000-2002
3 * Portions Copyright (c) Christoph Hellwig, 2001-2002 3 * Portions Copyright (C) Christoph Hellwig, 2001-2002
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
@@ -58,6 +58,8 @@ struct metapage {
58#define mark_metapage_dirty(mp) set_bit(META_dirty, &(mp)->flag) 58#define mark_metapage_dirty(mp) set_bit(META_dirty, &(mp)->flag)
59 59
60/* function prototypes */ 60/* function prototypes */
61extern int metapage_init(void);
62extern void metapage_exit(void);
61extern struct metapage *__get_metapage(struct inode *inode, 63extern struct metapage *__get_metapage(struct inode *inode,
62 unsigned long lblock, unsigned int size, 64 unsigned long lblock, unsigned int size,
63 int absolute, unsigned long new); 65 int absolute, unsigned long new);
diff --git a/fs/jfs/jfs_superblock.h b/fs/jfs/jfs_superblock.h
index ab0566f70cfa..fcf781bf31cb 100644
--- a/fs/jfs/jfs_superblock.h
+++ b/fs/jfs/jfs_superblock.h
@@ -109,5 +109,16 @@ struct jfs_superblock {
109extern int readSuper(struct super_block *, struct buffer_head **); 109extern int readSuper(struct super_block *, struct buffer_head **);
110extern int updateSuper(struct super_block *, uint); 110extern int updateSuper(struct super_block *, uint);
111extern void jfs_error(struct super_block *, const char *, ...); 111extern void jfs_error(struct super_block *, const char *, ...);
112extern int jfs_mount(struct super_block *);
113extern int jfs_mount_rw(struct super_block *, int);
114extern int jfs_umount(struct super_block *);
115extern int jfs_umount_rw(struct super_block *);
116
117extern int jfs_stop_threads;
118extern struct completion jfsIOwait;
119extern wait_queue_head_t jfs_IO_thread_wait;
120extern wait_queue_head_t jfs_commit_thread_wait;
121extern wait_queue_head_t jfs_sync_thread_wait;
122extern int jfs_extendfs(struct super_block *, s64, int);
112 123
113#endif /*_H_JFS_SUPERBLOCK */ 124#endif /*_H_JFS_SUPERBLOCK */
diff --git a/fs/jfs/jfs_txnmgr.c b/fs/jfs/jfs_txnmgr.c
index e93d01aa12c4..8cbaaff1d5fa 100644
--- a/fs/jfs/jfs_txnmgr.c
+++ b/fs/jfs/jfs_txnmgr.c
@@ -42,7 +42,6 @@
42 * hold on to mp+lock thru update of maps 42 * hold on to mp+lock thru update of maps
43 */ 43 */
44 44
45
46#include <linux/fs.h> 45#include <linux/fs.h>
47#include <linux/vmalloc.h> 46#include <linux/vmalloc.h>
48#include <linux/smp_lock.h> 47#include <linux/smp_lock.h>
@@ -51,6 +50,7 @@
51#include <linux/module.h> 50#include <linux/module.h>
52#include <linux/moduleparam.h> 51#include <linux/moduleparam.h>
53#include "jfs_incore.h" 52#include "jfs_incore.h"
53#include "jfs_inode.h"
54#include "jfs_filsys.h" 54#include "jfs_filsys.h"
55#include "jfs_metapage.h" 55#include "jfs_metapage.h"
56#include "jfs_dinode.h" 56#include "jfs_dinode.h"
@@ -109,7 +109,6 @@ static int TxLockHWM; /* High water mark for number of txLocks used */
109static int TxLockVHWM; /* Very High water mark */ 109static int TxLockVHWM; /* Very High water mark */
110struct tlock *TxLock; /* transaction lock table */ 110struct tlock *TxLock; /* transaction lock table */
111 111
112
113/* 112/*
114 * transaction management lock 113 * transaction management lock
115 */ 114 */
@@ -149,7 +148,6 @@ static inline void TXN_SLEEP_DROP_LOCK(wait_queue_head_t * event)
149 148
150#define TXN_WAKEUP(event) wake_up_all(event) 149#define TXN_WAKEUP(event) wake_up_all(event)
151 150
152
153/* 151/*
154 * statistics 152 * statistics
155 */ 153 */
@@ -161,16 +159,6 @@ static struct {
161 int waitlock; /* 4: # of tlock wait */ 159 int waitlock; /* 4: # of tlock wait */
162} stattx; 160} stattx;
163 161
164
165/*
166 * external references
167 */
168extern int lmGroupCommit(struct jfs_log *, struct tblock *);
169extern int jfs_commit_inode(struct inode *, int);
170extern int jfs_stop_threads;
171
172extern struct completion jfsIOwait;
173
174/* 162/*
175 * forward references 163 * forward references
176 */ 164 */
@@ -358,7 +346,6 @@ void txExit(void)
358 TxBlock = NULL; 346 TxBlock = NULL;
359} 347}
360 348
361
362/* 349/*
363 * NAME: txBegin() 350 * NAME: txBegin()
364 * 351 *
@@ -460,7 +447,6 @@ tid_t txBegin(struct super_block *sb, int flag)
460 return t; 447 return t;
461} 448}
462 449
463
464/* 450/*
465 * NAME: txBeginAnon() 451 * NAME: txBeginAnon()
466 * 452 *
@@ -503,7 +489,6 @@ void txBeginAnon(struct super_block *sb)
503 TXN_UNLOCK(); 489 TXN_UNLOCK();
504} 490}
505 491
506
507/* 492/*
508 * txEnd() 493 * txEnd()
509 * 494 *
@@ -592,7 +577,6 @@ wakeup:
592 TXN_WAKEUP(&TxAnchor.freewait); 577 TXN_WAKEUP(&TxAnchor.freewait);
593} 578}
594 579
595
596/* 580/*
597 * txLock() 581 * txLock()
598 * 582 *
@@ -868,7 +852,6 @@ struct tlock *txLock(tid_t tid, struct inode *ip, struct metapage * mp,
868 return NULL; 852 return NULL;
869} 853}
870 854
871
872/* 855/*
873 * NAME: txRelease() 856 * NAME: txRelease()
874 * 857 *
@@ -908,7 +891,6 @@ static void txRelease(struct tblock * tblk)
908 TXN_UNLOCK(); 891 TXN_UNLOCK();
909} 892}
910 893
911
912/* 894/*
913 * NAME: txUnlock() 895 * NAME: txUnlock()
914 * 896 *
@@ -996,7 +978,6 @@ static void txUnlock(struct tblock * tblk)
996 } 978 }
997} 979}
998 980
999
1000/* 981/*
1001 * txMaplock() 982 * txMaplock()
1002 * 983 *
@@ -1069,7 +1050,6 @@ struct tlock *txMaplock(tid_t tid, struct inode *ip, int type)
1069 return tlck; 1050 return tlck;
1070} 1051}
1071 1052
1072
1073/* 1053/*
1074 * txLinelock() 1054 * txLinelock()
1075 * 1055 *
@@ -1103,8 +1083,6 @@ struct linelock *txLinelock(struct linelock * tlock)
1103 return linelock; 1083 return linelock;
1104} 1084}
1105 1085
1106
1107
1108/* 1086/*
1109 * transaction commit management 1087 * transaction commit management
1110 * ----------------------------- 1088 * -----------------------------
@@ -1373,7 +1351,6 @@ int txCommit(tid_t tid, /* transaction identifier */
1373 return rc; 1351 return rc;
1374} 1352}
1375 1353
1376
1377/* 1354/*
1378 * NAME: txLog() 1355 * NAME: txLog()
1379 * 1356 *
@@ -1437,7 +1414,6 @@ static int txLog(struct jfs_log * log, struct tblock * tblk, struct commit * cd)
1437 return rc; 1414 return rc;
1438} 1415}
1439 1416
1440
1441/* 1417/*
1442 * diLog() 1418 * diLog()
1443 * 1419 *
@@ -1465,7 +1441,6 @@ static int diLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd,
1465 if (tlck->type & tlckENTRY) { 1441 if (tlck->type & tlckENTRY) {
1466 /* log after-image for logredo(): */ 1442 /* log after-image for logredo(): */
1467 lrd->type = cpu_to_le16(LOG_REDOPAGE); 1443 lrd->type = cpu_to_le16(LOG_REDOPAGE);
1468// *pxd = mp->cm_pxd;
1469 PXDaddress(pxd, mp->index); 1444 PXDaddress(pxd, mp->index);
1470 PXDlength(pxd, 1445 PXDlength(pxd,
1471 mp->logical_size >> tblk->sb->s_blocksize_bits); 1446 mp->logical_size >> tblk->sb->s_blocksize_bits);
@@ -1552,7 +1527,6 @@ static int diLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd,
1552 return rc; 1527 return rc;
1553} 1528}
1554 1529
1555
1556/* 1530/*
1557 * dataLog() 1531 * dataLog()
1558 * 1532 *
@@ -1599,7 +1573,6 @@ static int dataLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd,
1599 return 0; 1573 return 0;
1600} 1574}
1601 1575
1602
1603/* 1576/*
1604 * dtLog() 1577 * dtLog()
1605 * 1578 *
@@ -1639,7 +1612,6 @@ static void dtLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd,
1639 lrd->log.redopage.type |= cpu_to_le16(LOG_EXTEND); 1612 lrd->log.redopage.type |= cpu_to_le16(LOG_EXTEND);
1640 else 1613 else
1641 lrd->log.redopage.type |= cpu_to_le16(LOG_NEW); 1614 lrd->log.redopage.type |= cpu_to_le16(LOG_NEW);
1642// *pxd = mp->cm_pxd;
1643 PXDaddress(pxd, mp->index); 1615 PXDaddress(pxd, mp->index);
1644 PXDlength(pxd, 1616 PXDlength(pxd,
1645 mp->logical_size >> tblk->sb->s_blocksize_bits); 1617 mp->logical_size >> tblk->sb->s_blocksize_bits);
@@ -1704,7 +1676,6 @@ static void dtLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd,
1704 return; 1676 return;
1705} 1677}
1706 1678
1707
1708/* 1679/*
1709 * xtLog() 1680 * xtLog()
1710 * 1681 *
@@ -1760,7 +1731,6 @@ static void xtLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd,
1760 * applying the after-image to the meta-data page. 1731 * applying the after-image to the meta-data page.
1761 */ 1732 */
1762 lrd->type = cpu_to_le16(LOG_REDOPAGE); 1733 lrd->type = cpu_to_le16(LOG_REDOPAGE);
1763// *page_pxd = mp->cm_pxd;
1764 PXDaddress(page_pxd, mp->index); 1734 PXDaddress(page_pxd, mp->index);
1765 PXDlength(page_pxd, 1735 PXDlength(page_pxd,
1766 mp->logical_size >> tblk->sb->s_blocksize_bits); 1736 mp->logical_size >> tblk->sb->s_blocksize_bits);
@@ -2093,7 +2063,6 @@ static void xtLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd,
2093 return; 2063 return;
2094} 2064}
2095 2065
2096
2097/* 2066/*
2098 * mapLog() 2067 * mapLog()
2099 * 2068 *
@@ -2180,7 +2149,6 @@ void mapLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd,
2180 } 2149 }
2181} 2150}
2182 2151
2183
2184/* 2152/*
2185 * txEA() 2153 * txEA()
2186 * 2154 *
@@ -2233,7 +2201,6 @@ void txEA(tid_t tid, struct inode *ip, dxd_t * oldea, dxd_t * newea)
2233 } 2201 }
2234} 2202}
2235 2203
2236
2237/* 2204/*
2238 * txForce() 2205 * txForce()
2239 * 2206 *
@@ -2300,7 +2267,6 @@ void txForce(struct tblock * tblk)
2300 } 2267 }
2301} 2268}
2302 2269
2303
2304/* 2270/*
2305 * txUpdateMap() 2271 * txUpdateMap()
2306 * 2272 *
@@ -2437,7 +2403,6 @@ static void txUpdateMap(struct tblock * tblk)
2437 } 2403 }
2438} 2404}
2439 2405
2440
2441/* 2406/*
2442 * txAllocPMap() 2407 * txAllocPMap()
2443 * 2408 *
@@ -2509,7 +2474,6 @@ static void txAllocPMap(struct inode *ip, struct maplock * maplock,
2509 } 2474 }
2510} 2475}
2511 2476
2512
2513/* 2477/*
2514 * txFreeMap() 2478 * txFreeMap()
2515 * 2479 *
@@ -2611,7 +2575,6 @@ void txFreeMap(struct inode *ip,
2611 } 2575 }
2612} 2576}
2613 2577
2614
2615/* 2578/*
2616 * txFreelock() 2579 * txFreelock()
2617 * 2580 *
@@ -2652,7 +2615,6 @@ void txFreelock(struct inode *ip)
2652 TXN_UNLOCK(); 2615 TXN_UNLOCK();
2653} 2616}
2654 2617
2655
2656/* 2618/*
2657 * txAbort() 2619 * txAbort()
2658 * 2620 *
diff --git a/fs/jfs/jfs_txnmgr.h b/fs/jfs/jfs_txnmgr.h
index b71b82c2df04..59ad0f6b7231 100644
--- a/fs/jfs/jfs_txnmgr.h
+++ b/fs/jfs/jfs_txnmgr.h
@@ -285,34 +285,26 @@ struct commit {
285/* 285/*
286 * external declarations 286 * external declarations
287 */ 287 */
288extern struct tlock *txLock(tid_t tid, struct inode *ip, struct metapage *mp, 288extern int jfs_tlocks_low;
289 int flag); 289
290 290extern int txInit(void);
291extern struct tlock *txMaplock(tid_t tid, struct inode *ip, int flag); 291extern void txExit(void);
292 292extern struct tlock *txLock(tid_t, struct inode *, struct metapage *, int);
293extern int txCommit(tid_t tid, int nip, struct inode **iplist, int flag); 293extern struct tlock *txMaplock(tid_t, struct inode *, int);
294 294extern int txCommit(tid_t, int, struct inode **, int);
295extern tid_t txBegin(struct super_block *sb, int flag); 295extern tid_t txBegin(struct super_block *, int);
296 296extern void txBeginAnon(struct super_block *);
297extern void txBeginAnon(struct super_block *sb); 297extern void txEnd(tid_t);
298 298extern void txAbort(tid_t, int);
299extern void txEnd(tid_t tid); 299extern struct linelock *txLinelock(struct linelock *);
300 300extern void txFreeMap(struct inode *, struct maplock *, struct tblock *, int);
301extern void txAbort(tid_t tid, int dirty); 301extern void txEA(tid_t, struct inode *, dxd_t *, dxd_t *);
302 302extern void txFreelock(struct inode *);
303extern struct linelock *txLinelock(struct linelock * tlock); 303extern int lmLog(struct jfs_log *, struct tblock *, struct lrd *,
304 304 struct tlock *);
305extern void txFreeMap(struct inode *ip, struct maplock * maplock, 305extern void txQuiesce(struct super_block *);
306 struct tblock * tblk, int maptype); 306extern void txResume(struct super_block *);
307 307extern void txLazyUnlock(struct tblock *);
308extern void txEA(tid_t tid, struct inode *ip, dxd_t * oldea, dxd_t * newea); 308extern int jfs_lazycommit(void *);
309 309extern int jfs_sync(void *);
310extern void txFreelock(struct inode *ip);
311
312extern int lmLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd,
313 struct tlock * tlck);
314
315extern void txQuiesce(struct super_block *sb);
316
317extern void txResume(struct super_block *sb);
318#endif /* _H_JFS_TXNMGR */ 310#endif /* _H_JFS_TXNMGR */
diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c
index 8413a368f449..1cae14e741eb 100644
--- a/fs/jfs/namei.c
+++ b/fs/jfs/namei.c
@@ -31,20 +31,9 @@
31#include "jfs_acl.h" 31#include "jfs_acl.h"
32#include "jfs_debug.h" 32#include "jfs_debug.h"
33 33
34extern struct inode_operations jfs_file_inode_operations;
35extern struct inode_operations jfs_symlink_inode_operations;
36extern struct file_operations jfs_file_operations;
37extern struct address_space_operations jfs_aops;
38
39extern int jfs_fsync(struct file *, struct dentry *, int);
40extern void jfs_truncate_nolock(struct inode *, loff_t);
41extern int jfs_init_acl(struct inode *, struct inode *);
42
43/* 34/*
44 * forward references 35 * forward references
45 */ 36 */
46struct inode_operations jfs_dir_inode_operations;
47struct file_operations jfs_dir_operations;
48struct dentry_operations jfs_ci_dentry_operations; 37struct dentry_operations jfs_ci_dentry_operations;
49 38
50static s64 commitZeroLink(tid_t, struct inode *); 39static s64 commitZeroLink(tid_t, struct inode *);
@@ -655,7 +644,7 @@ static s64 commitZeroLink(tid_t tid, struct inode *ip)
655 644
656 645
657/* 646/*
658 * NAME: freeZeroLink() 647 * NAME: jfs_free_zero_link()
659 * 648 *
660 * FUNCTION: for non-directory, called by iClose(), 649 * FUNCTION: for non-directory, called by iClose(),
661 * free resources of a file from cache and WORKING map 650 * free resources of a file from cache and WORKING map
@@ -663,15 +652,12 @@ static s64 commitZeroLink(tid_t tid, struct inode *ip)
663 * while associated with a pager object, 652 * while associated with a pager object,
664 * 653 *
665 * PARAMETER: ip - pointer to inode of file. 654 * PARAMETER: ip - pointer to inode of file.
666 *
667 * RETURN: 0 -ok
668 */ 655 */
669int freeZeroLink(struct inode *ip) 656void jfs_free_zero_link(struct inode *ip)
670{ 657{
671 int rc = 0;
672 int type; 658 int type;
673 659
674 jfs_info("freeZeroLink: ip = 0x%p", ip); 660 jfs_info("jfs_free_zero_link: ip = 0x%p", ip);
675 661
676 /* return if not reg or symbolic link or if size is 662 /* return if not reg or symbolic link or if size is
677 * already ok. 663 * already ok.
@@ -684,10 +670,10 @@ int freeZeroLink(struct inode *ip)
684 case S_IFLNK: 670 case S_IFLNK:
685 /* if its contained in inode nothing to do */ 671 /* if its contained in inode nothing to do */
686 if (ip->i_size < IDATASIZE) 672 if (ip->i_size < IDATASIZE)
687 return 0; 673 return;
688 break; 674 break;
689 default: 675 default:
690 return 0; 676 return;
691 } 677 }
692 678
693 /* 679 /*
@@ -737,9 +723,7 @@ int freeZeroLink(struct inode *ip)
737 * free xtree/data blocks from working block map; 723 * free xtree/data blocks from working block map;
738 */ 724 */
739 if (ip->i_size) 725 if (ip->i_size)
740 rc = xtTruncate(0, ip, 0, COMMIT_WMAP); 726 xtTruncate(0, ip, 0, COMMIT_WMAP);
741
742 return rc;
743} 727}
744 728
745/* 729/*
diff --git a/fs/jfs/super.c b/fs/jfs/super.c
index 5e774ed7fb64..810a3653d8b3 100644
--- a/fs/jfs/super.c
+++ b/fs/jfs/super.c
@@ -28,6 +28,7 @@
28 28
29#include "jfs_incore.h" 29#include "jfs_incore.h"
30#include "jfs_filsys.h" 30#include "jfs_filsys.h"
31#include "jfs_inode.h"
31#include "jfs_metapage.h" 32#include "jfs_metapage.h"
32#include "jfs_superblock.h" 33#include "jfs_superblock.h"
33#include "jfs_dmap.h" 34#include "jfs_dmap.h"
@@ -62,37 +63,6 @@ module_param(jfsloglevel, int, 0644);
62MODULE_PARM_DESC(jfsloglevel, "Specify JFS loglevel (0, 1 or 2)"); 63MODULE_PARM_DESC(jfsloglevel, "Specify JFS loglevel (0, 1 or 2)");
63#endif 64#endif
64 65
65/*
66 * External declarations
67 */
68extern int jfs_mount(struct super_block *);
69extern int jfs_mount_rw(struct super_block *, int);
70extern int jfs_umount(struct super_block *);
71extern int jfs_umount_rw(struct super_block *);
72
73extern int jfsIOWait(void *);
74extern int jfs_lazycommit(void *);
75extern int jfs_sync(void *);
76
77extern void jfs_read_inode(struct inode *inode);
78extern void jfs_dirty_inode(struct inode *inode);
79extern void jfs_delete_inode(struct inode *inode);
80extern int jfs_write_inode(struct inode *inode, int wait);
81
82extern struct dentry *jfs_get_parent(struct dentry *dentry);
83extern int jfs_extendfs(struct super_block *, s64, int);
84
85extern struct dentry_operations jfs_ci_dentry_operations;
86
87#ifdef PROC_FS_JFS /* see jfs_debug.h */
88extern void jfs_proc_init(void);
89extern void jfs_proc_clean(void);
90#endif
91
92extern wait_queue_head_t jfs_IO_thread_wait;
93extern wait_queue_head_t jfs_commit_thread_wait;
94extern wait_queue_head_t jfs_sync_thread_wait;
95
96static void jfs_handle_error(struct super_block *sb) 66static void jfs_handle_error(struct super_block *sb)
97{ 67{
98 struct jfs_sb_info *sbi = JFS_SBI(sb); 68 struct jfs_sb_info *sbi = JFS_SBI(sb);
@@ -593,11 +563,6 @@ static struct file_system_type jfs_fs_type = {
593 .fs_flags = FS_REQUIRES_DEV, 563 .fs_flags = FS_REQUIRES_DEV,
594}; 564};
595 565
596extern int metapage_init(void);
597extern int txInit(void);
598extern void txExit(void);
599extern void metapage_exit(void);
600
601static void init_once(void *foo, kmem_cache_t * cachep, unsigned long flags) 566static void init_once(void *foo, kmem_cache_t * cachep, unsigned long flags)
602{ 567{
603 struct jfs_inode_info *jfs_ip = (struct jfs_inode_info *) foo; 568 struct jfs_inode_info *jfs_ip = (struct jfs_inode_info *) foo;
diff --git a/fs/jfs/symlink.c b/fs/jfs/symlink.c
index ef4c07ee92b2..287d8d6c3cfd 100644
--- a/fs/jfs/symlink.c
+++ b/fs/jfs/symlink.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) Christoph Hellwig, 2001-2002 2 * Copyright (C) Christoph Hellwig, 2001-2002
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by 5 * it under the terms of the GNU General Public License as published by
@@ -19,6 +19,7 @@
19#include <linux/fs.h> 19#include <linux/fs.h>
20#include <linux/namei.h> 20#include <linux/namei.h>
21#include "jfs_incore.h" 21#include "jfs_incore.h"
22#include "jfs_inode.h"
22#include "jfs_xattr.h" 23#include "jfs_xattr.h"
23 24
24static int jfs_follow_link(struct dentry *dentry, struct nameidata *nd) 25static int jfs_follow_link(struct dentry *dentry, struct nameidata *nd)
diff --git a/fs/jfs/xattr.c b/fs/jfs/xattr.c
index 7a9ffd5d03dc..6016373701a3 100644
--- a/fs/jfs/xattr.c
+++ b/fs/jfs/xattr.c
@@ -946,8 +946,7 @@ int __jfs_setxattr(struct inode *inode, const char *name, const void *value,
946 out: 946 out:
947 up_write(&JFS_IP(inode)->xattr_sem); 947 up_write(&JFS_IP(inode)->xattr_sem);
948 948
949 if (os2name) 949 kfree(os2name);
950 kfree(os2name);
951 950
952 return rc; 951 return rc;
953} 952}
@@ -1042,8 +1041,7 @@ ssize_t __jfs_getxattr(struct inode *inode, const char *name, void *data,
1042 out: 1041 out:
1043 up_read(&JFS_IP(inode)->xattr_sem); 1042 up_read(&JFS_IP(inode)->xattr_sem);
1044 1043
1045 if (os2name) 1044 kfree(os2name);
1046 kfree(os2name);
1047 1045
1048 return size; 1046 return size;
1049} 1047}
diff --git a/fs/libfs.c b/fs/libfs.c
index f90b29595927..5025563e7379 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -519,6 +519,102 @@ int simple_transaction_release(struct inode *inode, struct file *file)
519 return 0; 519 return 0;
520} 520}
521 521
522/* Simple attribute files */
523
524struct simple_attr {
525 u64 (*get)(void *);
526 void (*set)(void *, u64);
527 char get_buf[24]; /* enough to store a u64 and "\n\0" */
528 char set_buf[24];
529 void *data;
530 const char *fmt; /* format for read operation */
531 struct semaphore sem; /* protects access to these buffers */
532};
533
534/* simple_attr_open is called by an actual attribute open file operation
535 * to set the attribute specific access operations. */
536int simple_attr_open(struct inode *inode, struct file *file,
537 u64 (*get)(void *), void (*set)(void *, u64),
538 const char *fmt)
539{
540 struct simple_attr *attr;
541
542 attr = kmalloc(sizeof(*attr), GFP_KERNEL);
543 if (!attr)
544 return -ENOMEM;
545
546 attr->get = get;
547 attr->set = set;
548 attr->data = inode->u.generic_ip;
549 attr->fmt = fmt;
550 init_MUTEX(&attr->sem);
551
552 file->private_data = attr;
553
554 return nonseekable_open(inode, file);
555}
556
557int simple_attr_close(struct inode *inode, struct file *file)
558{
559 kfree(file->private_data);
560 return 0;
561}
562
563/* read from the buffer that is filled with the get function */
564ssize_t simple_attr_read(struct file *file, char __user *buf,
565 size_t len, loff_t *ppos)
566{
567 struct simple_attr *attr;
568 size_t size;
569 ssize_t ret;
570
571 attr = file->private_data;
572
573 if (!attr->get)
574 return -EACCES;
575
576 down(&attr->sem);
577 if (*ppos) /* continued read */
578 size = strlen(attr->get_buf);
579 else /* first read */
580 size = scnprintf(attr->get_buf, sizeof(attr->get_buf),
581 attr->fmt,
582 (unsigned long long)attr->get(attr->data));
583
584 ret = simple_read_from_buffer(buf, len, ppos, attr->get_buf, size);
585 up(&attr->sem);
586 return ret;
587}
588
589/* interpret the buffer as a number to call the set function with */
590ssize_t simple_attr_write(struct file *file, const char __user *buf,
591 size_t len, loff_t *ppos)
592{
593 struct simple_attr *attr;
594 u64 val;
595 size_t size;
596 ssize_t ret;
597
598 attr = file->private_data;
599
600 if (!attr->set)
601 return -EACCES;
602
603 down(&attr->sem);
604 ret = -EFAULT;
605 size = min(sizeof(attr->set_buf) - 1, len);
606 if (copy_from_user(attr->set_buf, buf, size))
607 goto out;
608
609 ret = len; /* claim we got the whole input */
610 attr->set_buf[size] = '\0';
611 val = simple_strtol(attr->set_buf, NULL, 0);
612 attr->set(attr->data, val);
613out:
614 up(&attr->sem);
615 return ret;
616}
617
522EXPORT_SYMBOL(dcache_dir_close); 618EXPORT_SYMBOL(dcache_dir_close);
523EXPORT_SYMBOL(dcache_dir_lseek); 619EXPORT_SYMBOL(dcache_dir_lseek);
524EXPORT_SYMBOL(dcache_dir_open); 620EXPORT_SYMBOL(dcache_dir_open);
@@ -547,3 +643,7 @@ EXPORT_SYMBOL(simple_read_from_buffer);
547EXPORT_SYMBOL(simple_transaction_get); 643EXPORT_SYMBOL(simple_transaction_get);
548EXPORT_SYMBOL(simple_transaction_read); 644EXPORT_SYMBOL(simple_transaction_read);
549EXPORT_SYMBOL(simple_transaction_release); 645EXPORT_SYMBOL(simple_transaction_release);
646EXPORT_SYMBOL_GPL(simple_attr_open);
647EXPORT_SYMBOL_GPL(simple_attr_close);
648EXPORT_SYMBOL_GPL(simple_attr_read);
649EXPORT_SYMBOL_GPL(simple_attr_write);
diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
index d4aaa88d0214..78899eeab974 100644
--- a/fs/sysfs/bin.c
+++ b/fs/sysfs/bin.c
@@ -25,7 +25,7 @@ fill_read(struct dentry *dentry, char *buffer, loff_t off, size_t count)
25 struct kobject * kobj = to_kobj(dentry->d_parent); 25 struct kobject * kobj = to_kobj(dentry->d_parent);
26 26
27 if (!attr->read) 27 if (!attr->read)
28 return -EINVAL; 28 return -EIO;
29 29
30 return attr->read(kobj, buffer, off, count); 30 return attr->read(kobj, buffer, off, count);
31} 31}
@@ -71,7 +71,7 @@ flush_write(struct dentry *dentry, char *buffer, loff_t offset, size_t count)
71 struct kobject *kobj = to_kobj(dentry->d_parent); 71 struct kobject *kobj = to_kobj(dentry->d_parent);
72 72
73 if (!attr->write) 73 if (!attr->write)
74 return -EINVAL; 74 return -EIO;
75 75
76 return attr->write(kobj, buffer, offset, count); 76 return attr->write(kobj, buffer, offset, count);
77} 77}
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index fe198210bc2d..37d7a6875d86 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -101,18 +101,19 @@ static int create_dir(struct kobject * k, struct dentry * p,
101 down(&p->d_inode->i_sem); 101 down(&p->d_inode->i_sem);
102 *d = sysfs_get_dentry(p,n); 102 *d = sysfs_get_dentry(p,n);
103 if (!IS_ERR(*d)) { 103 if (!IS_ERR(*d)) {
104 error = sysfs_create(*d, mode, init_dir); 104 error = sysfs_make_dirent(p->d_fsdata, *d, k, mode, SYSFS_DIR);
105 if (!error) { 105 if (!error) {
106 error = sysfs_make_dirent(p->d_fsdata, *d, k, mode, 106 error = sysfs_create(*d, mode, init_dir);
107 SYSFS_DIR);
108 if (!error) { 107 if (!error) {
109 p->d_inode->i_nlink++; 108 p->d_inode->i_nlink++;
110 (*d)->d_op = &sysfs_dentry_ops; 109 (*d)->d_op = &sysfs_dentry_ops;
111 d_rehash(*d); 110 d_rehash(*d);
112 } 111 }
113 } 112 }
114 if (error && (error != -EEXIST)) 113 if (error && (error != -EEXIST)) {
114 sysfs_put((*d)->d_fsdata);
115 d_drop(*d); 115 d_drop(*d);
116 }
116 dput(*d); 117 dput(*d);
117 } else 118 } else
118 error = PTR_ERR(*d); 119 error = PTR_ERR(*d);
@@ -171,17 +172,19 @@ static int sysfs_attach_attr(struct sysfs_dirent * sd, struct dentry * dentry)
171 init = init_file; 172 init = init_file;
172 } 173 }
173 174
175 dentry->d_fsdata = sysfs_get(sd);
176 sd->s_dentry = dentry;
174 error = sysfs_create(dentry, (attr->mode & S_IALLUGO) | S_IFREG, init); 177 error = sysfs_create(dentry, (attr->mode & S_IALLUGO) | S_IFREG, init);
175 if (error) 178 if (error) {
179 sysfs_put(sd);
176 return error; 180 return error;
181 }
177 182
178 if (bin_attr) { 183 if (bin_attr) {
179 dentry->d_inode->i_size = bin_attr->size; 184 dentry->d_inode->i_size = bin_attr->size;
180 dentry->d_inode->i_fop = &bin_fops; 185 dentry->d_inode->i_fop = &bin_fops;
181 } 186 }
182 dentry->d_op = &sysfs_dentry_ops; 187 dentry->d_op = &sysfs_dentry_ops;
183 dentry->d_fsdata = sysfs_get(sd);
184 sd->s_dentry = dentry;
185 d_rehash(dentry); 188 d_rehash(dentry);
186 189
187 return 0; 190 return 0;
@@ -191,13 +194,15 @@ static int sysfs_attach_link(struct sysfs_dirent * sd, struct dentry * dentry)
191{ 194{
192 int err = 0; 195 int err = 0;
193 196
197 dentry->d_fsdata = sysfs_get(sd);
198 sd->s_dentry = dentry;
194 err = sysfs_create(dentry, S_IFLNK|S_IRWXUGO, init_symlink); 199 err = sysfs_create(dentry, S_IFLNK|S_IRWXUGO, init_symlink);
195 if (!err) { 200 if (!err) {
196 dentry->d_op = &sysfs_dentry_ops; 201 dentry->d_op = &sysfs_dentry_ops;
197 dentry->d_fsdata = sysfs_get(sd);
198 sd->s_dentry = dentry;
199 d_rehash(dentry); 202 d_rehash(dentry);
200 } 203 } else
204 sysfs_put(sd);
205
201 return err; 206 return err;
202} 207}
203 208
@@ -228,6 +233,7 @@ static struct dentry * sysfs_lookup(struct inode *dir, struct dentry *dentry,
228 233
229struct inode_operations sysfs_dir_inode_operations = { 234struct inode_operations sysfs_dir_inode_operations = {
230 .lookup = sysfs_lookup, 235 .lookup = sysfs_lookup,
236 .setattr = sysfs_setattr,
231}; 237};
232 238
233static void remove_dir(struct dentry * d) 239static void remove_dir(struct dentry * d)
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index 364208071e17..849aac115460 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -23,7 +23,7 @@ subsys_attr_show(struct kobject * kobj, struct attribute * attr, char * page)
23{ 23{
24 struct subsystem * s = to_subsys(kobj); 24 struct subsystem * s = to_subsys(kobj);
25 struct subsys_attribute * sattr = to_sattr(attr); 25 struct subsys_attribute * sattr = to_sattr(attr);
26 ssize_t ret = 0; 26 ssize_t ret = -EIO;
27 27
28 if (sattr->show) 28 if (sattr->show)
29 ret = sattr->show(s,page); 29 ret = sattr->show(s,page);
@@ -36,7 +36,7 @@ subsys_attr_store(struct kobject * kobj, struct attribute * attr,
36{ 36{
37 struct subsystem * s = to_subsys(kobj); 37 struct subsystem * s = to_subsys(kobj);
38 struct subsys_attribute * sattr = to_sattr(attr); 38 struct subsys_attribute * sattr = to_sattr(attr);
39 ssize_t ret = 0; 39 ssize_t ret = -EIO;
40 40
41 if (sattr->store) 41 if (sattr->store)
42 ret = sattr->store(s,page,count); 42 ret = sattr->store(s,page,count);
@@ -182,7 +182,7 @@ fill_write_buffer(struct sysfs_buffer * buffer, const char __user * buf, size_t
182 return -ENOMEM; 182 return -ENOMEM;
183 183
184 if (count >= PAGE_SIZE) 184 if (count >= PAGE_SIZE)
185 count = PAGE_SIZE - 1; 185 count = PAGE_SIZE;
186 error = copy_from_user(buffer->page,buf,count); 186 error = copy_from_user(buffer->page,buf,count);
187 buffer->needs_read_fill = 1; 187 buffer->needs_read_fill = 1;
188 return error ? -EFAULT : count; 188 return error ? -EFAULT : count;
diff --git a/fs/sysfs/inode.c b/fs/sysfs/inode.c
index aff7b2dfa8ee..565cac1d4200 100644
--- a/fs/sysfs/inode.c
+++ b/fs/sysfs/inode.c
@@ -26,18 +26,107 @@ static struct backing_dev_info sysfs_backing_dev_info = {
26 .capabilities = BDI_CAP_NO_ACCT_DIRTY | BDI_CAP_NO_WRITEBACK, 26 .capabilities = BDI_CAP_NO_ACCT_DIRTY | BDI_CAP_NO_WRITEBACK,
27}; 27};
28 28
29struct inode * sysfs_new_inode(mode_t mode) 29static struct inode_operations sysfs_inode_operations ={
30 .setattr = sysfs_setattr,
31};
32
33int sysfs_setattr(struct dentry * dentry, struct iattr * iattr)
34{
35 struct inode * inode = dentry->d_inode;
36 struct sysfs_dirent * sd = dentry->d_fsdata;
37 struct iattr * sd_iattr;
38 unsigned int ia_valid = iattr->ia_valid;
39 int error;
40
41 if (!sd)
42 return -EINVAL;
43
44 sd_iattr = sd->s_iattr;
45
46 error = inode_change_ok(inode, iattr);
47 if (error)
48 return error;
49
50 error = inode_setattr(inode, iattr);
51 if (error)
52 return error;
53
54 if (!sd_iattr) {
55 /* setting attributes for the first time, allocate now */
56 sd_iattr = kmalloc(sizeof(struct iattr), GFP_KERNEL);
57 if (!sd_iattr)
58 return -ENOMEM;
59 /* assign default attributes */
60 memset(sd_iattr, 0, sizeof(struct iattr));
61 sd_iattr->ia_mode = sd->s_mode;
62 sd_iattr->ia_uid = 0;
63 sd_iattr->ia_gid = 0;
64 sd_iattr->ia_atime = sd_iattr->ia_mtime = sd_iattr->ia_ctime = CURRENT_TIME;
65 sd->s_iattr = sd_iattr;
66 }
67
68 /* attributes were changed atleast once in past */
69
70 if (ia_valid & ATTR_UID)
71 sd_iattr->ia_uid = iattr->ia_uid;
72 if (ia_valid & ATTR_GID)
73 sd_iattr->ia_gid = iattr->ia_gid;
74 if (ia_valid & ATTR_ATIME)
75 sd_iattr->ia_atime = timespec_trunc(iattr->ia_atime,
76 inode->i_sb->s_time_gran);
77 if (ia_valid & ATTR_MTIME)
78 sd_iattr->ia_mtime = timespec_trunc(iattr->ia_mtime,
79 inode->i_sb->s_time_gran);
80 if (ia_valid & ATTR_CTIME)
81 sd_iattr->ia_ctime = timespec_trunc(iattr->ia_ctime,
82 inode->i_sb->s_time_gran);
83 if (ia_valid & ATTR_MODE) {
84 umode_t mode = iattr->ia_mode;
85
86 if (!in_group_p(inode->i_gid) && !capable(CAP_FSETID))
87 mode &= ~S_ISGID;
88 sd_iattr->ia_mode = mode;
89 }
90
91 return error;
92}
93
94static inline void set_default_inode_attr(struct inode * inode, mode_t mode)
95{
96 inode->i_mode = mode;
97 inode->i_uid = 0;
98 inode->i_gid = 0;
99 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
100}
101
102static inline void set_inode_attr(struct inode * inode, struct iattr * iattr)
103{
104 inode->i_mode = iattr->ia_mode;
105 inode->i_uid = iattr->ia_uid;
106 inode->i_gid = iattr->ia_gid;
107 inode->i_atime = iattr->ia_atime;
108 inode->i_mtime = iattr->ia_mtime;
109 inode->i_ctime = iattr->ia_ctime;
110}
111
112struct inode * sysfs_new_inode(mode_t mode, struct sysfs_dirent * sd)
30{ 113{
31 struct inode * inode = new_inode(sysfs_sb); 114 struct inode * inode = new_inode(sysfs_sb);
32 if (inode) { 115 if (inode) {
33 inode->i_mode = mode;
34 inode->i_uid = 0;
35 inode->i_gid = 0;
36 inode->i_blksize = PAGE_CACHE_SIZE; 116 inode->i_blksize = PAGE_CACHE_SIZE;
37 inode->i_blocks = 0; 117 inode->i_blocks = 0;
38 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
39 inode->i_mapping->a_ops = &sysfs_aops; 118 inode->i_mapping->a_ops = &sysfs_aops;
40 inode->i_mapping->backing_dev_info = &sysfs_backing_dev_info; 119 inode->i_mapping->backing_dev_info = &sysfs_backing_dev_info;
120 inode->i_op = &sysfs_inode_operations;
121
122 if (sd->s_iattr) {
123 /* sysfs_dirent has non-default attributes
124 * get them for the new inode from persistent copy
125 * in sysfs_dirent
126 */
127 set_inode_attr(inode, sd->s_iattr);
128 } else
129 set_default_inode_attr(inode, mode);
41 } 130 }
42 return inode; 131 return inode;
43} 132}
@@ -48,7 +137,8 @@ int sysfs_create(struct dentry * dentry, int mode, int (*init)(struct inode *))
48 struct inode * inode = NULL; 137 struct inode * inode = NULL;
49 if (dentry) { 138 if (dentry) {
50 if (!dentry->d_inode) { 139 if (!dentry->d_inode) {
51 if ((inode = sysfs_new_inode(mode))) { 140 struct sysfs_dirent * sd = dentry->d_fsdata;
141 if ((inode = sysfs_new_inode(mode, sd))) {
52 if (dentry->d_parent && dentry->d_parent->d_inode) { 142 if (dentry->d_parent && dentry->d_parent->d_inode) {
53 struct inode *p_inode = dentry->d_parent->d_inode; 143 struct inode *p_inode = dentry->d_parent->d_inode;
54 p_inode->i_mtime = p_inode->i_ctime = CURRENT_TIME; 144 p_inode->i_mtime = p_inode->i_ctime = CURRENT_TIME;
diff --git a/fs/sysfs/mount.c b/fs/sysfs/mount.c
index 5c805bb1a4b7..f1117e885bd6 100644
--- a/fs/sysfs/mount.c
+++ b/fs/sysfs/mount.c
@@ -28,6 +28,7 @@ static struct sysfs_dirent sysfs_root = {
28 .s_children = LIST_HEAD_INIT(sysfs_root.s_children), 28 .s_children = LIST_HEAD_INIT(sysfs_root.s_children),
29 .s_element = NULL, 29 .s_element = NULL,
30 .s_type = SYSFS_ROOT, 30 .s_type = SYSFS_ROOT,
31 .s_iattr = NULL,
31}; 32};
32 33
33static int sysfs_fill_super(struct super_block *sb, void *data, int silent) 34static int sysfs_fill_super(struct super_block *sb, void *data, int silent)
@@ -42,7 +43,8 @@ static int sysfs_fill_super(struct super_block *sb, void *data, int silent)
42 sb->s_time_gran = 1; 43 sb->s_time_gran = 1;
43 sysfs_sb = sb; 44 sysfs_sb = sb;
44 45
45 inode = sysfs_new_inode(S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO); 46 inode = sysfs_new_inode(S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
47 &sysfs_root);
46 if (inode) { 48 if (inode) {
47 inode->i_op = &sysfs_dir_inode_operations; 49 inode->i_op = &sysfs_dir_inode_operations;
48 inode->i_fop = &sysfs_dir_operations; 50 inode->i_fop = &sysfs_dir_operations;
diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
index dfdf70174354..fae57c83a722 100644
--- a/fs/sysfs/symlink.c
+++ b/fs/sysfs/symlink.c
@@ -43,7 +43,7 @@ static void fill_object_path(struct kobject * kobj, char * buffer, int length)
43 } 43 }
44} 44}
45 45
46static int sysfs_add_link(struct dentry * parent, char * name, struct kobject * target) 46static int sysfs_add_link(struct dentry * parent, const char * name, struct kobject * target)
47{ 47{
48 struct sysfs_dirent * parent_sd = parent->d_fsdata; 48 struct sysfs_dirent * parent_sd = parent->d_fsdata;
49 struct sysfs_symlink * sl; 49 struct sysfs_symlink * sl;
@@ -79,7 +79,7 @@ exit1:
79 * @target: object we're pointing to. 79 * @target: object we're pointing to.
80 * @name: name of the symlink. 80 * @name: name of the symlink.
81 */ 81 */
82int sysfs_create_link(struct kobject * kobj, struct kobject * target, char * name) 82int sysfs_create_link(struct kobject * kobj, struct kobject * target, const char * name)
83{ 83{
84 struct dentry * dentry = kobj->dentry; 84 struct dentry * dentry = kobj->dentry;
85 int error = 0; 85 int error = 0;
@@ -99,13 +99,13 @@ int sysfs_create_link(struct kobject * kobj, struct kobject * target, char * nam
99 * @name: name of the symlink to remove. 99 * @name: name of the symlink to remove.
100 */ 100 */
101 101
102void sysfs_remove_link(struct kobject * kobj, char * name) 102void sysfs_remove_link(struct kobject * kobj, const char * name)
103{ 103{
104 sysfs_hash_and_remove(kobj->dentry,name); 104 sysfs_hash_and_remove(kobj->dentry,name);
105} 105}
106 106
107static int sysfs_get_target_path(struct kobject * kobj, struct kobject * target, 107static int sysfs_get_target_path(struct kobject * kobj, struct kobject * target,
108 char *path) 108 char *path)
109{ 109{
110 char * s; 110 char * s;
111 int depth, size; 111 int depth, size;
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h
index a8a24a0c0b3b..29da6f5f07c8 100644
--- a/fs/sysfs/sysfs.h
+++ b/fs/sysfs/sysfs.h
@@ -2,7 +2,7 @@
2extern struct vfsmount * sysfs_mount; 2extern struct vfsmount * sysfs_mount;
3extern kmem_cache_t *sysfs_dir_cachep; 3extern kmem_cache_t *sysfs_dir_cachep;
4 4
5extern struct inode * sysfs_new_inode(mode_t mode); 5extern struct inode * sysfs_new_inode(mode_t mode, struct sysfs_dirent *);
6extern int sysfs_create(struct dentry *, int mode, int (*init)(struct inode *)); 6extern int sysfs_create(struct dentry *, int mode, int (*init)(struct inode *));
7 7
8extern int sysfs_make_dirent(struct sysfs_dirent *, struct dentry *, void *, 8extern int sysfs_make_dirent(struct sysfs_dirent *, struct dentry *, void *,
@@ -17,6 +17,7 @@ extern void sysfs_remove_subdir(struct dentry *);
17 17
18extern const unsigned char * sysfs_get_name(struct sysfs_dirent *sd); 18extern const unsigned char * sysfs_get_name(struct sysfs_dirent *sd);
19extern void sysfs_drop_dentry(struct sysfs_dirent *sd, struct dentry *parent); 19extern void sysfs_drop_dentry(struct sysfs_dirent *sd, struct dentry *parent);
20extern int sysfs_setattr(struct dentry *dentry, struct iattr *iattr);
20 21
21extern struct rw_semaphore sysfs_rename_sem; 22extern struct rw_semaphore sysfs_rename_sem;
22extern struct super_block * sysfs_sb; 23extern struct super_block * sysfs_sb;
@@ -75,6 +76,7 @@ static inline void release_sysfs_dirent(struct sysfs_dirent * sd)
75 kobject_put(sl->target_kobj); 76 kobject_put(sl->target_kobj);
76 kfree(sl); 77 kfree(sl);
77 } 78 }
79 kfree(sd->s_iattr);
78 kmem_cache_free(sysfs_dir_cachep, sd); 80 kmem_cache_free(sysfs_dir_cachep, sd);
79} 81}
80 82
diff --git a/include/asm-arm/arch-aaec2000/aaec2000.h b/include/asm-arm/arch-aaec2000/aaec2000.h
new file mode 100644
index 000000000000..0e9b7e18af05
--- /dev/null
+++ b/include/asm-arm/arch-aaec2000/aaec2000.h
@@ -0,0 +1,151 @@
1/*
2 * linux/include/asm-arm/arch-aaec2000/aaec2000.h
3 *
4 * AAEC-2000 registers definition
5 *
6 * Copyright (c) 2005 Nicolas Bellido Y Ortega
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#ifndef __ASM_ARCH_AAEC2000_H
14#define __ASM_ARCH_AAEC2000_H
15
16#ifndef __ASM_ARCH_HARDWARE_H
17#error You must include hardware.h not this file
18#endif /* __ASM_ARCH_HARDWARE_H */
19
20/* Interrupt controller */
21#define IRQ_BASE __REG(0x80000500)
22#define IRQ_INTSR __REG(0x80000500) /* Int Status Register */
23#define IRQ_INTRSR __REG(0x80000504) /* Int Raw (unmasked) Status */
24#define IRQ_INTENS __REG(0x80000508) /* Int Enable Set */
25#define IRQ_INTENC __REG(0x8000050c) /* Int Enable Clear */
26
27/* UART 1 */
28#define UART1_BASE __REG(0x80000600)
29#define UART1_DR __REG(0x80000600) /* Data/FIFO Register */
30#define UART1_LCR __REG(0x80000604) /* Link Control Register */
31#define UART1_BRCR __REG(0x80000608) /* Baud Rate Control Register */
32#define UART1_CR __REG(0x8000060c) /* Control Register */
33#define UART1_SR __REG(0x80000610) /* Status Register */
34#define UART1_INT __REG(0x80000614) /* Interrupt Status Register */
35#define UART1_INTM __REG(0x80000618) /* Interrupt Mask Register */
36#define UART1_INTRES __REG(0x8000061c) /* Int Result (masked status) Register */
37
38/* UART 2 */
39#define UART2_BASE __REG(0x80000700)
40#define UART2_DR __REG(0x80000700) /* Data/FIFO Register */
41#define UART2_LCR __REG(0x80000704) /* Link Control Register */
42#define UART2_BRCR __REG(0x80000708) /* Baud Rate Control Register */
43#define UART2_CR __REG(0x8000070c) /* Control Register */
44#define UART2_SR __REG(0x80000710) /* Status Register */
45#define UART2_INT __REG(0x80000714) /* Interrupt Status Register */
46#define UART2_INTM __REG(0x80000718) /* Interrupt Mask Register */
47#define UART2_INTRES __REG(0x8000071c) /* Int Result (masked status) Register */
48
49/* UART 3 */
50#define UART3_BASE __REG(0x80000800)
51#define UART3_DR __REG(0x80000800) /* Data/FIFO Register */
52#define UART3_LCR __REG(0x80000804) /* Link Control Register */
53#define UART3_BRCR __REG(0x80000808) /* Baud Rate Control Register */
54#define UART3_CR __REG(0x8000080c) /* Control Register */
55#define UART3_SR __REG(0x80000810) /* Status Register */
56#define UART3_INT __REG(0x80000814) /* Interrupt Status Register */
57#define UART3_INTM __REG(0x80000818) /* Interrupt Mask Register */
58#define UART3_INTRES __REG(0x8000081c) /* Int Result (masked status) Register */
59
60/* These are used in some places */
61#define _UART1_BASE __PREG(UART1_BASE)
62#define _UART2_BASE __PREG(UART2_BASE)
63#define _UART3_BASE __PREG(UART3_BASE)
64
65/* UART Registers Offsets */
66#define UART_DR 0x00
67#define UART_LCR 0x04
68#define UART_BRCR 0x08
69#define UART_CR 0x0c
70#define UART_SR 0x10
71#define UART_INT 0x14
72#define UART_INTM 0x18
73#define UART_INTRES 0x1c
74
75/* UART_LCR Bitmask */
76#define UART_LCR_BRK (1 << 0) /* Send Break */
77#define UART_LCR_PEN (1 << 1) /* Parity Enable */
78#define UART_LCR_EP (1 << 2) /* Even/Odd Parity */
79#define UART_LCR_S2 (1 << 3) /* One/Two Stop bits */
80#define UART_LCR_FIFO (1 << 4) /* FIFO Enable */
81#define UART_LCR_WL5 (0 << 5) /* Word Length - 5 bits */
82#define UART_LCR_WL6 (1 << 5) /* Word Length - 6 bits */
83#define UART_LCR_WL7 (1 << 6) /* Word Length - 7 bits */
84#define UART_LCR_WL8 (1 << 7) /* Word Length - 8 bits */
85
86/* UART_CR Bitmask */
87#define UART_CR_EN (1 << 0) /* UART Enable */
88#define UART_CR_SIR (1 << 1) /* IrDA SIR Enable */
89#define UART_CR_SIRLP (1 << 2) /* Low Power IrDA Enable */
90#define UART_CR_RXP (1 << 3) /* Receive Pin Polarity */
91#define UART_CR_TXP (1 << 4) /* Transmit Pin Polarity */
92#define UART_CR_MXP (1 << 5) /* Modem Pin Polarity */
93#define UART_CR_LOOP (1 << 6) /* Loopback Mode */
94
95/* UART_SR Bitmask */
96#define UART_SR_CTS (1 << 0) /* Clear To Send Status */
97#define UART_SR_DSR (1 << 1) /* Data Set Ready Status */
98#define UART_SR_DCD (1 << 2) /* Data Carrier Detect Status */
99#define UART_SR_TxBSY (1 << 3) /* Transmitter Busy Status */
100#define UART_SR_RxFE (1 << 4) /* Receive FIFO Empty Status */
101#define UART_SR_TxFF (1 << 5) /* Transmit FIFO Full Status */
102#define UART_SR_RxFF (1 << 6) /* Receive FIFO Full Status */
103#define UART_SR_TxFE (1 << 7) /* Transmit FIFO Empty Status */
104
105/* UART_INT Bitmask */
106#define UART_INT_RIS (1 << 0) /* Rx Interrupt */
107#define UART_INT_TIS (1 << 1) /* Tx Interrupt */
108#define UART_INT_MIS (1 << 2) /* Modem Interrupt */
109#define UART_INT_RTIS (1 << 3) /* Receive Timeout Interrupt */
110
111/* Timer 1 */
112#define TIMER1_BASE __REG(0x80000c00)
113#define TIMER1_LOAD __REG(0x80000c00) /* Timer 1 Load Register */
114#define TIMER1_VAL __REG(0x80000c04) /* Timer 1 Value Register */
115#define TIMER1_CTRL __REG(0x80000c08) /* Timer 1 Control Register */
116#define TIMER1_CLEAR __REG(0x80000c0c) /* Timer 1 Clear Register */
117
118/* Timer 2 */
119#define TIMER2_BASE __REG(0x80000d00)
120#define TIMER2_LOAD __REG(0x80000d00) /* Timer 2 Load Register */
121#define TIMER2_VAL __REG(0x80000d04) /* Timer 2 Value Register */
122#define TIMER2_CTRL __REG(0x80000d08) /* Timer 2 Control Register */
123#define TIMER2_CLEAR __REG(0x80000d0c) /* Timer 2 Clear Register */
124
125/* Timer 3 */
126#define TIMER3_BASE __REG(0x80000e00)
127#define TIMER3_LOAD __REG(0x80000e00) /* Timer 3 Load Register */
128#define TIMER3_VAL __REG(0x80000e04) /* Timer 3 Value Register */
129#define TIMER3_CTRL __REG(0x80000e08) /* Timer 3 Control Register */
130#define TIMER3_CLEAR __REG(0x80000e0c) /* Timer 3 Clear Register */
131
132/* Timer Control register bits */
133#define TIMER_CTRL_ENABLE (1 << 7) /* Enable (Start° Timer */
134#define TIMER_CTRL_PERIODIC (1 << 6) /* Periodic Running Mode */
135#define TIMER_CTRL_FREE_RUNNING (0 << 6) /* Normal Running Mode */
136#define TIMER_CTRL_CLKSEL_508K (1 << 3) /* 508KHz Clock select (Timer 1, 2) */
137#define TIMER_CTRL_CLKSEL_2K (0 << 3) /* 2KHz Clock Select (Timer 1, 2)*/
138
139/* Power and State Control */
140#define POWER_BASE __REG(0x80000400)
141#define POWER_PWRSR __REG(0x80000400) /* Power Status Register */
142#define POWER_PWRCNT __REG(0x80000404) /* Power/Clock control */
143#define POWER_HALT __REG(0x80000408) /* Power Idle Mode */
144#define POWER_STDBY __REG(0x8000040c) /* Power Standby Mode */
145#define POWER_BLEOI __REG(0x80000410) /* Battery Low End of Interrupt */
146#define POWER_MCEOI __REG(0x80000414) /* Media Changed EoI */
147#define POWER_TEOI __REG(0x80000418) /* Tick EoI */
148#define POWER_STFCLR __REG(0x8000041c) /* NbFlg, RSTFlg, PFFlg, CLDFlg Clear */
149#define POWER_CLKSET __REG(0x80000420) /* Clock Speed Control */
150
151#endif /* __ARM_ARCH_AAEC2000_H */
diff --git a/include/asm-arm/arch-aaec2000/debug-macro.S b/include/asm-arm/arch-aaec2000/debug-macro.S
new file mode 100644
index 000000000000..e4f1fa539a74
--- /dev/null
+++ b/include/asm-arm/arch-aaec2000/debug-macro.S
@@ -0,0 +1,36 @@
1/* linux/include/asm-arm/arch-aaec2000/debug-macro.S
2 *
3 * Debugging macro include header
4 *
5 * Copyright (c) 2005 Nicolas Bellido Y Ortega
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12 .macro addruart,rx
13 mrc p15, 0, \rx, c1, c0
14 tst \rx, #1 @ MMU enabled?
15 moveq \rx, #0x80000000 @ physical
16 movne \rx, #io_p2v(0x80000000) @ virtual
17 orr \rx, \rx, #0x00000800
18 .endm
19
20 .macro senduart,rd,rx
21 str \rd, [\rx, #0]
22 .endm
23
24 .macro busyuart,rd,rx
251002: ldr \rd, [\rx, #0x10]
26 tst \rd, #(1 << 7)
27 beq 1002b
28 .endm
29
30 .macro waituart,rd,rx
31#if 0
321001: ldr \rd, [\rx, #0x10]
33 tst \rd, #(1 << 5)
34 beq 1001b
35#endif
36 .endm
diff --git a/include/asm-arm/arch-aaec2000/dma.h b/include/asm-arm/arch-aaec2000/dma.h
new file mode 100644
index 000000000000..28c890b4a1d3
--- /dev/null
+++ b/include/asm-arm/arch-aaec2000/dma.h
@@ -0,0 +1,17 @@
1/*
2 * linux/include/asm-arm/arch-aaec2000/dma.h
3 *
4 * Copyright (c) 2005 Nicolas Bellido Y Ortega
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#ifndef __ASM_ARCH_DMA_H
12#define __ASM_ARCH_DMA_H
13
14#define MAX_DMA_ADDRESS 0xffffffff
15#define MAX_DMA_CHANNELS 0
16
17#endif
diff --git a/include/asm-arm/arch-aaec2000/entry-macro.S b/include/asm-arm/arch-aaec2000/entry-macro.S
new file mode 100644
index 000000000000..df31313ab07e
--- /dev/null
+++ b/include/asm-arm/arch-aaec2000/entry-macro.S
@@ -0,0 +1,33 @@
1/*
2 * linux/include/asm-arm/arch-aaec2000/entry-macro.S
3 *
4 * Low-level IRQ helper for aaec-2000 based platforms
5 *
6 * Copyright (c) 2005 Nicolas Bellido Y Ortega
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 */
13
14 .macro disable_fiq
15 .endm
16
17 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
18 mov r4, #0xf8000000
19 add r4, r4, #0x00000500
20 mov \base, r4
21 ldr \irqstat, [\base, #0]
22 cmp \irqstat, #0
23 bne 1001f
24 ldr \irqnr, =NR_IRQS+1
25 b 1003f
261001: mov \irqnr, #0
271002: ands \tmp, \irqstat, #1
28 mov \irqstat, \irqstat, LSR #1
29 add \irqnr, \irqnr, #1
30 beq 1002b
31 sub \irqnr, \irqnr, #1
321003:
33 .endm
diff --git a/include/asm-arm/arch-aaec2000/hardware.h b/include/asm-arm/arch-aaec2000/hardware.h
new file mode 100644
index 000000000000..4c37219e030e
--- /dev/null
+++ b/include/asm-arm/arch-aaec2000/hardware.h
@@ -0,0 +1,49 @@
1/*
2 * linux/include/asm-arm/arch-aaec2000/hardware.h
3 *
4 * Copyright (c) 2005 Nicolas Bellido Y Ortega
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#ifndef __ASM_ARCH_HARDWARE_H
12#define __ASM_ARCH_HARDWARE_H
13
14#include <linux/config.h>
15
16/* The kernel is loaded at physical address 0xf8000000.
17 * We map the IO space a bit after
18 */
19#define PIO_APB_BASE 0x80000000
20#define VIO_APB_BASE 0xf8000000
21#define IO_APB_LENGTH 0x2000
22#define PIO_AHB_BASE 0x80002000
23#define VIO_AHB_BASE 0xf8002000
24#define IO_AHB_LENGTH 0x2000
25
26#define VIO_BASE VIO_APB_BASE
27#define PIO_BASE PIO_APB_BASE
28
29#define io_p2v(x) ( (x) - PIO_BASE + VIO_BASE )
30#define io_v2p(x) ( (x) + PIO_BASE - VIO_BASE )
31
32#ifndef __ASSEMBLY__
33
34#include <asm/types.h>
35
36/* FIXME: Is it needed to optimize this a la pxa ?? */
37#define __REG(x) (*((volatile u32 *)io_p2v(x)))
38#define __PREG(x) (io_v2p((u32)&(x)))
39
40#else /* __ASSEMBLY__ */
41
42#define __REG(x) io_p2v(x)
43#define __PREG(x) io_v2p(x)
44
45#endif
46
47#include "aaec2000.h"
48
49#endif /* __ASM_ARCH_HARDWARE_H */
diff --git a/include/asm-arm/arch-aaec2000/io.h b/include/asm-arm/arch-aaec2000/io.h
new file mode 100644
index 000000000000..c58a8d10425a
--- /dev/null
+++ b/include/asm-arm/arch-aaec2000/io.h
@@ -0,0 +1,19 @@
1/*
2 * linux/include/asm-arm/arch-aaec2000/io.h
3 *
4 * Copied from asm/arch/sa1100/io.h
5 */
6#ifndef __ASM_ARM_ARCH_IO_H
7#define __ASM_ARM_ARCH_IO_H
8
9#define IO_SPACE_LIMIT 0xffffffff
10
11/*
12 * We don't actually have real ISA nor PCI buses, but there is so many
13 * drivers out there that might just work if we fake them...
14 */
15#define __io(a) ((void __iomem *)(a))
16#define __mem_pci(a) (a)
17#define __mem_isa(a) (a)
18
19#endif
diff --git a/include/asm-arm/arch-aaec2000/irqs.h b/include/asm-arm/arch-aaec2000/irqs.h
new file mode 100644
index 000000000000..de252220e806
--- /dev/null
+++ b/include/asm-arm/arch-aaec2000/irqs.h
@@ -0,0 +1,46 @@
1/*
2 * linux/include/asm-arm/arch-aaec2000/irqs.h
3 *
4 * Copyright (c) 2005 Nicolas Bellido Y Ortega
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#ifndef __ASM_ARCH_IRQS_H
12#define __ASM_ARCH_IRQS_H
13
14
15#define INT_GPIOF0_FIQ 0 /* External GPIO Port F O Fast Interrupt Input */
16#define INT_BL_FIQ 1 /* Battery Low Fast Interrupt */
17#define INT_WE_FIQ 2 /* Watchdog Expired Fast Interrupt */
18#define INT_MV_FIQ 3 /* Media Changed Interrupt */
19#define INT_SC 4 /* Sound Codec Interrupt */
20#define INT_GPIO1 5 /* GPIO Port F Configurable Int 1 */
21#define INT_GPIO2 6 /* GPIO Port F Configurable Int 2 */
22#define INT_GPIO3 7 /* GPIO Port F Configurable Int 3 */
23#define INT_TMR1_OFL 8 /* Timer 1 Overflow Interrupt */
24#define INT_TMR2_OFL 9 /* Timer 2 Overflow Interrupt */
25#define INT_RTC_CM 10 /* RTC Compare Match Interrupt */
26#define INT_TICK 11 /* 64Hz Tick Interrupt */
27#define INT_UART1 12 /* UART1 Interrupt */
28#define INT_UART2 13 /* UART2 & Modem State Changed Interrupt */
29#define INT_LCD 14 /* LCD Interrupt */
30#define INT_SSI 15 /* SSI End of Transfer Interrupt */
31#define INT_UART3 16 /* UART3 Interrupt */
32#define INT_SCI 17 /* SCI Interrupt */
33#define INT_AAC 18 /* Advanced Audio Codec Interrupt */
34#define INT_MMC 19 /* MMC Interrupt */
35#define INT_USB 20 /* USB Interrupt */
36#define INT_DMA 21 /* DMA Interrupt */
37#define INT_TMR3_UOFL 22 /* Timer 3 Underflow Interrupt */
38#define INT_GPIO4 23 /* GPIO Port F Configurable Int 4 */
39#define INT_GPIO5 24 /* GPIO Port F Configurable Int 4 */
40#define INT_GPIO6 25 /* GPIO Port F Configurable Int 4 */
41#define INT_GPIO7 26 /* GPIO Port F Configurable Int 4 */
42#define INT_BMI 27 /* BMI Interrupt */
43
44#define NR_IRQS (INT_BMI + 1)
45
46#endif /* __ASM_ARCH_IRQS_H */
diff --git a/include/asm-arm/arch-aaec2000/memory.h b/include/asm-arm/arch-aaec2000/memory.h
new file mode 100644
index 000000000000..681b6a6171a1
--- /dev/null
+++ b/include/asm-arm/arch-aaec2000/memory.h
@@ -0,0 +1,73 @@
1/*
2 * linux/include/asm-arm/arch-aaec2000/memory.h
3 *
4 * Copyright (c) 2005 Nicolas Bellido Y Ortega
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#ifndef __ASM_ARCH_MEMORY_H
12#define __ASM_ARCH_MEMORY_H
13
14#include <linux/config.h>
15
16#define PHYS_OFFSET (0xf0000000UL)
17
18#define __virt_to_bus(x) __virt_to_phys(x)
19#define __bus_to_virt(x) __phys_to_virt(x)
20
21#ifdef CONFIG_DISCONTIGMEM
22
23/*
24 * The nodes are the followings:
25 *
26 * node 0: 0xf000.0000 - 0xf3ff.ffff
27 * node 1: 0xf400.0000 - 0xf7ff.ffff
28 * node 2: 0xf800.0000 - 0xfbff.ffff
29 * node 3: 0xfc00.0000 - 0xffff.ffff
30 */
31
32/*
33 * Given a kernel address, find the home node of the underlying memory.
34 */
35#define KVADDR_TO_NID(addr) \
36 (((unsigned long)(addr) - PAGE_OFFSET) >> NODE_MAX_MEM_SHIFT)
37
38/*
39 * Given a page frame number, convert it to a node id.
40 */
41#define PFN_TO_NID(pfn) \
42 (((pfn) - PHYS_PFN_OFFSET) >> (NODE_MAX_MEM_SHIFT - PAGE_SHIFT))
43
44/*
45 * Given a kaddr, ADDR_TO_MAPBASE finds the owning node of the memory
46 * and return the mem_map of that node.
47 */
48#define ADDR_TO_MAPBASE(kaddr) NODE_MEM_MAP(KVADDR_TO_NID(kaddr))
49
50/*
51 * Given a page frame number, find the owning node of the memory
52 * and return the mem_map of that node.
53 */
54#define PFN_TO_MAPBASE(pfn) NODE_MEM_MAP(PFN_TO_NID(pfn))
55
56/*
57 * Given a kaddr, LOCAL_MEM_MAP finds the owning node of the memory
58 * and returns the index corresponding to the appropriate page in the
59 * node's mem_map.
60 */
61#define LOCAL_MAP_NR(addr) \
62 (((unsigned long)(addr) & (NODE_MAX_MEM_SIZE - 1)) >> PAGE_SHIFT)
63
64#define NODE_MAX_MEM_SHIFT 26
65#define NODE_MAX_MEM_SIZE (1 << NODE_MAX_MEM_SHIFT)
66
67#else
68
69#define PFN_TO_NID(addr) (0)
70
71#endif /* CONFIG_DISCONTIGMEM */
72
73#endif /* __ASM_ARCH_MEMORY_H */
diff --git a/include/asm-arm/arch-aaec2000/param.h b/include/asm-arm/arch-aaec2000/param.h
new file mode 100644
index 000000000000..139936c2faf2
--- /dev/null
+++ b/include/asm-arm/arch-aaec2000/param.h
@@ -0,0 +1,15 @@
1/*
2 * linux/include/asm-arm/arch-aaec2000/param.h
3 *
4 * Copyright (c) 2005 Nicolas Bellido Y Ortega
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#ifndef __ASM_ARCH_PARAM_H
12#define __ASM_ARCH_PARAM_H
13
14#endif /* __ASM_ARCH_PARAM_H */
15
diff --git a/include/asm-arm/arch-aaec2000/system.h b/include/asm-arm/arch-aaec2000/system.h
new file mode 100644
index 000000000000..08de97b407a8
--- /dev/null
+++ b/include/asm-arm/arch-aaec2000/system.h
@@ -0,0 +1,24 @@
1/*
2 * linux/include/asm-arm/arch-aaed2000/system.h
3 *
4 * Copyright (c) 2005 Nicolas Bellido Y Ortega
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#ifndef __ASM_ARCH_SYSTEM_H
12#define __ASM_ARCH_SYSTEM_H
13
14static inline void arch_idle(void)
15{
16 cpu_do_idle();
17}
18
19static inline void arch_reset(char mode)
20{
21 cpu_reset(0);
22}
23
24#endif /* __ASM_ARCH_SYSTEM_H */
diff --git a/include/asm-arm/arch-aaec2000/timex.h b/include/asm-arm/arch-aaec2000/timex.h
new file mode 100644
index 000000000000..f5708b38fb7f
--- /dev/null
+++ b/include/asm-arm/arch-aaec2000/timex.h
@@ -0,0 +1,18 @@
1/*
2 * linux/include/asm-arm/arch-aaec2000/timex.h
3 *
4 * AAEC-2000 Architecture timex specification
5 *
6 * Copyright (c) 2005 Nicolas Bellido Y Ortega
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#ifndef __ASM_ARCH_TIMEX_H
14#define __ASM_ARCH_TIMEX_H
15
16#define CLOCK_TICK_RATE 508000
17
18#endif /* __ASM_ARCH_TIMEX_H */
diff --git a/include/asm-arm/arch-aaec2000/uncompress.h b/include/asm-arm/arch-aaec2000/uncompress.h
new file mode 100644
index 000000000000..fff0c94b75c4
--- /dev/null
+++ b/include/asm-arm/arch-aaec2000/uncompress.h
@@ -0,0 +1,47 @@
1/*
2 * linux/include/asm-arm/arch-aaec2000/uncompress.h
3 *
4 * Copyright (c) 2005 Nicolas Bellido Y Ortega
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#ifndef __ASM_ARCH_UNCOMPRESS_H
12#define __ASM_ARCH_UNCOMPRESS_H
13
14#include "hardware.h"
15
16#define UART(x) (*(volatile unsigned long *)(serial_port + (x)))
17
18static void putstr( const char *s )
19{
20 unsigned long serial_port;
21 do {
22 serial_port = _UART3_BASE;
23 if (UART(UART_CR) & UART_CR_EN) break;
24 serial_port = _UART1_BASE;
25 if (UART(UART_CR) & UART_CR_EN) break;
26 serial_port = _UART2_BASE;
27 if (UART(UART_CR) & UART_CR_EN) break;
28 return;
29 } while (0);
30
31 for (; *s; s++) {
32 /* wait for space in the UART's transmitter */
33 while ((UART(UART_SR) & UART_SR_TxFF));
34 /* send the character out. */
35 UART(UART_DR) = *s;
36 /* if a LF, also do CR... */
37 if (*s == 10) {
38 while ((UART(UART_SR) & UART_SR_TxFF));
39 UART(UART_DR) = 13;
40 }
41 }
42}
43
44#define arch_decomp_setup()
45#define arch_decomp_wdog()
46
47#endif /* __ASM_ARCH_UNCOMPRESS_H */
diff --git a/include/asm-arm/arch-aaec2000/vmalloc.h b/include/asm-arm/arch-aaec2000/vmalloc.h
new file mode 100644
index 000000000000..ecb991e2e4ff
--- /dev/null
+++ b/include/asm-arm/arch-aaec2000/vmalloc.h
@@ -0,0 +1,16 @@
1/*
2 * linux/include/asm-arm/arch-aaec2000/vmalloc.h
3 *
4 * Copyright (c) 2005 Nicolas Bellido Y Ortega
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#ifndef __ASM_ARCH_VMALLOC_H
12#define __ASM_ARCH_VMALLOC_H
13
14#define VMALLOC_END (PAGE_OFFSET + 0x10000000)
15
16#endif /* __ASM_ARCH_VMALLOC_H */
diff --git a/include/asm-arm/arch-ixp2000/ixp2000-regs.h b/include/asm-arm/arch-ixp2000/ixp2000-regs.h
index 6c56708d0ff0..a1d9e181b10f 100644
--- a/include/asm-arm/arch-ixp2000/ixp2000-regs.h
+++ b/include/asm-arm/arch-ixp2000/ixp2000-regs.h
@@ -363,6 +363,7 @@
363#define IXP2000_MIN_REV_MASK 0x0000000F 363#define IXP2000_MIN_REV_MASK 0x0000000F
364#define IXP2000_PROD_ID_MASK 0xFFFFFFFF 364#define IXP2000_PROD_ID_MASK 0xFFFFFFFF
365 365
366#define IXP2000_PRODUCT_ID GLOBAL_REG(0x00)
366#define IXP2000_MISC_CONTROL GLOBAL_REG(0x04) 367#define IXP2000_MISC_CONTROL GLOBAL_REG(0x04)
367#define IXP2000_MSF_CLK_CNTRL GLOBAL_REG(0x08) 368#define IXP2000_MSF_CLK_CNTRL GLOBAL_REG(0x08)
368#define IXP2000_RESET0 GLOBAL_REG(0x0c) 369#define IXP2000_RESET0 GLOBAL_REG(0x0c)
diff --git a/include/asm-arm/arch-versatile/hardware.h b/include/asm-arm/arch-versatile/hardware.h
index d5fb4a251e7f..41c1bee342ad 100644
--- a/include/asm-arm/arch-versatile/hardware.h
+++ b/include/asm-arm/arch-versatile/hardware.h
@@ -25,19 +25,26 @@
25#include <asm/sizes.h> 25#include <asm/sizes.h>
26#include <asm/arch/platform.h> 26#include <asm/arch/platform.h>
27 27
28// FIXME = PCI settings need to be fixed!!!!!
29
30/* 28/*
31 * Similar to above, but for PCI addresses (memory, IO, Config and the 29 * PCI space virtual addresses
32 * V3 chip itself). WARNING: this has to mirror definitions in platform.h
33 */ 30 */
34#define PCI_MEMORY_VADDR 0xe8000000 31#define VERSATILE_PCI_VIRT_BASE 0xe8000000
35#define PCI_CONFIG_VADDR 0xec000000 32#define VERSATILE_PCI_CFG_VIRT_BASE 0xe9000000
36#define PCI_V3_VADDR 0xed000000 33
37#define PCI_IO_VADDR 0xee000000 34#if 0
35#define VERSATILE_PCI_VIRT_MEM_BASE0 0xf4000000
36#define VERSATILE_PCI_VIRT_MEM_BASE1 0xf5000000
37#define VERSATILE_PCI_VIRT_MEM_BASE2 0xf6000000
38
39#define PCIO_BASE VERSATILE_PCI_VIRT_MEM_BASE0
40#define PCIMEM_BASE VERSATILE_PCI_VIRT_MEM_BASE1
41#endif
42
43/* CIK guesswork */
44#define PCIBIOS_MIN_IO 0x44000000
45#define PCIBIOS_MIN_MEM 0x50000000
38 46
39#define PCIO_BASE PCI_IO_VADDR 47#define pcibios_assign_all_busses() 1
40#define PCIMEM_BASE PCI_MEMORY_VADDR
41 48
42/* macro to get at IO space when running virtually */ 49/* macro to get at IO space when running virtually */
43#define IO_ADDRESS(x) (((x) & 0x0fffffff) + (((x) >> 4) & 0x0f000000) + 0xf0000000) 50#define IO_ADDRESS(x) (((x) & 0x0fffffff) + (((x) >> 4) & 0x0f000000) + 0xf0000000)
diff --git a/include/asm-arm/arch-versatile/io.h b/include/asm-arm/arch-versatile/io.h
index dbb7158788fc..9f895bf61494 100644
--- a/include/asm-arm/arch-versatile/io.h
+++ b/include/asm-arm/arch-versatile/io.h
@@ -20,7 +20,7 @@
20#ifndef __ASM_ARM_ARCH_IO_H 20#ifndef __ASM_ARM_ARCH_IO_H
21#define __ASM_ARM_ARCH_IO_H 21#define __ASM_ARM_ARCH_IO_H
22 22
23#define IO_SPACE_LIMIT 0xffff 23#define IO_SPACE_LIMIT 0xffffffff
24 24
25#define __io(a) ((void __iomem *)(a)) 25#define __io(a) ((void __iomem *)(a))
26#define __mem_pci(a) (a) 26#define __mem_pci(a) (a)
diff --git a/include/asm-arm/arch-versatile/platform.h b/include/asm-arm/arch-versatile/platform.h
index a71093e44c58..cbdd9fb96332 100644
--- a/include/asm-arm/arch-versatile/platform.h
+++ b/include/asm-arm/arch-versatile/platform.h
@@ -76,7 +76,7 @@
76#define VERSATILE_SYS_NVFLAGSSET_OFFSET 0x38 76#define VERSATILE_SYS_NVFLAGSSET_OFFSET 0x38
77#define VERSATILE_SYS_NVFLAGSCLR_OFFSET 0x3C 77#define VERSATILE_SYS_NVFLAGSCLR_OFFSET 0x3C
78#define VERSATILE_SYS_RESETCTL_OFFSET 0x40 78#define VERSATILE_SYS_RESETCTL_OFFSET 0x40
79#define VERSATILE_SYS_PICCTL_OFFSET 0x44 79#define VERSATILE_SYS_PCICTL_OFFSET 0x44
80#define VERSATILE_SYS_MCI_OFFSET 0x48 80#define VERSATILE_SYS_MCI_OFFSET 0x48
81#define VERSATILE_SYS_FLASH_OFFSET 0x4C 81#define VERSATILE_SYS_FLASH_OFFSET 0x4C
82#define VERSATILE_SYS_CLCD_OFFSET 0x50 82#define VERSATILE_SYS_CLCD_OFFSET 0x50
@@ -114,7 +114,7 @@
114#define VERSATILE_SYS_NVFLAGSSET (VERSATILE_SYS_BASE + VERSATILE_SYS_NVFLAGSSET_OFFSET) 114#define VERSATILE_SYS_NVFLAGSSET (VERSATILE_SYS_BASE + VERSATILE_SYS_NVFLAGSSET_OFFSET)
115#define VERSATILE_SYS_NVFLAGSCLR (VERSATILE_SYS_BASE + VERSATILE_SYS_NVFLAGSCLR_OFFSET) 115#define VERSATILE_SYS_NVFLAGSCLR (VERSATILE_SYS_BASE + VERSATILE_SYS_NVFLAGSCLR_OFFSET)
116#define VERSATILE_SYS_RESETCTL (VERSATILE_SYS_BASE + VERSATILE_SYS_RESETCTL_OFFSET) 116#define VERSATILE_SYS_RESETCTL (VERSATILE_SYS_BASE + VERSATILE_SYS_RESETCTL_OFFSET)
117#define VERSATILE_SYS_PICCTL (VERSATILE_SYS_BASE + VERSATILE_SYS_PICCTL_OFFSET) 117#define VERSATILE_SYS_PCICTL (VERSATILE_SYS_BASE + VERSATILE_SYS_PCICTL_OFFSET)
118#define VERSATILE_SYS_MCI (VERSATILE_SYS_BASE + VERSATILE_SYS_MCI_OFFSET) 118#define VERSATILE_SYS_MCI (VERSATILE_SYS_BASE + VERSATILE_SYS_MCI_OFFSET)
119#define VERSATILE_SYS_FLASH (VERSATILE_SYS_BASE + VERSATILE_SYS_FLASH_OFFSET) 119#define VERSATILE_SYS_FLASH (VERSATILE_SYS_BASE + VERSATILE_SYS_FLASH_OFFSET)
120#define VERSATILE_SYS_CLCD (VERSATILE_SYS_BASE + VERSATILE_SYS_CLCD_OFFSET) 120#define VERSATILE_SYS_CLCD (VERSATILE_SYS_BASE + VERSATILE_SYS_CLCD_OFFSET)
@@ -225,7 +225,20 @@
225#define VERSATILE_SSMC_BASE 0x20000000 /* SSMC */ 225#define VERSATILE_SSMC_BASE 0x20000000 /* SSMC */
226#define VERSATILE_IB2_BASE 0x24000000 /* IB2 module */ 226#define VERSATILE_IB2_BASE 0x24000000 /* IB2 module */
227#define VERSATILE_MBX_BASE 0x40000000 /* MBX */ 227#define VERSATILE_MBX_BASE 0x40000000 /* MBX */
228
229/* PCI space */
228#define VERSATILE_PCI_BASE 0x41000000 /* PCI Interface */ 230#define VERSATILE_PCI_BASE 0x41000000 /* PCI Interface */
231#define VERSATILE_PCI_CFG_BASE 0x42000000
232#define VERSATILE_PCI_MEM_BASE0 0x44000000
233#define VERSATILE_PCI_MEM_BASE1 0x50000000
234#define VERSATILE_PCI_MEM_BASE2 0x60000000
235/* Sizes of above maps */
236#define VERSATILE_PCI_BASE_SIZE 0x01000000
237#define VERSATILE_PCI_CFG_BASE_SIZE 0x02000000
238#define VERSATILE_PCI_MEM_BASE0_SIZE 0x0c000000 /* 32Mb */
239#define VERSATILE_PCI_MEM_BASE1_SIZE 0x10000000 /* 256Mb */
240#define VERSATILE_PCI_MEM_BASE2_SIZE 0x10000000 /* 256Mb */
241
229#define VERSATILE_SDRAM67_BASE 0x70000000 /* SDRAM banks 6 and 7 */ 242#define VERSATILE_SDRAM67_BASE 0x70000000 /* SDRAM banks 6 and 7 */
230#define VERSATILE_LT_BASE 0x80000000 /* Logic Tile expansion */ 243#define VERSATILE_LT_BASE 0x80000000 /* Logic Tile expansion */
231 244
diff --git a/include/asm-arm/cacheflush.h b/include/asm-arm/cacheflush.h
index 09ffeed507c2..035cdcff43d2 100644
--- a/include/asm-arm/cacheflush.h
+++ b/include/asm-arm/cacheflush.h
@@ -16,6 +16,9 @@
16 16
17#include <asm/mman.h> 17#include <asm/mman.h>
18#include <asm/glue.h> 18#include <asm/glue.h>
19#include <asm/shmparam.h>
20
21#define CACHE_COLOUR(vaddr) ((vaddr & (SHMLBA - 1)) >> PAGE_SHIFT)
19 22
20/* 23/*
21 * Cache Model 24 * Cache Model
diff --git a/include/asm-arm/io.h b/include/asm-arm/io.h
index 658ffa384fda..08a46302d265 100644
--- a/include/asm-arm/io.h
+++ b/include/asm-arm/io.h
@@ -273,6 +273,33 @@ extern void __iounmap(void __iomem *addr);
273#endif 273#endif
274 274
275/* 275/*
276 * io{read,write}{8,16,32} macros
277 */
278#define ioread8(p) ({ unsigned int __v = __raw_readb(p); __v; })
279#define ioread16(p) ({ unsigned int __v = le16_to_cpu(__raw_readw(p)); __v; })
280#define ioread32(p) ({ unsigned int __v = le32_to_cpu(__raw_readl(p)); __v; })
281
282#define iowrite8(v,p) __raw_writeb(v, p)
283#define iowrite16(v,p) __raw_writew(cpu_to_le16(v), p)
284#define iowrite32(v,p) __raw_writel(cpu_to_le32(v), p)
285
286#define ioread8_rep(p,d,c) __raw_readsb(p,d,c)
287#define ioread16_rep(p,d,c) __raw_readsw(p,d,c)
288#define ioread32_rep(p,d,c) __raw_readsl(p,d,c)
289
290#define iowrite8_rep(p,s,c) __raw_writesb(p,s,c)
291#define iowrite16_rep(p,s,c) __raw_writesw(p,s,c)
292#define iowrite32_rep(p,s,c) __raw_writesl(p,s,c)
293
294extern void __iomem *ioport_map(unsigned long port, unsigned int nr);
295extern void ioport_unmap(void __iomem *addr);
296
297struct pci_dev;
298
299extern void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen);
300extern void pci_iounmap(struct pci_dev *dev, void __iomem *addr);
301
302/*
276 * can the hardware map this into one segment or not, given no other 303 * can the hardware map this into one segment or not, given no other
277 * constraints. 304 * constraints.
278 */ 305 */
diff --git a/include/asm-ppc/ocp.h b/include/asm-ppc/ocp.h
index b98db3cdae83..c726f1845190 100644
--- a/include/asm-ppc/ocp.h
+++ b/include/asm-ppc/ocp.h
@@ -189,7 +189,7 @@ extern void ocp_for_each_device(void(*callback)(struct ocp_device *, void *arg),
189/* Sysfs support */ 189/* Sysfs support */
190#define OCP_SYSFS_ADDTL(type, format, name, field) \ 190#define OCP_SYSFS_ADDTL(type, format, name, field) \
191static ssize_t \ 191static ssize_t \
192show_##name##_##field(struct device *dev, char *buf) \ 192show_##name##_##field(struct device *dev, struct device_attribute *attr, char *buf) \
193{ \ 193{ \
194 struct ocp_device *odev = to_ocp_dev(dev); \ 194 struct ocp_device *odev = to_ocp_dev(dev); \
195 type *add = odev->def->additions; \ 195 type *add = odev->def->additions; \
diff --git a/include/linux/atalk.h b/include/linux/atalk.h
index 31d3fc25ccbd..09a1451c1159 100644
--- a/include/linux/atalk.h
+++ b/include/linux/atalk.h
@@ -20,7 +20,7 @@
20#define SIOCATALKDIFADDR (SIOCPROTOPRIVATE + 0) 20#define SIOCATALKDIFADDR (SIOCPROTOPRIVATE + 0)
21 21
22struct atalk_addr { 22struct atalk_addr {
23 __u16 s_net; 23 __be16 s_net;
24 __u8 s_node; 24 __u8 s_node;
25}; 25};
26 26
@@ -33,8 +33,8 @@ struct sockaddr_at {
33 33
34struct atalk_netrange { 34struct atalk_netrange {
35 __u8 nr_phase; 35 __u8 nr_phase;
36 __u16 nr_firstnet; 36 __be16 nr_firstnet;
37 __u16 nr_lastnet; 37 __be16 nr_lastnet;
38}; 38};
39 39
40#ifdef __KERNEL__ 40#ifdef __KERNEL__
@@ -70,8 +70,8 @@ struct atalk_iface {
70struct atalk_sock { 70struct atalk_sock {
71 /* struct sock has to be the first member of atalk_sock */ 71 /* struct sock has to be the first member of atalk_sock */
72 struct sock sk; 72 struct sock sk;
73 unsigned short dest_net; 73 __be16 dest_net;
74 unsigned short src_net; 74 __be16 src_net;
75 unsigned char dest_node; 75 unsigned char dest_node;
76 unsigned char src_node; 76 unsigned char src_node;
77 unsigned char dest_port; 77 unsigned char dest_port;
@@ -95,9 +95,9 @@ struct ddpehdr {
95 deh_hops:4, 95 deh_hops:4,
96 deh_len:10; 96 deh_len:10;
97#endif 97#endif
98 __u16 deh_sum; 98 __be16 deh_sum;
99 __u16 deh_dnet; 99 __be16 deh_dnet;
100 __u16 deh_snet; 100 __be16 deh_snet;
101 __u8 deh_dnode; 101 __u8 deh_dnode;
102 __u8 deh_snode; 102 __u8 deh_snode;
103 __u8 deh_dport; 103 __u8 deh_dport;
@@ -142,24 +142,24 @@ struct ddpshdr {
142 142
143/* AppleTalk AARP headers */ 143/* AppleTalk AARP headers */
144struct elapaarp { 144struct elapaarp {
145 __u16 hw_type; 145 __be16 hw_type;
146#define AARP_HW_TYPE_ETHERNET 1 146#define AARP_HW_TYPE_ETHERNET 1
147#define AARP_HW_TYPE_TOKENRING 2 147#define AARP_HW_TYPE_TOKENRING 2
148 __u16 pa_type; 148 __be16 pa_type;
149 __u8 hw_len; 149 __u8 hw_len;
150 __u8 pa_len; 150 __u8 pa_len;
151#define AARP_PA_ALEN 4 151#define AARP_PA_ALEN 4
152 __u16 function; 152 __be16 function;
153#define AARP_REQUEST 1 153#define AARP_REQUEST 1
154#define AARP_REPLY 2 154#define AARP_REPLY 2
155#define AARP_PROBE 3 155#define AARP_PROBE 3
156 __u8 hw_src[ETH_ALEN] __attribute__ ((packed)); 156 __u8 hw_src[ETH_ALEN] __attribute__ ((packed));
157 __u8 pa_src_zero __attribute__ ((packed)); 157 __u8 pa_src_zero __attribute__ ((packed));
158 __u16 pa_src_net __attribute__ ((packed)); 158 __be16 pa_src_net __attribute__ ((packed));
159 __u8 pa_src_node __attribute__ ((packed)); 159 __u8 pa_src_node __attribute__ ((packed));
160 __u8 hw_dst[ETH_ALEN] __attribute__ ((packed)); 160 __u8 hw_dst[ETH_ALEN] __attribute__ ((packed));
161 __u8 pa_dst_zero __attribute__ ((packed)); 161 __u8 pa_dst_zero __attribute__ ((packed));
162 __u16 pa_dst_net __attribute__ ((packed)); 162 __be16 pa_dst_net __attribute__ ((packed));
163 __u8 pa_dst_node __attribute__ ((packed)); 163 __u8 pa_dst_node __attribute__ ((packed));
164}; 164};
165 165
diff --git a/include/linux/device.h b/include/linux/device.h
index df94c0de53f2..7b781a72b293 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -14,6 +14,7 @@
14#include <linux/config.h> 14#include <linux/config.h>
15#include <linux/ioport.h> 15#include <linux/ioport.h>
16#include <linux/kobject.h> 16#include <linux/kobject.h>
17#include <linux/klist.h>
17#include <linux/list.h> 18#include <linux/list.h>
18#include <linux/types.h> 19#include <linux/types.h>
19#include <linux/module.h> 20#include <linux/module.h>
@@ -44,14 +45,15 @@ struct device;
44struct device_driver; 45struct device_driver;
45struct class; 46struct class;
46struct class_device; 47struct class_device;
47struct class_simple;
48 48
49struct bus_type { 49struct bus_type {
50 char * name; 50 const char * name;
51 51
52 struct subsystem subsys; 52 struct subsystem subsys;
53 struct kset drivers; 53 struct kset drivers;
54 struct kset devices; 54 struct kset devices;
55 struct klist klist_devices;
56 struct klist klist_drivers;
55 57
56 struct bus_attribute * bus_attrs; 58 struct bus_attribute * bus_attrs;
57 struct device_attribute * dev_attrs; 59 struct device_attribute * dev_attrs;
@@ -98,17 +100,18 @@ extern int bus_create_file(struct bus_type *, struct bus_attribute *);
98extern void bus_remove_file(struct bus_type *, struct bus_attribute *); 100extern void bus_remove_file(struct bus_type *, struct bus_attribute *);
99 101
100struct device_driver { 102struct device_driver {
101 char * name; 103 const char * name;
102 struct bus_type * bus; 104 struct bus_type * bus;
103 105
104 struct completion unloaded; 106 struct completion unloaded;
105 struct kobject kobj; 107 struct kobject kobj;
106 struct list_head devices; 108 struct klist klist_devices;
109 struct klist_node knode_bus;
107 110
108 struct module * owner; 111 struct module * owner;
109 112
110 int (*probe) (struct device * dev); 113 int (*probe) (struct device * dev);
111 int (*remove) (struct device * dev); 114 int (*remove) (struct device * dev);
112 void (*shutdown) (struct device * dev); 115 void (*shutdown) (struct device * dev);
113 int (*suspend) (struct device * dev, pm_message_t state, u32 level); 116 int (*suspend) (struct device * dev, pm_message_t state, u32 level);
114 int (*resume) (struct device * dev, u32 level); 117 int (*resume) (struct device * dev, u32 level);
@@ -137,12 +140,16 @@ struct driver_attribute driver_attr_##_name = __ATTR(_name,_mode,_show,_store)
137extern int driver_create_file(struct device_driver *, struct driver_attribute *); 140extern int driver_create_file(struct device_driver *, struct driver_attribute *);
138extern void driver_remove_file(struct device_driver *, struct driver_attribute *); 141extern void driver_remove_file(struct device_driver *, struct driver_attribute *);
139 142
143extern int driver_for_each_device(struct device_driver * drv, struct device * start,
144 void * data, int (*fn)(struct device *, void *));
145
140 146
141/* 147/*
142 * device classes 148 * device classes
143 */ 149 */
144struct class { 150struct class {
145 char * name; 151 const char * name;
152 struct module * owner;
146 153
147 struct subsystem subsys; 154 struct subsystem subsys;
148 struct list_head children; 155 struct list_head children;
@@ -185,6 +192,7 @@ struct class_device {
185 struct kobject kobj; 192 struct kobject kobj;
186 struct class * class; /* required */ 193 struct class * class; /* required */
187 dev_t devt; /* dev_t, creates the sysfs "dev" */ 194 dev_t devt; /* dev_t, creates the sysfs "dev" */
195 struct class_device_attribute *devt_attr;
188 struct device * dev; /* not necessary, but nice to have */ 196 struct device * dev; /* not necessary, but nice to have */
189 void * class_data; /* class-specific data */ 197 void * class_data; /* class-specific data */
190 198
@@ -245,26 +253,28 @@ struct class_interface {
245extern int class_interface_register(struct class_interface *); 253extern int class_interface_register(struct class_interface *);
246extern void class_interface_unregister(struct class_interface *); 254extern void class_interface_unregister(struct class_interface *);
247 255
248/* interface for class simple stuff */ 256extern struct class *class_create(struct module *owner, char *name);
249extern struct class_simple *class_simple_create(struct module *owner, char *name); 257extern void class_destroy(struct class *cls);
250extern void class_simple_destroy(struct class_simple *cs); 258extern struct class_device *class_device_create(struct class *cls, dev_t devt,
251extern struct class_device *class_simple_device_add(struct class_simple *cs, dev_t dev, struct device *device, const char *fmt, ...) 259 struct device *device, char *fmt, ...)
252 __attribute__((format(printf,4,5))); 260 __attribute__((format(printf,4,5)));
253extern int class_simple_set_hotplug(struct class_simple *, 261extern void class_device_destroy(struct class *cls, dev_t devt);
254 int (*hotplug)(struct class_device *dev, char **envp, int num_envp, char *buffer, int buffer_size));
255extern void class_simple_device_remove(dev_t dev);
256 262
257 263
258struct device { 264struct device {
259 struct list_head node; /* node in sibling list */ 265 struct klist klist_children;
260 struct list_head bus_list; /* node in bus's list */ 266 struct klist_node knode_parent; /* node in sibling list */
261 struct list_head driver_list; 267 struct klist_node knode_driver;
262 struct list_head children; 268 struct klist_node knode_bus;
263 struct device * parent; 269 struct device * parent;
264 270
265 struct kobject kobj; 271 struct kobject kobj;
266 char bus_id[BUS_ID_SIZE]; /* position on parent bus */ 272 char bus_id[BUS_ID_SIZE]; /* position on parent bus */
267 273
274 struct semaphore sem; /* semaphore to synchronize calls to
275 * its driver.
276 */
277
268 struct bus_type * bus; /* type of bus device is on */ 278 struct bus_type * bus; /* type of bus device is on */
269 struct device_driver *driver; /* which driver has allocated this 279 struct device_driver *driver; /* which driver has allocated this
270 device */ 280 device */
@@ -288,12 +298,6 @@ struct device {
288 void (*release)(struct device * dev); 298 void (*release)(struct device * dev);
289}; 299};
290 300
291static inline struct device *
292list_to_dev(struct list_head *node)
293{
294 return list_entry(node, struct device, node);
295}
296
297static inline void * 301static inline void *
298dev_get_drvdata (struct device *dev) 302dev_get_drvdata (struct device *dev)
299{ 303{
@@ -321,7 +325,6 @@ extern int device_for_each_child(struct device *, void *,
321 * Manual binding of a device to driver. See drivers/base/bus.c 325 * Manual binding of a device to driver. See drivers/base/bus.c
322 * for information on use. 326 * for information on use.
323 */ 327 */
324extern int driver_probe_device(struct device_driver * drv, struct device * dev);
325extern void device_bind_driver(struct device * dev); 328extern void device_bind_driver(struct device * dev);
326extern void device_release_driver(struct device * dev); 329extern void device_release_driver(struct device * dev);
327extern int device_attach(struct device * dev); 330extern int device_attach(struct device * dev);
@@ -332,8 +335,10 @@ extern void driver_attach(struct device_driver * drv);
332 335
333struct device_attribute { 336struct device_attribute {
334 struct attribute attr; 337 struct attribute attr;
335 ssize_t (*show)(struct device * dev, char * buf); 338 ssize_t (*show)(struct device *dev, struct device_attribute *attr,
336 ssize_t (*store)(struct device * dev, const char * buf, size_t count); 339 char *buf);
340 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
341 const char *buf, size_t count);
337}; 342};
338 343
339#define DEVICE_ATTR(_name,_mode,_show,_store) \ 344#define DEVICE_ATTR(_name,_mode,_show,_store) \
@@ -360,13 +365,12 @@ extern int (*platform_notify_remove)(struct device * dev);
360 */ 365 */
361extern struct device * get_device(struct device * dev); 366extern struct device * get_device(struct device * dev);
362extern void put_device(struct device * dev); 367extern void put_device(struct device * dev);
363extern struct device *device_find(const char *name, struct bus_type *bus);
364 368
365 369
366/* drivers/base/platform.c */ 370/* drivers/base/platform.c */
367 371
368struct platform_device { 372struct platform_device {
369 char * name; 373 const char * name;
370 u32 id; 374 u32 id;
371 struct device dev; 375 struct device dev;
372 u32 num_resources; 376 u32 num_resources;
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 0180102dace1..9b8b696d4f15 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1657,6 +1657,52 @@ static inline void simple_transaction_set(struct file *file, size_t n)
1657 ar->size = n; 1657 ar->size = n;
1658} 1658}
1659 1659
1660/*
1661 * simple attribute files
1662 *
1663 * These attributes behave similar to those in sysfs:
1664 *
1665 * Writing to an attribute immediately sets a value, an open file can be
1666 * written to multiple times.
1667 *
1668 * Reading from an attribute creates a buffer from the value that might get
1669 * read with multiple read calls. When the attribute has been read
1670 * completely, no further read calls are possible until the file is opened
1671 * again.
1672 *
1673 * All attributes contain a text representation of a numeric value
1674 * that are accessed with the get() and set() functions.
1675 */
1676#define DEFINE_SIMPLE_ATTRIBUTE(__fops, __get, __set, __fmt) \
1677static int __fops ## _open(struct inode *inode, struct file *file) \
1678{ \
1679 __simple_attr_check_format(__fmt, 0ull); \
1680 return simple_attr_open(inode, file, __get, __set, __fmt); \
1681} \
1682static struct file_operations __fops = { \
1683 .owner = THIS_MODULE, \
1684 .open = __fops ## _open, \
1685 .release = simple_attr_close, \
1686 .read = simple_attr_read, \
1687 .write = simple_attr_write, \
1688};
1689
1690static inline void __attribute__((format(printf, 1, 2)))
1691__simple_attr_check_format(const char *fmt, ...)
1692{
1693 /* don't do anything, just let the compiler check the arguments; */
1694}
1695
1696int simple_attr_open(struct inode *inode, struct file *file,
1697 u64 (*get)(void *), void (*set)(void *, u64),
1698 const char *fmt);
1699int simple_attr_close(struct inode *inode, struct file *file);
1700ssize_t simple_attr_read(struct file *file, char __user *buf,
1701 size_t len, loff_t *ppos);
1702ssize_t simple_attr_write(struct file *file, const char __user *buf,
1703 size_t len, loff_t *ppos);
1704
1705
1660#ifdef CONFIG_SECURITY 1706#ifdef CONFIG_SECURITY
1661static inline char *alloc_secdata(void) 1707static inline char *alloc_secdata(void)
1662{ 1708{
diff --git a/include/linux/i2c-sysfs.h b/include/linux/i2c-sysfs.h
new file mode 100644
index 000000000000..d7bf6ce11679
--- /dev/null
+++ b/include/linux/i2c-sysfs.h
@@ -0,0 +1,36 @@
1/*
2 * i2c-sysfs.h - i2c chip driver sysfs defines
3 *
4 * Copyright (C) 2005 Yani Ioannou <yani.ioannou@gmail.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20#ifndef _LINUX_I2C_SYSFS_H
21#define _LINUX_I2C_SYSFS_H
22
23struct sensor_device_attribute{
24 struct device_attribute dev_attr;
25 int index;
26};
27#define to_sensor_dev_attr(_dev_attr) \
28 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
29
30#define SENSOR_DEVICE_ATTR(_name,_mode,_show,_store,_index) \
31struct sensor_device_attribute sensor_dev_attr_##_name = { \
32 .dev_attr = __ATTR(_name,_mode,_show,_store), \
33 .index = _index, \
34}
35
36#endif /* _LINUX_I2C_SYSFS_H */
diff --git a/include/linux/input.h b/include/linux/input.h
index 72731d7d189e..9d9598ed760d 100644
--- a/include/linux/input.h
+++ b/include/linux/input.h
@@ -1015,7 +1015,7 @@ static inline void input_set_abs_params(struct input_dev *dev, int axis, int min
1015 dev->absbit[LONG(axis)] |= BIT(axis); 1015 dev->absbit[LONG(axis)] |= BIT(axis);
1016} 1016}
1017 1017
1018extern struct class_simple *input_class; 1018extern struct class *input_class;
1019 1019
1020#endif 1020#endif
1021#endif 1021#endif
diff --git a/include/linux/klist.h b/include/linux/klist.h
new file mode 100644
index 000000000000..eebf5e5696ec
--- /dev/null
+++ b/include/linux/klist.h
@@ -0,0 +1,55 @@
1/*
2 * klist.h - Some generic list helpers, extending struct list_head a bit.
3 *
4 * Implementations are found in lib/klist.c
5 *
6 *
7 * Copyright (C) 2005 Patrick Mochel
8 *
9 * This file is rleased under the GPL v2.
10 */
11
12#include <linux/spinlock.h>
13#include <linux/completion.h>
14#include <linux/kref.h>
15#include <linux/list.h>
16
17
18struct klist {
19 spinlock_t k_lock;
20 struct list_head k_list;
21};
22
23
24extern void klist_init(struct klist * k);
25
26
27struct klist_node {
28 struct klist * n_klist;
29 struct list_head n_node;
30 struct kref n_ref;
31 struct completion n_removed;
32};
33
34extern void klist_add_tail(struct klist * k, struct klist_node * n);
35extern void klist_add_head(struct klist * k, struct klist_node * n);
36
37extern void klist_del(struct klist_node * n);
38extern void klist_remove(struct klist_node * n);
39
40extern int klist_node_attached(struct klist_node * n);
41
42
43struct klist_iter {
44 struct klist * i_klist;
45 struct list_head * i_head;
46 struct klist_node * i_cur;
47};
48
49
50extern void klist_iter_init(struct klist * k, struct klist_iter * i);
51extern void klist_iter_init_node(struct klist * k, struct klist_iter * i,
52 struct klist_node * n);
53extern void klist_iter_exit(struct klist_iter * i);
54extern struct klist_node * klist_next(struct klist_iter * i);
55
diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index 765d660d3bea..3b22304f12fd 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -33,7 +33,7 @@
33extern u64 hotplug_seqnum; 33extern u64 hotplug_seqnum;
34 34
35struct kobject { 35struct kobject {
36 char * k_name; 36 const char * k_name;
37 char name[KOBJ_NAME_LEN]; 37 char name[KOBJ_NAME_LEN];
38 struct kref kref; 38 struct kref kref;
39 struct list_head entry; 39 struct list_head entry;
@@ -46,7 +46,7 @@ struct kobject {
46extern int kobject_set_name(struct kobject *, const char *, ...) 46extern int kobject_set_name(struct kobject *, const char *, ...)
47 __attribute__((format(printf,2,3))); 47 __attribute__((format(printf,2,3)));
48 48
49static inline char * kobject_name(struct kobject * kobj) 49static inline const char * kobject_name(const struct kobject * kobj)
50{ 50{
51 return kobj->k_name; 51 return kobj->k_name;
52} 52}
@@ -57,7 +57,7 @@ extern void kobject_cleanup(struct kobject *);
57extern int kobject_add(struct kobject *); 57extern int kobject_add(struct kobject *);
58extern void kobject_del(struct kobject *); 58extern void kobject_del(struct kobject *);
59 59
60extern int kobject_rename(struct kobject *, char *new_name); 60extern int kobject_rename(struct kobject *, const char *new_name);
61 61
62extern int kobject_register(struct kobject *); 62extern int kobject_register(struct kobject *);
63extern void kobject_unregister(struct kobject *); 63extern void kobject_unregister(struct kobject *);
@@ -94,7 +94,7 @@ struct kobj_type {
94 */ 94 */
95struct kset_hotplug_ops { 95struct kset_hotplug_ops {
96 int (*filter)(struct kset *kset, struct kobject *kobj); 96 int (*filter)(struct kset *kset, struct kobject *kobj);
97 char *(*name)(struct kset *kset, struct kobject *kobj); 97 const char *(*name)(struct kset *kset, struct kobject *kobj);
98 int (*hotplug)(struct kset *kset, struct kobject *kobj, char **envp, 98 int (*hotplug)(struct kset *kset, struct kobject *kobj, char **envp,
99 int num_envp, char *buffer, int buffer_size); 99 int num_envp, char *buffer, int buffer_size);
100}; 100};
diff --git a/include/linux/netfilter_ipv4.h b/include/linux/netfilter_ipv4.h
index 9e5750079e09..3ebc36afae1a 100644
--- a/include/linux/netfilter_ipv4.h
+++ b/include/linux/netfilter_ipv4.h
@@ -75,12 +75,6 @@ enum nf_ip_hook_priorities {
75#define SO_ORIGINAL_DST 80 75#define SO_ORIGINAL_DST 80
76 76
77#ifdef __KERNEL__ 77#ifdef __KERNEL__
78#ifdef CONFIG_NETFILTER_DEBUG
79void nf_debug_ip_local_deliver(struct sk_buff *skb);
80void nf_debug_ip_loopback_xmit(struct sk_buff *newskb);
81void nf_debug_ip_finish_output2(struct sk_buff *skb);
82#endif /*CONFIG_NETFILTER_DEBUG*/
83
84extern int ip_route_me_harder(struct sk_buff **pskb); 78extern int ip_route_me_harder(struct sk_buff **pskb);
85 79
86/* Call this before modifying an existing IP packet: ensures it is 80/* Call this before modifying an existing IP packet: ensures it is
diff --git a/include/linux/netfilter_ipv4/ip_conntrack_core.h b/include/linux/netfilter_ipv4/ip_conntrack_core.h
index d84be02cb4fc..694aec9b4784 100644
--- a/include/linux/netfilter_ipv4/ip_conntrack_core.h
+++ b/include/linux/netfilter_ipv4/ip_conntrack_core.h
@@ -1,7 +1,6 @@
1#ifndef _IP_CONNTRACK_CORE_H 1#ifndef _IP_CONNTRACK_CORE_H
2#define _IP_CONNTRACK_CORE_H 2#define _IP_CONNTRACK_CORE_H
3#include <linux/netfilter.h> 3#include <linux/netfilter.h>
4#include <linux/netfilter_ipv4/lockhelp.h>
5 4
6/* This header is used to share core functionality between the 5/* This header is used to share core functionality between the
7 standalone connection tracking module, and the compatibility layer's use 6 standalone connection tracking module, and the compatibility layer's use
@@ -47,6 +46,6 @@ static inline int ip_conntrack_confirm(struct sk_buff **pskb)
47 46
48extern struct list_head *ip_conntrack_hash; 47extern struct list_head *ip_conntrack_hash;
49extern struct list_head ip_conntrack_expect_list; 48extern struct list_head ip_conntrack_expect_list;
50DECLARE_RWLOCK_EXTERN(ip_conntrack_lock); 49extern rwlock_t ip_conntrack_lock;
51#endif /* _IP_CONNTRACK_CORE_H */ 50#endif /* _IP_CONNTRACK_CORE_H */
52 51
diff --git a/include/linux/netfilter_ipv4/ip_nat.h b/include/linux/netfilter_ipv4/ip_nat.h
index 2b72b86176f0..e201ec6e9905 100644
--- a/include/linux/netfilter_ipv4/ip_nat.h
+++ b/include/linux/netfilter_ipv4/ip_nat.h
@@ -50,10 +50,9 @@ struct ip_nat_multi_range_compat
50 50
51#ifdef __KERNEL__ 51#ifdef __KERNEL__
52#include <linux/list.h> 52#include <linux/list.h>
53#include <linux/netfilter_ipv4/lockhelp.h>
54 53
55/* Protects NAT hash tables, and NAT-private part of conntracks. */ 54/* Protects NAT hash tables, and NAT-private part of conntracks. */
56DECLARE_RWLOCK_EXTERN(ip_nat_lock); 55extern rwlock_t ip_nat_lock;
57 56
58/* The structure embedded in the conntrack structure. */ 57/* The structure embedded in the conntrack structure. */
59struct ip_nat_info 58struct ip_nat_info
diff --git a/include/linux/netfilter_ipv4/listhelp.h b/include/linux/netfilter_ipv4/listhelp.h
index f2ae7c5e57bb..360429f48737 100644
--- a/include/linux/netfilter_ipv4/listhelp.h
+++ b/include/linux/netfilter_ipv4/listhelp.h
@@ -2,7 +2,6 @@
2#define _LISTHELP_H 2#define _LISTHELP_H
3#include <linux/config.h> 3#include <linux/config.h>
4#include <linux/list.h> 4#include <linux/list.h>
5#include <linux/netfilter_ipv4/lockhelp.h>
6 5
7/* Header to do more comprehensive job than linux/list.h; assume list 6/* Header to do more comprehensive job than linux/list.h; assume list
8 is first entry in structure. */ 7 is first entry in structure. */
diff --git a/include/linux/netfilter_ipv4/lockhelp.h b/include/linux/netfilter_ipv4/lockhelp.h
deleted file mode 100644
index a3288633ab46..000000000000
--- a/include/linux/netfilter_ipv4/lockhelp.h
+++ /dev/null
@@ -1,129 +0,0 @@
1#ifndef _LOCKHELP_H
2#define _LOCKHELP_H
3#include <linux/config.h>
4
5#include <linux/spinlock.h>
6#include <asm/atomic.h>
7#include <linux/interrupt.h>
8#include <linux/smp.h>
9
10/* Header to do help in lock debugging. */
11
12#ifdef CONFIG_NETFILTER_DEBUG
13struct spinlock_debug
14{
15 spinlock_t l;
16 atomic_t locked_by;
17};
18
19struct rwlock_debug
20{
21 rwlock_t l;
22 long read_locked_map;
23 long write_locked_map;
24};
25
26#define DECLARE_LOCK(l) \
27struct spinlock_debug l = { SPIN_LOCK_UNLOCKED, ATOMIC_INIT(-1) }
28#define DECLARE_LOCK_EXTERN(l) \
29extern struct spinlock_debug l
30#define DECLARE_RWLOCK(l) \
31struct rwlock_debug l = { RW_LOCK_UNLOCKED, 0, 0 }
32#define DECLARE_RWLOCK_EXTERN(l) \
33extern struct rwlock_debug l
34
35#define MUST_BE_LOCKED(l) \
36do { if (atomic_read(&(l)->locked_by) != smp_processor_id()) \
37 printk("ASSERT %s:%u %s unlocked\n", __FILE__, __LINE__, #l); \
38} while(0)
39
40#define MUST_BE_UNLOCKED(l) \
41do { if (atomic_read(&(l)->locked_by) == smp_processor_id()) \
42 printk("ASSERT %s:%u %s locked\n", __FILE__, __LINE__, #l); \
43} while(0)
44
45/* Write locked OK as well. */
46#define MUST_BE_READ_LOCKED(l) \
47do { if (!((l)->read_locked_map & (1UL << smp_processor_id())) \
48 && !((l)->write_locked_map & (1UL << smp_processor_id()))) \
49 printk("ASSERT %s:%u %s not readlocked\n", __FILE__, __LINE__, #l); \
50} while(0)
51
52#define MUST_BE_WRITE_LOCKED(l) \
53do { if (!((l)->write_locked_map & (1UL << smp_processor_id()))) \
54 printk("ASSERT %s:%u %s not writelocked\n", __FILE__, __LINE__, #l); \
55} while(0)
56
57#define MUST_BE_READ_WRITE_UNLOCKED(l) \
58do { if ((l)->read_locked_map & (1UL << smp_processor_id())) \
59 printk("ASSERT %s:%u %s readlocked\n", __FILE__, __LINE__, #l); \
60 else if ((l)->write_locked_map & (1UL << smp_processor_id())) \
61 printk("ASSERT %s:%u %s writelocked\n", __FILE__, __LINE__, #l); \
62} while(0)
63
64#define LOCK_BH(lk) \
65do { \
66 MUST_BE_UNLOCKED(lk); \
67 spin_lock_bh(&(lk)->l); \
68 atomic_set(&(lk)->locked_by, smp_processor_id()); \
69} while(0)
70
71#define UNLOCK_BH(lk) \
72do { \
73 MUST_BE_LOCKED(lk); \
74 atomic_set(&(lk)->locked_by, -1); \
75 spin_unlock_bh(&(lk)->l); \
76} while(0)
77
78#define READ_LOCK(lk) \
79do { \
80 MUST_BE_READ_WRITE_UNLOCKED(lk); \
81 read_lock_bh(&(lk)->l); \
82 set_bit(smp_processor_id(), &(lk)->read_locked_map); \
83} while(0)
84
85#define WRITE_LOCK(lk) \
86do { \
87 MUST_BE_READ_WRITE_UNLOCKED(lk); \
88 write_lock_bh(&(lk)->l); \
89 set_bit(smp_processor_id(), &(lk)->write_locked_map); \
90} while(0)
91
92#define READ_UNLOCK(lk) \
93do { \
94 if (!((lk)->read_locked_map & (1UL << smp_processor_id()))) \
95 printk("ASSERT: %s:%u %s not readlocked\n", \
96 __FILE__, __LINE__, #lk); \
97 clear_bit(smp_processor_id(), &(lk)->read_locked_map); \
98 read_unlock_bh(&(lk)->l); \
99} while(0)
100
101#define WRITE_UNLOCK(lk) \
102do { \
103 MUST_BE_WRITE_LOCKED(lk); \
104 clear_bit(smp_processor_id(), &(lk)->write_locked_map); \
105 write_unlock_bh(&(lk)->l); \
106} while(0)
107
108#else
109#define DECLARE_LOCK(l) spinlock_t l = SPIN_LOCK_UNLOCKED
110#define DECLARE_LOCK_EXTERN(l) extern spinlock_t l
111#define DECLARE_RWLOCK(l) rwlock_t l = RW_LOCK_UNLOCKED
112#define DECLARE_RWLOCK_EXTERN(l) extern rwlock_t l
113
114#define MUST_BE_LOCKED(l)
115#define MUST_BE_UNLOCKED(l)
116#define MUST_BE_READ_LOCKED(l)
117#define MUST_BE_WRITE_LOCKED(l)
118#define MUST_BE_READ_WRITE_UNLOCKED(l)
119
120#define LOCK_BH(l) spin_lock_bh(l)
121#define UNLOCK_BH(l) spin_unlock_bh(l)
122
123#define READ_LOCK(l) read_lock_bh(l)
124#define WRITE_LOCK(l) write_lock_bh(l)
125#define READ_UNLOCK(l) read_unlock_bh(l)
126#define WRITE_UNLOCK(l) write_unlock_bh(l)
127#endif /*CONFIG_NETFILTER_DEBUG*/
128
129#endif /* _LOCKHELP_H */
diff --git a/include/linux/netlink.h b/include/linux/netlink.h
index e38407a23d04..3029cad63a01 100644
--- a/include/linux/netlink.h
+++ b/include/linux/netlink.h
@@ -14,6 +14,7 @@
14#define NETLINK_SELINUX 7 /* SELinux event notifications */ 14#define NETLINK_SELINUX 7 /* SELinux event notifications */
15#define NETLINK_ARPD 8 15#define NETLINK_ARPD 8
16#define NETLINK_AUDIT 9 /* auditing */ 16#define NETLINK_AUDIT 9 /* auditing */
17#define NETLINK_FIB_LOOKUP 10
17#define NETLINK_ROUTE6 11 /* af_inet6 route comm channel */ 18#define NETLINK_ROUTE6 11 /* af_inet6 route comm channel */
18#define NETLINK_IP6_FW 13 19#define NETLINK_IP6_FW 13
19#define NETLINK_DNRTMSG 14 /* DECnet routing messages */ 20#define NETLINK_DNRTMSG 14 /* DECnet routing messages */
@@ -146,7 +147,7 @@ struct netlink_callback
146 int (*dump)(struct sk_buff * skb, struct netlink_callback *cb); 147 int (*dump)(struct sk_buff * skb, struct netlink_callback *cb);
147 int (*done)(struct netlink_callback *cb); 148 int (*done)(struct netlink_callback *cb);
148 int family; 149 int family;
149 long args[4]; 150 long args[5];
150}; 151};
151 152
152struct netlink_notify 153struct netlink_notify
diff --git a/include/linux/node.h b/include/linux/node.h
index 6e0a697e594e..254dc3de650b 100644
--- a/include/linux/node.h
+++ b/include/linux/node.h
@@ -27,6 +27,7 @@ struct node {
27}; 27};
28 28
29extern int register_node(struct node *, int, struct node *); 29extern int register_node(struct node *, int, struct node *);
30extern void unregister_node(struct node *node);
30 31
31#define to_node(sys_device) container_of(sys_device, struct node, sysdev) 32#define to_node(sys_device) container_of(sys_device, struct node, sysdev)
32 33
diff --git a/include/linux/pfkeyv2.h b/include/linux/pfkeyv2.h
index e6b519220245..724066778aff 100644
--- a/include/linux/pfkeyv2.h
+++ b/include/linux/pfkeyv2.h
@@ -245,6 +245,7 @@ struct sadb_x_nat_t_port {
245 245
246/* Security Association flags */ 246/* Security Association flags */
247#define SADB_SAFLAGS_PFS 1 247#define SADB_SAFLAGS_PFS 1
248#define SADB_SAFLAGS_NOPMTUDISC 0x20000000
248#define SADB_SAFLAGS_DECAP_DSCP 0x40000000 249#define SADB_SAFLAGS_DECAP_DSCP 0x40000000
249#define SADB_SAFLAGS_NOECN 0x80000000 250#define SADB_SAFLAGS_NOECN 0x80000000
250 251
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index cc04f5cd2286..d7c839a21842 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -193,7 +193,6 @@ struct skb_shared_info {
193 * @nfcache: Cache info 193 * @nfcache: Cache info
194 * @nfct: Associated connection, if any 194 * @nfct: Associated connection, if any
195 * @nfctinfo: Relationship of this skb to the connection 195 * @nfctinfo: Relationship of this skb to the connection
196 * @nf_debug: Netfilter debugging
197 * @nf_bridge: Saved data about a bridged frame - see br_netfilter.c 196 * @nf_bridge: Saved data about a bridged frame - see br_netfilter.c
198 * @private: Data which is private to the HIPPI implementation 197 * @private: Data which is private to the HIPPI implementation
199 * @tc_index: Traffic control index 198 * @tc_index: Traffic control index
@@ -264,9 +263,6 @@ struct sk_buff {
264 __u32 nfcache; 263 __u32 nfcache;
265 __u32 nfctinfo; 264 __u32 nfctinfo;
266 struct nf_conntrack *nfct; 265 struct nf_conntrack *nfct;
267#ifdef CONFIG_NETFILTER_DEBUG
268 unsigned int nf_debug;
269#endif
270#ifdef CONFIG_BRIDGE_NETFILTER 266#ifdef CONFIG_BRIDGE_NETFILTER
271 struct nf_bridge_info *nf_bridge; 267 struct nf_bridge_info *nf_bridge;
272#endif 268#endif
@@ -1219,15 +1215,6 @@ static inline void nf_reset(struct sk_buff *skb)
1219{ 1215{
1220 nf_conntrack_put(skb->nfct); 1216 nf_conntrack_put(skb->nfct);
1221 skb->nfct = NULL; 1217 skb->nfct = NULL;
1222#ifdef CONFIG_NETFILTER_DEBUG
1223 skb->nf_debug = 0;
1224#endif
1225}
1226static inline void nf_reset_debug(struct sk_buff *skb)
1227{
1228#ifdef CONFIG_NETFILTER_DEBUG
1229 skb->nf_debug = 0;
1230#endif
1231} 1218}
1232 1219
1233#ifdef CONFIG_BRIDGE_NETFILTER 1220#ifdef CONFIG_BRIDGE_NETFILTER
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
index 38b58b30814a..392da5a6dacb 100644
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -16,13 +16,13 @@ struct kobject;
16struct module; 16struct module;
17 17
18struct attribute { 18struct attribute {
19 char * name; 19 const char * name;
20 struct module * owner; 20 struct module * owner;
21 mode_t mode; 21 mode_t mode;
22}; 22};
23 23
24struct attribute_group { 24struct attribute_group {
25 char * name; 25 const char * name;
26 struct attribute ** attrs; 26 struct attribute ** attrs;
27}; 27};
28 28
@@ -73,6 +73,7 @@ struct sysfs_dirent {
73 int s_type; 73 int s_type;
74 umode_t s_mode; 74 umode_t s_mode;
75 struct dentry * s_dentry; 75 struct dentry * s_dentry;
76 struct iattr * s_iattr;
76}; 77};
77 78
78#define SYSFS_ROOT 0x0001 79#define SYSFS_ROOT 0x0001
@@ -105,11 +106,11 @@ sysfs_chmod_file(struct kobject *kobj, struct attribute *attr, mode_t mode);
105extern void 106extern void
106sysfs_remove_file(struct kobject *, const struct attribute *); 107sysfs_remove_file(struct kobject *, const struct attribute *);
107 108
108extern int 109extern int
109sysfs_create_link(struct kobject * kobj, struct kobject * target, char * name); 110sysfs_create_link(struct kobject * kobj, struct kobject * target, const char * name);
110 111
111extern void 112extern void
112sysfs_remove_link(struct kobject *, char * name); 113sysfs_remove_link(struct kobject *, const char * name);
113 114
114int sysfs_create_bin_file(struct kobject * kobj, struct bin_attribute * attr); 115int sysfs_create_bin_file(struct kobject * kobj, struct bin_attribute * attr);
115int sysfs_remove_bin_file(struct kobject * kobj, struct bin_attribute * attr); 116int sysfs_remove_bin_file(struct kobject * kobj, struct bin_attribute * attr);
@@ -153,12 +154,12 @@ static inline void sysfs_remove_file(struct kobject * k, const struct attribute
153 ; 154 ;
154} 155}
155 156
156static inline int sysfs_create_link(struct kobject * k, struct kobject * t, char * n) 157static inline int sysfs_create_link(struct kobject * k, struct kobject * t, const char * n)
157{ 158{
158 return 0; 159 return 0;
159} 160}
160 161
161static inline void sysfs_remove_link(struct kobject * k, char * name) 162static inline void sysfs_remove_link(struct kobject * k, const char * name)
162{ 163{
163 ; 164 ;
164} 165}
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 2d1ac5058534..3d508bf08402 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -287,15 +287,14 @@ struct usb_bus {
287 287
288 struct dentry *usbfs_dentry; /* usbfs dentry entry for the bus */ 288 struct dentry *usbfs_dentry; /* usbfs dentry entry for the bus */
289 289
290 struct class_device class_dev; /* class device for this bus */ 290 struct class_device *class_dev; /* class device for this bus */
291 struct kref kref; /* handles reference counting this bus */
291 void (*release)(struct usb_bus *bus); /* function to destroy this bus's memory */ 292 void (*release)(struct usb_bus *bus); /* function to destroy this bus's memory */
292#if defined(CONFIG_USB_MON) || defined(CONFIG_USB_MON_MODULE) 293#if defined(CONFIG_USB_MON) || defined(CONFIG_USB_MON_MODULE)
293 struct mon_bus *mon_bus; /* non-null when associated */ 294 struct mon_bus *mon_bus; /* non-null when associated */
294 int monitored; /* non-zero when monitored */ 295 int monitored; /* non-zero when monitored */
295#endif 296#endif
296}; 297};
297#define to_usb_bus(d) container_of(d, struct usb_bus, class_dev)
298
299 298
300/* -------------------------------------------------------------------------- */ 299/* -------------------------------------------------------------------------- */
301 300
diff --git a/include/linux/xfrm.h b/include/linux/xfrm.h
index d68391a9b9f3..f0d423300d84 100644
--- a/include/linux/xfrm.h
+++ b/include/linux/xfrm.h
@@ -196,6 +196,7 @@ struct xfrm_usersa_info {
196 __u8 flags; 196 __u8 flags;
197#define XFRM_STATE_NOECN 1 197#define XFRM_STATE_NOECN 1
198#define XFRM_STATE_DECAP_DSCP 2 198#define XFRM_STATE_DECAP_DSCP 2
199#define XFRM_STATE_NOPMTUDISC 4
199}; 200};
200 201
201struct xfrm_usersa_id { 202struct xfrm_usersa_id {
diff --git a/include/net/ax25.h b/include/net/ax25.h
index 9e6368a54547..828a3a93dda1 100644
--- a/include/net/ax25.h
+++ b/include/net/ax25.h
@@ -220,7 +220,7 @@ static __inline__ void ax25_cb_put(ax25_cb *ax25)
220 } 220 }
221} 221}
222 222
223static inline unsigned short ax25_type_trans(struct sk_buff *skb, struct net_device *dev) 223static inline __be16 ax25_type_trans(struct sk_buff *skb, struct net_device *dev)
224{ 224{
225 skb->dev = dev; 225 skb->dev = dev;
226 skb->pkt_type = PACKET_HOST; 226 skb->pkt_type = PACKET_HOST;
diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h
index 319904518194..a66e9de16a6c 100644
--- a/include/net/ip6_fib.h
+++ b/include/net/ip6_fib.h
@@ -167,14 +167,17 @@ extern int fib6_walk_continue(struct fib6_walker_t *w);
167extern int fib6_add(struct fib6_node *root, 167extern int fib6_add(struct fib6_node *root,
168 struct rt6_info *rt, 168 struct rt6_info *rt,
169 struct nlmsghdr *nlh, 169 struct nlmsghdr *nlh,
170 void *rtattr); 170 void *rtattr,
171 struct netlink_skb_parms *req);
171 172
172extern int fib6_del(struct rt6_info *rt, 173extern int fib6_del(struct rt6_info *rt,
173 struct nlmsghdr *nlh, 174 struct nlmsghdr *nlh,
174 void *rtattr); 175 void *rtattr,
176 struct netlink_skb_parms *req);
175 177
176extern void inet6_rt_notify(int event, struct rt6_info *rt, 178extern void inet6_rt_notify(int event, struct rt6_info *rt,
177 struct nlmsghdr *nlh); 179 struct nlmsghdr *nlh,
180 struct netlink_skb_parms *req);
178 181
179extern void fib6_run_gc(unsigned long dummy); 182extern void fib6_run_gc(unsigned long dummy);
180 183
diff --git a/include/net/ip6_route.h b/include/net/ip6_route.h
index d5d1dd10cdb8..f920706d526b 100644
--- a/include/net/ip6_route.h
+++ b/include/net/ip6_route.h
@@ -41,13 +41,16 @@ extern int ipv6_route_ioctl(unsigned int cmd, void __user *arg);
41 41
42extern int ip6_route_add(struct in6_rtmsg *rtmsg, 42extern int ip6_route_add(struct in6_rtmsg *rtmsg,
43 struct nlmsghdr *, 43 struct nlmsghdr *,
44 void *rtattr); 44 void *rtattr,
45 struct netlink_skb_parms *req);
45extern int ip6_ins_rt(struct rt6_info *, 46extern int ip6_ins_rt(struct rt6_info *,
46 struct nlmsghdr *, 47 struct nlmsghdr *,
47 void *rtattr); 48 void *rtattr,
49 struct netlink_skb_parms *req);
48extern int ip6_del_rt(struct rt6_info *, 50extern int ip6_del_rt(struct rt6_info *,
49 struct nlmsghdr *, 51 struct nlmsghdr *,
50 void *rtattr); 52 void *rtattr,
53 struct netlink_skb_parms *req);
51 54
52extern int ip6_rt_addr_add(struct in6_addr *addr, 55extern int ip6_rt_addr_add(struct in6_addr *addr,
53 struct net_device *dev, 56 struct net_device *dev,
diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
index e5a5f6b62f88..a4208a336ac0 100644
--- a/include/net/ip_fib.h
+++ b/include/net/ip_fib.h
@@ -109,6 +109,20 @@ struct fib_result {
109#endif 109#endif
110}; 110};
111 111
112struct fib_result_nl {
113 u32 fl_addr; /* To be looked up*/
114 u32 fl_fwmark;
115 unsigned char fl_tos;
116 unsigned char fl_scope;
117 unsigned char tb_id_in;
118
119 unsigned char tb_id; /* Results */
120 unsigned char prefixlen;
121 unsigned char nh_sel;
122 unsigned char type;
123 unsigned char scope;
124 int err;
125};
112 126
113#ifdef CONFIG_IP_ROUTE_MULTIPATH 127#ifdef CONFIG_IP_ROUTE_MULTIPATH
114 128
diff --git a/include/net/sctp/command.h b/include/net/sctp/command.h
index ebc5282e6d58..dc107ffad483 100644
--- a/include/net/sctp/command.h
+++ b/include/net/sctp/command.h
@@ -65,9 +65,11 @@ typedef enum {
65 SCTP_CMD_TIMER_START, /* Start a timer. */ 65 SCTP_CMD_TIMER_START, /* Start a timer. */
66 SCTP_CMD_TIMER_RESTART, /* Restart a timer. */ 66 SCTP_CMD_TIMER_RESTART, /* Restart a timer. */
67 SCTP_CMD_TIMER_STOP, /* Stop a timer. */ 67 SCTP_CMD_TIMER_STOP, /* Stop a timer. */
68 SCTP_CMD_COUNTER_RESET, /* Reset a counter. */ 68 SCTP_CMD_INIT_CHOOSE_TRANSPORT, /* Choose transport for an INIT. */
69 SCTP_CMD_COUNTER_INC, /* Increment a counter. */ 69 SCTP_CMD_INIT_COUNTER_RESET, /* Reset init counter. */
70 SCTP_CMD_INIT_COUNTER_INC, /* Increment init counter. */
70 SCTP_CMD_INIT_RESTART, /* High level, do init timer work. */ 71 SCTP_CMD_INIT_RESTART, /* High level, do init timer work. */
72 SCTP_CMD_COOKIEECHO_RESTART, /* High level, do cookie-echo timer work. */
71 SCTP_CMD_INIT_FAILED, /* High level, do init failure work. */ 73 SCTP_CMD_INIT_FAILED, /* High level, do init failure work. */
72 SCTP_CMD_REPORT_DUP, /* Report a duplicate TSN. */ 74 SCTP_CMD_REPORT_DUP, /* Report a duplicate TSN. */
73 SCTP_CMD_STRIKE, /* Mark a strike against a transport. */ 75 SCTP_CMD_STRIKE, /* Mark a strike against a transport. */
@@ -118,7 +120,6 @@ typedef union {
118 int error; 120 int error;
119 sctp_state_t state; 121 sctp_state_t state;
120 sctp_event_timeout_t to; 122 sctp_event_timeout_t to;
121 sctp_counter_t counter;
122 void *ptr; 123 void *ptr;
123 struct sctp_chunk *chunk; 124 struct sctp_chunk *chunk;
124 struct sctp_association *asoc; 125 struct sctp_association *asoc;
@@ -165,7 +166,6 @@ SCTP_ARG_CONSTRUCTOR(U16, __u16, u16)
165SCTP_ARG_CONSTRUCTOR(U8, __u8, u8) 166SCTP_ARG_CONSTRUCTOR(U8, __u8, u8)
166SCTP_ARG_CONSTRUCTOR(ERROR, int, error) 167SCTP_ARG_CONSTRUCTOR(ERROR, int, error)
167SCTP_ARG_CONSTRUCTOR(STATE, sctp_state_t, state) 168SCTP_ARG_CONSTRUCTOR(STATE, sctp_state_t, state)
168SCTP_ARG_CONSTRUCTOR(COUNTER, sctp_counter_t, counter)
169SCTP_ARG_CONSTRUCTOR(TO, sctp_event_timeout_t, to) 169SCTP_ARG_CONSTRUCTOR(TO, sctp_event_timeout_t, to)
170SCTP_ARG_CONSTRUCTOR(PTR, void *, ptr) 170SCTP_ARG_CONSTRUCTOR(PTR, void *, ptr)
171SCTP_ARG_CONSTRUCTOR(CHUNK, struct sctp_chunk *, chunk) 171SCTP_ARG_CONSTRUCTOR(CHUNK, struct sctp_chunk *, chunk)
diff --git a/include/net/sctp/constants.h b/include/net/sctp/constants.h
index 2b76c0f4babc..4868c7f7749d 100644
--- a/include/net/sctp/constants.h
+++ b/include/net/sctp/constants.h
@@ -263,13 +263,6 @@ enum { SCTP_MIN_PMTU = 576 };
263enum { SCTP_MAX_DUP_TSNS = 16 }; 263enum { SCTP_MAX_DUP_TSNS = 16 };
264enum { SCTP_MAX_GABS = 16 }; 264enum { SCTP_MAX_GABS = 16 };
265 265
266typedef enum {
267 SCTP_COUNTER_INIT_ERROR,
268} sctp_counter_t;
269
270/* How many counters does an association need? */
271#define SCTP_NUMBER_COUNTERS 5
272
273/* Here we define the default timers. */ 266/* Here we define the default timers. */
274 267
275/* cookie timer def = ? seconds */ 268/* cookie timer def = ? seconds */
diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
index 960abfa48d68..ef2738159ab3 100644
--- a/include/net/sctp/sctp.h
+++ b/include/net/sctp/sctp.h
@@ -223,6 +223,22 @@ DECLARE_SNMP_STAT(struct sctp_mib, sctp_statistics);
223extern int sctp_debug_flag; 223extern int sctp_debug_flag;
224#define SCTP_DEBUG_PRINTK(whatever...) \ 224#define SCTP_DEBUG_PRINTK(whatever...) \
225 ((void) (sctp_debug_flag && printk(KERN_DEBUG whatever))) 225 ((void) (sctp_debug_flag && printk(KERN_DEBUG whatever)))
226#define SCTP_DEBUG_PRINTK_IPADDR(lead, trail, leadparm, saddr, otherparms...) \
227 if (sctp_debug_flag) { \
228 if (saddr->sa.sa_family == AF_INET6) { \
229 printk(KERN_DEBUG \
230 lead "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x" trail, \
231 leadparm, \
232 NIP6(saddr->v6.sin6_addr), \
233 otherparms); \
234 } else { \
235 printk(KERN_DEBUG \
236 lead "%u.%u.%u.%u" trail, \
237 leadparm, \
238 NIPQUAD(saddr->v4.sin_addr.s_addr), \
239 otherparms); \
240 } \
241 }
226#define SCTP_ENABLE_DEBUG { sctp_debug_flag = 1; } 242#define SCTP_ENABLE_DEBUG { sctp_debug_flag = 1; }
227#define SCTP_DISABLE_DEBUG { sctp_debug_flag = 0; } 243#define SCTP_DISABLE_DEBUG { sctp_debug_flag = 0; }
228 244
@@ -236,6 +252,7 @@ extern int sctp_debug_flag;
236#else /* SCTP_DEBUG */ 252#else /* SCTP_DEBUG */
237 253
238#define SCTP_DEBUG_PRINTK(whatever...) 254#define SCTP_DEBUG_PRINTK(whatever...)
255#define SCTP_DEBUG_PRINTK_IPADDR(whatever...)
239#define SCTP_ENABLE_DEBUG 256#define SCTP_ENABLE_DEBUG
240#define SCTP_DISABLE_DEBUG 257#define SCTP_DISABLE_DEBUG
241#define SCTP_ASSERT(expr, str, func) 258#define SCTP_ASSERT(expr, str, func)
diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
index f4fcee104707..a53e08a45e32 100644
--- a/include/net/sctp/sm.h
+++ b/include/net/sctp/sm.h
@@ -116,7 +116,8 @@ sctp_state_fn_t sctp_sf_eat_data_fast_4_4;
116sctp_state_fn_t sctp_sf_eat_sack_6_2; 116sctp_state_fn_t sctp_sf_eat_sack_6_2;
117sctp_state_fn_t sctp_sf_tabort_8_4_8; 117sctp_state_fn_t sctp_sf_tabort_8_4_8;
118sctp_state_fn_t sctp_sf_operr_notify; 118sctp_state_fn_t sctp_sf_operr_notify;
119sctp_state_fn_t sctp_sf_t1_timer_expire; 119sctp_state_fn_t sctp_sf_t1_init_timer_expire;
120sctp_state_fn_t sctp_sf_t1_cookie_timer_expire;
120sctp_state_fn_t sctp_sf_t2_timer_expire; 121sctp_state_fn_t sctp_sf_t2_timer_expire;
121sctp_state_fn_t sctp_sf_t4_timer_expire; 122sctp_state_fn_t sctp_sf_t4_timer_expire;
122sctp_state_fn_t sctp_sf_t5_timer_expire; 123sctp_state_fn_t sctp_sf_t5_timer_expire;
@@ -258,7 +259,10 @@ struct sctp_chunk *sctp_make_fwdtsn(const struct sctp_association *asoc,
258void sctp_chunk_assign_tsn(struct sctp_chunk *); 259void sctp_chunk_assign_tsn(struct sctp_chunk *);
259void sctp_chunk_assign_ssn(struct sctp_chunk *); 260void sctp_chunk_assign_ssn(struct sctp_chunk *);
260 261
261void sctp_stop_t1_and_abort(sctp_cmd_seq_t *commands, __u16 error); 262sctp_disposition_t sctp_stop_t1_and_abort(sctp_cmd_seq_t *commands,
263 __u16 error,
264 const struct sctp_association *asoc,
265 struct sctp_transport *transport);
262 266
263/* Prototypes for statetable processing. */ 267/* Prototypes for statetable processing. */
264 268
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index 6c24d9cd3d66..dfad4d3c581c 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -867,10 +867,13 @@ struct sctp_transport {
867 */ 867 */
868 unsigned long last_time_ecne_reduced; 868 unsigned long last_time_ecne_reduced;
869 869
870 /* active : The current active state of this destination, 870 /* The number of times INIT has been sent on this transport. */
871 * : i.e. DOWN, UP, etc. 871 int init_sent_count;
872
873 /* state : The current state of this destination,
874 * : i.e. SCTP_ACTIVE, SCTP_INACTIVE, SCTP_UNKOWN.
872 */ 875 */
873 int active; 876 int state;
874 877
875 /* hb_allowed : The current heartbeat state of this destination, 878 /* hb_allowed : The current heartbeat state of this destination,
876 * : i.e. ALLOW-HB, NO-HEARTBEAT, etc. 879 * : i.e. ALLOW-HB, NO-HEARTBEAT, etc.
@@ -1222,9 +1225,6 @@ struct sctp_endpoint {
1222 1225
1223 /* sendbuf acct. policy. */ 1226 /* sendbuf acct. policy. */
1224 __u32 sndbuf_policy; 1227 __u32 sndbuf_policy;
1225
1226 /* Name for debugging output... */
1227 char *debug_name;
1228}; 1228};
1229 1229
1230/* Recover the outter endpoint structure. */ 1230/* Recover the outter endpoint structure. */
@@ -1314,11 +1314,23 @@ struct sctp_association {
1314 * : association. Normally this information is 1314 * : association. Normally this information is
1315 * : hashed or keyed for quick lookup and access 1315 * : hashed or keyed for quick lookup and access
1316 * : of the TCB. 1316 * : of the TCB.
1317 * : The list is also initialized with the list
1318 * : of addresses passed with the sctp_connectx()
1319 * : call.
1317 * 1320 *
1318 * It is a list of SCTP_transport's. 1321 * It is a list of SCTP_transport's.
1319 */ 1322 */
1320 struct list_head transport_addr_list; 1323 struct list_head transport_addr_list;
1321 1324
1325 /* transport_count
1326 *
1327 * Peer : A count of the number of peer addresses
1328 * Transport : in the Peer Transport Address List.
1329 * Address :
1330 * Count :
1331 */
1332 __u16 transport_count;
1333
1322 /* port 1334 /* port
1323 * The transport layer port number. 1335 * The transport layer port number.
1324 */ 1336 */
@@ -1486,6 +1498,9 @@ struct sctp_association {
1486 /* Transport to which SHUTDOWN chunk was last sent. */ 1498 /* Transport to which SHUTDOWN chunk was last sent. */
1487 struct sctp_transport *shutdown_last_sent_to; 1499 struct sctp_transport *shutdown_last_sent_to;
1488 1500
1501 /* Transport to which INIT chunk was last sent. */
1502 struct sctp_transport *init_last_sent_to;
1503
1489 /* Next TSN : The next TSN number to be assigned to a new 1504 /* Next TSN : The next TSN number to be assigned to a new
1490 * : DATA chunk. This is sent in the INIT or INIT 1505 * : DATA chunk. This is sent in the INIT or INIT
1491 * : ACK chunk to the peer and incremented each 1506 * : ACK chunk to the peer and incremented each
@@ -1549,8 +1564,11 @@ struct sctp_association {
1549 /* The message size at which SCTP fragmentation will occur. */ 1564 /* The message size at which SCTP fragmentation will occur. */
1550 __u32 frag_point; 1565 __u32 frag_point;
1551 1566
1552 /* Currently only one counter is used to count INIT errors. */ 1567 /* Counter used to count INIT errors. */
1553 int counters[SCTP_NUMBER_COUNTERS]; 1568 int init_err_counter;
1569
1570 /* Count the number of INIT cycles (for doubling timeout). */
1571 int init_cycle;
1554 1572
1555 /* Default send parameters. */ 1573 /* Default send parameters. */
1556 __u16 default_stream; 1574 __u16 default_stream;
@@ -1708,6 +1726,8 @@ void sctp_association_free(struct sctp_association *);
1708void sctp_association_put(struct sctp_association *); 1726void sctp_association_put(struct sctp_association *);
1709void sctp_association_hold(struct sctp_association *); 1727void sctp_association_hold(struct sctp_association *);
1710 1728
1729struct sctp_transport *sctp_assoc_choose_init_transport(
1730 struct sctp_association *);
1711struct sctp_transport *sctp_assoc_choose_shutdown_transport( 1731struct sctp_transport *sctp_assoc_choose_shutdown_transport(
1712 struct sctp_association *); 1732 struct sctp_association *);
1713void sctp_assoc_update_retran_path(struct sctp_association *); 1733void sctp_assoc_update_retran_path(struct sctp_association *);
@@ -1717,9 +1737,12 @@ int sctp_assoc_lookup_laddr(struct sctp_association *asoc,
1717 const union sctp_addr *laddr); 1737 const union sctp_addr *laddr);
1718struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *, 1738struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *,
1719 const union sctp_addr *address, 1739 const union sctp_addr *address,
1720 const int gfp); 1740 const int gfp,
1741 const int peer_state);
1721void sctp_assoc_del_peer(struct sctp_association *asoc, 1742void sctp_assoc_del_peer(struct sctp_association *asoc,
1722 const union sctp_addr *addr); 1743 const union sctp_addr *addr);
1744void sctp_assoc_rm_peer(struct sctp_association *asoc,
1745 struct sctp_transport *peer);
1723void sctp_assoc_control_transport(struct sctp_association *, 1746void sctp_assoc_control_transport(struct sctp_association *,
1724 struct sctp_transport *, 1747 struct sctp_transport *,
1725 sctp_transport_cmd_t, sctp_sn_error_t); 1748 sctp_transport_cmd_t, sctp_sn_error_t);
diff --git a/include/net/sctp/user.h b/include/net/sctp/user.h
index 2758e8ce4f25..f6328aeddcce 100644
--- a/include/net/sctp/user.h
+++ b/include/net/sctp/user.h
@@ -111,6 +111,8 @@ enum sctp_optname {
111#define SCTP_GET_LOCAL_ADDRS_NUM SCTP_GET_LOCAL_ADDRS_NUM 111#define SCTP_GET_LOCAL_ADDRS_NUM SCTP_GET_LOCAL_ADDRS_NUM
112 SCTP_GET_LOCAL_ADDRS, /* Get all local addresss. */ 112 SCTP_GET_LOCAL_ADDRS, /* Get all local addresss. */
113#define SCTP_GET_LOCAL_ADDRS SCTP_GET_LOCAL_ADDRS 113#define SCTP_GET_LOCAL_ADDRS SCTP_GET_LOCAL_ADDRS
114 SCTP_SOCKOPT_CONNECTX, /* CONNECTX requests. */
115#define SCTP_SOCKOPT_CONNECTX SCTP_SOCKOPT_CONNECTX
114}; 116};
115 117
116/* 118/*
@@ -527,6 +529,7 @@ struct sctp_paddrinfo {
527enum sctp_spinfo_state { 529enum sctp_spinfo_state {
528 SCTP_INACTIVE, 530 SCTP_INACTIVE,
529 SCTP_ACTIVE, 531 SCTP_ACTIVE,
532 SCTP_UNKNOWN = 0xffff /* Value used for transport state unknown */
530}; 533};
531 534
532/* 535/*
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index 0e65e02b7a1d..029522a4ceda 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -204,6 +204,7 @@ struct xfrm_state_afinfo {
204 rwlock_t lock; 204 rwlock_t lock;
205 struct list_head *state_bydst; 205 struct list_head *state_bydst;
206 struct list_head *state_byspi; 206 struct list_head *state_byspi;
207 int (*init_flags)(struct xfrm_state *x);
207 void (*init_tempsel)(struct xfrm_state *x, struct flowi *fl, 208 void (*init_tempsel)(struct xfrm_state *x, struct flowi *fl,
208 struct xfrm_tmpl *tmpl, 209 struct xfrm_tmpl *tmpl,
209 xfrm_address_t *daddr, xfrm_address_t *saddr); 210 xfrm_address_t *daddr, xfrm_address_t *saddr);
@@ -225,7 +226,7 @@ struct xfrm_type
225 struct module *owner; 226 struct module *owner;
226 __u8 proto; 227 __u8 proto;
227 228
228 int (*init_state)(struct xfrm_state *x, void *args); 229 int (*init_state)(struct xfrm_state *x);
229 void (*destructor)(struct xfrm_state *); 230 void (*destructor)(struct xfrm_state *);
230 int (*input)(struct xfrm_state *, struct xfrm_decap_state *, struct sk_buff *skb); 231 int (*input)(struct xfrm_state *, struct xfrm_decap_state *, struct sk_buff *skb);
231 int (*post_input)(struct xfrm_state *, struct xfrm_decap_state *, struct sk_buff *skb); 232 int (*post_input)(struct xfrm_state *, struct xfrm_decap_state *, struct sk_buff *skb);
@@ -839,6 +840,7 @@ extern int xfrm_replay_check(struct xfrm_state *x, u32 seq);
839extern void xfrm_replay_advance(struct xfrm_state *x, u32 seq); 840extern void xfrm_replay_advance(struct xfrm_state *x, u32 seq);
840extern int xfrm_state_check(struct xfrm_state *x, struct sk_buff *skb); 841extern int xfrm_state_check(struct xfrm_state *x, struct sk_buff *skb);
841extern int xfrm_state_mtu(struct xfrm_state *x, int mtu); 842extern int xfrm_state_mtu(struct xfrm_state *x, int mtu);
843extern int xfrm_init_state(struct xfrm_state *x);
842extern int xfrm4_rcv(struct sk_buff *skb); 844extern int xfrm4_rcv(struct sk_buff *skb);
843extern int xfrm4_output(struct sk_buff *skb); 845extern int xfrm4_output(struct sk_buff *skb);
844extern int xfrm4_tunnel_register(struct xfrm_tunnel *handler); 846extern int xfrm4_tunnel_register(struct xfrm_tunnel *handler);
diff --git a/kernel/params.c b/kernel/params.c
index 5513844bec13..d586c35ef8fc 100644
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -629,7 +629,7 @@ static ssize_t module_attr_show(struct kobject *kobj,
629 mk = to_module_kobject(kobj); 629 mk = to_module_kobject(kobj);
630 630
631 if (!attribute->show) 631 if (!attribute->show)
632 return -EPERM; 632 return -EIO;
633 633
634 if (!try_module_get(mk->mod)) 634 if (!try_module_get(mk->mod))
635 return -ENODEV; 635 return -ENODEV;
@@ -653,7 +653,7 @@ static ssize_t module_attr_store(struct kobject *kobj,
653 mk = to_module_kobject(kobj); 653 mk = to_module_kobject(kobj);
654 654
655 if (!attribute->store) 655 if (!attribute->store)
656 return -EPERM; 656 return -EIO;
657 657
658 if (!try_module_get(mk->mod)) 658 if (!try_module_get(mk->mod))
659 return -ENODEV; 659 return -ENODEV;
diff --git a/lib/Makefile b/lib/Makefile
index 7c70db79c0e0..9eccea9429a7 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -4,9 +4,10 @@
4 4
5lib-y := errno.o ctype.o string.o vsprintf.o cmdline.o \ 5lib-y := errno.o ctype.o string.o vsprintf.o cmdline.o \
6 bust_spinlocks.o rbtree.o radix-tree.o dump_stack.o \ 6 bust_spinlocks.o rbtree.o radix-tree.o dump_stack.o \
7 kobject.o kref.o idr.o div64.o int_sqrt.o \ 7 idr.o div64.o int_sqrt.o bitmap.o extable.o prio_tree.o \
8 bitmap.o extable.o kobject_uevent.o prio_tree.o sha1.o \ 8 sha1.o halfmd4.o
9 halfmd4.o 9
10lib-y += kobject.o kref.o kobject_uevent.o klist.o
10 11
11obj-y += sort.o parser.o 12obj-y += sort.o parser.o
12 13
diff --git a/lib/klist.c b/lib/klist.c
new file mode 100644
index 000000000000..738ab810160a
--- /dev/null
+++ b/lib/klist.c
@@ -0,0 +1,265 @@
1/*
2 * klist.c - Routines for manipulating klists.
3 *
4 *
5 * This klist interface provides a couple of structures that wrap around
6 * struct list_head to provide explicit list "head" (struct klist) and
7 * list "node" (struct klist_node) objects. For struct klist, a spinlock
8 * is included that protects access to the actual list itself. struct
9 * klist_node provides a pointer to the klist that owns it and a kref
10 * reference count that indicates the number of current users of that node
11 * in the list.
12 *
13 * The entire point is to provide an interface for iterating over a list
14 * that is safe and allows for modification of the list during the
15 * iteration (e.g. insertion and removal), including modification of the
16 * current node on the list.
17 *
18 * It works using a 3rd object type - struct klist_iter - that is declared
19 * and initialized before an iteration. klist_next() is used to acquire the
20 * next element in the list. It returns NULL if there are no more items.
21 * Internally, that routine takes the klist's lock, decrements the reference
22 * count of the previous klist_node and increments the count of the next
23 * klist_node. It then drops the lock and returns.
24 *
25 * There are primitives for adding and removing nodes to/from a klist.
26 * When deleting, klist_del() will simply decrement the reference count.
27 * Only when the count goes to 0 is the node removed from the list.
28 * klist_remove() will try to delete the node from the list and block
29 * until it is actually removed. This is useful for objects (like devices)
30 * that have been removed from the system and must be freed (but must wait
31 * until all accessors have finished).
32 *
33 * Copyright (C) 2005 Patrick Mochel
34 *
35 * This file is released under the GPL v2.
36 */
37
38#include <linux/klist.h>
39#include <linux/module.h>
40
41
42/**
43 * klist_init - Initialize a klist structure.
44 * @k: The klist we're initializing.
45 */
46
47void klist_init(struct klist * k)
48{
49 INIT_LIST_HEAD(&k->k_list);
50 spin_lock_init(&k->k_lock);
51}
52
53EXPORT_SYMBOL_GPL(klist_init);
54
55
56static void add_head(struct klist * k, struct klist_node * n)
57{
58 spin_lock(&k->k_lock);
59 list_add(&n->n_node, &k->k_list);
60 spin_unlock(&k->k_lock);
61}
62
63static void add_tail(struct klist * k, struct klist_node * n)
64{
65 spin_lock(&k->k_lock);
66 list_add_tail(&n->n_node, &k->k_list);
67 spin_unlock(&k->k_lock);
68}
69
70
71static void klist_node_init(struct klist * k, struct klist_node * n)
72{
73 INIT_LIST_HEAD(&n->n_node);
74 init_completion(&n->n_removed);
75 kref_init(&n->n_ref);
76 n->n_klist = k;
77}
78
79
80/**
81 * klist_add_head - Initialize a klist_node and add it to front.
82 * @k: klist it's going on.
83 * @n: node we're adding.
84 */
85
86void klist_add_head(struct klist * k, struct klist_node * n)
87{
88 klist_node_init(k, n);
89 add_head(k, n);
90}
91
92EXPORT_SYMBOL_GPL(klist_add_head);
93
94
95/**
96 * klist_add_tail - Initialize a klist_node and add it to back.
97 * @k: klist it's going on.
98 * @n: node we're adding.
99 */
100
101void klist_add_tail(struct klist * k, struct klist_node * n)
102{
103 klist_node_init(k, n);
104 add_tail(k, n);
105}
106
107EXPORT_SYMBOL_GPL(klist_add_tail);
108
109
110static void klist_release(struct kref * kref)
111{
112 struct klist_node * n = container_of(kref, struct klist_node, n_ref);
113 list_del(&n->n_node);
114 complete(&n->n_removed);
115 n->n_klist = NULL;
116}
117
118static int klist_dec_and_del(struct klist_node * n)
119{
120 return kref_put(&n->n_ref, klist_release);
121}
122
123
124/**
125 * klist_del - Decrement the reference count of node and try to remove.
126 * @n: node we're deleting.
127 */
128
129void klist_del(struct klist_node * n)
130{
131 struct klist * k = n->n_klist;
132
133 spin_lock(&k->k_lock);
134 klist_dec_and_del(n);
135 spin_unlock(&k->k_lock);
136}
137
138EXPORT_SYMBOL_GPL(klist_del);
139
140
141/**
142 * klist_remove - Decrement the refcount of node and wait for it to go away.
143 * @n: node we're removing.
144 */
145
146void klist_remove(struct klist_node * n)
147{
148 struct klist * k = n->n_klist;
149 spin_lock(&k->k_lock);
150 klist_dec_and_del(n);
151 spin_unlock(&k->k_lock);
152 wait_for_completion(&n->n_removed);
153}
154
155EXPORT_SYMBOL_GPL(klist_remove);
156
157
158/**
159 * klist_node_attached - Say whether a node is bound to a list or not.
160 * @n: Node that we're testing.
161 */
162
163int klist_node_attached(struct klist_node * n)
164{
165 return (n->n_klist != NULL);
166}
167
168EXPORT_SYMBOL_GPL(klist_node_attached);
169
170
171/**
172 * klist_iter_init_node - Initialize a klist_iter structure.
173 * @k: klist we're iterating.
174 * @i: klist_iter we're filling.
175 * @n: node to start with.
176 *
177 * Similar to klist_iter_init(), but starts the action off with @n,
178 * instead of with the list head.
179 */
180
181void klist_iter_init_node(struct klist * k, struct klist_iter * i, struct klist_node * n)
182{
183 i->i_klist = k;
184 i->i_head = &k->k_list;
185 i->i_cur = n;
186}
187
188EXPORT_SYMBOL_GPL(klist_iter_init_node);
189
190
191/**
192 * klist_iter_init - Iniitalize a klist_iter structure.
193 * @k: klist we're iterating.
194 * @i: klist_iter structure we're filling.
195 *
196 * Similar to klist_iter_init_node(), but start with the list head.
197 */
198
199void klist_iter_init(struct klist * k, struct klist_iter * i)
200{
201 klist_iter_init_node(k, i, NULL);
202}
203
204EXPORT_SYMBOL_GPL(klist_iter_init);
205
206
207/**
208 * klist_iter_exit - Finish a list iteration.
209 * @i: Iterator structure.
210 *
211 * Must be called when done iterating over list, as it decrements the
212 * refcount of the current node. Necessary in case iteration exited before
213 * the end of the list was reached, and always good form.
214 */
215
216void klist_iter_exit(struct klist_iter * i)
217{
218 if (i->i_cur) {
219 klist_del(i->i_cur);
220 i->i_cur = NULL;
221 }
222}
223
224EXPORT_SYMBOL_GPL(klist_iter_exit);
225
226
227static struct klist_node * to_klist_node(struct list_head * n)
228{
229 return container_of(n, struct klist_node, n_node);
230}
231
232
233/**
234 * klist_next - Ante up next node in list.
235 * @i: Iterator structure.
236 *
237 * First grab list lock. Decrement the reference count of the previous
238 * node, if there was one. Grab the next node, increment its reference
239 * count, drop the lock, and return that next node.
240 */
241
242struct klist_node * klist_next(struct klist_iter * i)
243{
244 struct list_head * next;
245 struct klist_node * knode = NULL;
246
247 spin_lock(&i->i_klist->k_lock);
248 if (i->i_cur) {
249 next = i->i_cur->n_node.next;
250 klist_dec_and_del(i->i_cur);
251 } else
252 next = i->i_head->next;
253
254 if (next != i->i_head) {
255 knode = to_klist_node(next);
256 kref_get(&knode->n_ref);
257 }
258 i->i_cur = knode;
259 spin_unlock(&i->i_klist->k_lock);
260 return knode;
261}
262
263EXPORT_SYMBOL_GPL(klist_next);
264
265
diff --git a/lib/kobject.c b/lib/kobject.c
index 94048826624c..dd0917dd9fa9 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -279,7 +279,7 @@ EXPORT_SYMBOL(kobject_set_name);
279 * @new_name: object's new name 279 * @new_name: object's new name
280 */ 280 */
281 281
282int kobject_rename(struct kobject * kobj, char *new_name) 282int kobject_rename(struct kobject * kobj, const char *new_name)
283{ 283{
284 int error = 0; 284 int error = 0;
285 285
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
index 2a4e7671eaf4..8e49d21057e4 100644
--- a/lib/kobject_uevent.c
+++ b/lib/kobject_uevent.c
@@ -197,7 +197,7 @@ void kobject_hotplug(struct kobject *kobj, enum kobject_action action)
197 int i = 0; 197 int i = 0;
198 int retval; 198 int retval;
199 char *kobj_path = NULL; 199 char *kobj_path = NULL;
200 char *name = NULL; 200 const char *name = NULL;
201 char *action_string; 201 char *action_string;
202 u64 seq; 202 u64 seq;
203 struct kobject *top_kobj = kobj; 203 struct kobject *top_kobj = kobj;
@@ -246,10 +246,10 @@ void kobject_hotplug(struct kobject *kobj, enum kobject_action action)
246 if (hotplug_ops->name) 246 if (hotplug_ops->name)
247 name = hotplug_ops->name(kset, kobj); 247 name = hotplug_ops->name(kset, kobj);
248 if (name == NULL) 248 if (name == NULL)
249 name = kset->kobj.name; 249 name = kobject_name(&kset->kobj);
250 250
251 argv [0] = hotplug_path; 251 argv [0] = hotplug_path;
252 argv [1] = name; 252 argv [1] = (char *)name; /* won't be changed but 'const' has to go */
253 argv [2] = NULL; 253 argv [2] = NULL;
254 254
255 /* minimal command environment */ 255 /* minimal command environment */
diff --git a/net/appletalk/aarp.c b/net/appletalk/aarp.c
index 54640c01b50c..10d040461021 100644
--- a/net/appletalk/aarp.c
+++ b/net/appletalk/aarp.c
@@ -565,7 +565,7 @@ int aarp_send_ddp(struct net_device *dev, struct sk_buff *skb,
565 * numbers we just happen to need. Now put the 565 * numbers we just happen to need. Now put the
566 * length in the lower two. 566 * length in the lower two.
567 */ 567 */
568 *((__u16 *)skb->data) = htons(skb->len); 568 *((__be16 *)skb->data) = htons(skb->len);
569 ft = 1; 569 ft = 1;
570 } 570 }
571 /* 571 /*
diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c
index 876dbac71060..192b529f86a4 100644
--- a/net/appletalk/ddp.c
+++ b/net/appletalk/ddp.c
@@ -401,7 +401,7 @@ out_err:
401} 401}
402 402
403/* Find a match for a specific network:node pair */ 403/* Find a match for a specific network:node pair */
404static struct atalk_iface *atalk_find_interface(int net, int node) 404static struct atalk_iface *atalk_find_interface(__be16 net, int node)
405{ 405{
406 struct atalk_iface *iface; 406 struct atalk_iface *iface;
407 407
diff --git a/net/bridge/br_forward.c b/net/bridge/br_forward.c
index ef9f2095f96e..069253f830c1 100644
--- a/net/bridge/br_forward.c
+++ b/net/bridge/br_forward.c
@@ -57,9 +57,6 @@ int br_forward_finish(struct sk_buff *skb)
57static void __br_deliver(const struct net_bridge_port *to, struct sk_buff *skb) 57static void __br_deliver(const struct net_bridge_port *to, struct sk_buff *skb)
58{ 58{
59 skb->dev = to->dev; 59 skb->dev = to->dev;
60#ifdef CONFIG_NETFILTER_DEBUG
61 skb->nf_debug = 0;
62#endif
63 NF_HOOK(PF_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev, 60 NF_HOOK(PF_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev,
64 br_forward_finish); 61 br_forward_finish);
65} 62}
diff --git a/net/bridge/br_input.c b/net/bridge/br_input.c
index 8f5f2e730992..9a45e6279c57 100644
--- a/net/bridge/br_input.c
+++ b/net/bridge/br_input.c
@@ -23,11 +23,7 @@ const unsigned char bridge_ula[6] = { 0x01, 0x80, 0xc2, 0x00, 0x00, 0x00 };
23 23
24static int br_pass_frame_up_finish(struct sk_buff *skb) 24static int br_pass_frame_up_finish(struct sk_buff *skb)
25{ 25{
26#ifdef CONFIG_NETFILTER_DEBUG
27 skb->nf_debug = 0;
28#endif
29 netif_receive_skb(skb); 26 netif_receive_skb(skb);
30
31 return 0; 27 return 0;
32} 28}
33 29
diff --git a/net/bridge/br_netfilter.c b/net/bridge/br_netfilter.c
index be03d3ad2648..03ae4edddac3 100644
--- a/net/bridge/br_netfilter.c
+++ b/net/bridge/br_netfilter.c
@@ -102,10 +102,6 @@ static int br_nf_pre_routing_finish_ipv6(struct sk_buff *skb)
102{ 102{
103 struct nf_bridge_info *nf_bridge = skb->nf_bridge; 103 struct nf_bridge_info *nf_bridge = skb->nf_bridge;
104 104
105#ifdef CONFIG_NETFILTER_DEBUG
106 skb->nf_debug ^= (1 << NF_BR_PRE_ROUTING);
107#endif
108
109 if (nf_bridge->mask & BRNF_PKT_TYPE) { 105 if (nf_bridge->mask & BRNF_PKT_TYPE) {
110 skb->pkt_type = PACKET_OTHERHOST; 106 skb->pkt_type = PACKET_OTHERHOST;
111 nf_bridge->mask ^= BRNF_PKT_TYPE; 107 nf_bridge->mask ^= BRNF_PKT_TYPE;
@@ -182,10 +178,6 @@ static void __br_dnat_complain(void)
182 * --Bart, 20021007 (updated) */ 178 * --Bart, 20021007 (updated) */
183static int br_nf_pre_routing_finish_bridge(struct sk_buff *skb) 179static int br_nf_pre_routing_finish_bridge(struct sk_buff *skb)
184{ 180{
185#ifdef CONFIG_NETFILTER_DEBUG
186 skb->nf_debug |= (1 << NF_BR_PRE_ROUTING) | (1 << NF_BR_FORWARD);
187#endif
188
189 if (skb->pkt_type == PACKET_OTHERHOST) { 181 if (skb->pkt_type == PACKET_OTHERHOST) {
190 skb->pkt_type = PACKET_HOST; 182 skb->pkt_type = PACKET_HOST;
191 skb->nf_bridge->mask |= BRNF_PKT_TYPE; 183 skb->nf_bridge->mask |= BRNF_PKT_TYPE;
@@ -207,10 +199,6 @@ static int br_nf_pre_routing_finish(struct sk_buff *skb)
207 struct iphdr *iph = skb->nh.iph; 199 struct iphdr *iph = skb->nh.iph;
208 struct nf_bridge_info *nf_bridge = skb->nf_bridge; 200 struct nf_bridge_info *nf_bridge = skb->nf_bridge;
209 201
210#ifdef CONFIG_NETFILTER_DEBUG
211 skb->nf_debug ^= (1 << NF_BR_PRE_ROUTING);
212#endif
213
214 if (nf_bridge->mask & BRNF_PKT_TYPE) { 202 if (nf_bridge->mask & BRNF_PKT_TYPE) {
215 skb->pkt_type = PACKET_OTHERHOST; 203 skb->pkt_type = PACKET_OTHERHOST;
216 nf_bridge->mask ^= BRNF_PKT_TYPE; 204 nf_bridge->mask ^= BRNF_PKT_TYPE;
@@ -382,9 +370,6 @@ static unsigned int br_nf_pre_routing_ipv6(unsigned int hook,
382 if (hdr->nexthdr == NEXTHDR_HOP && check_hbh_len(skb)) 370 if (hdr->nexthdr == NEXTHDR_HOP && check_hbh_len(skb))
383 goto inhdr_error; 371 goto inhdr_error;
384 372
385#ifdef CONFIG_NETFILTER_DEBUG
386 skb->nf_debug ^= (1 << NF_IP6_PRE_ROUTING);
387#endif
388 if ((nf_bridge = nf_bridge_alloc(skb)) == NULL) 373 if ((nf_bridge = nf_bridge_alloc(skb)) == NULL)
389 return NF_DROP; 374 return NF_DROP;
390 setup_pre_routing(skb); 375 setup_pre_routing(skb);
@@ -468,9 +453,6 @@ static unsigned int br_nf_pre_routing(unsigned int hook, struct sk_buff **pskb,
468 skb->ip_summed = CHECKSUM_NONE; 453 skb->ip_summed = CHECKSUM_NONE;
469 } 454 }
470 455
471#ifdef CONFIG_NETFILTER_DEBUG
472 skb->nf_debug ^= (1 << NF_IP_PRE_ROUTING);
473#endif
474 if ((nf_bridge = nf_bridge_alloc(skb)) == NULL) 456 if ((nf_bridge = nf_bridge_alloc(skb)) == NULL)
475 return NF_DROP; 457 return NF_DROP;
476 setup_pre_routing(skb); 458 setup_pre_routing(skb);
@@ -517,10 +499,6 @@ static int br_nf_forward_finish(struct sk_buff *skb)
517 struct net_device *in; 499 struct net_device *in;
518 struct vlan_ethhdr *hdr = vlan_eth_hdr(skb); 500 struct vlan_ethhdr *hdr = vlan_eth_hdr(skb);
519 501
520#ifdef CONFIG_NETFILTER_DEBUG
521 skb->nf_debug ^= (1 << NF_BR_FORWARD);
522#endif
523
524 if (skb->protocol != __constant_htons(ETH_P_ARP) && !IS_VLAN_ARP) { 502 if (skb->protocol != __constant_htons(ETH_P_ARP) && !IS_VLAN_ARP) {
525 in = nf_bridge->physindev; 503 in = nf_bridge->physindev;
526 if (nf_bridge->mask & BRNF_PKT_TYPE) { 504 if (nf_bridge->mask & BRNF_PKT_TYPE) {
@@ -566,9 +544,6 @@ static unsigned int br_nf_forward_ip(unsigned int hook, struct sk_buff **pskb,
566 (*pskb)->nh.raw += VLAN_HLEN; 544 (*pskb)->nh.raw += VLAN_HLEN;
567 } 545 }
568 546
569#ifdef CONFIG_NETFILTER_DEBUG
570 skb->nf_debug ^= (1 << NF_BR_FORWARD);
571#endif
572 nf_bridge = skb->nf_bridge; 547 nf_bridge = skb->nf_bridge;
573 if (skb->pkt_type == PACKET_OTHERHOST) { 548 if (skb->pkt_type == PACKET_OTHERHOST) {
574 skb->pkt_type = PACKET_HOST; 549 skb->pkt_type = PACKET_HOST;
@@ -605,10 +580,6 @@ static unsigned int br_nf_forward_arp(unsigned int hook, struct sk_buff **pskb,
605 (*pskb)->nh.raw += VLAN_HLEN; 580 (*pskb)->nh.raw += VLAN_HLEN;
606 } 581 }
607 582
608#ifdef CONFIG_NETFILTER_DEBUG
609 skb->nf_debug ^= (1 << NF_BR_FORWARD);
610#endif
611
612 if (skb->nh.arph->ar_pln != 4) { 583 if (skb->nh.arph->ar_pln != 4) {
613 if (IS_VLAN_ARP) { 584 if (IS_VLAN_ARP) {
614 skb_push(*pskb, VLAN_HLEN); 585 skb_push(*pskb, VLAN_HLEN);
@@ -627,9 +598,6 @@ static unsigned int br_nf_forward_arp(unsigned int hook, struct sk_buff **pskb,
627/* PF_BRIDGE/LOCAL_OUT ***********************************************/ 598/* PF_BRIDGE/LOCAL_OUT ***********************************************/
628static int br_nf_local_out_finish(struct sk_buff *skb) 599static int br_nf_local_out_finish(struct sk_buff *skb)
629{ 600{
630#ifdef CONFIG_NETFILTER_DEBUG
631 skb->nf_debug &= ~(1 << NF_BR_LOCAL_OUT);
632#endif
633 if (skb->protocol == __constant_htons(ETH_P_8021Q)) { 601 if (skb->protocol == __constant_htons(ETH_P_8021Q)) {
634 skb_push(skb, VLAN_HLEN); 602 skb_push(skb, VLAN_HLEN);
635 skb->nh.raw -= VLAN_HLEN; 603 skb->nh.raw -= VLAN_HLEN;
@@ -731,10 +699,6 @@ static unsigned int br_nf_local_out(unsigned int hook, struct sk_buff **pskb,
731 realoutdev, br_nf_local_out_finish, 699 realoutdev, br_nf_local_out_finish,
732 NF_IP_PRI_BRIDGE_SABOTAGE_FORWARD + 1); 700 NF_IP_PRI_BRIDGE_SABOTAGE_FORWARD + 1);
733 } else { 701 } else {
734#ifdef CONFIG_NETFILTER_DEBUG
735 skb->nf_debug ^= (1 << NF_IP_LOCAL_OUT);
736#endif
737
738 NF_HOOK_THRESH(pf, NF_IP_LOCAL_OUT, skb, realindev, 702 NF_HOOK_THRESH(pf, NF_IP_LOCAL_OUT, skb, realindev,
739 realoutdev, br_nf_local_out_finish, 703 realoutdev, br_nf_local_out_finish,
740 NF_IP_PRI_BRIDGE_SABOTAGE_LOCAL_OUT + 1); 704 NF_IP_PRI_BRIDGE_SABOTAGE_LOCAL_OUT + 1);
@@ -779,8 +743,6 @@ static unsigned int br_nf_post_routing(unsigned int hook, struct sk_buff **pskb,
779 printk(KERN_CRIT "br_netfilter: skb->dst == NULL."); 743 printk(KERN_CRIT "br_netfilter: skb->dst == NULL.");
780 goto print_error; 744 goto print_error;
781 } 745 }
782
783 skb->nf_debug ^= (1 << NF_IP_POST_ROUTING);
784#endif 746#endif
785 747
786 /* We assume any code from br_dev_queue_push_xmit onwards doesn't care 748 /* We assume any code from br_dev_queue_push_xmit onwards doesn't care
diff --git a/net/core/netfilter.c b/net/core/netfilter.c
index 22a8f127c4aa..076c156d5eda 100644
--- a/net/core/netfilter.c
+++ b/net/core/netfilter.c
@@ -141,136 +141,6 @@ void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
141 up(&nf_sockopt_mutex); 141 up(&nf_sockopt_mutex);
142} 142}
143 143
144#ifdef CONFIG_NETFILTER_DEBUG
145#include <net/ip.h>
146#include <net/tcp.h>
147#include <linux/netfilter_ipv4.h>
148
149static void debug_print_hooks_ip(unsigned int nf_debug)
150{
151 if (nf_debug & (1 << NF_IP_PRE_ROUTING)) {
152 printk("PRE_ROUTING ");
153 nf_debug ^= (1 << NF_IP_PRE_ROUTING);
154 }
155 if (nf_debug & (1 << NF_IP_LOCAL_IN)) {
156 printk("LOCAL_IN ");
157 nf_debug ^= (1 << NF_IP_LOCAL_IN);
158 }
159 if (nf_debug & (1 << NF_IP_FORWARD)) {
160 printk("FORWARD ");
161 nf_debug ^= (1 << NF_IP_FORWARD);
162 }
163 if (nf_debug & (1 << NF_IP_LOCAL_OUT)) {
164 printk("LOCAL_OUT ");
165 nf_debug ^= (1 << NF_IP_LOCAL_OUT);
166 }
167 if (nf_debug & (1 << NF_IP_POST_ROUTING)) {
168 printk("POST_ROUTING ");
169 nf_debug ^= (1 << NF_IP_POST_ROUTING);
170 }
171 if (nf_debug)
172 printk("Crap bits: 0x%04X", nf_debug);
173 printk("\n");
174}
175
176static void nf_dump_skb(int pf, struct sk_buff *skb)
177{
178 printk("skb: pf=%i %s dev=%s len=%u\n",
179 pf,
180 skb->sk ? "(owned)" : "(unowned)",
181 skb->dev ? skb->dev->name : "(no dev)",
182 skb->len);
183 switch (pf) {
184 case PF_INET: {
185 const struct iphdr *ip = skb->nh.iph;
186 __u32 *opt = (__u32 *) (ip + 1);
187 int opti;
188 __u16 src_port = 0, dst_port = 0;
189
190 if (ip->protocol == IPPROTO_TCP
191 || ip->protocol == IPPROTO_UDP) {
192 struct tcphdr *tcp=(struct tcphdr *)((__u32 *)ip+ip->ihl);
193 src_port = ntohs(tcp->source);
194 dst_port = ntohs(tcp->dest);
195 }
196
197 printk("PROTO=%d %u.%u.%u.%u:%hu %u.%u.%u.%u:%hu"
198 " L=%hu S=0x%2.2hX I=%hu F=0x%4.4hX T=%hu",
199 ip->protocol, NIPQUAD(ip->saddr),
200 src_port, NIPQUAD(ip->daddr),
201 dst_port,
202 ntohs(ip->tot_len), ip->tos, ntohs(ip->id),
203 ntohs(ip->frag_off), ip->ttl);
204
205 for (opti = 0; opti < (ip->ihl - sizeof(struct iphdr) / 4); opti++)
206 printk(" O=0x%8.8X", *opt++);
207 printk("\n");
208 }
209 }
210}
211
212void nf_debug_ip_local_deliver(struct sk_buff *skb)
213{
214 /* If it's a loopback packet, it must have come through
215 * NF_IP_LOCAL_OUT, NF_IP_RAW_INPUT, NF_IP_PRE_ROUTING and
216 * NF_IP_LOCAL_IN. Otherwise, must have gone through
217 * NF_IP_RAW_INPUT and NF_IP_PRE_ROUTING. */
218 if (!skb->dev) {
219 printk("ip_local_deliver: skb->dev is NULL.\n");
220 } else {
221 if (skb->nf_debug != ((1<<NF_IP_PRE_ROUTING)
222 | (1<<NF_IP_LOCAL_IN))) {
223 printk("ip_local_deliver: bad skb: ");
224 debug_print_hooks_ip(skb->nf_debug);
225 nf_dump_skb(PF_INET, skb);
226 }
227 }
228}
229
230void nf_debug_ip_loopback_xmit(struct sk_buff *newskb)
231{
232 if (newskb->nf_debug != ((1 << NF_IP_LOCAL_OUT)
233 | (1 << NF_IP_POST_ROUTING))) {
234 printk("ip_dev_loopback_xmit: bad owned skb = %p: ",
235 newskb);
236 debug_print_hooks_ip(newskb->nf_debug);
237 nf_dump_skb(PF_INET, newskb);
238 }
239}
240
241void nf_debug_ip_finish_output2(struct sk_buff *skb)
242{
243 /* If it's owned, it must have gone through the
244 * NF_IP_LOCAL_OUT and NF_IP_POST_ROUTING.
245 * Otherwise, must have gone through
246 * NF_IP_PRE_ROUTING, NF_IP_FORWARD and NF_IP_POST_ROUTING.
247 */
248 if (skb->sk) {
249 if (skb->nf_debug != ((1 << NF_IP_LOCAL_OUT)
250 | (1 << NF_IP_POST_ROUTING))) {
251 printk("ip_finish_output: bad owned skb = %p: ", skb);
252 debug_print_hooks_ip(skb->nf_debug);
253 nf_dump_skb(PF_INET, skb);
254 }
255 } else {
256 if (skb->nf_debug != ((1 << NF_IP_PRE_ROUTING)
257 | (1 << NF_IP_FORWARD)
258 | (1 << NF_IP_POST_ROUTING))) {
259 /* Fragments, entunnelled packets, TCP RSTs
260 generated by ipt_REJECT will have no
261 owners, but still may be local */
262 if (skb->nf_debug != ((1 << NF_IP_LOCAL_OUT)
263 | (1 << NF_IP_POST_ROUTING))){
264 printk("ip_finish_output:"
265 " bad unowned skb = %p: ",skb);
266 debug_print_hooks_ip(skb->nf_debug);
267 nf_dump_skb(PF_INET, skb);
268 }
269 }
270 }
271}
272#endif /*CONFIG_NETFILTER_DEBUG*/
273
274/* Call get/setsockopt() */ 144/* Call get/setsockopt() */
275static int nf_sockopt(struct sock *sk, int pf, int val, 145static int nf_sockopt(struct sock *sk, int pf, int val,
276 char __user *opt, int *len, int get) 146 char __user *opt, int *len, int get)
@@ -488,14 +358,6 @@ int nf_hook_slow(int pf, unsigned int hook, struct sk_buff **pskb,
488 /* We may already have this, but read-locks nest anyway */ 358 /* We may already have this, but read-locks nest anyway */
489 rcu_read_lock(); 359 rcu_read_lock();
490 360
491#ifdef CONFIG_NETFILTER_DEBUG
492 if (unlikely((*pskb)->nf_debug & (1 << hook))) {
493 printk("nf_hook: hook %i already set.\n", hook);
494 nf_dump_skb(pf, *pskb);
495 }
496 (*pskb)->nf_debug |= (1 << hook);
497#endif
498
499 elem = &nf_hooks[pf][hook]; 361 elem = &nf_hooks[pf][hook];
500next_hook: 362next_hook:
501 verdict = nf_iterate(&nf_hooks[pf][hook], pskb, hook, indev, 363 verdict = nf_iterate(&nf_hooks[pf][hook], pskb, hook, indev,
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index f65b3de590a9..6d68c03bc051 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -365,9 +365,6 @@ struct sk_buff *skb_clone(struct sk_buff *skb, int gfp_mask)
365 C(nfct); 365 C(nfct);
366 nf_conntrack_get(skb->nfct); 366 nf_conntrack_get(skb->nfct);
367 C(nfctinfo); 367 C(nfctinfo);
368#ifdef CONFIG_NETFILTER_DEBUG
369 C(nf_debug);
370#endif
371#ifdef CONFIG_BRIDGE_NETFILTER 368#ifdef CONFIG_BRIDGE_NETFILTER
372 C(nf_bridge); 369 C(nf_bridge);
373 nf_bridge_get(skb->nf_bridge); 370 nf_bridge_get(skb->nf_bridge);
@@ -432,9 +429,6 @@ static void copy_skb_header(struct sk_buff *new, const struct sk_buff *old)
432 new->nfct = old->nfct; 429 new->nfct = old->nfct;
433 nf_conntrack_get(old->nfct); 430 nf_conntrack_get(old->nfct);
434 new->nfctinfo = old->nfctinfo; 431 new->nfctinfo = old->nfctinfo;
435#ifdef CONFIG_NETFILTER_DEBUG
436 new->nf_debug = old->nf_debug;
437#endif
438#ifdef CONFIG_BRIDGE_NETFILTER 432#ifdef CONFIG_BRIDGE_NETFILTER
439 new->nf_bridge = old->nf_bridge; 433 new->nf_bridge = old->nf_bridge;
440 nf_bridge_get(old->nf_bridge); 434 nf_bridge_get(old->nf_bridge);
diff --git a/net/ipv4/Kconfig b/net/ipv4/Kconfig
index 6d3e8b1bd1f2..05107e0dc145 100644
--- a/net/ipv4/Kconfig
+++ b/net/ipv4/Kconfig
@@ -1,6 +1,32 @@
1# 1#
2# IP configuration 2# IP configuration
3# 3#
4choice
5 prompt "Choose IP: FIB lookup""
6 depends on INET
7 default IP_FIB_HASH
8
9config IP_FIB_HASH
10 bool "FIB_HASH"
11 ---help---
12 Current FIB is very proven and good enough for most users.
13
14config IP_FIB_TRIE
15 bool "FIB_TRIE"
16 ---help---
17 Use new experimental LC-trie as FIB lookup algoritm.
18 This improves lookup performance
19
20 LC-trie is described in:
21
22 IP-address lookup using LC-tries. Stefan Nilsson and Gunnar Karlsson
23 IEEE Journal on Selected Areas in Communications, 17(6):1083-1092, June 1999
24 An experimental study of compression methods for dynamic tries
25 Stefan Nilsson and Matti Tikkanen. Algorithmica, 33(1):19-33, 2002.
26 http://www.nada.kth.se/~snilsson/public/papers/dyntrie2/
27
28endchoice
29
4config IP_MULTICAST 30config IP_MULTICAST
5 bool "IP: multicasting" 31 bool "IP: multicasting"
6 depends on INET 32 depends on INET
diff --git a/net/ipv4/Makefile b/net/ipv4/Makefile
index 8b379627ebb6..65d57d8e1add 100644
--- a/net/ipv4/Makefile
+++ b/net/ipv4/Makefile
@@ -7,8 +7,10 @@ obj-y := utils.o route.o inetpeer.o protocol.o \
7 ip_output.o ip_sockglue.o \ 7 ip_output.o ip_sockglue.o \
8 tcp.o tcp_input.o tcp_output.o tcp_timer.o tcp_ipv4.o tcp_minisocks.o \ 8 tcp.o tcp_input.o tcp_output.o tcp_timer.o tcp_ipv4.o tcp_minisocks.o \
9 datagram.o raw.o udp.o arp.o icmp.o devinet.o af_inet.o igmp.o \ 9 datagram.o raw.o udp.o arp.o icmp.o devinet.o af_inet.o igmp.o \
10 sysctl_net_ipv4.o fib_frontend.o fib_semantics.o fib_hash.o 10 sysctl_net_ipv4.o fib_frontend.o fib_semantics.o
11 11
12obj-$(CONFIG_IP_FIB_HASH) += fib_hash.o
13obj-$(CONFIG_IP_FIB_TRIE) += fib_trie.o
12obj-$(CONFIG_PROC_FS) += proc.o 14obj-$(CONFIG_PROC_FS) += proc.o
13obj-$(CONFIG_IP_MULTIPLE_TABLES) += fib_rules.o 15obj-$(CONFIG_IP_MULTIPLE_TABLES) += fib_rules.o
14obj-$(CONFIG_IP_MROUTE) += ipmr.o 16obj-$(CONFIG_IP_MROUTE) += ipmr.o
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index 03942f133944..658e7977924d 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -1119,6 +1119,10 @@ module_init(inet_init);
1119#ifdef CONFIG_PROC_FS 1119#ifdef CONFIG_PROC_FS
1120extern int fib_proc_init(void); 1120extern int fib_proc_init(void);
1121extern void fib_proc_exit(void); 1121extern void fib_proc_exit(void);
1122#ifdef CONFIG_IP_FIB_TRIE
1123extern int fib_stat_proc_init(void);
1124extern void fib_stat_proc_exit(void);
1125#endif
1122extern int ip_misc_proc_init(void); 1126extern int ip_misc_proc_init(void);
1123extern int raw_proc_init(void); 1127extern int raw_proc_init(void);
1124extern void raw_proc_exit(void); 1128extern void raw_proc_exit(void);
@@ -1139,11 +1143,19 @@ static int __init ipv4_proc_init(void)
1139 goto out_udp; 1143 goto out_udp;
1140 if (fib_proc_init()) 1144 if (fib_proc_init())
1141 goto out_fib; 1145 goto out_fib;
1146#ifdef CONFIG_IP_FIB_TRIE
1147 if (fib_stat_proc_init())
1148 goto out_fib_stat;
1149 #endif
1142 if (ip_misc_proc_init()) 1150 if (ip_misc_proc_init())
1143 goto out_misc; 1151 goto out_misc;
1144out: 1152out:
1145 return rc; 1153 return rc;
1146out_misc: 1154out_misc:
1155#ifdef CONFIG_IP_FIB_TRIE
1156 fib_stat_proc_exit();
1157out_fib_stat:
1158#endif
1147 fib_proc_exit(); 1159 fib_proc_exit();
1148out_fib: 1160out_fib:
1149 udp4_proc_exit(); 1161 udp4_proc_exit();
diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c
index 0e98f2235b6e..514c85b2631a 100644
--- a/net/ipv4/ah4.c
+++ b/net/ipv4/ah4.c
@@ -200,7 +200,7 @@ static void ah4_err(struct sk_buff *skb, u32 info)
200 xfrm_state_put(x); 200 xfrm_state_put(x);
201} 201}
202 202
203static int ah_init_state(struct xfrm_state *x, void *args) 203static int ah_init_state(struct xfrm_state *x)
204{ 204{
205 struct ah_data *ahp = NULL; 205 struct ah_data *ahp = NULL;
206 struct xfrm_algo_desc *aalg_desc; 206 struct xfrm_algo_desc *aalg_desc;
diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
index eae84cc39d3f..ba57446d5d1f 100644
--- a/net/ipv4/esp4.c
+++ b/net/ipv4/esp4.c
@@ -362,7 +362,7 @@ static void esp_destroy(struct xfrm_state *x)
362 kfree(esp); 362 kfree(esp);
363} 363}
364 364
365static int esp_init_state(struct xfrm_state *x, void *args) 365static int esp_init_state(struct xfrm_state *x)
366{ 366{
367 struct esp_data *esp = NULL; 367 struct esp_data *esp = NULL;
368 368
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index 563e7d612706..cd8e45ab9580 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -516,6 +516,60 @@ static void fib_del_ifaddr(struct in_ifaddr *ifa)
516#undef BRD1_OK 516#undef BRD1_OK
517} 517}
518 518
519static void nl_fib_lookup(struct fib_result_nl *frn, struct fib_table *tb )
520{
521
522 struct fib_result res;
523 struct flowi fl = { .nl_u = { .ip4_u = { .daddr = frn->fl_addr,
524 .fwmark = frn->fl_fwmark,
525 .tos = frn->fl_tos,
526 .scope = frn->fl_scope } } };
527 if (tb) {
528 local_bh_disable();
529
530 frn->tb_id = tb->tb_id;
531 frn->err = tb->tb_lookup(tb, &fl, &res);
532
533 if (!frn->err) {
534 frn->prefixlen = res.prefixlen;
535 frn->nh_sel = res.nh_sel;
536 frn->type = res.type;
537 frn->scope = res.scope;
538 }
539 local_bh_enable();
540 }
541}
542
543static void nl_fib_input(struct sock *sk, int len)
544{
545 struct sk_buff *skb = NULL;
546 struct nlmsghdr *nlh = NULL;
547 struct fib_result_nl *frn;
548 int err;
549 u32 pid;
550 struct fib_table *tb;
551
552 skb = skb_recv_datagram(sk, 0, 0, &err);
553 nlh = (struct nlmsghdr *)skb->data;
554
555 frn = (struct fib_result_nl *) NLMSG_DATA(nlh);
556 tb = fib_get_table(frn->tb_id_in);
557
558 nl_fib_lookup(frn, tb);
559
560 pid = nlh->nlmsg_pid; /*pid of sending process */
561 NETLINK_CB(skb).groups = 0; /* not in mcast group */
562 NETLINK_CB(skb).pid = 0; /* from kernel */
563 NETLINK_CB(skb).dst_pid = pid;
564 NETLINK_CB(skb).dst_groups = 0; /* unicast */
565 netlink_unicast(sk, skb, pid, MSG_DONTWAIT);
566}
567
568static void nl_fib_lookup_init(void)
569{
570 netlink_kernel_create(NETLINK_FIB_LOOKUP, nl_fib_input);
571}
572
519static void fib_disable_ip(struct net_device *dev, int force) 573static void fib_disable_ip(struct net_device *dev, int force)
520{ 574{
521 if (fib_sync_down(0, dev, force)) 575 if (fib_sync_down(0, dev, force))
@@ -604,6 +658,7 @@ void __init ip_fib_init(void)
604 658
605 register_netdevice_notifier(&fib_netdev_notifier); 659 register_netdevice_notifier(&fib_netdev_notifier);
606 register_inetaddr_notifier(&fib_inetaddr_notifier); 660 register_inetaddr_notifier(&fib_inetaddr_notifier);
661 nl_fib_lookup_init();
607} 662}
608 663
609EXPORT_SYMBOL(inet_addr_type); 664EXPORT_SYMBOL(inet_addr_type);
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
new file mode 100644
index 000000000000..0671569ee6f0
--- /dev/null
+++ b/net/ipv4/fib_trie.c
@@ -0,0 +1,2454 @@
1/*
2 * This program is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU General Public License
4 * as published by the Free Software Foundation; either version
5 * 2 of the License, or (at your option) any later version.
6 *
7 * Robert Olsson <robert.olsson@its.uu.se> Uppsala Universitet
8 * & Swedish University of Agricultural Sciences.
9 *
10 * Jens Laas <jens.laas@data.slu.se> Swedish University of
11 * Agricultural Sciences.
12 *
13 * Hans Liss <hans.liss@its.uu.se> Uppsala Universitet
14 *
15 * This work is based on the LPC-trie which is originally descibed in:
16 *
17 * An experimental study of compression methods for dynamic tries
18 * Stefan Nilsson and Matti Tikkanen. Algorithmica, 33(1):19-33, 2002.
19 * http://www.nada.kth.se/~snilsson/public/papers/dyntrie2/
20 *
21 *
22 * IP-address lookup using LC-tries. Stefan Nilsson and Gunnar Karlsson
23 * IEEE Journal on Selected Areas in Communications, 17(6):1083-1092, June 1999
24 *
25 * Version: $Id: fib_trie.c,v 1.3 2005/06/08 14:20:01 robert Exp $
26 *
27 *
28 * Code from fib_hash has been reused which includes the following header:
29 *
30 *
31 * INET An implementation of the TCP/IP protocol suite for the LINUX
32 * operating system. INET is implemented using the BSD Socket
33 * interface as the means of communication with the user level.
34 *
35 * IPv4 FIB: lookup engine and maintenance routines.
36 *
37 *
38 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
39 *
40 * This program is free software; you can redistribute it and/or
41 * modify it under the terms of the GNU General Public License
42 * as published by the Free Software Foundation; either version
43 * 2 of the License, or (at your option) any later version.
44 */
45
46#define VERSION "0.323"
47
48#include <linux/config.h>
49#include <asm/uaccess.h>
50#include <asm/system.h>
51#include <asm/bitops.h>
52#include <linux/types.h>
53#include <linux/kernel.h>
54#include <linux/sched.h>
55#include <linux/mm.h>
56#include <linux/string.h>
57#include <linux/socket.h>
58#include <linux/sockios.h>
59#include <linux/errno.h>
60#include <linux/in.h>
61#include <linux/inet.h>
62#include <linux/netdevice.h>
63#include <linux/if_arp.h>
64#include <linux/proc_fs.h>
65#include <linux/skbuff.h>
66#include <linux/netlink.h>
67#include <linux/init.h>
68#include <linux/list.h>
69#include <net/ip.h>
70#include <net/protocol.h>
71#include <net/route.h>
72#include <net/tcp.h>
73#include <net/sock.h>
74#include <net/ip_fib.h>
75#include "fib_lookup.h"
76
77#undef CONFIG_IP_FIB_TRIE_STATS
78#define MAX_CHILDS 16384
79
80#define EXTRACT(p, n, str) ((str)<<(p)>>(32-(n)))
81#define KEYLENGTH (8*sizeof(t_key))
82#define MASK_PFX(k, l) (((l)==0)?0:(k >> (KEYLENGTH-l)) << (KEYLENGTH-l))
83#define TKEY_GET_MASK(offset, bits) (((bits)==0)?0:((t_key)(-1) << (KEYLENGTH - bits) >> offset))
84
85static DEFINE_RWLOCK(fib_lock);
86
87typedef unsigned int t_key;
88
89#define T_TNODE 0
90#define T_LEAF 1
91#define NODE_TYPE_MASK 0x1UL
92#define NODE_PARENT(_node) \
93((struct tnode *)((_node)->_parent & ~NODE_TYPE_MASK))
94#define NODE_SET_PARENT(_node, _ptr) \
95((_node)->_parent = (((unsigned long)(_ptr)) | \
96 ((_node)->_parent & NODE_TYPE_MASK)))
97#define NODE_INIT_PARENT(_node, _type) \
98((_node)->_parent = (_type))
99#define NODE_TYPE(_node) \
100((_node)->_parent & NODE_TYPE_MASK)
101
102#define IS_TNODE(n) (!(n->_parent & T_LEAF))
103#define IS_LEAF(n) (n->_parent & T_LEAF)
104
105struct node {
106 t_key key;
107 unsigned long _parent;
108};
109
110struct leaf {
111 t_key key;
112 unsigned long _parent;
113 struct hlist_head list;
114};
115
116struct leaf_info {
117 struct hlist_node hlist;
118 int plen;
119 struct list_head falh;
120};
121
122struct tnode {
123 t_key key;
124 unsigned long _parent;
125 unsigned short pos:5; /* 2log(KEYLENGTH) bits needed */
126 unsigned short bits:5; /* 2log(KEYLENGTH) bits needed */
127 unsigned short full_children; /* KEYLENGTH bits needed */
128 unsigned short empty_children; /* KEYLENGTH bits needed */
129 struct node *child[0];
130};
131
132#ifdef CONFIG_IP_FIB_TRIE_STATS
133struct trie_use_stats {
134 unsigned int gets;
135 unsigned int backtrack;
136 unsigned int semantic_match_passed;
137 unsigned int semantic_match_miss;
138 unsigned int null_node_hit;
139};
140#endif
141
142struct trie_stat {
143 unsigned int totdepth;
144 unsigned int maxdepth;
145 unsigned int tnodes;
146 unsigned int leaves;
147 unsigned int nullpointers;
148 unsigned int nodesizes[MAX_CHILDS];
149};
150
151struct trie {
152 struct node *trie;
153#ifdef CONFIG_IP_FIB_TRIE_STATS
154 struct trie_use_stats stats;
155#endif
156 int size;
157 unsigned int revision;
158};
159
160static int trie_debug = 0;
161
162static int tnode_full(struct tnode *tn, struct node *n);
163static void put_child(struct trie *t, struct tnode *tn, int i, struct node *n);
164static void tnode_put_child_reorg(struct tnode *tn, int i, struct node *n, int wasfull);
165static int tnode_child_length(struct tnode *tn);
166static struct node *resize(struct trie *t, struct tnode *tn);
167static struct tnode *inflate(struct trie *t, struct tnode *tn);
168static struct tnode *halve(struct trie *t, struct tnode *tn);
169static void tnode_free(struct tnode *tn);
170static void trie_dump_seq(struct seq_file *seq, struct trie *t);
171extern struct fib_alias *fib_find_alias(struct list_head *fah, u8 tos, u32 prio);
172extern int fib_detect_death(struct fib_info *fi, int order,
173 struct fib_info **last_resort, int *last_idx, int *dflt);
174
175extern void rtmsg_fib(int event, u32 key, struct fib_alias *fa, int z, int tb_id,
176 struct nlmsghdr *n, struct netlink_skb_parms *req);
177
178static kmem_cache_t *fn_alias_kmem;
179static struct trie *trie_local = NULL, *trie_main = NULL;
180
181static void trie_bug(char *err)
182{
183 printk("Trie Bug: %s\n", err);
184 BUG();
185}
186
187static inline struct node *tnode_get_child(struct tnode *tn, int i)
188{
189 if (i >= 1<<tn->bits)
190 trie_bug("tnode_get_child");
191
192 return tn->child[i];
193}
194
195static inline int tnode_child_length(struct tnode *tn)
196{
197 return 1<<tn->bits;
198}
199
200/*
201 _________________________________________________________________
202 | i | i | i | i | i | i | i | N | N | N | S | S | S | S | S | C |
203 ----------------------------------------------------------------
204 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
205
206 _________________________________________________________________
207 | C | C | C | u | u | u | u | u | u | u | u | u | u | u | u | u |
208 -----------------------------------------------------------------
209 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
210
211 tp->pos = 7
212 tp->bits = 3
213 n->pos = 15
214 n->bits=4
215 KEYLENGTH=32
216*/
217
218static inline t_key tkey_extract_bits(t_key a, int offset, int bits)
219{
220 if (offset < KEYLENGTH)
221 return ((t_key)(a << offset)) >> (KEYLENGTH - bits);
222 else
223 return 0;
224}
225
226static inline int tkey_equals(t_key a, t_key b)
227{
228 return a == b;
229}
230
231static inline int tkey_sub_equals(t_key a, int offset, int bits, t_key b)
232{
233 if (bits == 0 || offset >= KEYLENGTH)
234 return 1;
235 bits = bits > KEYLENGTH ? KEYLENGTH : bits;
236 return ((a ^ b) << offset) >> (KEYLENGTH - bits) == 0;
237}
238
239static inline int tkey_mismatch(t_key a, int offset, t_key b)
240{
241 t_key diff = a ^ b;
242 int i = offset;
243
244 if(!diff)
245 return 0;
246 while((diff << i) >> (KEYLENGTH-1) == 0)
247 i++;
248 return i;
249}
250
251/* Candiate for fib_semantics */
252
253static void fn_free_alias(struct fib_alias *fa)
254{
255 fib_release_info(fa->fa_info);
256 kmem_cache_free(fn_alias_kmem, fa);
257}
258
259/*
260 To understand this stuff, an understanding of keys and all their bits is
261 necessary. Every node in the trie has a key associated with it, but not
262 all of the bits in that key are significant.
263
264 Consider a node 'n' and its parent 'tp'.
265
266 If n is a leaf, every bit in its key is significant. Its presence is
267 necessitaded by path compression, since during a tree traversal (when
268 searching for a leaf - unless we are doing an insertion) we will completely
269 ignore all skipped bits we encounter. Thus we need to verify, at the end of
270 a potentially successful search, that we have indeed been walking the
271 correct key path.
272
273 Note that we can never "miss" the correct key in the tree if present by
274 following the wrong path. Path compression ensures that segments of the key
275 that are the same for all keys with a given prefix are skipped, but the
276 skipped part *is* identical for each node in the subtrie below the skipped
277 bit! trie_insert() in this implementation takes care of that - note the
278 call to tkey_sub_equals() in trie_insert().
279
280 if n is an internal node - a 'tnode' here, the various parts of its key
281 have many different meanings.
282
283 Example:
284 _________________________________________________________________
285 | i | i | i | i | i | i | i | N | N | N | S | S | S | S | S | C |
286 -----------------------------------------------------------------
287 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
288
289 _________________________________________________________________
290 | C | C | C | u | u | u | u | u | u | u | u | u | u | u | u | u |
291 -----------------------------------------------------------------
292 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
293
294 tp->pos = 7
295 tp->bits = 3
296 n->pos = 15
297 n->bits=4
298
299 First, let's just ignore the bits that come before the parent tp, that is
300 the bits from 0 to (tp->pos-1). They are *known* but at this point we do
301 not use them for anything.
302
303 The bits from (tp->pos) to (tp->pos + tp->bits - 1) - "N", above - are the
304 index into the parent's child array. That is, they will be used to find
305 'n' among tp's children.
306
307 The bits from (tp->pos + tp->bits) to (n->pos - 1) - "S" - are skipped bits
308 for the node n.
309
310 All the bits we have seen so far are significant to the node n. The rest
311 of the bits are really not needed or indeed known in n->key.
312
313 The bits from (n->pos) to (n->pos + n->bits - 1) - "C" - are the index into
314 n's child array, and will of course be different for each child.
315
316 The rest of the bits, from (n->pos + n->bits) onward, are completely unknown
317 at this point.
318
319*/
320
321static void check_tnode(struct tnode *tn)
322{
323 if(tn && tn->pos+tn->bits > 32) {
324 printk("TNODE ERROR tn=%p, pos=%d, bits=%d\n", tn, tn->pos, tn->bits);
325 }
326}
327
328static int halve_threshold = 25;
329static int inflate_threshold = 50;
330
331static struct leaf *leaf_new(void)
332{
333 struct leaf *l = kmalloc(sizeof(struct leaf), GFP_KERNEL);
334 if(l) {
335 NODE_INIT_PARENT(l, T_LEAF);
336 INIT_HLIST_HEAD(&l->list);
337 }
338 return l;
339}
340
341static struct leaf_info *leaf_info_new(int plen)
342{
343 struct leaf_info *li = kmalloc(sizeof(struct leaf_info), GFP_KERNEL);
344 li->plen = plen;
345 INIT_LIST_HEAD(&li->falh);
346 return li;
347}
348
349static inline void free_leaf(struct leaf *l)
350{
351 kfree(l);
352}
353
354static inline void free_leaf_info(struct leaf_info *li)
355{
356 kfree(li);
357}
358
359static struct tnode* tnode_new(t_key key, int pos, int bits)
360{
361 int nchildren = 1<<bits;
362 int sz = sizeof(struct tnode) + nchildren * sizeof(struct node *);
363 struct tnode *tn = kmalloc(sz, GFP_KERNEL);
364
365 if(tn) {
366 memset(tn, 0, sz);
367 NODE_INIT_PARENT(tn, T_TNODE);
368 tn->pos = pos;
369 tn->bits = bits;
370 tn->key = key;
371 tn->full_children = 0;
372 tn->empty_children = 1<<bits;
373 }
374 if(trie_debug > 0)
375 printk("AT %p s=%u %u\n", tn, (unsigned int) sizeof(struct tnode),
376 (unsigned int) (sizeof(struct node) * 1<<bits));
377 return tn;
378}
379
380static void tnode_free(struct tnode *tn)
381{
382 if(!tn) {
383 trie_bug("tnode_free\n");
384 }
385 if(IS_LEAF(tn)) {
386 free_leaf((struct leaf *)tn);
387 if(trie_debug > 0 )
388 printk("FL %p \n", tn);
389 }
390 else if(IS_TNODE(tn)) {
391 kfree(tn);
392 if(trie_debug > 0 )
393 printk("FT %p \n", tn);
394 }
395 else {
396 trie_bug("tnode_free\n");
397 }
398}
399
400/*
401 * Check whether a tnode 'n' is "full", i.e. it is an internal node
402 * and no bits are skipped. See discussion in dyntree paper p. 6
403 */
404
405static inline int tnode_full(struct tnode *tn, struct node *n)
406{
407 if(n == NULL || IS_LEAF(n))
408 return 0;
409
410 return ((struct tnode *) n)->pos == tn->pos + tn->bits;
411}
412
413static inline void put_child(struct trie *t, struct tnode *tn, int i, struct node *n)
414{
415 tnode_put_child_reorg(tn, i, n, -1);
416}
417
418 /*
419 * Add a child at position i overwriting the old value.
420 * Update the value of full_children and empty_children.
421 */
422
423static void tnode_put_child_reorg(struct tnode *tn, int i, struct node *n, int wasfull)
424{
425 struct node *chi;
426 int isfull;
427
428 if(i >= 1<<tn->bits) {
429 printk("bits=%d, i=%d\n", tn->bits, i);
430 trie_bug("tnode_put_child_reorg bits");
431 }
432 write_lock_bh(&fib_lock);
433 chi = tn->child[i];
434
435 /* update emptyChildren */
436 if (n == NULL && chi != NULL)
437 tn->empty_children++;
438 else if (n != NULL && chi == NULL)
439 tn->empty_children--;
440
441 /* update fullChildren */
442 if (wasfull == -1)
443 wasfull = tnode_full(tn, chi);
444
445 isfull = tnode_full(tn, n);
446 if (wasfull && !isfull)
447 tn->full_children--;
448
449 else if (!wasfull && isfull)
450 tn->full_children++;
451 if(n)
452 NODE_SET_PARENT(n, tn);
453
454 tn->child[i] = n;
455 write_unlock_bh(&fib_lock);
456}
457
458static struct node *resize(struct trie *t, struct tnode *tn)
459{
460 int i;
461
462 if (!tn)
463 return NULL;
464
465 if(trie_debug)
466 printk("In tnode_resize %p inflate_threshold=%d threshold=%d\n",
467 tn, inflate_threshold, halve_threshold);
468
469 /* No children */
470 if (tn->empty_children == tnode_child_length(tn)) {
471 tnode_free(tn);
472 return NULL;
473 }
474 /* One child */
475 if (tn->empty_children == tnode_child_length(tn) - 1)
476 for (i = 0; i < tnode_child_length(tn); i++) {
477
478 write_lock_bh(&fib_lock);
479 if (tn->child[i] != NULL) {
480
481 /* compress one level */
482 struct node *n = tn->child[i];
483 if(n)
484 NODE_INIT_PARENT(n, NODE_TYPE(n));
485
486 write_unlock_bh(&fib_lock);
487 tnode_free(tn);
488 return n;
489 }
490 write_unlock_bh(&fib_lock);
491 }
492 /*
493 * Double as long as the resulting node has a number of
494 * nonempty nodes that are above the threshold.
495 */
496
497 /*
498 * From "Implementing a dynamic compressed trie" by Stefan Nilsson of
499 * the Helsinki University of Technology and Matti Tikkanen of Nokia
500 * Telecommunications, page 6:
501 * "A node is doubled if the ratio of non-empty children to all
502 * children in the *doubled* node is at least 'high'."
503 *
504 * 'high' in this instance is the variable 'inflate_threshold'. It
505 * is expressed as a percentage, so we multiply it with
506 * tnode_child_length() and instead of multiplying by 2 (since the
507 * child array will be doubled by inflate()) and multiplying
508 * the left-hand side by 100 (to handle the percentage thing) we
509 * multiply the left-hand side by 50.
510 *
511 * The left-hand side may look a bit weird: tnode_child_length(tn)
512 * - tn->empty_children is of course the number of non-null children
513 * in the current node. tn->full_children is the number of "full"
514 * children, that is non-null tnodes with a skip value of 0.
515 * All of those will be doubled in the resulting inflated tnode, so
516 * we just count them one extra time here.
517 *
518 * A clearer way to write this would be:
519 *
520 * to_be_doubled = tn->full_children;
521 * not_to_be_doubled = tnode_child_length(tn) - tn->empty_children -
522 * tn->full_children;
523 *
524 * new_child_length = tnode_child_length(tn) * 2;
525 *
526 * new_fill_factor = 100 * (not_to_be_doubled + 2*to_be_doubled) /
527 * new_child_length;
528 * if (new_fill_factor >= inflate_threshold)
529 *
530 * ...and so on, tho it would mess up the while() loop.
531 *
532 * anyway,
533 * 100 * (not_to_be_doubled + 2*to_be_doubled) / new_child_length >=
534 * inflate_threshold
535 *
536 * avoid a division:
537 * 100 * (not_to_be_doubled + 2*to_be_doubled) >=
538 * inflate_threshold * new_child_length
539 *
540 * expand not_to_be_doubled and to_be_doubled, and shorten:
541 * 100 * (tnode_child_length(tn) - tn->empty_children +
542 * tn->full_children ) >= inflate_threshold * new_child_length
543 *
544 * expand new_child_length:
545 * 100 * (tnode_child_length(tn) - tn->empty_children +
546 * tn->full_children ) >=
547 * inflate_threshold * tnode_child_length(tn) * 2
548 *
549 * shorten again:
550 * 50 * (tn->full_children + tnode_child_length(tn) -
551 * tn->empty_children ) >= inflate_threshold *
552 * tnode_child_length(tn)
553 *
554 */
555
556 check_tnode(tn);
557
558 while ((tn->full_children > 0 &&
559 50 * (tn->full_children + tnode_child_length(tn) - tn->empty_children) >=
560 inflate_threshold * tnode_child_length(tn))) {
561
562 tn = inflate(t, tn);
563 }
564
565 check_tnode(tn);
566
567 /*
568 * Halve as long as the number of empty children in this
569 * node is above threshold.
570 */
571 while (tn->bits > 1 &&
572 100 * (tnode_child_length(tn) - tn->empty_children) <
573 halve_threshold * tnode_child_length(tn))
574
575 tn = halve(t, tn);
576
577 /* Only one child remains */
578
579 if (tn->empty_children == tnode_child_length(tn) - 1)
580 for (i = 0; i < tnode_child_length(tn); i++) {
581
582 write_lock_bh(&fib_lock);
583 if (tn->child[i] != NULL) {
584 /* compress one level */
585 struct node *n = tn->child[i];
586
587 if(n)
588 NODE_INIT_PARENT(n, NODE_TYPE(n));
589
590 write_unlock_bh(&fib_lock);
591 tnode_free(tn);
592 return n;
593 }
594 write_unlock_bh(&fib_lock);
595 }
596
597 return (struct node *) tn;
598}
599
600static struct tnode *inflate(struct trie *t, struct tnode *tn)
601{
602 struct tnode *inode;
603 struct tnode *oldtnode = tn;
604 int olen = tnode_child_length(tn);
605 int i;
606
607 if(trie_debug)
608 printk("In inflate\n");
609
610 tn = tnode_new(oldtnode->key, oldtnode->pos, oldtnode->bits + 1);
611
612 if (!tn)
613 trie_bug("tnode_new failed");
614
615 for(i = 0; i < olen; i++) {
616 struct node *node = tnode_get_child(oldtnode, i);
617
618 /* An empty child */
619 if (node == NULL)
620 continue;
621
622 /* A leaf or an internal node with skipped bits */
623
624 if(IS_LEAF(node) || ((struct tnode *) node)->pos >
625 tn->pos + tn->bits - 1) {
626 if(tkey_extract_bits(node->key, tn->pos + tn->bits - 1,
627 1) == 0)
628 put_child(t, tn, 2*i, node);
629 else
630 put_child(t, tn, 2*i+1, node);
631 continue;
632 }
633
634 /* An internal node with two children */
635 inode = (struct tnode *) node;
636
637 if (inode->bits == 1) {
638 put_child(t, tn, 2*i, inode->child[0]);
639 put_child(t, tn, 2*i+1, inode->child[1]);
640
641 tnode_free(inode);
642 }
643
644 /* An internal node with more than two children */
645 else {
646 struct tnode *left, *right;
647 int size, j;
648
649 /* We will replace this node 'inode' with two new
650 * ones, 'left' and 'right', each with half of the
651 * original children. The two new nodes will have
652 * a position one bit further down the key and this
653 * means that the "significant" part of their keys
654 * (see the discussion near the top of this file)
655 * will differ by one bit, which will be "0" in
656 * left's key and "1" in right's key. Since we are
657 * moving the key position by one step, the bit that
658 * we are moving away from - the bit at position
659 * (inode->pos) - is the one that will differ between
660 * left and right. So... we synthesize that bit in the
661 * two new keys.
662 * The mask 'm' below will be a single "one" bit at
663 * the position (inode->pos)
664 */
665
666 t_key m = TKEY_GET_MASK(inode->pos, 1);
667
668 /* Use the old key, but set the new significant
669 * bit to zero.
670 */
671 left = tnode_new(inode->key&(~m), inode->pos + 1,
672 inode->bits - 1);
673
674 if(!left)
675 trie_bug("tnode_new failed");
676
677
678 /* Use the old key, but set the new significant
679 * bit to one.
680 */
681 right = tnode_new(inode->key|m, inode->pos + 1,
682 inode->bits - 1);
683
684 if(!right)
685 trie_bug("tnode_new failed");
686
687 size = tnode_child_length(left);
688 for(j = 0; j < size; j++) {
689 put_child(t, left, j, inode->child[j]);
690 put_child(t, right, j, inode->child[j + size]);
691 }
692 put_child(t, tn, 2*i, resize(t, left));
693 put_child(t, tn, 2*i+1, resize(t, right));
694
695 tnode_free(inode);
696 }
697 }
698 tnode_free(oldtnode);
699 return tn;
700}
701
702static struct tnode *halve(struct trie *t, struct tnode *tn)
703{
704 struct tnode *oldtnode = tn;
705 struct node *left, *right;
706 int i;
707 int olen = tnode_child_length(tn);
708
709 if(trie_debug) printk("In halve\n");
710
711 tn=tnode_new(oldtnode->key, oldtnode->pos, oldtnode->bits - 1);
712
713 if(!tn)
714 trie_bug("tnode_new failed");
715
716 for(i = 0; i < olen; i += 2) {
717 left = tnode_get_child(oldtnode, i);
718 right = tnode_get_child(oldtnode, i+1);
719
720 /* At least one of the children is empty */
721 if (left == NULL) {
722 if (right == NULL) /* Both are empty */
723 continue;
724 put_child(t, tn, i/2, right);
725 } else if (right == NULL)
726 put_child(t, tn, i/2, left);
727
728 /* Two nonempty children */
729 else {
730 struct tnode *newBinNode =
731 tnode_new(left->key, tn->pos + tn->bits, 1);
732
733 if(!newBinNode)
734 trie_bug("tnode_new failed");
735
736 put_child(t, newBinNode, 0, left);
737 put_child(t, newBinNode, 1, right);
738 put_child(t, tn, i/2, resize(t, newBinNode));
739 }
740 }
741 tnode_free(oldtnode);
742 return tn;
743}
744
745static void *trie_init(struct trie *t)
746{
747 if(t) {
748 t->size = 0;
749 t->trie = NULL;
750 t->revision = 0;
751#ifdef CONFIG_IP_FIB_TRIE_STATS
752 memset(&t->stats, 0, sizeof(struct trie_use_stats));
753#endif
754 }
755 return t;
756}
757
758static struct leaf_info *find_leaf_info(struct hlist_head *head, int plen)
759{
760 struct hlist_node *node;
761 struct leaf_info *li;
762
763 hlist_for_each_entry(li, node, head, hlist) {
764
765 if ( li->plen == plen )
766 return li;
767 }
768 return NULL;
769}
770
771static inline struct list_head * get_fa_head(struct leaf *l, int plen)
772{
773 struct list_head *fa_head=NULL;
774 struct leaf_info *li = find_leaf_info(&l->list, plen);
775
776 if(li)
777 fa_head = &li->falh;
778
779 return fa_head;
780}
781
782static void insert_leaf_info(struct hlist_head *head, struct leaf_info *new)
783{
784 struct leaf_info *li=NULL, *last=NULL;
785 struct hlist_node *node, *tmp;
786
787 write_lock_bh(&fib_lock);
788
789 if(hlist_empty(head))
790 hlist_add_head(&new->hlist, head);
791 else {
792 hlist_for_each_entry_safe(li, node, tmp, head, hlist) {
793
794 if (new->plen > li->plen)
795 break;
796
797 last = li;
798 }
799 if(last)
800 hlist_add_after(&last->hlist, &new->hlist);
801 else
802 hlist_add_before(&new->hlist, &li->hlist);
803 }
804 write_unlock_bh(&fib_lock);
805}
806
807static struct leaf *
808fib_find_node(struct trie *t, u32 key)
809{
810 int pos;
811 struct tnode *tn;
812 struct node *n;
813
814 pos = 0;
815 n=t->trie;
816
817 while (n != NULL && NODE_TYPE(n) == T_TNODE) {
818 tn = (struct tnode *) n;
819
820 check_tnode(tn);
821
822 if(tkey_sub_equals(tn->key, pos, tn->pos-pos, key)) {
823 pos=tn->pos + tn->bits;
824 n = tnode_get_child(tn, tkey_extract_bits(key, tn->pos, tn->bits));
825 }
826 else
827 break;
828 }
829 /* Case we have found a leaf. Compare prefixes */
830
831 if (n != NULL && IS_LEAF(n) && tkey_equals(key, n->key)) {
832 struct leaf *l = (struct leaf *) n;
833 return l;
834 }
835 return NULL;
836}
837
838static struct node *trie_rebalance(struct trie *t, struct tnode *tn)
839{
840 int i = 0;
841 int wasfull;
842 t_key cindex, key;
843 struct tnode *tp = NULL;
844
845 if(!tn)
846 BUG();
847
848 key = tn->key;
849 i = 0;
850
851 while (tn != NULL && NODE_PARENT(tn) != NULL) {
852
853 if( i > 10 ) {
854 printk("Rebalance tn=%p \n", tn);
855 if(tn) printk("tn->parent=%p \n", NODE_PARENT(tn));
856
857 printk("Rebalance tp=%p \n", tp);
858 if(tp) printk("tp->parent=%p \n", NODE_PARENT(tp));
859 }
860
861 if( i > 12 ) BUG();
862 i++;
863
864 tp = NODE_PARENT(tn);
865 cindex = tkey_extract_bits(key, tp->pos, tp->bits);
866 wasfull = tnode_full(tp, tnode_get_child(tp, cindex));
867 tn = (struct tnode *) resize (t, (struct tnode *)tn);
868 tnode_put_child_reorg((struct tnode *)tp, cindex,(struct node*)tn, wasfull);
869
870 if(!NODE_PARENT(tn))
871 break;
872
873 tn = NODE_PARENT(tn);
874 }
875 /* Handle last (top) tnode */
876 if (IS_TNODE(tn))
877 tn = (struct tnode*) resize(t, (struct tnode *)tn);
878
879 return (struct node*) tn;
880}
881
882static struct list_head *
883fib_insert_node(struct trie *t, u32 key, int plen)
884{
885 int pos, newpos;
886 struct tnode *tp = NULL, *tn = NULL;
887 struct node *n;
888 struct leaf *l;
889 int missbit;
890 struct list_head *fa_head=NULL;
891 struct leaf_info *li;
892 t_key cindex;
893
894 pos = 0;
895 n=t->trie;
896
897 /* If we point to NULL, stop. Either the tree is empty and we should
898 * just put a new leaf in if, or we have reached an empty child slot,
899 * and we should just put our new leaf in that.
900 * If we point to a T_TNODE, check if it matches our key. Note that
901 * a T_TNODE might be skipping any number of bits - its 'pos' need
902 * not be the parent's 'pos'+'bits'!
903 *
904 * If it does match the current key, get pos/bits from it, extract
905 * the index from our key, push the T_TNODE and walk the tree.
906 *
907 * If it doesn't, we have to replace it with a new T_TNODE.
908 *
909 * If we point to a T_LEAF, it might or might not have the same key
910 * as we do. If it does, just change the value, update the T_LEAF's
911 * value, and return it.
912 * If it doesn't, we need to replace it with a T_TNODE.
913 */
914
915 while (n != NULL && NODE_TYPE(n) == T_TNODE) {
916 tn = (struct tnode *) n;
917
918 check_tnode(tn);
919
920 if(tkey_sub_equals(tn->key, pos, tn->pos-pos, key)) {
921 tp = tn;
922 pos=tn->pos + tn->bits;
923 n = tnode_get_child(tn, tkey_extract_bits(key, tn->pos, tn->bits));
924
925 if(n && NODE_PARENT(n) != tn) {
926 printk("BUG tn=%p, n->parent=%p\n", tn, NODE_PARENT(n));
927 BUG();
928 }
929 }
930 else
931 break;
932 }
933
934 /*
935 * n ----> NULL, LEAF or TNODE
936 *
937 * tp is n's (parent) ----> NULL or TNODE
938 */
939
940 if(tp && IS_LEAF(tp))
941 BUG();
942
943 t->revision++;
944
945 /* Case 1: n is a leaf. Compare prefixes */
946
947 if (n != NULL && IS_LEAF(n) && tkey_equals(key, n->key)) {
948 struct leaf *l = ( struct leaf *) n;
949
950 li = leaf_info_new(plen);
951
952 if(! li)
953 BUG();
954
955 fa_head = &li->falh;
956 insert_leaf_info(&l->list, li);
957 goto done;
958 }
959 t->size++;
960 l = leaf_new();
961
962 if(! l)
963 BUG();
964
965 l->key = key;
966 li = leaf_info_new(plen);
967
968 if(! li)
969 BUG();
970
971 fa_head = &li->falh;
972 insert_leaf_info(&l->list, li);
973
974 /* Case 2: n is NULL, and will just insert a new leaf */
975 if (t->trie && n == NULL) {
976
977 NODE_SET_PARENT(l, tp);
978
979 if (!tp)
980 BUG();
981
982 else {
983 cindex = tkey_extract_bits(key, tp->pos, tp->bits);
984 put_child(t, (struct tnode *)tp, cindex, (struct node *)l);
985 }
986 }
987 /* Case 3: n is a LEAF or a TNODE and the key doesn't match. */
988 else {
989 /*
990 * Add a new tnode here
991 * first tnode need some special handling
992 */
993
994 if (tp)
995 pos=tp->pos+tp->bits;
996 else
997 pos=0;
998 if(n) {
999 newpos = tkey_mismatch(key, pos, n->key);
1000 tn = tnode_new(n->key, newpos, 1);
1001 }
1002 else {
1003 newpos = 0;
1004 tn = tnode_new(key, newpos, 1); /* First tnode */
1005 }
1006 if(!tn)
1007 trie_bug("tnode_pfx_new failed");
1008
1009 NODE_SET_PARENT(tn, tp);
1010
1011 missbit=tkey_extract_bits(key, newpos, 1);
1012 put_child(t, tn, missbit, (struct node *)l);
1013 put_child(t, tn, 1-missbit, n);
1014
1015 if(tp) {
1016 cindex = tkey_extract_bits(key, tp->pos, tp->bits);
1017 put_child(t, (struct tnode *)tp, cindex, (struct node *)tn);
1018 }
1019 else {
1020 t->trie = (struct node*) tn; /* First tnode */
1021 tp = tn;
1022 }
1023 }
1024 if(tp && tp->pos+tp->bits > 32) {
1025 printk("ERROR tp=%p pos=%d, bits=%d, key=%0x plen=%d\n",
1026 tp, tp->pos, tp->bits, key, plen);
1027 }
1028 /* Rebalance the trie */
1029 t->trie = trie_rebalance(t, tp);
1030done:;
1031 return fa_head;
1032}
1033
1034static int
1035fn_trie_insert(struct fib_table *tb, struct rtmsg *r, struct kern_rta *rta,
1036 struct nlmsghdr *nlhdr, struct netlink_skb_parms *req)
1037{
1038 struct trie *t = (struct trie *) tb->tb_data;
1039 struct fib_alias *fa, *new_fa;
1040 struct list_head *fa_head=NULL;
1041 struct fib_info *fi;
1042 int plen = r->rtm_dst_len;
1043 int type = r->rtm_type;
1044 u8 tos = r->rtm_tos;
1045 u32 key, mask;
1046 int err;
1047 struct leaf *l;
1048
1049 if (plen > 32)
1050 return -EINVAL;
1051
1052 key = 0;
1053 if (rta->rta_dst)
1054 memcpy(&key, rta->rta_dst, 4);
1055
1056 key = ntohl(key);
1057
1058 if(trie_debug)
1059 printk("Insert table=%d %08x/%d\n", tb->tb_id, key, plen);
1060
1061 mask = ntohl( inet_make_mask(plen) );
1062
1063 if(key & ~mask)
1064 return -EINVAL;
1065
1066 key = key & mask;
1067
1068 if ((fi = fib_create_info(r, rta, nlhdr, &err)) == NULL)
1069 goto err;
1070
1071 l = fib_find_node(t, key);
1072 fa = NULL;
1073
1074 if(l) {
1075 fa_head = get_fa_head(l, plen);
1076 fa = fib_find_alias(fa_head, tos, fi->fib_priority);
1077 }
1078
1079 /* Now fa, if non-NULL, points to the first fib alias
1080 * with the same keys [prefix,tos,priority], if such key already
1081 * exists or to the node before which we will insert new one.
1082 *
1083 * If fa is NULL, we will need to allocate a new one and
1084 * insert to the head of f.
1085 *
1086 * If f is NULL, no fib node matched the destination key
1087 * and we need to allocate a new one of those as well.
1088 */
1089
1090 if (fa &&
1091 fa->fa_info->fib_priority == fi->fib_priority) {
1092 struct fib_alias *fa_orig;
1093
1094 err = -EEXIST;
1095 if (nlhdr->nlmsg_flags & NLM_F_EXCL)
1096 goto out;
1097
1098 if (nlhdr->nlmsg_flags & NLM_F_REPLACE) {
1099 struct fib_info *fi_drop;
1100 u8 state;
1101
1102 write_lock_bh(&fib_lock);
1103
1104 fi_drop = fa->fa_info;
1105 fa->fa_info = fi;
1106 fa->fa_type = type;
1107 fa->fa_scope = r->rtm_scope;
1108 state = fa->fa_state;
1109 fa->fa_state &= ~FA_S_ACCESSED;
1110
1111 write_unlock_bh(&fib_lock);
1112
1113 fib_release_info(fi_drop);
1114 if (state & FA_S_ACCESSED)
1115 rt_cache_flush(-1);
1116
1117 goto succeeded;
1118 }
1119 /* Error if we find a perfect match which
1120 * uses the same scope, type, and nexthop
1121 * information.
1122 */
1123 fa_orig = fa;
1124 list_for_each_entry(fa, fa_orig->fa_list.prev, fa_list) {
1125 if (fa->fa_tos != tos)
1126 break;
1127 if (fa->fa_info->fib_priority != fi->fib_priority)
1128 break;
1129 if (fa->fa_type == type &&
1130 fa->fa_scope == r->rtm_scope &&
1131 fa->fa_info == fi) {
1132 goto out;
1133 }
1134 }
1135 if (!(nlhdr->nlmsg_flags & NLM_F_APPEND))
1136 fa = fa_orig;
1137 }
1138 err = -ENOENT;
1139 if (!(nlhdr->nlmsg_flags&NLM_F_CREATE))
1140 goto out;
1141
1142 err = -ENOBUFS;
1143 new_fa = kmem_cache_alloc(fn_alias_kmem, SLAB_KERNEL);
1144 if (new_fa == NULL)
1145 goto out;
1146
1147 new_fa->fa_info = fi;
1148 new_fa->fa_tos = tos;
1149 new_fa->fa_type = type;
1150 new_fa->fa_scope = r->rtm_scope;
1151 new_fa->fa_state = 0;
1152#if 0
1153 new_fa->dst = NULL;
1154#endif
1155 /*
1156 * Insert new entry to the list.
1157 */
1158
1159 if(!fa_head)
1160 fa_head = fib_insert_node(t, key, plen);
1161
1162 write_lock_bh(&fib_lock);
1163
1164 list_add_tail(&new_fa->fa_list,
1165 (fa ? &fa->fa_list : fa_head));
1166
1167 write_unlock_bh(&fib_lock);
1168
1169 rt_cache_flush(-1);
1170 rtmsg_fib(RTM_NEWROUTE, htonl(key), new_fa, plen, tb->tb_id, nlhdr, req);
1171succeeded:
1172 return 0;
1173out:
1174 fib_release_info(fi);
1175err:;
1176 return err;
1177}
1178
1179static inline int check_leaf(struct trie *t, struct leaf *l, t_key key, int *plen, const struct flowi *flp,
1180 struct fib_result *res, int *err)
1181{
1182 int i;
1183 t_key mask;
1184 struct leaf_info *li;
1185 struct hlist_head *hhead = &l->list;
1186 struct hlist_node *node;
1187
1188 hlist_for_each_entry(li, node, hhead, hlist) {
1189
1190 i = li->plen;
1191 mask = ntohl(inet_make_mask(i));
1192 if (l->key != (key & mask))
1193 continue;
1194
1195 if (((*err) = fib_semantic_match(&li->falh, flp, res, l->key, mask, i)) == 0) {
1196 *plen = i;
1197#ifdef CONFIG_IP_FIB_TRIE_STATS
1198 t->stats.semantic_match_passed++;
1199#endif
1200 return 1;
1201 }
1202#ifdef CONFIG_IP_FIB_TRIE_STATS
1203 t->stats.semantic_match_miss++;
1204#endif
1205 }
1206 return 0;
1207}
1208
1209static int
1210fn_trie_lookup(struct fib_table *tb, const struct flowi *flp, struct fib_result *res)
1211{
1212 struct trie *t = (struct trie *) tb->tb_data;
1213 int plen, ret = 0;
1214 struct node *n;
1215 struct tnode *pn;
1216 int pos, bits;
1217 t_key key=ntohl(flp->fl4_dst);
1218 int chopped_off;
1219 t_key cindex = 0;
1220 int current_prefix_length = KEYLENGTH;
1221 n = t->trie;
1222
1223 read_lock(&fib_lock);
1224 if(!n)
1225 goto failed;
1226
1227#ifdef CONFIG_IP_FIB_TRIE_STATS
1228 t->stats.gets++;
1229#endif
1230
1231 /* Just a leaf? */
1232 if (IS_LEAF(n)) {
1233 if( check_leaf(t, (struct leaf *)n, key, &plen, flp, res, &ret) )
1234 goto found;
1235 goto failed;
1236 }
1237 pn = (struct tnode *) n;
1238 chopped_off = 0;
1239
1240 while (pn) {
1241
1242 pos = pn->pos;
1243 bits = pn->bits;
1244
1245 if(!chopped_off)
1246 cindex = tkey_extract_bits(MASK_PFX(key, current_prefix_length), pos, bits);
1247
1248 n = tnode_get_child(pn, cindex);
1249
1250 if (n == NULL) {
1251#ifdef CONFIG_IP_FIB_TRIE_STATS
1252 t->stats.null_node_hit++;
1253#endif
1254 goto backtrace;
1255 }
1256
1257 if (IS_TNODE(n)) {
1258#define HL_OPTIMIZE
1259#ifdef HL_OPTIMIZE
1260 struct tnode *cn = (struct tnode *)n;
1261 t_key node_prefix, key_prefix, pref_mismatch;
1262 int mp;
1263
1264 /*
1265 * It's a tnode, and we can do some extra checks here if we
1266 * like, to avoid descending into a dead-end branch.
1267 * This tnode is in the parent's child array at index
1268 * key[p_pos..p_pos+p_bits] but potentially with some bits
1269 * chopped off, so in reality the index may be just a
1270 * subprefix, padded with zero at the end.
1271 * We can also take a look at any skipped bits in this
1272 * tnode - everything up to p_pos is supposed to be ok,
1273 * and the non-chopped bits of the index (se previous
1274 * paragraph) are also guaranteed ok, but the rest is
1275 * considered unknown.
1276 *
1277 * The skipped bits are key[pos+bits..cn->pos].
1278 */
1279
1280 /* If current_prefix_length < pos+bits, we are already doing
1281 * actual prefix matching, which means everything from
1282 * pos+(bits-chopped_off) onward must be zero along some
1283 * branch of this subtree - otherwise there is *no* valid
1284 * prefix present. Here we can only check the skipped
1285 * bits. Remember, since we have already indexed into the
1286 * parent's child array, we know that the bits we chopped of
1287 * *are* zero.
1288 */
1289
1290 /* NOTA BENE: CHECKING ONLY SKIPPED BITS FOR THE NEW NODE HERE */
1291
1292 if (current_prefix_length < pos+bits) {
1293 if (tkey_extract_bits(cn->key, current_prefix_length,
1294 cn->pos - current_prefix_length) != 0 ||
1295 !(cn->child[0]))
1296 goto backtrace;
1297 }
1298
1299 /*
1300 * If chopped_off=0, the index is fully validated and we
1301 * only need to look at the skipped bits for this, the new,
1302 * tnode. What we actually want to do is to find out if
1303 * these skipped bits match our key perfectly, or if we will
1304 * have to count on finding a matching prefix further down,
1305 * because if we do, we would like to have some way of
1306 * verifying the existence of such a prefix at this point.
1307 */
1308
1309 /* The only thing we can do at this point is to verify that
1310 * any such matching prefix can indeed be a prefix to our
1311 * key, and if the bits in the node we are inspecting that
1312 * do not match our key are not ZERO, this cannot be true.
1313 * Thus, find out where there is a mismatch (before cn->pos)
1314 * and verify that all the mismatching bits are zero in the
1315 * new tnode's key.
1316 */
1317
1318 /* Note: We aren't very concerned about the piece of the key
1319 * that precede pn->pos+pn->bits, since these have already been
1320 * checked. The bits after cn->pos aren't checked since these are
1321 * by definition "unknown" at this point. Thus, what we want to
1322 * see is if we are about to enter the "prefix matching" state,
1323 * and in that case verify that the skipped bits that will prevail
1324 * throughout this subtree are zero, as they have to be if we are
1325 * to find a matching prefix.
1326 */
1327
1328 node_prefix = MASK_PFX(cn->key, cn->pos);
1329 key_prefix = MASK_PFX(key, cn->pos);
1330 pref_mismatch = key_prefix^node_prefix;
1331 mp = 0;
1332
1333 /* In short: If skipped bits in this node do not match the search
1334 * key, enter the "prefix matching" state.directly.
1335 */
1336 if (pref_mismatch) {
1337 while (!(pref_mismatch & (1<<(KEYLENGTH-1)))) {
1338 mp++;
1339 pref_mismatch = pref_mismatch <<1;
1340 }
1341 key_prefix = tkey_extract_bits(cn->key, mp, cn->pos-mp);
1342
1343 if (key_prefix != 0)
1344 goto backtrace;
1345
1346 if (current_prefix_length >= cn->pos)
1347 current_prefix_length=mp;
1348 }
1349#endif
1350 pn = (struct tnode *)n; /* Descend */
1351 chopped_off = 0;
1352 continue;
1353 }
1354 if (IS_LEAF(n)) {
1355 if( check_leaf(t, (struct leaf *)n, key, &plen, flp, res, &ret))
1356 goto found;
1357 }
1358backtrace:
1359 chopped_off++;
1360
1361 /* As zero don't change the child key (cindex) */
1362 while ((chopped_off <= pn->bits) && !(cindex & (1<<(chopped_off-1)))) {
1363 chopped_off++;
1364 }
1365
1366 /* Decrease current_... with bits chopped off */
1367 if (current_prefix_length > pn->pos + pn->bits - chopped_off)
1368 current_prefix_length = pn->pos + pn->bits - chopped_off;
1369
1370 /*
1371 * Either we do the actual chop off according or if we have
1372 * chopped off all bits in this tnode walk up to our parent.
1373 */
1374
1375 if(chopped_off <= pn->bits)
1376 cindex &= ~(1 << (chopped_off-1));
1377 else {
1378 if( NODE_PARENT(pn) == NULL)
1379 goto failed;
1380
1381 /* Get Child's index */
1382 cindex = tkey_extract_bits(pn->key, NODE_PARENT(pn)->pos, NODE_PARENT(pn)->bits);
1383 pn = NODE_PARENT(pn);
1384 chopped_off = 0;
1385
1386#ifdef CONFIG_IP_FIB_TRIE_STATS
1387 t->stats.backtrack++;
1388#endif
1389 goto backtrace;
1390 }
1391 }
1392failed:
1393 ret = 1;
1394found:
1395 read_unlock(&fib_lock);
1396 return ret;
1397}
1398
1399static int trie_leaf_remove(struct trie *t, t_key key)
1400{
1401 t_key cindex;
1402 struct tnode *tp = NULL;
1403 struct node *n = t->trie;
1404 struct leaf *l;
1405
1406 if(trie_debug)
1407 printk("entering trie_leaf_remove(%p)\n", n);
1408
1409 /* Note that in the case skipped bits, those bits are *not* checked!
1410 * When we finish this, we will have NULL or a T_LEAF, and the
1411 * T_LEAF may or may not match our key.
1412 */
1413
1414 while (n != NULL && IS_TNODE(n)) {
1415 struct tnode *tn = (struct tnode *) n;
1416 check_tnode(tn);
1417 n = tnode_get_child(tn ,tkey_extract_bits(key, tn->pos, tn->bits));
1418
1419 if(n && NODE_PARENT(n) != tn) {
1420 printk("BUG tn=%p, n->parent=%p\n", tn, NODE_PARENT(n));
1421 BUG();
1422 }
1423 }
1424 l = (struct leaf *) n;
1425
1426 if(!n || !tkey_equals(l->key, key))
1427 return 0;
1428
1429 /*
1430 * Key found.
1431 * Remove the leaf and rebalance the tree
1432 */
1433
1434 t->revision++;
1435 t->size--;
1436
1437 tp = NODE_PARENT(n);
1438 tnode_free((struct tnode *) n);
1439
1440 if(tp) {
1441 cindex = tkey_extract_bits(key, tp->pos, tp->bits);
1442 put_child(t, (struct tnode *)tp, cindex, NULL);
1443 t->trie = trie_rebalance(t, tp);
1444 }
1445 else
1446 t->trie = NULL;
1447
1448 return 1;
1449}
1450
1451static int
1452fn_trie_delete(struct fib_table *tb, struct rtmsg *r, struct kern_rta *rta,
1453 struct nlmsghdr *nlhdr, struct netlink_skb_parms *req)
1454{
1455 struct trie *t = (struct trie *) tb->tb_data;
1456 u32 key, mask;
1457 int plen = r->rtm_dst_len;
1458 u8 tos = r->rtm_tos;
1459 struct fib_alias *fa, *fa_to_delete;
1460 struct list_head *fa_head;
1461 struct leaf *l;
1462
1463 if (plen > 32)
1464 return -EINVAL;
1465
1466 key = 0;
1467 if (rta->rta_dst)
1468 memcpy(&key, rta->rta_dst, 4);
1469
1470 key = ntohl(key);
1471 mask = ntohl( inet_make_mask(plen) );
1472
1473 if(key & ~mask)
1474 return -EINVAL;
1475
1476 key = key & mask;
1477 l = fib_find_node(t, key);
1478
1479 if(!l)
1480 return -ESRCH;
1481
1482 fa_head = get_fa_head(l, plen);
1483 fa = fib_find_alias(fa_head, tos, 0);
1484
1485 if (!fa)
1486 return -ESRCH;
1487
1488 if (trie_debug)
1489 printk("Deleting %08x/%d tos=%d t=%p\n", key, plen, tos, t);
1490
1491 fa_to_delete = NULL;
1492 fa_head = fa->fa_list.prev;
1493 list_for_each_entry(fa, fa_head, fa_list) {
1494 struct fib_info *fi = fa->fa_info;
1495
1496 if (fa->fa_tos != tos)
1497 break;
1498
1499 if ((!r->rtm_type ||
1500 fa->fa_type == r->rtm_type) &&
1501 (r->rtm_scope == RT_SCOPE_NOWHERE ||
1502 fa->fa_scope == r->rtm_scope) &&
1503 (!r->rtm_protocol ||
1504 fi->fib_protocol == r->rtm_protocol) &&
1505 fib_nh_match(r, nlhdr, rta, fi) == 0) {
1506 fa_to_delete = fa;
1507 break;
1508 }
1509 }
1510
1511 if (fa_to_delete) {
1512 int kill_li = 0;
1513 struct leaf_info *li;
1514
1515 fa = fa_to_delete;
1516 rtmsg_fib(RTM_DELROUTE, htonl(key), fa, plen, tb->tb_id, nlhdr, req);
1517
1518 l = fib_find_node(t, key);
1519 li = find_leaf_info(&l->list, plen);
1520
1521 write_lock_bh(&fib_lock);
1522
1523 list_del(&fa->fa_list);
1524
1525 if(list_empty(fa_head)) {
1526 hlist_del(&li->hlist);
1527 kill_li = 1;
1528 }
1529 write_unlock_bh(&fib_lock);
1530
1531 if(kill_li)
1532 free_leaf_info(li);
1533
1534 if(hlist_empty(&l->list))
1535 trie_leaf_remove(t, key);
1536
1537 if (fa->fa_state & FA_S_ACCESSED)
1538 rt_cache_flush(-1);
1539
1540 fn_free_alias(fa);
1541 return 0;
1542 }
1543 return -ESRCH;
1544}
1545
1546static int trie_flush_list(struct trie *t, struct list_head *head)
1547{
1548 struct fib_alias *fa, *fa_node;
1549 int found = 0;
1550
1551 list_for_each_entry_safe(fa, fa_node, head, fa_list) {
1552 struct fib_info *fi = fa->fa_info;
1553
1554 if (fi && (fi->fib_flags&RTNH_F_DEAD)) {
1555
1556 write_lock_bh(&fib_lock);
1557 list_del(&fa->fa_list);
1558 write_unlock_bh(&fib_lock);
1559
1560 fn_free_alias(fa);
1561 found++;
1562 }
1563 }
1564 return found;
1565}
1566
1567static int trie_flush_leaf(struct trie *t, struct leaf *l)
1568{
1569 int found = 0;
1570 struct hlist_head *lih = &l->list;
1571 struct hlist_node *node, *tmp;
1572 struct leaf_info *li = NULL;
1573
1574 hlist_for_each_entry_safe(li, node, tmp, lih, hlist) {
1575
1576 found += trie_flush_list(t, &li->falh);
1577
1578 if (list_empty(&li->falh)) {
1579
1580 write_lock_bh(&fib_lock);
1581 hlist_del(&li->hlist);
1582 write_unlock_bh(&fib_lock);
1583
1584 free_leaf_info(li);
1585 }
1586 }
1587 return found;
1588}
1589
1590static struct leaf *nextleaf(struct trie *t, struct leaf *thisleaf)
1591{
1592 struct node *c = (struct node *) thisleaf;
1593 struct tnode *p;
1594 int idx;
1595
1596 if(c == NULL) {
1597 if(t->trie == NULL)
1598 return NULL;
1599
1600 if (IS_LEAF(t->trie)) /* trie w. just a leaf */
1601 return (struct leaf *) t->trie;
1602
1603 p = (struct tnode*) t->trie; /* Start */
1604 }
1605 else
1606 p = (struct tnode *) NODE_PARENT(c);
1607 while (p) {
1608 int pos, last;
1609
1610 /* Find the next child of the parent */
1611 if(c)
1612 pos = 1 + tkey_extract_bits(c->key, p->pos, p->bits);
1613 else
1614 pos = 0;
1615
1616 last = 1 << p->bits;
1617 for(idx = pos; idx < last ; idx++) {
1618 if( p->child[idx]) {
1619
1620 /* Decend if tnode */
1621
1622 while (IS_TNODE(p->child[idx])) {
1623 p = (struct tnode*) p->child[idx];
1624 idx = 0;
1625
1626 /* Rightmost non-NULL branch */
1627 if( p && IS_TNODE(p) )
1628 while ( p->child[idx] == NULL && idx < (1 << p->bits) ) idx++;
1629
1630 /* Done with this tnode? */
1631 if( idx >= (1 << p->bits) || p->child[idx] == NULL )
1632 goto up;
1633 }
1634 return (struct leaf*) p->child[idx];
1635 }
1636 }
1637up:
1638 /* No more children go up one step */
1639 c = (struct node*) p;
1640 p = (struct tnode *) NODE_PARENT(p);
1641 }
1642 return NULL; /* Ready. Root of trie */
1643}
1644
1645static int fn_trie_flush(struct fib_table *tb)
1646{
1647 struct trie *t = (struct trie *) tb->tb_data;
1648 struct leaf *ll = NULL, *l = NULL;
1649 int found = 0, h;
1650
1651 t->revision++;
1652
1653 for (h=0; (l = nextleaf(t, l)) != NULL; h++) {
1654 found += trie_flush_leaf(t, l);
1655
1656 if (ll && hlist_empty(&ll->list))
1657 trie_leaf_remove(t, ll->key);
1658 ll = l;
1659 }
1660
1661 if (ll && hlist_empty(&ll->list))
1662 trie_leaf_remove(t, ll->key);
1663
1664 if(trie_debug)
1665 printk("trie_flush found=%d\n", found);
1666 return found;
1667}
1668
1669static int trie_last_dflt=-1;
1670
1671static void
1672fn_trie_select_default(struct fib_table *tb, const struct flowi *flp, struct fib_result *res)
1673{
1674 struct trie *t = (struct trie *) tb->tb_data;
1675 int order, last_idx;
1676 struct fib_info *fi = NULL;
1677 struct fib_info *last_resort;
1678 struct fib_alias *fa = NULL;
1679 struct list_head *fa_head;
1680 struct leaf *l;
1681
1682 last_idx = -1;
1683 last_resort = NULL;
1684 order = -1;
1685
1686 read_lock(&fib_lock);
1687
1688 l = fib_find_node(t, 0);
1689 if(!l)
1690 goto out;
1691
1692 fa_head = get_fa_head(l, 0);
1693 if(!fa_head)
1694 goto out;
1695
1696 if (list_empty(fa_head))
1697 goto out;
1698
1699 list_for_each_entry(fa, fa_head, fa_list) {
1700 struct fib_info *next_fi = fa->fa_info;
1701
1702 if (fa->fa_scope != res->scope ||
1703 fa->fa_type != RTN_UNICAST)
1704 continue;
1705
1706 if (next_fi->fib_priority > res->fi->fib_priority)
1707 break;
1708 if (!next_fi->fib_nh[0].nh_gw ||
1709 next_fi->fib_nh[0].nh_scope != RT_SCOPE_LINK)
1710 continue;
1711 fa->fa_state |= FA_S_ACCESSED;
1712
1713 if (fi == NULL) {
1714 if (next_fi != res->fi)
1715 break;
1716 } else if (!fib_detect_death(fi, order, &last_resort,
1717 &last_idx, &trie_last_dflt)) {
1718 if (res->fi)
1719 fib_info_put(res->fi);
1720 res->fi = fi;
1721 atomic_inc(&fi->fib_clntref);
1722 trie_last_dflt = order;
1723 goto out;
1724 }
1725 fi = next_fi;
1726 order++;
1727 }
1728 if (order <= 0 || fi == NULL) {
1729 trie_last_dflt = -1;
1730 goto out;
1731 }
1732
1733 if (!fib_detect_death(fi, order, &last_resort, &last_idx, &trie_last_dflt)) {
1734 if (res->fi)
1735 fib_info_put(res->fi);
1736 res->fi = fi;
1737 atomic_inc(&fi->fib_clntref);
1738 trie_last_dflt = order;
1739 goto out;
1740 }
1741 if (last_idx >= 0) {
1742 if (res->fi)
1743 fib_info_put(res->fi);
1744 res->fi = last_resort;
1745 if (last_resort)
1746 atomic_inc(&last_resort->fib_clntref);
1747 }
1748 trie_last_dflt = last_idx;
1749 out:;
1750 read_unlock(&fib_lock);
1751}
1752
1753static int fn_trie_dump_fa(t_key key, int plen, struct list_head *fah, struct fib_table *tb,
1754 struct sk_buff *skb, struct netlink_callback *cb)
1755{
1756 int i, s_i;
1757 struct fib_alias *fa;
1758
1759 u32 xkey=htonl(key);
1760
1761 s_i=cb->args[3];
1762 i = 0;
1763
1764 list_for_each_entry(fa, fah, fa_list) {
1765 if (i < s_i) {
1766 i++;
1767 continue;
1768 }
1769 if (fa->fa_info->fib_nh == NULL) {
1770 printk("Trie error _fib_nh=NULL in fa[%d] k=%08x plen=%d\n", i, key, plen);
1771 i++;
1772 continue;
1773 }
1774 if (fa->fa_info == NULL) {
1775 printk("Trie error fa_info=NULL in fa[%d] k=%08x plen=%d\n", i, key, plen);
1776 i++;
1777 continue;
1778 }
1779
1780 if (fib_dump_info(skb, NETLINK_CB(cb->skb).pid,
1781 cb->nlh->nlmsg_seq,
1782 RTM_NEWROUTE,
1783 tb->tb_id,
1784 fa->fa_type,
1785 fa->fa_scope,
1786 &xkey,
1787 plen,
1788 fa->fa_tos,
1789 fa->fa_info, 0) < 0) {
1790 cb->args[3] = i;
1791 return -1;
1792 }
1793 i++;
1794 }
1795 cb->args[3]=i;
1796 return skb->len;
1797}
1798
1799static int fn_trie_dump_plen(struct trie *t, int plen, struct fib_table *tb, struct sk_buff *skb,
1800 struct netlink_callback *cb)
1801{
1802 int h, s_h;
1803 struct list_head *fa_head;
1804 struct leaf *l = NULL;
1805 s_h=cb->args[2];
1806
1807 for (h=0; (l = nextleaf(t, l)) != NULL; h++) {
1808
1809 if (h < s_h)
1810 continue;
1811 if (h > s_h)
1812 memset(&cb->args[3], 0,
1813 sizeof(cb->args) - 3*sizeof(cb->args[0]));
1814
1815 fa_head = get_fa_head(l, plen);
1816
1817 if(!fa_head)
1818 continue;
1819
1820 if(list_empty(fa_head))
1821 continue;
1822
1823 if (fn_trie_dump_fa(l->key, plen, fa_head, tb, skb, cb)<0) {
1824 cb->args[2]=h;
1825 return -1;
1826 }
1827 }
1828 cb->args[2]=h;
1829 return skb->len;
1830}
1831
1832static int fn_trie_dump(struct fib_table *tb, struct sk_buff *skb, struct netlink_callback *cb)
1833{
1834 int m, s_m;
1835 struct trie *t = (struct trie *) tb->tb_data;
1836
1837 s_m = cb->args[1];
1838
1839 read_lock(&fib_lock);
1840 for (m=0; m<=32; m++) {
1841
1842 if (m < s_m)
1843 continue;
1844 if (m > s_m)
1845 memset(&cb->args[2], 0,
1846 sizeof(cb->args) - 2*sizeof(cb->args[0]));
1847
1848 if (fn_trie_dump_plen(t, 32-m, tb, skb, cb)<0) {
1849 cb->args[1] = m;
1850 goto out;
1851 }
1852 }
1853 read_unlock(&fib_lock);
1854 cb->args[1] = m;
1855 return skb->len;
1856 out:
1857 read_unlock(&fib_lock);
1858 return -1;
1859}
1860
1861/* Fix more generic FIB names for init later */
1862
1863#ifdef CONFIG_IP_MULTIPLE_TABLES
1864struct fib_table * fib_hash_init(int id)
1865#else
1866struct fib_table * __init fib_hash_init(int id)
1867#endif
1868{
1869 struct fib_table *tb;
1870 struct trie *t;
1871
1872 if (fn_alias_kmem == NULL)
1873 fn_alias_kmem = kmem_cache_create("ip_fib_alias",
1874 sizeof(struct fib_alias),
1875 0, SLAB_HWCACHE_ALIGN,
1876 NULL, NULL);
1877
1878 tb = kmalloc(sizeof(struct fib_table) + sizeof(struct trie),
1879 GFP_KERNEL);
1880 if (tb == NULL)
1881 return NULL;
1882
1883 tb->tb_id = id;
1884 tb->tb_lookup = fn_trie_lookup;
1885 tb->tb_insert = fn_trie_insert;
1886 tb->tb_delete = fn_trie_delete;
1887 tb->tb_flush = fn_trie_flush;
1888 tb->tb_select_default = fn_trie_select_default;
1889 tb->tb_dump = fn_trie_dump;
1890 memset(tb->tb_data, 0, sizeof(struct trie));
1891
1892 t = (struct trie *) tb->tb_data;
1893
1894 trie_init(t);
1895
1896 if (id == RT_TABLE_LOCAL)
1897 trie_local=t;
1898 else if (id == RT_TABLE_MAIN)
1899 trie_main=t;
1900
1901 if (id == RT_TABLE_LOCAL)
1902 printk("IPv4 FIB: Using LC-trie version %s\n", VERSION);
1903
1904 return tb;
1905}
1906
1907/* Trie dump functions */
1908
1909static void putspace_seq(struct seq_file *seq, int n)
1910{
1911 while (n--) seq_printf(seq, " ");
1912}
1913
1914static void printbin_seq(struct seq_file *seq, unsigned int v, int bits)
1915{
1916 while (bits--)
1917 seq_printf(seq, "%s", (v & (1<<bits))?"1":"0");
1918}
1919
1920static void printnode_seq(struct seq_file *seq, int indent, struct node *n,
1921 int pend, int cindex, int bits)
1922{
1923 putspace_seq(seq, indent);
1924 if (IS_LEAF(n))
1925 seq_printf(seq, "|");
1926 else
1927 seq_printf(seq, "+");
1928 if (bits) {
1929 seq_printf(seq, "%d/", cindex);
1930 printbin_seq(seq, cindex, bits);
1931 seq_printf(seq, ": ");
1932 }
1933 else
1934 seq_printf(seq, "<root>: ");
1935 seq_printf(seq, "%s:%p ", IS_LEAF(n)?"Leaf":"Internal node", n);
1936
1937 if (IS_LEAF(n))
1938 seq_printf(seq, "key=%d.%d.%d.%d\n",
1939 n->key >> 24, (n->key >> 16) % 256, (n->key >> 8) % 256, n->key % 256);
1940 else {
1941 int plen=((struct tnode *)n)->pos;
1942 t_key prf=MASK_PFX(n->key, plen);
1943 seq_printf(seq, "key=%d.%d.%d.%d/%d\n",
1944 prf >> 24, (prf >> 16) % 256, (prf >> 8) % 256, prf % 256, plen);
1945 }
1946 if (IS_LEAF(n)) {
1947 struct leaf *l=(struct leaf *)n;
1948 struct fib_alias *fa;
1949 int i;
1950 for (i=32; i>=0; i--)
1951 if(find_leaf_info(&l->list, i)) {
1952
1953 struct list_head *fa_head = get_fa_head(l, i);
1954
1955 if(!fa_head)
1956 continue;
1957
1958 if(list_empty(fa_head))
1959 continue;
1960
1961 putspace_seq(seq, indent+2);
1962 seq_printf(seq, "{/%d...dumping}\n", i);
1963
1964
1965 list_for_each_entry(fa, fa_head, fa_list) {
1966 putspace_seq(seq, indent+2);
1967 if (fa->fa_info->fib_nh == NULL) {
1968 seq_printf(seq, "Error _fib_nh=NULL\n");
1969 continue;
1970 }
1971 if (fa->fa_info == NULL) {
1972 seq_printf(seq, "Error fa_info=NULL\n");
1973 continue;
1974 }
1975
1976 seq_printf(seq, "{type=%d scope=%d TOS=%d}\n",
1977 fa->fa_type,
1978 fa->fa_scope,
1979 fa->fa_tos);
1980 }
1981 }
1982 }
1983 else if (IS_TNODE(n)) {
1984 struct tnode *tn=(struct tnode *)n;
1985 putspace_seq(seq, indent); seq_printf(seq, "| ");
1986 seq_printf(seq, "{key prefix=%08x/", tn->key&TKEY_GET_MASK(0, tn->pos));
1987 printbin_seq(seq, tkey_extract_bits(tn->key, 0, tn->pos), tn->pos);
1988 seq_printf(seq, "}\n");
1989 putspace_seq(seq, indent); seq_printf(seq, "| ");
1990 seq_printf(seq, "{pos=%d", tn->pos);
1991 seq_printf(seq, " (skip=%d bits)", tn->pos - pend);
1992 seq_printf(seq, " bits=%d (%u children)}\n", tn->bits, (1 << tn->bits));
1993 putspace_seq(seq, indent); seq_printf(seq, "| ");
1994 seq_printf(seq, "{empty=%d full=%d}\n", tn->empty_children, tn->full_children);
1995 }
1996}
1997
1998static void trie_dump_seq(struct seq_file *seq, struct trie *t)
1999{
2000 struct node *n=t->trie;
2001 int cindex=0;
2002 int indent=1;
2003 int pend=0;
2004 int depth = 0;
2005
2006 read_lock(&fib_lock);
2007
2008 seq_printf(seq, "------ trie_dump of t=%p ------\n", t);
2009 if (n) {
2010 printnode_seq(seq, indent, n, pend, cindex, 0);
2011 if (IS_TNODE(n)) {
2012 struct tnode *tn=(struct tnode *)n;
2013 pend = tn->pos+tn->bits;
2014 putspace_seq(seq, indent); seq_printf(seq, "\\--\n");
2015 indent += 3;
2016 depth++;
2017
2018 while (tn && cindex < (1 << tn->bits)) {
2019 if (tn->child[cindex]) {
2020
2021 /* Got a child */
2022
2023 printnode_seq(seq, indent, tn->child[cindex], pend, cindex, tn->bits);
2024 if (IS_LEAF(tn->child[cindex])) {
2025 cindex++;
2026
2027 }
2028 else {
2029 /*
2030 * New tnode. Decend one level
2031 */
2032
2033 depth++;
2034 n=tn->child[cindex];
2035 tn=(struct tnode *)n;
2036 pend=tn->pos+tn->bits;
2037 putspace_seq(seq, indent); seq_printf(seq, "\\--\n");
2038 indent+=3;
2039 cindex=0;
2040 }
2041 }
2042 else
2043 cindex++;
2044
2045 /*
2046 * Test if we are done
2047 */
2048
2049 while (cindex >= (1 << tn->bits)) {
2050
2051 /*
2052 * Move upwards and test for root
2053 * pop off all traversed nodes
2054 */
2055
2056 if (NODE_PARENT(tn) == NULL) {
2057 tn = NULL;
2058 n = NULL;
2059 break;
2060 }
2061 else {
2062 cindex = tkey_extract_bits(tn->key, NODE_PARENT(tn)->pos, NODE_PARENT(tn)->bits);
2063 tn = NODE_PARENT(tn);
2064 cindex++;
2065 n=(struct node *)tn;
2066 pend=tn->pos+tn->bits;
2067 indent-=3;
2068 depth--;
2069 }
2070 }
2071 }
2072 }
2073 else n = NULL;
2074 }
2075 else seq_printf(seq, "------ trie is empty\n");
2076
2077 read_unlock(&fib_lock);
2078}
2079
2080static struct trie_stat *trie_stat_new(void)
2081{
2082 struct trie_stat *s = kmalloc(sizeof(struct trie_stat), GFP_KERNEL);
2083 int i;
2084
2085 if(s) {
2086 s->totdepth = 0;
2087 s->maxdepth = 0;
2088 s->tnodes = 0;
2089 s->leaves = 0;
2090 s->nullpointers = 0;
2091
2092 for(i=0; i< MAX_CHILDS; i++)
2093 s->nodesizes[i] = 0;
2094 }
2095 return s;
2096}
2097
2098static struct trie_stat *trie_collect_stats(struct trie *t)
2099{
2100 struct node *n=t->trie;
2101 struct trie_stat *s = trie_stat_new();
2102 int cindex = 0;
2103 int indent = 1;
2104 int pend = 0;
2105 int depth = 0;
2106
2107 read_lock(&fib_lock);
2108
2109 if (s) {
2110 if (n) {
2111 if (IS_TNODE(n)) {
2112 struct tnode *tn = (struct tnode *)n;
2113 pend=tn->pos+tn->bits;
2114 indent += 3;
2115 s->nodesizes[tn->bits]++;
2116 depth++;
2117
2118 while (tn && cindex < (1 << tn->bits)) {
2119 if (tn->child[cindex]) {
2120 /* Got a child */
2121
2122 if (IS_LEAF(tn->child[cindex])) {
2123 cindex++;
2124
2125 /* stats */
2126 if (depth > s->maxdepth)
2127 s->maxdepth = depth;
2128 s->totdepth += depth;
2129 s->leaves++;
2130 }
2131
2132 else {
2133 /*
2134 * New tnode. Decend one level
2135 */
2136
2137 s->tnodes++;
2138 s->nodesizes[tn->bits]++;
2139 depth++;
2140
2141 n = tn->child[cindex];
2142 tn = (struct tnode *)n;
2143 pend = tn->pos+tn->bits;
2144
2145 indent += 3;
2146 cindex = 0;
2147 }
2148 }
2149 else {
2150 cindex++;
2151 s->nullpointers++;
2152 }
2153
2154 /*
2155 * Test if we are done
2156 */
2157
2158 while (cindex >= (1 << tn->bits)) {
2159
2160 /*
2161 * Move upwards and test for root
2162 * pop off all traversed nodes
2163 */
2164
2165
2166 if (NODE_PARENT(tn) == NULL) {
2167 tn = NULL;
2168 n = NULL;
2169 break;
2170 }
2171 else {
2172 cindex = tkey_extract_bits(tn->key, NODE_PARENT(tn)->pos, NODE_PARENT(tn)->bits);
2173 tn = NODE_PARENT(tn);
2174 cindex++;
2175 n = (struct node *)tn;
2176 pend=tn->pos+tn->bits;
2177 indent -= 3;
2178 depth--;
2179 }
2180 }
2181 }
2182 }
2183 else n = NULL;
2184 }
2185 }
2186
2187 read_unlock(&fib_lock);
2188 return s;
2189}
2190
2191#ifdef CONFIG_PROC_FS
2192
2193static struct fib_alias *fib_triestat_get_first(struct seq_file *seq)
2194{
2195 return NULL;
2196}
2197
2198static struct fib_alias *fib_triestat_get_next(struct seq_file *seq)
2199{
2200 return NULL;
2201}
2202
2203static void *fib_triestat_seq_start(struct seq_file *seq, loff_t *pos)
2204{
2205 void *v = NULL;
2206
2207 if (ip_fib_main_table)
2208 v = *pos ? fib_triestat_get_next(seq) : SEQ_START_TOKEN;
2209 return v;
2210}
2211
2212static void *fib_triestat_seq_next(struct seq_file *seq, void *v, loff_t *pos)
2213{
2214 ++*pos;
2215 return v == SEQ_START_TOKEN ? fib_triestat_get_first(seq) : fib_triestat_get_next(seq);
2216}
2217
2218static void fib_triestat_seq_stop(struct seq_file *seq, void *v)
2219{
2220
2221}
2222
2223/*
2224 * This outputs /proc/net/fib_triestats
2225 *
2226 * It always works in backward compatibility mode.
2227 * The format of the file is not supposed to be changed.
2228 */
2229
2230static void collect_and_show(struct trie *t, struct seq_file *seq)
2231{
2232 int bytes = 0; /* How many bytes are used, a ref is 4 bytes */
2233 int i, max, pointers;
2234 struct trie_stat *stat;
2235 int avdepth;
2236
2237 stat = trie_collect_stats(t);
2238
2239 bytes=0;
2240 seq_printf(seq, "trie=%p\n", t);
2241
2242 if (stat) {
2243 if (stat->leaves)
2244 avdepth=stat->totdepth*100 / stat->leaves;
2245 else
2246 avdepth=0;
2247 seq_printf(seq, "Aver depth: %d.%02d\n", avdepth / 100, avdepth % 100 );
2248 seq_printf(seq, "Max depth: %4d\n", stat->maxdepth);
2249
2250 seq_printf(seq, "Leaves: %d\n", stat->leaves);
2251 bytes += sizeof(struct leaf) * stat->leaves;
2252 seq_printf(seq, "Internal nodes: %d\n", stat->tnodes);
2253 bytes += sizeof(struct tnode) * stat->tnodes;
2254
2255 max = MAX_CHILDS-1;
2256
2257 while (max >= 0 && stat->nodesizes[max] == 0)
2258 max--;
2259 pointers = 0;
2260
2261 for (i = 1; i <= max; i++)
2262 if (stat->nodesizes[i] != 0) {
2263 seq_printf(seq, " %d: %d", i, stat->nodesizes[i]);
2264 pointers += (1<<i) * stat->nodesizes[i];
2265 }
2266 seq_printf(seq, "\n");
2267 seq_printf(seq, "Pointers: %d\n", pointers);
2268 bytes += sizeof(struct node *) * pointers;
2269 seq_printf(seq, "Null ptrs: %d\n", stat->nullpointers);
2270 seq_printf(seq, "Total size: %d kB\n", bytes / 1024);
2271
2272 kfree(stat);
2273 }
2274
2275#ifdef CONFIG_IP_FIB_TRIE_STATS
2276 seq_printf(seq, "Counters:\n---------\n");
2277 seq_printf(seq,"gets = %d\n", t->stats.gets);
2278 seq_printf(seq,"backtracks = %d\n", t->stats.backtrack);
2279 seq_printf(seq,"semantic match passed = %d\n", t->stats.semantic_match_passed);
2280 seq_printf(seq,"semantic match miss = %d\n", t->stats.semantic_match_miss);
2281 seq_printf(seq,"null node hit= %d\n", t->stats.null_node_hit);
2282#ifdef CLEAR_STATS
2283 memset(&(t->stats), 0, sizeof(t->stats));
2284#endif
2285#endif /* CONFIG_IP_FIB_TRIE_STATS */
2286}
2287
2288static int fib_triestat_seq_show(struct seq_file *seq, void *v)
2289{
2290 char bf[128];
2291
2292 if (v == SEQ_START_TOKEN) {
2293 seq_printf(seq, "Basic info: size of leaf: %Zd bytes, size of tnode: %Zd bytes.\n",
2294 sizeof(struct leaf), sizeof(struct tnode));
2295 if (trie_local)
2296 collect_and_show(trie_local, seq);
2297
2298 if (trie_main)
2299 collect_and_show(trie_main, seq);
2300 }
2301 else {
2302 snprintf(bf, sizeof(bf),
2303 "*\t%08X\t%08X", 200, 400);
2304
2305 seq_printf(seq, "%-127s\n", bf);
2306 }
2307 return 0;
2308}
2309
2310static struct seq_operations fib_triestat_seq_ops = {
2311 .start = fib_triestat_seq_start,
2312 .next = fib_triestat_seq_next,
2313 .stop = fib_triestat_seq_stop,
2314 .show = fib_triestat_seq_show,
2315};
2316
2317static int fib_triestat_seq_open(struct inode *inode, struct file *file)
2318{
2319 struct seq_file *seq;
2320 int rc = -ENOMEM;
2321
2322 rc = seq_open(file, &fib_triestat_seq_ops);
2323 if (rc)
2324 goto out_kfree;
2325
2326 seq = file->private_data;
2327out:
2328 return rc;
2329out_kfree:
2330 goto out;
2331}
2332
2333static struct file_operations fib_triestat_seq_fops = {
2334 .owner = THIS_MODULE,
2335 .open = fib_triestat_seq_open,
2336 .read = seq_read,
2337 .llseek = seq_lseek,
2338 .release = seq_release_private,
2339};
2340
2341int __init fib_stat_proc_init(void)
2342{
2343 if (!proc_net_fops_create("fib_triestat", S_IRUGO, &fib_triestat_seq_fops))
2344 return -ENOMEM;
2345 return 0;
2346}
2347
2348void __init fib_stat_proc_exit(void)
2349{
2350 proc_net_remove("fib_triestat");
2351}
2352
2353static struct fib_alias *fib_trie_get_first(struct seq_file *seq)
2354{
2355 return NULL;
2356}
2357
2358static struct fib_alias *fib_trie_get_next(struct seq_file *seq)
2359{
2360 return NULL;
2361}
2362
2363static void *fib_trie_seq_start(struct seq_file *seq, loff_t *pos)
2364{
2365 void *v = NULL;
2366
2367 if (ip_fib_main_table)
2368 v = *pos ? fib_trie_get_next(seq) : SEQ_START_TOKEN;
2369 return v;
2370}
2371
2372static void *fib_trie_seq_next(struct seq_file *seq, void *v, loff_t *pos)
2373{
2374 ++*pos;
2375 return v == SEQ_START_TOKEN ? fib_trie_get_first(seq) : fib_trie_get_next(seq);
2376}
2377
2378static void fib_trie_seq_stop(struct seq_file *seq, void *v)
2379{
2380
2381}
2382
2383/*
2384 * This outputs /proc/net/fib_trie.
2385 *
2386 * It always works in backward compatibility mode.
2387 * The format of the file is not supposed to be changed.
2388 */
2389
2390static int fib_trie_seq_show(struct seq_file *seq, void *v)
2391{
2392 char bf[128];
2393
2394 if (v == SEQ_START_TOKEN) {
2395 if (trie_local)
2396 trie_dump_seq(seq, trie_local);
2397
2398 if (trie_main)
2399 trie_dump_seq(seq, trie_main);
2400 }
2401
2402 else {
2403 snprintf(bf, sizeof(bf),
2404 "*\t%08X\t%08X", 200, 400);
2405 seq_printf(seq, "%-127s\n", bf);
2406 }
2407
2408 return 0;
2409}
2410
2411static struct seq_operations fib_trie_seq_ops = {
2412 .start = fib_trie_seq_start,
2413 .next = fib_trie_seq_next,
2414 .stop = fib_trie_seq_stop,
2415 .show = fib_trie_seq_show,
2416};
2417
2418static int fib_trie_seq_open(struct inode *inode, struct file *file)
2419{
2420 struct seq_file *seq;
2421 int rc = -ENOMEM;
2422
2423 rc = seq_open(file, &fib_trie_seq_ops);
2424 if (rc)
2425 goto out_kfree;
2426
2427 seq = file->private_data;
2428out:
2429 return rc;
2430out_kfree:
2431 goto out;
2432}
2433
2434static struct file_operations fib_trie_seq_fops = {
2435 .owner = THIS_MODULE,
2436 .open = fib_trie_seq_open,
2437 .read = seq_read,
2438 .llseek = seq_lseek,
2439 .release = seq_release_private,
2440};
2441
2442int __init fib_proc_init(void)
2443{
2444 if (!proc_net_fops_create("fib_trie", S_IRUGO, &fib_trie_seq_fops))
2445 return -ENOMEM;
2446 return 0;
2447}
2448
2449void __init fib_proc_exit(void)
2450{
2451 proc_net_remove("fib_trie");
2452}
2453
2454#endif /* CONFIG_PROC_FS */
diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c
index 4e47a2658c7c..af2ec88bbb2f 100644
--- a/net/ipv4/ip_input.c
+++ b/net/ipv4/ip_input.c
@@ -184,6 +184,7 @@ int ip_call_ra_chain(struct sk_buff *skb)
184 raw_rcv(last, skb2); 184 raw_rcv(last, skb2);
185 } 185 }
186 last = sk; 186 last = sk;
187 nf_reset(skb);
187 } 188 }
188 } 189 }
189 190
@@ -200,10 +201,6 @@ static inline int ip_local_deliver_finish(struct sk_buff *skb)
200{ 201{
201 int ihl = skb->nh.iph->ihl*4; 202 int ihl = skb->nh.iph->ihl*4;
202 203
203#ifdef CONFIG_NETFILTER_DEBUG
204 nf_debug_ip_local_deliver(skb);
205#endif /*CONFIG_NETFILTER_DEBUG*/
206
207 __skb_pull(skb, ihl); 204 __skb_pull(skb, ihl);
208 205
209 /* Free reference early: we don't need it any more, and it may 206 /* Free reference early: we don't need it any more, and it may
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index 760dc8238d65..ee07aec215a0 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -107,10 +107,6 @@ static int ip_dev_loopback_xmit(struct sk_buff *newskb)
107 newskb->pkt_type = PACKET_LOOPBACK; 107 newskb->pkt_type = PACKET_LOOPBACK;
108 newskb->ip_summed = CHECKSUM_UNNECESSARY; 108 newskb->ip_summed = CHECKSUM_UNNECESSARY;
109 BUG_TRAP(newskb->dst); 109 BUG_TRAP(newskb->dst);
110
111#ifdef CONFIG_NETFILTER_DEBUG
112 nf_debug_ip_loopback_xmit(newskb);
113#endif
114 nf_reset(newskb); 110 nf_reset(newskb);
115 netif_rx(newskb); 111 netif_rx(newskb);
116 return 0; 112 return 0;
@@ -192,10 +188,6 @@ static inline int ip_finish_output2(struct sk_buff *skb)
192 skb = skb2; 188 skb = skb2;
193 } 189 }
194 190
195#ifdef CONFIG_NETFILTER_DEBUG
196 nf_debug_ip_finish_output2(skb);
197#endif /*CONFIG_NETFILTER_DEBUG*/
198
199 nf_reset(skb); 191 nf_reset(skb);
200 192
201 if (hh) { 193 if (hh) {
@@ -415,9 +407,6 @@ static void ip_copy_metadata(struct sk_buff *to, struct sk_buff *from)
415 to->nf_bridge = from->nf_bridge; 407 to->nf_bridge = from->nf_bridge;
416 nf_bridge_get(to->nf_bridge); 408 nf_bridge_get(to->nf_bridge);
417#endif 409#endif
418#ifdef CONFIG_NETFILTER_DEBUG
419 to->nf_debug = from->nf_debug;
420#endif
421#endif 410#endif
422} 411}
423 412
diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
index 1a23c5263b99..2065944fd9e5 100644
--- a/net/ipv4/ipcomp.c
+++ b/net/ipv4/ipcomp.c
@@ -236,15 +236,10 @@ static struct xfrm_state *ipcomp_tunnel_create(struct xfrm_state *x)
236 t->props.mode = 1; 236 t->props.mode = 1;
237 t->props.saddr.a4 = x->props.saddr.a4; 237 t->props.saddr.a4 = x->props.saddr.a4;
238 t->props.flags = x->props.flags; 238 t->props.flags = x->props.flags;
239 239
240 t->type = xfrm_get_type(IPPROTO_IPIP, t->props.family); 240 if (xfrm_init_state(t))
241 if (t->type == NULL)
242 goto error;
243
244 if (t->type->init_state(t, NULL))
245 goto error; 241 goto error;
246 242
247 t->km.state = XFRM_STATE_VALID;
248 atomic_set(&t->tunnel_users, 1); 243 atomic_set(&t->tunnel_users, 1);
249out: 244out:
250 return t; 245 return t;
@@ -422,7 +417,7 @@ static void ipcomp_destroy(struct xfrm_state *x)
422 kfree(ipcd); 417 kfree(ipcd);
423} 418}
424 419
425static int ipcomp_init_state(struct xfrm_state *x, void *args) 420static int ipcomp_init_state(struct xfrm_state *x)
426{ 421{
427 int err; 422 int err;
428 struct ipcomp_data *ipcd; 423 struct ipcomp_data *ipcd;
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index e21c049ec62a..e4f809a93f47 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -1350,6 +1350,7 @@ int ip_mr_input(struct sk_buff *skb)
1350 */ 1350 */
1351 read_lock(&mrt_lock); 1351 read_lock(&mrt_lock);
1352 if (mroute_socket) { 1352 if (mroute_socket) {
1353 nf_reset(skb);
1353 raw_rcv(mroute_socket, skb); 1354 raw_rcv(mroute_socket, skb);
1354 read_unlock(&mrt_lock); 1355 read_unlock(&mrt_lock);
1355 return 0; 1356 return 0;
diff --git a/net/ipv4/ipvs/ip_vs_xmit.c b/net/ipv4/ipvs/ip_vs_xmit.c
index de21da00057f..a8512a3fd08a 100644
--- a/net/ipv4/ipvs/ip_vs_xmit.c
+++ b/net/ipv4/ipvs/ip_vs_xmit.c
@@ -127,7 +127,6 @@ ip_vs_dst_reset(struct ip_vs_dest *dest)
127 127
128#define IP_VS_XMIT(skb, rt) \ 128#define IP_VS_XMIT(skb, rt) \
129do { \ 129do { \
130 nf_reset_debug(skb); \
131 (skb)->nfcache |= NFC_IPVS_PROPERTY; \ 130 (skb)->nfcache |= NFC_IPVS_PROPERTY; \
132 (skb)->ip_summed = CHECKSUM_NONE; \ 131 (skb)->ip_summed = CHECKSUM_NONE; \
133 NF_HOOK(PF_INET, NF_IP_LOCAL_OUT, (skb), NULL, \ 132 NF_HOOK(PF_INET, NF_IP_LOCAL_OUT, (skb), NULL, \
diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
index df79f5ed6a0a..fa1634256680 100644
--- a/net/ipv4/netfilter/arp_tables.c
+++ b/net/ipv4/netfilter/arp_tables.c
@@ -60,7 +60,6 @@ static DECLARE_MUTEX(arpt_mutex);
60 60
61#define ASSERT_READ_LOCK(x) ARP_NF_ASSERT(down_trylock(&arpt_mutex) != 0) 61#define ASSERT_READ_LOCK(x) ARP_NF_ASSERT(down_trylock(&arpt_mutex) != 0)
62#define ASSERT_WRITE_LOCK(x) ARP_NF_ASSERT(down_trylock(&arpt_mutex) != 0) 62#define ASSERT_WRITE_LOCK(x) ARP_NF_ASSERT(down_trylock(&arpt_mutex) != 0)
63#include <linux/netfilter_ipv4/lockhelp.h>
64#include <linux/netfilter_ipv4/listhelp.h> 63#include <linux/netfilter_ipv4/listhelp.h>
65 64
66struct arpt_table_info { 65struct arpt_table_info {
diff --git a/net/ipv4/netfilter/ip_conntrack_amanda.c b/net/ipv4/netfilter/ip_conntrack_amanda.c
index 3dbddd062605..a78a320eee08 100644
--- a/net/ipv4/netfilter/ip_conntrack_amanda.c
+++ b/net/ipv4/netfilter/ip_conntrack_amanda.c
@@ -26,7 +26,6 @@
26#include <net/checksum.h> 26#include <net/checksum.h>
27#include <net/udp.h> 27#include <net/udp.h>
28 28
29#include <linux/netfilter_ipv4/lockhelp.h>
30#include <linux/netfilter_ipv4/ip_conntrack_helper.h> 29#include <linux/netfilter_ipv4/ip_conntrack_helper.h>
31#include <linux/netfilter_ipv4/ip_conntrack_amanda.h> 30#include <linux/netfilter_ipv4/ip_conntrack_amanda.h>
32 31
@@ -42,7 +41,7 @@ static char *conns[] = { "DATA ", "MESG ", "INDEX " };
42 41
43/* This is slow, but it's simple. --RR */ 42/* This is slow, but it's simple. --RR */
44static char amanda_buffer[65536]; 43static char amanda_buffer[65536];
45static DECLARE_LOCK(amanda_buffer_lock); 44static DEFINE_SPINLOCK(amanda_buffer_lock);
46 45
47unsigned int (*ip_nat_amanda_hook)(struct sk_buff **pskb, 46unsigned int (*ip_nat_amanda_hook)(struct sk_buff **pskb,
48 enum ip_conntrack_info ctinfo, 47 enum ip_conntrack_info ctinfo,
@@ -76,7 +75,7 @@ static int help(struct sk_buff **pskb,
76 return NF_ACCEPT; 75 return NF_ACCEPT;
77 } 76 }
78 77
79 LOCK_BH(&amanda_buffer_lock); 78 spin_lock_bh(&amanda_buffer_lock);
80 skb_copy_bits(*pskb, dataoff, amanda_buffer, (*pskb)->len - dataoff); 79 skb_copy_bits(*pskb, dataoff, amanda_buffer, (*pskb)->len - dataoff);
81 data = amanda_buffer; 80 data = amanda_buffer;
82 data_limit = amanda_buffer + (*pskb)->len - dataoff; 81 data_limit = amanda_buffer + (*pskb)->len - dataoff;
@@ -134,7 +133,7 @@ static int help(struct sk_buff **pskb,
134 } 133 }
135 134
136out: 135out:
137 UNLOCK_BH(&amanda_buffer_lock); 136 spin_unlock_bh(&amanda_buffer_lock);
138 return ret; 137 return ret;
139} 138}
140 139
diff --git a/net/ipv4/netfilter/ip_conntrack_core.c b/net/ipv4/netfilter/ip_conntrack_core.c
index 09e824622977..4b78ebeb6635 100644
--- a/net/ipv4/netfilter/ip_conntrack_core.c
+++ b/net/ipv4/netfilter/ip_conntrack_core.c
@@ -38,10 +38,10 @@
38#include <linux/percpu.h> 38#include <linux/percpu.h>
39#include <linux/moduleparam.h> 39#include <linux/moduleparam.h>
40 40
41/* This rwlock protects the main hash table, protocol/helper/expected 41/* ip_conntrack_lock protects the main hash table, protocol/helper/expected
42 registrations, conntrack timers*/ 42 registrations, conntrack timers*/
43#define ASSERT_READ_LOCK(x) MUST_BE_READ_LOCKED(&ip_conntrack_lock) 43#define ASSERT_READ_LOCK(x)
44#define ASSERT_WRITE_LOCK(x) MUST_BE_WRITE_LOCKED(&ip_conntrack_lock) 44#define ASSERT_WRITE_LOCK(x)
45 45
46#include <linux/netfilter_ipv4/ip_conntrack.h> 46#include <linux/netfilter_ipv4/ip_conntrack.h>
47#include <linux/netfilter_ipv4/ip_conntrack_protocol.h> 47#include <linux/netfilter_ipv4/ip_conntrack_protocol.h>
@@ -57,7 +57,7 @@
57#define DEBUGP(format, args...) 57#define DEBUGP(format, args...)
58#endif 58#endif
59 59
60DECLARE_RWLOCK(ip_conntrack_lock); 60DEFINE_RWLOCK(ip_conntrack_lock);
61 61
62/* ip_conntrack_standalone needs this */ 62/* ip_conntrack_standalone needs this */
63atomic_t ip_conntrack_count = ATOMIC_INIT(0); 63atomic_t ip_conntrack_count = ATOMIC_INIT(0);
@@ -147,7 +147,7 @@ static void destroy_expect(struct ip_conntrack_expect *exp)
147 147
148static void unlink_expect(struct ip_conntrack_expect *exp) 148static void unlink_expect(struct ip_conntrack_expect *exp)
149{ 149{
150 MUST_BE_WRITE_LOCKED(&ip_conntrack_lock); 150 ASSERT_WRITE_LOCK(&ip_conntrack_lock);
151 list_del(&exp->list); 151 list_del(&exp->list);
152 /* Logically in destroy_expect, but we hold the lock here. */ 152 /* Logically in destroy_expect, but we hold the lock here. */
153 exp->master->expecting--; 153 exp->master->expecting--;
@@ -157,9 +157,9 @@ static void expectation_timed_out(unsigned long ul_expect)
157{ 157{
158 struct ip_conntrack_expect *exp = (void *)ul_expect; 158 struct ip_conntrack_expect *exp = (void *)ul_expect;
159 159
160 WRITE_LOCK(&ip_conntrack_lock); 160 write_lock_bh(&ip_conntrack_lock);
161 unlink_expect(exp); 161 unlink_expect(exp);
162 WRITE_UNLOCK(&ip_conntrack_lock); 162 write_unlock_bh(&ip_conntrack_lock);
163 destroy_expect(exp); 163 destroy_expect(exp);
164} 164}
165 165
@@ -209,7 +209,7 @@ clean_from_lists(struct ip_conntrack *ct)
209 unsigned int ho, hr; 209 unsigned int ho, hr;
210 210
211 DEBUGP("clean_from_lists(%p)\n", ct); 211 DEBUGP("clean_from_lists(%p)\n", ct);
212 MUST_BE_WRITE_LOCKED(&ip_conntrack_lock); 212 ASSERT_WRITE_LOCK(&ip_conntrack_lock);
213 213
214 ho = hash_conntrack(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple); 214 ho = hash_conntrack(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple);
215 hr = hash_conntrack(&ct->tuplehash[IP_CT_DIR_REPLY].tuple); 215 hr = hash_conntrack(&ct->tuplehash[IP_CT_DIR_REPLY].tuple);
@@ -240,7 +240,7 @@ destroy_conntrack(struct nf_conntrack *nfct)
240 if (ip_conntrack_destroyed) 240 if (ip_conntrack_destroyed)
241 ip_conntrack_destroyed(ct); 241 ip_conntrack_destroyed(ct);
242 242
243 WRITE_LOCK(&ip_conntrack_lock); 243 write_lock_bh(&ip_conntrack_lock);
244 /* Expectations will have been removed in clean_from_lists, 244 /* Expectations will have been removed in clean_from_lists,
245 * except TFTP can create an expectation on the first packet, 245 * except TFTP can create an expectation on the first packet,
246 * before connection is in the list, so we need to clean here, 246 * before connection is in the list, so we need to clean here,
@@ -254,7 +254,7 @@ destroy_conntrack(struct nf_conntrack *nfct)
254 } 254 }
255 255
256 CONNTRACK_STAT_INC(delete); 256 CONNTRACK_STAT_INC(delete);
257 WRITE_UNLOCK(&ip_conntrack_lock); 257 write_unlock_bh(&ip_conntrack_lock);
258 258
259 if (ct->master) 259 if (ct->master)
260 ip_conntrack_put(ct->master); 260 ip_conntrack_put(ct->master);
@@ -268,12 +268,12 @@ static void death_by_timeout(unsigned long ul_conntrack)
268{ 268{
269 struct ip_conntrack *ct = (void *)ul_conntrack; 269 struct ip_conntrack *ct = (void *)ul_conntrack;
270 270
271 WRITE_LOCK(&ip_conntrack_lock); 271 write_lock_bh(&ip_conntrack_lock);
272 /* Inside lock so preempt is disabled on module removal path. 272 /* Inside lock so preempt is disabled on module removal path.
273 * Otherwise we can get spurious warnings. */ 273 * Otherwise we can get spurious warnings. */
274 CONNTRACK_STAT_INC(delete_list); 274 CONNTRACK_STAT_INC(delete_list);
275 clean_from_lists(ct); 275 clean_from_lists(ct);
276 WRITE_UNLOCK(&ip_conntrack_lock); 276 write_unlock_bh(&ip_conntrack_lock);
277 ip_conntrack_put(ct); 277 ip_conntrack_put(ct);
278} 278}
279 279
@@ -282,7 +282,7 @@ conntrack_tuple_cmp(const struct ip_conntrack_tuple_hash *i,
282 const struct ip_conntrack_tuple *tuple, 282 const struct ip_conntrack_tuple *tuple,
283 const struct ip_conntrack *ignored_conntrack) 283 const struct ip_conntrack *ignored_conntrack)
284{ 284{
285 MUST_BE_READ_LOCKED(&ip_conntrack_lock); 285 ASSERT_READ_LOCK(&ip_conntrack_lock);
286 return tuplehash_to_ctrack(i) != ignored_conntrack 286 return tuplehash_to_ctrack(i) != ignored_conntrack
287 && ip_ct_tuple_equal(tuple, &i->tuple); 287 && ip_ct_tuple_equal(tuple, &i->tuple);
288} 288}
@@ -294,7 +294,7 @@ __ip_conntrack_find(const struct ip_conntrack_tuple *tuple,
294 struct ip_conntrack_tuple_hash *h; 294 struct ip_conntrack_tuple_hash *h;
295 unsigned int hash = hash_conntrack(tuple); 295 unsigned int hash = hash_conntrack(tuple);
296 296
297 MUST_BE_READ_LOCKED(&ip_conntrack_lock); 297 ASSERT_READ_LOCK(&ip_conntrack_lock);
298 list_for_each_entry(h, &ip_conntrack_hash[hash], list) { 298 list_for_each_entry(h, &ip_conntrack_hash[hash], list) {
299 if (conntrack_tuple_cmp(h, tuple, ignored_conntrack)) { 299 if (conntrack_tuple_cmp(h, tuple, ignored_conntrack)) {
300 CONNTRACK_STAT_INC(found); 300 CONNTRACK_STAT_INC(found);
@@ -313,11 +313,11 @@ ip_conntrack_find_get(const struct ip_conntrack_tuple *tuple,
313{ 313{
314 struct ip_conntrack_tuple_hash *h; 314 struct ip_conntrack_tuple_hash *h;
315 315
316 READ_LOCK(&ip_conntrack_lock); 316 read_lock_bh(&ip_conntrack_lock);
317 h = __ip_conntrack_find(tuple, ignored_conntrack); 317 h = __ip_conntrack_find(tuple, ignored_conntrack);
318 if (h) 318 if (h)
319 atomic_inc(&tuplehash_to_ctrack(h)->ct_general.use); 319 atomic_inc(&tuplehash_to_ctrack(h)->ct_general.use);
320 READ_UNLOCK(&ip_conntrack_lock); 320 read_unlock_bh(&ip_conntrack_lock);
321 321
322 return h; 322 return h;
323} 323}
@@ -352,7 +352,7 @@ __ip_conntrack_confirm(struct sk_buff **pskb)
352 IP_NF_ASSERT(!is_confirmed(ct)); 352 IP_NF_ASSERT(!is_confirmed(ct));
353 DEBUGP("Confirming conntrack %p\n", ct); 353 DEBUGP("Confirming conntrack %p\n", ct);
354 354
355 WRITE_LOCK(&ip_conntrack_lock); 355 write_lock_bh(&ip_conntrack_lock);
356 356
357 /* See if there's one in the list already, including reverse: 357 /* See if there's one in the list already, including reverse:
358 NAT could have grabbed it without realizing, since we're 358 NAT could have grabbed it without realizing, since we're
@@ -380,12 +380,12 @@ __ip_conntrack_confirm(struct sk_buff **pskb)
380 atomic_inc(&ct->ct_general.use); 380 atomic_inc(&ct->ct_general.use);
381 set_bit(IPS_CONFIRMED_BIT, &ct->status); 381 set_bit(IPS_CONFIRMED_BIT, &ct->status);
382 CONNTRACK_STAT_INC(insert); 382 CONNTRACK_STAT_INC(insert);
383 WRITE_UNLOCK(&ip_conntrack_lock); 383 write_unlock_bh(&ip_conntrack_lock);
384 return NF_ACCEPT; 384 return NF_ACCEPT;
385 } 385 }
386 386
387 CONNTRACK_STAT_INC(insert_failed); 387 CONNTRACK_STAT_INC(insert_failed);
388 WRITE_UNLOCK(&ip_conntrack_lock); 388 write_unlock_bh(&ip_conntrack_lock);
389 389
390 return NF_DROP; 390 return NF_DROP;
391} 391}
@@ -398,9 +398,9 @@ ip_conntrack_tuple_taken(const struct ip_conntrack_tuple *tuple,
398{ 398{
399 struct ip_conntrack_tuple_hash *h; 399 struct ip_conntrack_tuple_hash *h;
400 400
401 READ_LOCK(&ip_conntrack_lock); 401 read_lock_bh(&ip_conntrack_lock);
402 h = __ip_conntrack_find(tuple, ignored_conntrack); 402 h = __ip_conntrack_find(tuple, ignored_conntrack);
403 READ_UNLOCK(&ip_conntrack_lock); 403 read_unlock_bh(&ip_conntrack_lock);
404 404
405 return h != NULL; 405 return h != NULL;
406} 406}
@@ -419,13 +419,13 @@ static int early_drop(struct list_head *chain)
419 struct ip_conntrack *ct = NULL; 419 struct ip_conntrack *ct = NULL;
420 int dropped = 0; 420 int dropped = 0;
421 421
422 READ_LOCK(&ip_conntrack_lock); 422 read_lock_bh(&ip_conntrack_lock);
423 h = LIST_FIND_B(chain, unreplied, struct ip_conntrack_tuple_hash *); 423 h = LIST_FIND_B(chain, unreplied, struct ip_conntrack_tuple_hash *);
424 if (h) { 424 if (h) {
425 ct = tuplehash_to_ctrack(h); 425 ct = tuplehash_to_ctrack(h);
426 atomic_inc(&ct->ct_general.use); 426 atomic_inc(&ct->ct_general.use);
427 } 427 }
428 READ_UNLOCK(&ip_conntrack_lock); 428 read_unlock_bh(&ip_conntrack_lock);
429 429
430 if (!ct) 430 if (!ct)
431 return dropped; 431 return dropped;
@@ -508,7 +508,7 @@ init_conntrack(const struct ip_conntrack_tuple *tuple,
508 conntrack->timeout.data = (unsigned long)conntrack; 508 conntrack->timeout.data = (unsigned long)conntrack;
509 conntrack->timeout.function = death_by_timeout; 509 conntrack->timeout.function = death_by_timeout;
510 510
511 WRITE_LOCK(&ip_conntrack_lock); 511 write_lock_bh(&ip_conntrack_lock);
512 exp = find_expectation(tuple); 512 exp = find_expectation(tuple);
513 513
514 if (exp) { 514 if (exp) {
@@ -532,7 +532,7 @@ init_conntrack(const struct ip_conntrack_tuple *tuple,
532 list_add(&conntrack->tuplehash[IP_CT_DIR_ORIGINAL].list, &unconfirmed); 532 list_add(&conntrack->tuplehash[IP_CT_DIR_ORIGINAL].list, &unconfirmed);
533 533
534 atomic_inc(&ip_conntrack_count); 534 atomic_inc(&ip_conntrack_count);
535 WRITE_UNLOCK(&ip_conntrack_lock); 535 write_unlock_bh(&ip_conntrack_lock);
536 536
537 if (exp) { 537 if (exp) {
538 if (exp->expectfn) 538 if (exp->expectfn)
@@ -723,17 +723,17 @@ void ip_conntrack_unexpect_related(struct ip_conntrack_expect *exp)
723{ 723{
724 struct ip_conntrack_expect *i; 724 struct ip_conntrack_expect *i;
725 725
726 WRITE_LOCK(&ip_conntrack_lock); 726 write_lock_bh(&ip_conntrack_lock);
727 /* choose the the oldest expectation to evict */ 727 /* choose the the oldest expectation to evict */
728 list_for_each_entry_reverse(i, &ip_conntrack_expect_list, list) { 728 list_for_each_entry_reverse(i, &ip_conntrack_expect_list, list) {
729 if (expect_matches(i, exp) && del_timer(&i->timeout)) { 729 if (expect_matches(i, exp) && del_timer(&i->timeout)) {
730 unlink_expect(i); 730 unlink_expect(i);
731 WRITE_UNLOCK(&ip_conntrack_lock); 731 write_unlock_bh(&ip_conntrack_lock);
732 destroy_expect(i); 732 destroy_expect(i);
733 return; 733 return;
734 } 734 }
735 } 735 }
736 WRITE_UNLOCK(&ip_conntrack_lock); 736 write_unlock_bh(&ip_conntrack_lock);
737} 737}
738 738
739struct ip_conntrack_expect *ip_conntrack_expect_alloc(void) 739struct ip_conntrack_expect *ip_conntrack_expect_alloc(void)
@@ -760,15 +760,11 @@ static void ip_conntrack_expect_insert(struct ip_conntrack_expect *exp)
760 exp->master->expecting++; 760 exp->master->expecting++;
761 list_add(&exp->list, &ip_conntrack_expect_list); 761 list_add(&exp->list, &ip_conntrack_expect_list);
762 762
763 if (exp->master->helper->timeout) { 763 init_timer(&exp->timeout);
764 init_timer(&exp->timeout); 764 exp->timeout.data = (unsigned long)exp;
765 exp->timeout.data = (unsigned long)exp; 765 exp->timeout.function = expectation_timed_out;
766 exp->timeout.function = expectation_timed_out; 766 exp->timeout.expires = jiffies + exp->master->helper->timeout * HZ;
767 exp->timeout.expires 767 add_timer(&exp->timeout);
768 = jiffies + exp->master->helper->timeout * HZ;
769 add_timer(&exp->timeout);
770 } else
771 exp->timeout.function = NULL;
772 768
773 CONNTRACK_STAT_INC(expect_create); 769 CONNTRACK_STAT_INC(expect_create);
774} 770}
@@ -808,7 +804,7 @@ int ip_conntrack_expect_related(struct ip_conntrack_expect *expect)
808 DEBUGP("tuple: "); DUMP_TUPLE(&expect->tuple); 804 DEBUGP("tuple: "); DUMP_TUPLE(&expect->tuple);
809 DEBUGP("mask: "); DUMP_TUPLE(&expect->mask); 805 DEBUGP("mask: "); DUMP_TUPLE(&expect->mask);
810 806
811 WRITE_LOCK(&ip_conntrack_lock); 807 write_lock_bh(&ip_conntrack_lock);
812 list_for_each_entry(i, &ip_conntrack_expect_list, list) { 808 list_for_each_entry(i, &ip_conntrack_expect_list, list) {
813 if (expect_matches(i, expect)) { 809 if (expect_matches(i, expect)) {
814 /* Refresh timer: if it's dying, ignore.. */ 810 /* Refresh timer: if it's dying, ignore.. */
@@ -832,7 +828,7 @@ int ip_conntrack_expect_related(struct ip_conntrack_expect *expect)
832 ip_conntrack_expect_insert(expect); 828 ip_conntrack_expect_insert(expect);
833 ret = 0; 829 ret = 0;
834out: 830out:
835 WRITE_UNLOCK(&ip_conntrack_lock); 831 write_unlock_bh(&ip_conntrack_lock);
836 return ret; 832 return ret;
837} 833}
838 834
@@ -841,7 +837,7 @@ out:
841void ip_conntrack_alter_reply(struct ip_conntrack *conntrack, 837void ip_conntrack_alter_reply(struct ip_conntrack *conntrack,
842 const struct ip_conntrack_tuple *newreply) 838 const struct ip_conntrack_tuple *newreply)
843{ 839{
844 WRITE_LOCK(&ip_conntrack_lock); 840 write_lock_bh(&ip_conntrack_lock);
845 /* Should be unconfirmed, so not in hash table yet */ 841 /* Should be unconfirmed, so not in hash table yet */
846 IP_NF_ASSERT(!is_confirmed(conntrack)); 842 IP_NF_ASSERT(!is_confirmed(conntrack));
847 843
@@ -851,15 +847,15 @@ void ip_conntrack_alter_reply(struct ip_conntrack *conntrack,
851 conntrack->tuplehash[IP_CT_DIR_REPLY].tuple = *newreply; 847 conntrack->tuplehash[IP_CT_DIR_REPLY].tuple = *newreply;
852 if (!conntrack->master && conntrack->expecting == 0) 848 if (!conntrack->master && conntrack->expecting == 0)
853 conntrack->helper = ip_ct_find_helper(newreply); 849 conntrack->helper = ip_ct_find_helper(newreply);
854 WRITE_UNLOCK(&ip_conntrack_lock); 850 write_unlock_bh(&ip_conntrack_lock);
855} 851}
856 852
857int ip_conntrack_helper_register(struct ip_conntrack_helper *me) 853int ip_conntrack_helper_register(struct ip_conntrack_helper *me)
858{ 854{
859 BUG_ON(me->timeout == 0); 855 BUG_ON(me->timeout == 0);
860 WRITE_LOCK(&ip_conntrack_lock); 856 write_lock_bh(&ip_conntrack_lock);
861 list_prepend(&helpers, me); 857 list_prepend(&helpers, me);
862 WRITE_UNLOCK(&ip_conntrack_lock); 858 write_unlock_bh(&ip_conntrack_lock);
863 859
864 return 0; 860 return 0;
865} 861}
@@ -878,7 +874,7 @@ void ip_conntrack_helper_unregister(struct ip_conntrack_helper *me)
878 struct ip_conntrack_expect *exp, *tmp; 874 struct ip_conntrack_expect *exp, *tmp;
879 875
880 /* Need write lock here, to delete helper. */ 876 /* Need write lock here, to delete helper. */
881 WRITE_LOCK(&ip_conntrack_lock); 877 write_lock_bh(&ip_conntrack_lock);
882 LIST_DELETE(&helpers, me); 878 LIST_DELETE(&helpers, me);
883 879
884 /* Get rid of expectations */ 880 /* Get rid of expectations */
@@ -893,7 +889,7 @@ void ip_conntrack_helper_unregister(struct ip_conntrack_helper *me)
893 for (i = 0; i < ip_conntrack_htable_size; i++) 889 for (i = 0; i < ip_conntrack_htable_size; i++)
894 LIST_FIND_W(&ip_conntrack_hash[i], unhelp, 890 LIST_FIND_W(&ip_conntrack_hash[i], unhelp,
895 struct ip_conntrack_tuple_hash *, me); 891 struct ip_conntrack_tuple_hash *, me);
896 WRITE_UNLOCK(&ip_conntrack_lock); 892 write_unlock_bh(&ip_conntrack_lock);
897 893
898 /* Someone could be still looking at the helper in a bh. */ 894 /* Someone could be still looking at the helper in a bh. */
899 synchronize_net(); 895 synchronize_net();
@@ -925,14 +921,14 @@ void ip_ct_refresh_acct(struct ip_conntrack *ct,
925 ct->timeout.expires = extra_jiffies; 921 ct->timeout.expires = extra_jiffies;
926 ct_add_counters(ct, ctinfo, skb); 922 ct_add_counters(ct, ctinfo, skb);
927 } else { 923 } else {
928 WRITE_LOCK(&ip_conntrack_lock); 924 write_lock_bh(&ip_conntrack_lock);
929 /* Need del_timer for race avoidance (may already be dying). */ 925 /* Need del_timer for race avoidance (may already be dying). */
930 if (del_timer(&ct->timeout)) { 926 if (del_timer(&ct->timeout)) {
931 ct->timeout.expires = jiffies + extra_jiffies; 927 ct->timeout.expires = jiffies + extra_jiffies;
932 add_timer(&ct->timeout); 928 add_timer(&ct->timeout);
933 } 929 }
934 ct_add_counters(ct, ctinfo, skb); 930 ct_add_counters(ct, ctinfo, skb);
935 WRITE_UNLOCK(&ip_conntrack_lock); 931 write_unlock_bh(&ip_conntrack_lock);
936 } 932 }
937} 933}
938 934
@@ -940,10 +936,6 @@ void ip_ct_refresh_acct(struct ip_conntrack *ct,
940struct sk_buff * 936struct sk_buff *
941ip_ct_gather_frags(struct sk_buff *skb, u_int32_t user) 937ip_ct_gather_frags(struct sk_buff *skb, u_int32_t user)
942{ 938{
943#ifdef CONFIG_NETFILTER_DEBUG
944 unsigned int olddebug = skb->nf_debug;
945#endif
946
947 skb_orphan(skb); 939 skb_orphan(skb);
948 940
949 local_bh_disable(); 941 local_bh_disable();
@@ -953,12 +945,7 @@ ip_ct_gather_frags(struct sk_buff *skb, u_int32_t user)
953 if (skb) { 945 if (skb) {
954 ip_send_check(skb->nh.iph); 946 ip_send_check(skb->nh.iph);
955 skb->nfcache |= NFC_ALTERED; 947 skb->nfcache |= NFC_ALTERED;
956#ifdef CONFIG_NETFILTER_DEBUG
957 /* Packet path as if nothing had happened. */
958 skb->nf_debug = olddebug;
959#endif
960 } 948 }
961
962 return skb; 949 return skb;
963} 950}
964 951
@@ -997,7 +984,7 @@ get_next_corpse(int (*iter)(struct ip_conntrack *i, void *data),
997{ 984{
998 struct ip_conntrack_tuple_hash *h = NULL; 985 struct ip_conntrack_tuple_hash *h = NULL;
999 986
1000 WRITE_LOCK(&ip_conntrack_lock); 987 write_lock_bh(&ip_conntrack_lock);
1001 for (; *bucket < ip_conntrack_htable_size; (*bucket)++) { 988 for (; *bucket < ip_conntrack_htable_size; (*bucket)++) {
1002 h = LIST_FIND_W(&ip_conntrack_hash[*bucket], do_iter, 989 h = LIST_FIND_W(&ip_conntrack_hash[*bucket], do_iter,
1003 struct ip_conntrack_tuple_hash *, iter, data); 990 struct ip_conntrack_tuple_hash *, iter, data);
@@ -1009,7 +996,7 @@ get_next_corpse(int (*iter)(struct ip_conntrack *i, void *data),
1009 struct ip_conntrack_tuple_hash *, iter, data); 996 struct ip_conntrack_tuple_hash *, iter, data);
1010 if (h) 997 if (h)
1011 atomic_inc(&tuplehash_to_ctrack(h)->ct_general.use); 998 atomic_inc(&tuplehash_to_ctrack(h)->ct_general.use);
1012 WRITE_UNLOCK(&ip_conntrack_lock); 999 write_unlock_bh(&ip_conntrack_lock);
1013 1000
1014 return h; 1001 return h;
1015} 1002}
@@ -1201,14 +1188,14 @@ int __init ip_conntrack_init(void)
1201 } 1188 }
1202 1189
1203 /* Don't NEED lock here, but good form anyway. */ 1190 /* Don't NEED lock here, but good form anyway. */
1204 WRITE_LOCK(&ip_conntrack_lock); 1191 write_lock_bh(&ip_conntrack_lock);
1205 for (i = 0; i < MAX_IP_CT_PROTO; i++) 1192 for (i = 0; i < MAX_IP_CT_PROTO; i++)
1206 ip_ct_protos[i] = &ip_conntrack_generic_protocol; 1193 ip_ct_protos[i] = &ip_conntrack_generic_protocol;
1207 /* Sew in builtin protocols. */ 1194 /* Sew in builtin protocols. */
1208 ip_ct_protos[IPPROTO_TCP] = &ip_conntrack_protocol_tcp; 1195 ip_ct_protos[IPPROTO_TCP] = &ip_conntrack_protocol_tcp;
1209 ip_ct_protos[IPPROTO_UDP] = &ip_conntrack_protocol_udp; 1196 ip_ct_protos[IPPROTO_UDP] = &ip_conntrack_protocol_udp;
1210 ip_ct_protos[IPPROTO_ICMP] = &ip_conntrack_protocol_icmp; 1197 ip_ct_protos[IPPROTO_ICMP] = &ip_conntrack_protocol_icmp;
1211 WRITE_UNLOCK(&ip_conntrack_lock); 1198 write_unlock_bh(&ip_conntrack_lock);
1212 1199
1213 for (i = 0; i < ip_conntrack_htable_size; i++) 1200 for (i = 0; i < ip_conntrack_htable_size; i++)
1214 INIT_LIST_HEAD(&ip_conntrack_hash[i]); 1201 INIT_LIST_HEAD(&ip_conntrack_hash[i]);
diff --git a/net/ipv4/netfilter/ip_conntrack_ftp.c b/net/ipv4/netfilter/ip_conntrack_ftp.c
index dd86503aa788..fea6dd2a00b6 100644
--- a/net/ipv4/netfilter/ip_conntrack_ftp.c
+++ b/net/ipv4/netfilter/ip_conntrack_ftp.c
@@ -16,7 +16,6 @@
16#include <net/checksum.h> 16#include <net/checksum.h>
17#include <net/tcp.h> 17#include <net/tcp.h>
18 18
19#include <linux/netfilter_ipv4/lockhelp.h>
20#include <linux/netfilter_ipv4/ip_conntrack_helper.h> 19#include <linux/netfilter_ipv4/ip_conntrack_helper.h>
21#include <linux/netfilter_ipv4/ip_conntrack_ftp.h> 20#include <linux/netfilter_ipv4/ip_conntrack_ftp.h>
22#include <linux/moduleparam.h> 21#include <linux/moduleparam.h>
@@ -28,7 +27,7 @@ MODULE_DESCRIPTION("ftp connection tracking helper");
28/* This is slow, but it's simple. --RR */ 27/* This is slow, but it's simple. --RR */
29static char ftp_buffer[65536]; 28static char ftp_buffer[65536];
30 29
31static DECLARE_LOCK(ip_ftp_lock); 30static DEFINE_SPINLOCK(ip_ftp_lock);
32 31
33#define MAX_PORTS 8 32#define MAX_PORTS 8
34static int ports[MAX_PORTS]; 33static int ports[MAX_PORTS];
@@ -319,7 +318,7 @@ static int help(struct sk_buff **pskb,
319 } 318 }
320 datalen = (*pskb)->len - dataoff; 319 datalen = (*pskb)->len - dataoff;
321 320
322 LOCK_BH(&ip_ftp_lock); 321 spin_lock_bh(&ip_ftp_lock);
323 fb_ptr = skb_header_pointer(*pskb, dataoff, 322 fb_ptr = skb_header_pointer(*pskb, dataoff,
324 (*pskb)->len - dataoff, ftp_buffer); 323 (*pskb)->len - dataoff, ftp_buffer);
325 BUG_ON(fb_ptr == NULL); 324 BUG_ON(fb_ptr == NULL);
@@ -442,7 +441,7 @@ out_update_nl:
442 if (ends_in_nl) 441 if (ends_in_nl)
443 update_nl_seq(seq, ct_ftp_info,dir); 442 update_nl_seq(seq, ct_ftp_info,dir);
444 out: 443 out:
445 UNLOCK_BH(&ip_ftp_lock); 444 spin_unlock_bh(&ip_ftp_lock);
446 return ret; 445 return ret;
447} 446}
448 447
diff --git a/net/ipv4/netfilter/ip_conntrack_irc.c b/net/ipv4/netfilter/ip_conntrack_irc.c
index 33cc7348b6ee..cd98772cc332 100644
--- a/net/ipv4/netfilter/ip_conntrack_irc.c
+++ b/net/ipv4/netfilter/ip_conntrack_irc.c
@@ -29,7 +29,6 @@
29#include <net/checksum.h> 29#include <net/checksum.h>
30#include <net/tcp.h> 30#include <net/tcp.h>
31 31
32#include <linux/netfilter_ipv4/lockhelp.h>
33#include <linux/netfilter_ipv4/ip_conntrack_helper.h> 32#include <linux/netfilter_ipv4/ip_conntrack_helper.h>
34#include <linux/netfilter_ipv4/ip_conntrack_irc.h> 33#include <linux/netfilter_ipv4/ip_conntrack_irc.h>
35#include <linux/moduleparam.h> 34#include <linux/moduleparam.h>
@@ -41,7 +40,7 @@ static int max_dcc_channels = 8;
41static unsigned int dcc_timeout = 300; 40static unsigned int dcc_timeout = 300;
42/* This is slow, but it's simple. --RR */ 41/* This is slow, but it's simple. --RR */
43static char irc_buffer[65536]; 42static char irc_buffer[65536];
44static DECLARE_LOCK(irc_buffer_lock); 43static DEFINE_SPINLOCK(irc_buffer_lock);
45 44
46unsigned int (*ip_nat_irc_hook)(struct sk_buff **pskb, 45unsigned int (*ip_nat_irc_hook)(struct sk_buff **pskb,
47 enum ip_conntrack_info ctinfo, 46 enum ip_conntrack_info ctinfo,
@@ -141,7 +140,7 @@ static int help(struct sk_buff **pskb,
141 if (dataoff >= (*pskb)->len) 140 if (dataoff >= (*pskb)->len)
142 return NF_ACCEPT; 141 return NF_ACCEPT;
143 142
144 LOCK_BH(&irc_buffer_lock); 143 spin_lock_bh(&irc_buffer_lock);
145 ib_ptr = skb_header_pointer(*pskb, dataoff, 144 ib_ptr = skb_header_pointer(*pskb, dataoff,
146 (*pskb)->len - dataoff, irc_buffer); 145 (*pskb)->len - dataoff, irc_buffer);
147 BUG_ON(ib_ptr == NULL); 146 BUG_ON(ib_ptr == NULL);
@@ -237,7 +236,7 @@ static int help(struct sk_buff **pskb,
237 } /* while data < ... */ 236 } /* while data < ... */
238 237
239 out: 238 out:
240 UNLOCK_BH(&irc_buffer_lock); 239 spin_unlock_bh(&irc_buffer_lock);
241 return ret; 240 return ret;
242} 241}
243 242
diff --git a/net/ipv4/netfilter/ip_conntrack_proto_sctp.c b/net/ipv4/netfilter/ip_conntrack_proto_sctp.c
index ff8c34a860ff..31d75390bf12 100644
--- a/net/ipv4/netfilter/ip_conntrack_proto_sctp.c
+++ b/net/ipv4/netfilter/ip_conntrack_proto_sctp.c
@@ -26,7 +26,6 @@
26 26
27#include <linux/netfilter_ipv4/ip_conntrack.h> 27#include <linux/netfilter_ipv4/ip_conntrack.h>
28#include <linux/netfilter_ipv4/ip_conntrack_protocol.h> 28#include <linux/netfilter_ipv4/ip_conntrack_protocol.h>
29#include <linux/netfilter_ipv4/lockhelp.h>
30 29
31#if 0 30#if 0
32#define DEBUGP(format, ...) printk(format, ## __VA_ARGS__) 31#define DEBUGP(format, ...) printk(format, ## __VA_ARGS__)
@@ -35,7 +34,7 @@
35#endif 34#endif
36 35
37/* Protects conntrack->proto.sctp */ 36/* Protects conntrack->proto.sctp */
38static DECLARE_RWLOCK(sctp_lock); 37static DEFINE_RWLOCK(sctp_lock);
39 38
40/* FIXME: Examine ipfilter's timeouts and conntrack transitions more 39/* FIXME: Examine ipfilter's timeouts and conntrack transitions more
41 closely. They're more complex. --RR 40 closely. They're more complex. --RR
@@ -199,9 +198,9 @@ static int sctp_print_conntrack(struct seq_file *s,
199 DEBUGP(__FUNCTION__); 198 DEBUGP(__FUNCTION__);
200 DEBUGP("\n"); 199 DEBUGP("\n");
201 200
202 READ_LOCK(&sctp_lock); 201 read_lock_bh(&sctp_lock);
203 state = conntrack->proto.sctp.state; 202 state = conntrack->proto.sctp.state;
204 READ_UNLOCK(&sctp_lock); 203 read_unlock_bh(&sctp_lock);
205 204
206 return seq_printf(s, "%s ", sctp_conntrack_names[state]); 205 return seq_printf(s, "%s ", sctp_conntrack_names[state]);
207} 206}
@@ -343,13 +342,13 @@ static int sctp_packet(struct ip_conntrack *conntrack,
343 342
344 oldsctpstate = newconntrack = SCTP_CONNTRACK_MAX; 343 oldsctpstate = newconntrack = SCTP_CONNTRACK_MAX;
345 for_each_sctp_chunk (skb, sch, _sch, offset, count) { 344 for_each_sctp_chunk (skb, sch, _sch, offset, count) {
346 WRITE_LOCK(&sctp_lock); 345 write_lock_bh(&sctp_lock);
347 346
348 /* Special cases of Verification tag check (Sec 8.5.1) */ 347 /* Special cases of Verification tag check (Sec 8.5.1) */
349 if (sch->type == SCTP_CID_INIT) { 348 if (sch->type == SCTP_CID_INIT) {
350 /* Sec 8.5.1 (A) */ 349 /* Sec 8.5.1 (A) */
351 if (sh->vtag != 0) { 350 if (sh->vtag != 0) {
352 WRITE_UNLOCK(&sctp_lock); 351 write_unlock_bh(&sctp_lock);
353 return -1; 352 return -1;
354 } 353 }
355 } else if (sch->type == SCTP_CID_ABORT) { 354 } else if (sch->type == SCTP_CID_ABORT) {
@@ -357,7 +356,7 @@ static int sctp_packet(struct ip_conntrack *conntrack,
357 if (!(sh->vtag == conntrack->proto.sctp.vtag[CTINFO2DIR(ctinfo)]) 356 if (!(sh->vtag == conntrack->proto.sctp.vtag[CTINFO2DIR(ctinfo)])
358 && !(sh->vtag == conntrack->proto.sctp.vtag 357 && !(sh->vtag == conntrack->proto.sctp.vtag
359 [1 - CTINFO2DIR(ctinfo)])) { 358 [1 - CTINFO2DIR(ctinfo)])) {
360 WRITE_UNLOCK(&sctp_lock); 359 write_unlock_bh(&sctp_lock);
361 return -1; 360 return -1;
362 } 361 }
363 } else if (sch->type == SCTP_CID_SHUTDOWN_COMPLETE) { 362 } else if (sch->type == SCTP_CID_SHUTDOWN_COMPLETE) {
@@ -366,13 +365,13 @@ static int sctp_packet(struct ip_conntrack *conntrack,
366 && !(sh->vtag == conntrack->proto.sctp.vtag 365 && !(sh->vtag == conntrack->proto.sctp.vtag
367 [1 - CTINFO2DIR(ctinfo)] 366 [1 - CTINFO2DIR(ctinfo)]
368 && (sch->flags & 1))) { 367 && (sch->flags & 1))) {
369 WRITE_UNLOCK(&sctp_lock); 368 write_unlock_bh(&sctp_lock);
370 return -1; 369 return -1;
371 } 370 }
372 } else if (sch->type == SCTP_CID_COOKIE_ECHO) { 371 } else if (sch->type == SCTP_CID_COOKIE_ECHO) {
373 /* Sec 8.5.1 (D) */ 372 /* Sec 8.5.1 (D) */
374 if (!(sh->vtag == conntrack->proto.sctp.vtag[CTINFO2DIR(ctinfo)])) { 373 if (!(sh->vtag == conntrack->proto.sctp.vtag[CTINFO2DIR(ctinfo)])) {
375 WRITE_UNLOCK(&sctp_lock); 374 write_unlock_bh(&sctp_lock);
376 return -1; 375 return -1;
377 } 376 }
378 } 377 }
@@ -384,7 +383,7 @@ static int sctp_packet(struct ip_conntrack *conntrack,
384 if (newconntrack == SCTP_CONNTRACK_MAX) { 383 if (newconntrack == SCTP_CONNTRACK_MAX) {
385 DEBUGP("ip_conntrack_sctp: Invalid dir=%i ctype=%u conntrack=%u\n", 384 DEBUGP("ip_conntrack_sctp: Invalid dir=%i ctype=%u conntrack=%u\n",
386 CTINFO2DIR(ctinfo), sch->type, oldsctpstate); 385 CTINFO2DIR(ctinfo), sch->type, oldsctpstate);
387 WRITE_UNLOCK(&sctp_lock); 386 write_unlock_bh(&sctp_lock);
388 return -1; 387 return -1;
389 } 388 }
390 389
@@ -396,7 +395,7 @@ static int sctp_packet(struct ip_conntrack *conntrack,
396 ih = skb_header_pointer(skb, offset + sizeof(sctp_chunkhdr_t), 395 ih = skb_header_pointer(skb, offset + sizeof(sctp_chunkhdr_t),
397 sizeof(_inithdr), &_inithdr); 396 sizeof(_inithdr), &_inithdr);
398 if (ih == NULL) { 397 if (ih == NULL) {
399 WRITE_UNLOCK(&sctp_lock); 398 write_unlock_bh(&sctp_lock);
400 return -1; 399 return -1;
401 } 400 }
402 DEBUGP("Setting vtag %x for dir %d\n", 401 DEBUGP("Setting vtag %x for dir %d\n",
@@ -405,7 +404,7 @@ static int sctp_packet(struct ip_conntrack *conntrack,
405 } 404 }
406 405
407 conntrack->proto.sctp.state = newconntrack; 406 conntrack->proto.sctp.state = newconntrack;
408 WRITE_UNLOCK(&sctp_lock); 407 write_unlock_bh(&sctp_lock);
409 } 408 }
410 409
411 ip_ct_refresh_acct(conntrack, ctinfo, skb, *sctp_timeouts[newconntrack]); 410 ip_ct_refresh_acct(conntrack, ctinfo, skb, *sctp_timeouts[newconntrack]);
diff --git a/net/ipv4/netfilter/ip_conntrack_proto_tcp.c b/net/ipv4/netfilter/ip_conntrack_proto_tcp.c
index 721ddbf522b4..809dfed766d4 100644
--- a/net/ipv4/netfilter/ip_conntrack_proto_tcp.c
+++ b/net/ipv4/netfilter/ip_conntrack_proto_tcp.c
@@ -36,7 +36,6 @@
36#include <linux/netfilter_ipv4.h> 36#include <linux/netfilter_ipv4.h>
37#include <linux/netfilter_ipv4/ip_conntrack.h> 37#include <linux/netfilter_ipv4/ip_conntrack.h>
38#include <linux/netfilter_ipv4/ip_conntrack_protocol.h> 38#include <linux/netfilter_ipv4/ip_conntrack_protocol.h>
39#include <linux/netfilter_ipv4/lockhelp.h>
40 39
41#if 0 40#if 0
42#define DEBUGP printk 41#define DEBUGP printk
@@ -46,7 +45,7 @@
46#endif 45#endif
47 46
48/* Protects conntrack->proto.tcp */ 47/* Protects conntrack->proto.tcp */
49static DECLARE_RWLOCK(tcp_lock); 48static DEFINE_RWLOCK(tcp_lock);
50 49
51/* "Be conservative in what you do, 50/* "Be conservative in what you do,
52 be liberal in what you accept from others." 51 be liberal in what you accept from others."
@@ -330,9 +329,9 @@ static int tcp_print_conntrack(struct seq_file *s,
330{ 329{
331 enum tcp_conntrack state; 330 enum tcp_conntrack state;
332 331
333 READ_LOCK(&tcp_lock); 332 read_lock_bh(&tcp_lock);
334 state = conntrack->proto.tcp.state; 333 state = conntrack->proto.tcp.state;
335 READ_UNLOCK(&tcp_lock); 334 read_unlock_bh(&tcp_lock);
336 335
337 return seq_printf(s, "%s ", tcp_conntrack_names[state]); 336 return seq_printf(s, "%s ", tcp_conntrack_names[state]);
338} 337}
@@ -738,14 +737,14 @@ void ip_conntrack_tcp_update(struct sk_buff *skb,
738 737
739 end = segment_seq_plus_len(ntohl(tcph->seq), skb->len, iph, tcph); 738 end = segment_seq_plus_len(ntohl(tcph->seq), skb->len, iph, tcph);
740 739
741 WRITE_LOCK(&tcp_lock); 740 write_lock_bh(&tcp_lock);
742 /* 741 /*
743 * We have to worry for the ack in the reply packet only... 742 * We have to worry for the ack in the reply packet only...
744 */ 743 */
745 if (after(end, conntrack->proto.tcp.seen[dir].td_end)) 744 if (after(end, conntrack->proto.tcp.seen[dir].td_end))
746 conntrack->proto.tcp.seen[dir].td_end = end; 745 conntrack->proto.tcp.seen[dir].td_end = end;
747 conntrack->proto.tcp.last_end = end; 746 conntrack->proto.tcp.last_end = end;
748 WRITE_UNLOCK(&tcp_lock); 747 write_unlock_bh(&tcp_lock);
749 DEBUGP("tcp_update: sender end=%u maxend=%u maxwin=%u scale=%i " 748 DEBUGP("tcp_update: sender end=%u maxend=%u maxwin=%u scale=%i "
750 "receiver end=%u maxend=%u maxwin=%u scale=%i\n", 749 "receiver end=%u maxend=%u maxwin=%u scale=%i\n",
751 sender->td_end, sender->td_maxend, sender->td_maxwin, 750 sender->td_end, sender->td_maxend, sender->td_maxwin,
@@ -857,7 +856,7 @@ static int tcp_packet(struct ip_conntrack *conntrack,
857 sizeof(_tcph), &_tcph); 856 sizeof(_tcph), &_tcph);
858 BUG_ON(th == NULL); 857 BUG_ON(th == NULL);
859 858
860 WRITE_LOCK(&tcp_lock); 859 write_lock_bh(&tcp_lock);
861 old_state = conntrack->proto.tcp.state; 860 old_state = conntrack->proto.tcp.state;
862 dir = CTINFO2DIR(ctinfo); 861 dir = CTINFO2DIR(ctinfo);
863 index = get_conntrack_index(th); 862 index = get_conntrack_index(th);
@@ -879,7 +878,7 @@ static int tcp_packet(struct ip_conntrack *conntrack,
879 * that the client cannot but retransmit its SYN and 878 * that the client cannot but retransmit its SYN and
880 * thus initiate a clean new session. 879 * thus initiate a clean new session.
881 */ 880 */
882 WRITE_UNLOCK(&tcp_lock); 881 write_unlock_bh(&tcp_lock);
883 if (LOG_INVALID(IPPROTO_TCP)) 882 if (LOG_INVALID(IPPROTO_TCP))
884 nf_log_packet(PF_INET, 0, skb, NULL, NULL, 883 nf_log_packet(PF_INET, 0, skb, NULL, NULL,
885 "ip_ct_tcp: killing out of sync session "); 884 "ip_ct_tcp: killing out of sync session ");
@@ -894,7 +893,7 @@ static int tcp_packet(struct ip_conntrack *conntrack,
894 conntrack->proto.tcp.last_end = 893 conntrack->proto.tcp.last_end =
895 segment_seq_plus_len(ntohl(th->seq), skb->len, iph, th); 894 segment_seq_plus_len(ntohl(th->seq), skb->len, iph, th);
896 895
897 WRITE_UNLOCK(&tcp_lock); 896 write_unlock_bh(&tcp_lock);
898 if (LOG_INVALID(IPPROTO_TCP)) 897 if (LOG_INVALID(IPPROTO_TCP))
899 nf_log_packet(PF_INET, 0, skb, NULL, NULL, 898 nf_log_packet(PF_INET, 0, skb, NULL, NULL,
900 "ip_ct_tcp: invalid packet ignored "); 899 "ip_ct_tcp: invalid packet ignored ");
@@ -904,7 +903,7 @@ static int tcp_packet(struct ip_conntrack *conntrack,
904 DEBUGP("ip_ct_tcp: Invalid dir=%i index=%u ostate=%u\n", 903 DEBUGP("ip_ct_tcp: Invalid dir=%i index=%u ostate=%u\n",
905 dir, get_conntrack_index(th), 904 dir, get_conntrack_index(th),
906 old_state); 905 old_state);
907 WRITE_UNLOCK(&tcp_lock); 906 write_unlock_bh(&tcp_lock);
908 if (LOG_INVALID(IPPROTO_TCP)) 907 if (LOG_INVALID(IPPROTO_TCP))
909 nf_log_packet(PF_INET, 0, skb, NULL, NULL, 908 nf_log_packet(PF_INET, 0, skb, NULL, NULL,
910 "ip_ct_tcp: invalid state "); 909 "ip_ct_tcp: invalid state ");
@@ -918,13 +917,13 @@ static int tcp_packet(struct ip_conntrack *conntrack,
918 conntrack->proto.tcp.seen[dir].td_end)) { 917 conntrack->proto.tcp.seen[dir].td_end)) {
919 /* Attempt to reopen a closed connection. 918 /* Attempt to reopen a closed connection.
920 * Delete this connection and look up again. */ 919 * Delete this connection and look up again. */
921 WRITE_UNLOCK(&tcp_lock); 920 write_unlock_bh(&tcp_lock);
922 if (del_timer(&conntrack->timeout)) 921 if (del_timer(&conntrack->timeout))
923 conntrack->timeout.function((unsigned long) 922 conntrack->timeout.function((unsigned long)
924 conntrack); 923 conntrack);
925 return -NF_REPEAT; 924 return -NF_REPEAT;
926 } else { 925 } else {
927 WRITE_UNLOCK(&tcp_lock); 926 write_unlock_bh(&tcp_lock);
928 if (LOG_INVALID(IPPROTO_TCP)) 927 if (LOG_INVALID(IPPROTO_TCP))
929 nf_log_packet(PF_INET, 0, skb, NULL, NULL, 928 nf_log_packet(PF_INET, 0, skb, NULL, NULL,
930 "ip_ct_tcp: invalid SYN"); 929 "ip_ct_tcp: invalid SYN");
@@ -949,7 +948,7 @@ static int tcp_packet(struct ip_conntrack *conntrack,
949 948
950 if (!tcp_in_window(&conntrack->proto.tcp, dir, index, 949 if (!tcp_in_window(&conntrack->proto.tcp, dir, index,
951 skb, iph, th)) { 950 skb, iph, th)) {
952 WRITE_UNLOCK(&tcp_lock); 951 write_unlock_bh(&tcp_lock);
953 return -NF_ACCEPT; 952 return -NF_ACCEPT;
954 } 953 }
955 in_window: 954 in_window:
@@ -972,7 +971,7 @@ static int tcp_packet(struct ip_conntrack *conntrack,
972 timeout = conntrack->proto.tcp.retrans >= ip_ct_tcp_max_retrans 971 timeout = conntrack->proto.tcp.retrans >= ip_ct_tcp_max_retrans
973 && *tcp_timeouts[new_state] > ip_ct_tcp_timeout_max_retrans 972 && *tcp_timeouts[new_state] > ip_ct_tcp_timeout_max_retrans
974 ? ip_ct_tcp_timeout_max_retrans : *tcp_timeouts[new_state]; 973 ? ip_ct_tcp_timeout_max_retrans : *tcp_timeouts[new_state];
975 WRITE_UNLOCK(&tcp_lock); 974 write_unlock_bh(&tcp_lock);
976 975
977 if (!test_bit(IPS_SEEN_REPLY_BIT, &conntrack->status)) { 976 if (!test_bit(IPS_SEEN_REPLY_BIT, &conntrack->status)) {
978 /* If only reply is a RST, we can consider ourselves not to 977 /* If only reply is a RST, we can consider ourselves not to
diff --git a/net/ipv4/netfilter/ip_conntrack_proto_udp.c b/net/ipv4/netfilter/ip_conntrack_proto_udp.c
index 5bc28a224623..8c1eaba098d4 100644
--- a/net/ipv4/netfilter/ip_conntrack_proto_udp.c
+++ b/net/ipv4/netfilter/ip_conntrack_proto_udp.c
@@ -120,6 +120,7 @@ static int udp_error(struct sk_buff *skb, enum ip_conntrack_info *ctinfo,
120 * and moreover root might send raw packets. 120 * and moreover root might send raw packets.
121 * FIXME: Source route IP option packets --RR */ 121 * FIXME: Source route IP option packets --RR */
122 if (hooknum == NF_IP_PRE_ROUTING 122 if (hooknum == NF_IP_PRE_ROUTING
123 && skb->ip_summed != CHECKSUM_UNNECESSARY
123 && csum_tcpudp_magic(iph->saddr, iph->daddr, udplen, IPPROTO_UDP, 124 && csum_tcpudp_magic(iph->saddr, iph->daddr, udplen, IPPROTO_UDP,
124 skb->ip_summed == CHECKSUM_HW ? skb->csum 125 skb->ip_summed == CHECKSUM_HW ? skb->csum
125 : skb_checksum(skb, iph->ihl*4, udplen, 0))) { 126 : skb_checksum(skb, iph->ihl*4, udplen, 0))) {
diff --git a/net/ipv4/netfilter/ip_conntrack_standalone.c b/net/ipv4/netfilter/ip_conntrack_standalone.c
index bc59f7b39805..42dc95102873 100644
--- a/net/ipv4/netfilter/ip_conntrack_standalone.c
+++ b/net/ipv4/netfilter/ip_conntrack_standalone.c
@@ -28,8 +28,8 @@
28#include <net/checksum.h> 28#include <net/checksum.h>
29#include <net/ip.h> 29#include <net/ip.h>
30 30
31#define ASSERT_READ_LOCK(x) MUST_BE_READ_LOCKED(&ip_conntrack_lock) 31#define ASSERT_READ_LOCK(x)
32#define ASSERT_WRITE_LOCK(x) MUST_BE_WRITE_LOCKED(&ip_conntrack_lock) 32#define ASSERT_WRITE_LOCK(x)
33 33
34#include <linux/netfilter_ipv4/ip_conntrack.h> 34#include <linux/netfilter_ipv4/ip_conntrack.h>
35#include <linux/netfilter_ipv4/ip_conntrack_protocol.h> 35#include <linux/netfilter_ipv4/ip_conntrack_protocol.h>
@@ -119,7 +119,7 @@ static struct list_head *ct_get_idx(struct seq_file *seq, loff_t pos)
119 119
120static void *ct_seq_start(struct seq_file *seq, loff_t *pos) 120static void *ct_seq_start(struct seq_file *seq, loff_t *pos)
121{ 121{
122 READ_LOCK(&ip_conntrack_lock); 122 read_lock_bh(&ip_conntrack_lock);
123 return ct_get_idx(seq, *pos); 123 return ct_get_idx(seq, *pos);
124} 124}
125 125
@@ -131,7 +131,7 @@ static void *ct_seq_next(struct seq_file *s, void *v, loff_t *pos)
131 131
132static void ct_seq_stop(struct seq_file *s, void *v) 132static void ct_seq_stop(struct seq_file *s, void *v)
133{ 133{
134 READ_UNLOCK(&ip_conntrack_lock); 134 read_unlock_bh(&ip_conntrack_lock);
135} 135}
136 136
137static int ct_seq_show(struct seq_file *s, void *v) 137static int ct_seq_show(struct seq_file *s, void *v)
@@ -140,7 +140,7 @@ static int ct_seq_show(struct seq_file *s, void *v)
140 const struct ip_conntrack *conntrack = tuplehash_to_ctrack(hash); 140 const struct ip_conntrack *conntrack = tuplehash_to_ctrack(hash);
141 struct ip_conntrack_protocol *proto; 141 struct ip_conntrack_protocol *proto;
142 142
143 MUST_BE_READ_LOCKED(&ip_conntrack_lock); 143 ASSERT_READ_LOCK(&ip_conntrack_lock);
144 IP_NF_ASSERT(conntrack); 144 IP_NF_ASSERT(conntrack);
145 145
146 /* we only want to print DIR_ORIGINAL */ 146 /* we only want to print DIR_ORIGINAL */
@@ -239,7 +239,7 @@ static void *exp_seq_start(struct seq_file *s, loff_t *pos)
239 239
240 /* strange seq_file api calls stop even if we fail, 240 /* strange seq_file api calls stop even if we fail,
241 * thus we need to grab lock since stop unlocks */ 241 * thus we need to grab lock since stop unlocks */
242 READ_LOCK(&ip_conntrack_lock); 242 read_lock_bh(&ip_conntrack_lock);
243 243
244 if (list_empty(e)) 244 if (list_empty(e))
245 return NULL; 245 return NULL;
@@ -267,7 +267,7 @@ static void *exp_seq_next(struct seq_file *s, void *v, loff_t *pos)
267 267
268static void exp_seq_stop(struct seq_file *s, void *v) 268static void exp_seq_stop(struct seq_file *s, void *v)
269{ 269{
270 READ_UNLOCK(&ip_conntrack_lock); 270 read_unlock_bh(&ip_conntrack_lock);
271} 271}
272 272
273static int exp_seq_show(struct seq_file *s, void *v) 273static int exp_seq_show(struct seq_file *s, void *v)
@@ -921,22 +921,22 @@ int ip_conntrack_protocol_register(struct ip_conntrack_protocol *proto)
921{ 921{
922 int ret = 0; 922 int ret = 0;
923 923
924 WRITE_LOCK(&ip_conntrack_lock); 924 write_lock_bh(&ip_conntrack_lock);
925 if (ip_ct_protos[proto->proto] != &ip_conntrack_generic_protocol) { 925 if (ip_ct_protos[proto->proto] != &ip_conntrack_generic_protocol) {
926 ret = -EBUSY; 926 ret = -EBUSY;
927 goto out; 927 goto out;
928 } 928 }
929 ip_ct_protos[proto->proto] = proto; 929 ip_ct_protos[proto->proto] = proto;
930 out: 930 out:
931 WRITE_UNLOCK(&ip_conntrack_lock); 931 write_unlock_bh(&ip_conntrack_lock);
932 return ret; 932 return ret;
933} 933}
934 934
935void ip_conntrack_protocol_unregister(struct ip_conntrack_protocol *proto) 935void ip_conntrack_protocol_unregister(struct ip_conntrack_protocol *proto)
936{ 936{
937 WRITE_LOCK(&ip_conntrack_lock); 937 write_lock_bh(&ip_conntrack_lock);
938 ip_ct_protos[proto->proto] = &ip_conntrack_generic_protocol; 938 ip_ct_protos[proto->proto] = &ip_conntrack_generic_protocol;
939 WRITE_UNLOCK(&ip_conntrack_lock); 939 write_unlock_bh(&ip_conntrack_lock);
940 940
941 /* Somebody could be still looking at the proto in bh. */ 941 /* Somebody could be still looking at the proto in bh. */
942 synchronize_net(); 942 synchronize_net();
diff --git a/net/ipv4/netfilter/ip_nat_core.c b/net/ipv4/netfilter/ip_nat_core.c
index 9fc6f93af0dd..739b6dde1c82 100644
--- a/net/ipv4/netfilter/ip_nat_core.c
+++ b/net/ipv4/netfilter/ip_nat_core.c
@@ -22,8 +22,8 @@
22#include <linux/udp.h> 22#include <linux/udp.h>
23#include <linux/jhash.h> 23#include <linux/jhash.h>
24 24
25#define ASSERT_READ_LOCK(x) MUST_BE_READ_LOCKED(&ip_nat_lock) 25#define ASSERT_READ_LOCK(x)
26#define ASSERT_WRITE_LOCK(x) MUST_BE_WRITE_LOCKED(&ip_nat_lock) 26#define ASSERT_WRITE_LOCK(x)
27 27
28#include <linux/netfilter_ipv4/ip_conntrack.h> 28#include <linux/netfilter_ipv4/ip_conntrack.h>
29#include <linux/netfilter_ipv4/ip_conntrack_core.h> 29#include <linux/netfilter_ipv4/ip_conntrack_core.h>
@@ -41,7 +41,7 @@
41#define DEBUGP(format, args...) 41#define DEBUGP(format, args...)
42#endif 42#endif
43 43
44DECLARE_RWLOCK(ip_nat_lock); 44DEFINE_RWLOCK(ip_nat_lock);
45 45
46/* Calculated at init based on memory size */ 46/* Calculated at init based on memory size */
47static unsigned int ip_nat_htable_size; 47static unsigned int ip_nat_htable_size;
@@ -65,9 +65,9 @@ static void ip_nat_cleanup_conntrack(struct ip_conntrack *conn)
65 if (!(conn->status & IPS_NAT_DONE_MASK)) 65 if (!(conn->status & IPS_NAT_DONE_MASK))
66 return; 66 return;
67 67
68 WRITE_LOCK(&ip_nat_lock); 68 write_lock_bh(&ip_nat_lock);
69 list_del(&conn->nat.info.bysource); 69 list_del(&conn->nat.info.bysource);
70 WRITE_UNLOCK(&ip_nat_lock); 70 write_unlock_bh(&ip_nat_lock);
71} 71}
72 72
73/* We do checksum mangling, so if they were wrong before they're still 73/* We do checksum mangling, so if they were wrong before they're still
@@ -142,7 +142,7 @@ find_appropriate_src(const struct ip_conntrack_tuple *tuple,
142 unsigned int h = hash_by_src(tuple); 142 unsigned int h = hash_by_src(tuple);
143 struct ip_conntrack *ct; 143 struct ip_conntrack *ct;
144 144
145 READ_LOCK(&ip_nat_lock); 145 read_lock_bh(&ip_nat_lock);
146 list_for_each_entry(ct, &bysource[h], nat.info.bysource) { 146 list_for_each_entry(ct, &bysource[h], nat.info.bysource) {
147 if (same_src(ct, tuple)) { 147 if (same_src(ct, tuple)) {
148 /* Copy source part from reply tuple. */ 148 /* Copy source part from reply tuple. */
@@ -151,12 +151,12 @@ find_appropriate_src(const struct ip_conntrack_tuple *tuple,
151 result->dst = tuple->dst; 151 result->dst = tuple->dst;
152 152
153 if (in_range(result, range)) { 153 if (in_range(result, range)) {
154 READ_UNLOCK(&ip_nat_lock); 154 read_unlock_bh(&ip_nat_lock);
155 return 1; 155 return 1;
156 } 156 }
157 } 157 }
158 } 158 }
159 READ_UNLOCK(&ip_nat_lock); 159 read_unlock_bh(&ip_nat_lock);
160 return 0; 160 return 0;
161} 161}
162 162
@@ -297,9 +297,9 @@ ip_nat_setup_info(struct ip_conntrack *conntrack,
297 unsigned int srchash 297 unsigned int srchash
298 = hash_by_src(&conntrack->tuplehash[IP_CT_DIR_ORIGINAL] 298 = hash_by_src(&conntrack->tuplehash[IP_CT_DIR_ORIGINAL]
299 .tuple); 299 .tuple);
300 WRITE_LOCK(&ip_nat_lock); 300 write_lock_bh(&ip_nat_lock);
301 list_add(&info->bysource, &bysource[srchash]); 301 list_add(&info->bysource, &bysource[srchash]);
302 WRITE_UNLOCK(&ip_nat_lock); 302 write_unlock_bh(&ip_nat_lock);
303 } 303 }
304 304
305 /* It's done. */ 305 /* It's done. */
@@ -474,23 +474,23 @@ int ip_nat_protocol_register(struct ip_nat_protocol *proto)
474{ 474{
475 int ret = 0; 475 int ret = 0;
476 476
477 WRITE_LOCK(&ip_nat_lock); 477 write_lock_bh(&ip_nat_lock);
478 if (ip_nat_protos[proto->protonum] != &ip_nat_unknown_protocol) { 478 if (ip_nat_protos[proto->protonum] != &ip_nat_unknown_protocol) {
479 ret = -EBUSY; 479 ret = -EBUSY;
480 goto out; 480 goto out;
481 } 481 }
482 ip_nat_protos[proto->protonum] = proto; 482 ip_nat_protos[proto->protonum] = proto;
483 out: 483 out:
484 WRITE_UNLOCK(&ip_nat_lock); 484 write_unlock_bh(&ip_nat_lock);
485 return ret; 485 return ret;
486} 486}
487 487
488/* Noone stores the protocol anywhere; simply delete it. */ 488/* Noone stores the protocol anywhere; simply delete it. */
489void ip_nat_protocol_unregister(struct ip_nat_protocol *proto) 489void ip_nat_protocol_unregister(struct ip_nat_protocol *proto)
490{ 490{
491 WRITE_LOCK(&ip_nat_lock); 491 write_lock_bh(&ip_nat_lock);
492 ip_nat_protos[proto->protonum] = &ip_nat_unknown_protocol; 492 ip_nat_protos[proto->protonum] = &ip_nat_unknown_protocol;
493 WRITE_UNLOCK(&ip_nat_lock); 493 write_unlock_bh(&ip_nat_lock);
494 494
495 /* Someone could be still looking at the proto in a bh. */ 495 /* Someone could be still looking at the proto in a bh. */
496 synchronize_net(); 496 synchronize_net();
@@ -509,13 +509,13 @@ int __init ip_nat_init(void)
509 return -ENOMEM; 509 return -ENOMEM;
510 510
511 /* Sew in builtin protocols. */ 511 /* Sew in builtin protocols. */
512 WRITE_LOCK(&ip_nat_lock); 512 write_lock_bh(&ip_nat_lock);
513 for (i = 0; i < MAX_IP_NAT_PROTO; i++) 513 for (i = 0; i < MAX_IP_NAT_PROTO; i++)
514 ip_nat_protos[i] = &ip_nat_unknown_protocol; 514 ip_nat_protos[i] = &ip_nat_unknown_protocol;
515 ip_nat_protos[IPPROTO_TCP] = &ip_nat_protocol_tcp; 515 ip_nat_protos[IPPROTO_TCP] = &ip_nat_protocol_tcp;
516 ip_nat_protos[IPPROTO_UDP] = &ip_nat_protocol_udp; 516 ip_nat_protos[IPPROTO_UDP] = &ip_nat_protocol_udp;
517 ip_nat_protos[IPPROTO_ICMP] = &ip_nat_protocol_icmp; 517 ip_nat_protos[IPPROTO_ICMP] = &ip_nat_protocol_icmp;
518 WRITE_UNLOCK(&ip_nat_lock); 518 write_unlock_bh(&ip_nat_lock);
519 519
520 for (i = 0; i < ip_nat_htable_size; i++) { 520 for (i = 0; i < ip_nat_htable_size; i++) {
521 INIT_LIST_HEAD(&bysource[i]); 521 INIT_LIST_HEAD(&bysource[i]);
diff --git a/net/ipv4/netfilter/ip_nat_helper.c b/net/ipv4/netfilter/ip_nat_helper.c
index 1637b96d8c01..158f34f32c04 100644
--- a/net/ipv4/netfilter/ip_nat_helper.c
+++ b/net/ipv4/netfilter/ip_nat_helper.c
@@ -28,8 +28,8 @@
28#include <net/tcp.h> 28#include <net/tcp.h>
29#include <net/udp.h> 29#include <net/udp.h>
30 30
31#define ASSERT_READ_LOCK(x) MUST_BE_READ_LOCKED(&ip_nat_lock) 31#define ASSERT_READ_LOCK(x)
32#define ASSERT_WRITE_LOCK(x) MUST_BE_WRITE_LOCKED(&ip_nat_lock) 32#define ASSERT_WRITE_LOCK(x)
33 33
34#include <linux/netfilter_ipv4/ip_conntrack.h> 34#include <linux/netfilter_ipv4/ip_conntrack.h>
35#include <linux/netfilter_ipv4/ip_conntrack_helper.h> 35#include <linux/netfilter_ipv4/ip_conntrack_helper.h>
@@ -47,7 +47,7 @@
47#define DUMP_OFFSET(x) 47#define DUMP_OFFSET(x)
48#endif 48#endif
49 49
50static DECLARE_LOCK(ip_nat_seqofs_lock); 50static DEFINE_SPINLOCK(ip_nat_seqofs_lock);
51 51
52/* Setup TCP sequence correction given this change at this sequence */ 52/* Setup TCP sequence correction given this change at this sequence */
53static inline void 53static inline void
@@ -70,7 +70,7 @@ adjust_tcp_sequence(u32 seq,
70 DEBUGP("ip_nat_resize_packet: Seq_offset before: "); 70 DEBUGP("ip_nat_resize_packet: Seq_offset before: ");
71 DUMP_OFFSET(this_way); 71 DUMP_OFFSET(this_way);
72 72
73 LOCK_BH(&ip_nat_seqofs_lock); 73 spin_lock_bh(&ip_nat_seqofs_lock);
74 74
75 /* SYN adjust. If it's uninitialized, or this is after last 75 /* SYN adjust. If it's uninitialized, or this is after last
76 * correction, record it: we don't handle more than one 76 * correction, record it: we don't handle more than one
@@ -82,7 +82,7 @@ adjust_tcp_sequence(u32 seq,
82 this_way->offset_before = this_way->offset_after; 82 this_way->offset_before = this_way->offset_after;
83 this_way->offset_after += sizediff; 83 this_way->offset_after += sizediff;
84 } 84 }
85 UNLOCK_BH(&ip_nat_seqofs_lock); 85 spin_unlock_bh(&ip_nat_seqofs_lock);
86 86
87 DEBUGP("ip_nat_resize_packet: Seq_offset after: "); 87 DEBUGP("ip_nat_resize_packet: Seq_offset after: ");
88 DUMP_OFFSET(this_way); 88 DUMP_OFFSET(this_way);
@@ -142,9 +142,6 @@ static int enlarge_skb(struct sk_buff **pskb, unsigned int extra)
142 /* Transfer socket to new skb. */ 142 /* Transfer socket to new skb. */
143 if ((*pskb)->sk) 143 if ((*pskb)->sk)
144 skb_set_owner_w(nskb, (*pskb)->sk); 144 skb_set_owner_w(nskb, (*pskb)->sk);
145#ifdef CONFIG_NETFILTER_DEBUG
146 nskb->nf_debug = (*pskb)->nf_debug;
147#endif
148 kfree_skb(*pskb); 145 kfree_skb(*pskb);
149 *pskb = nskb; 146 *pskb = nskb;
150 return 1; 147 return 1;
diff --git a/net/ipv4/netfilter/ip_nat_rule.c b/net/ipv4/netfilter/ip_nat_rule.c
index 581f097f5a24..60d70fa41a15 100644
--- a/net/ipv4/netfilter/ip_nat_rule.c
+++ b/net/ipv4/netfilter/ip_nat_rule.c
@@ -19,8 +19,8 @@
19#include <net/route.h> 19#include <net/route.h>
20#include <linux/bitops.h> 20#include <linux/bitops.h>
21 21
22#define ASSERT_READ_LOCK(x) MUST_BE_READ_LOCKED(&ip_nat_lock) 22#define ASSERT_READ_LOCK(x)
23#define ASSERT_WRITE_LOCK(x) MUST_BE_WRITE_LOCKED(&ip_nat_lock) 23#define ASSERT_WRITE_LOCK(x)
24 24
25#include <linux/netfilter_ipv4/ip_tables.h> 25#include <linux/netfilter_ipv4/ip_tables.h>
26#include <linux/netfilter_ipv4/ip_nat.h> 26#include <linux/netfilter_ipv4/ip_nat.h>
diff --git a/net/ipv4/netfilter/ip_nat_standalone.c b/net/ipv4/netfilter/ip_nat_standalone.c
index 79f56f662b33..bc59d0d6e89e 100644
--- a/net/ipv4/netfilter/ip_nat_standalone.c
+++ b/net/ipv4/netfilter/ip_nat_standalone.c
@@ -31,8 +31,8 @@
31#include <net/checksum.h> 31#include <net/checksum.h>
32#include <linux/spinlock.h> 32#include <linux/spinlock.h>
33 33
34#define ASSERT_READ_LOCK(x) MUST_BE_READ_LOCKED(&ip_nat_lock) 34#define ASSERT_READ_LOCK(x)
35#define ASSERT_WRITE_LOCK(x) MUST_BE_WRITE_LOCKED(&ip_nat_lock) 35#define ASSERT_WRITE_LOCK(x)
36 36
37#include <linux/netfilter_ipv4/ip_nat.h> 37#include <linux/netfilter_ipv4/ip_nat.h>
38#include <linux/netfilter_ipv4/ip_nat_rule.h> 38#include <linux/netfilter_ipv4/ip_nat_rule.h>
@@ -373,7 +373,6 @@ static int init_or_cleanup(int init)
373 cleanup_rule_init: 373 cleanup_rule_init:
374 ip_nat_rule_cleanup(); 374 ip_nat_rule_cleanup();
375 cleanup_nothing: 375 cleanup_nothing:
376 MUST_BE_READ_WRITE_UNLOCKED(&ip_nat_lock);
377 return ret; 376 return ret;
378} 377}
379 378
diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
index 8a54f92b8496..c88dfcd38c56 100644
--- a/net/ipv4/netfilter/ip_tables.c
+++ b/net/ipv4/netfilter/ip_tables.c
@@ -67,7 +67,6 @@ static DECLARE_MUTEX(ipt_mutex);
67/* Must have mutex */ 67/* Must have mutex */
68#define ASSERT_READ_LOCK(x) IP_NF_ASSERT(down_trylock(&ipt_mutex) != 0) 68#define ASSERT_READ_LOCK(x) IP_NF_ASSERT(down_trylock(&ipt_mutex) != 0)
69#define ASSERT_WRITE_LOCK(x) IP_NF_ASSERT(down_trylock(&ipt_mutex) != 0) 69#define ASSERT_WRITE_LOCK(x) IP_NF_ASSERT(down_trylock(&ipt_mutex) != 0)
70#include <linux/netfilter_ipv4/lockhelp.h>
71#include <linux/netfilter_ipv4/listhelp.h> 70#include <linux/netfilter_ipv4/listhelp.h>
72 71
73#if 0 72#if 0
diff --git a/net/ipv4/netfilter/ipt_CLUSTERIP.c b/net/ipv4/netfilter/ipt_CLUSTERIP.c
index 0f12e3a3dc73..dc4362b57cfa 100644
--- a/net/ipv4/netfilter/ipt_CLUSTERIP.c
+++ b/net/ipv4/netfilter/ipt_CLUSTERIP.c
@@ -29,7 +29,6 @@
29#include <linux/netfilter_ipv4/ip_tables.h> 29#include <linux/netfilter_ipv4/ip_tables.h>
30#include <linux/netfilter_ipv4/ipt_CLUSTERIP.h> 30#include <linux/netfilter_ipv4/ipt_CLUSTERIP.h>
31#include <linux/netfilter_ipv4/ip_conntrack.h> 31#include <linux/netfilter_ipv4/ip_conntrack.h>
32#include <linux/netfilter_ipv4/lockhelp.h>
33 32
34#define CLUSTERIP_VERSION "0.6" 33#define CLUSTERIP_VERSION "0.6"
35 34
@@ -41,6 +40,8 @@
41#define DEBUGP 40#define DEBUGP
42#endif 41#endif
43 42
43#define ASSERT_READ_LOCK(x)
44
44MODULE_LICENSE("GPL"); 45MODULE_LICENSE("GPL");
45MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>"); 46MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
46MODULE_DESCRIPTION("iptables target for CLUSTERIP"); 47MODULE_DESCRIPTION("iptables target for CLUSTERIP");
@@ -67,7 +68,7 @@ static LIST_HEAD(clusterip_configs);
67 68
68/* clusterip_lock protects the clusterip_configs list _AND_ the configurable 69/* clusterip_lock protects the clusterip_configs list _AND_ the configurable
69 * data within all structurses (num_local_nodes, local_nodes[]) */ 70 * data within all structurses (num_local_nodes, local_nodes[]) */
70static DECLARE_RWLOCK(clusterip_lock); 71static DEFINE_RWLOCK(clusterip_lock);
71 72
72#ifdef CONFIG_PROC_FS 73#ifdef CONFIG_PROC_FS
73static struct file_operations clusterip_proc_fops; 74static struct file_operations clusterip_proc_fops;
@@ -82,9 +83,9 @@ clusterip_config_get(struct clusterip_config *c) {
82static inline void 83static inline void
83clusterip_config_put(struct clusterip_config *c) { 84clusterip_config_put(struct clusterip_config *c) {
84 if (atomic_dec_and_test(&c->refcount)) { 85 if (atomic_dec_and_test(&c->refcount)) {
85 WRITE_LOCK(&clusterip_lock); 86 write_lock_bh(&clusterip_lock);
86 list_del(&c->list); 87 list_del(&c->list);
87 WRITE_UNLOCK(&clusterip_lock); 88 write_unlock_bh(&clusterip_lock);
88 dev_mc_delete(c->dev, c->clustermac, ETH_ALEN, 0); 89 dev_mc_delete(c->dev, c->clustermac, ETH_ALEN, 0);
89 dev_put(c->dev); 90 dev_put(c->dev);
90 kfree(c); 91 kfree(c);
@@ -97,7 +98,7 @@ __clusterip_config_find(u_int32_t clusterip)
97{ 98{
98 struct list_head *pos; 99 struct list_head *pos;
99 100
100 MUST_BE_READ_LOCKED(&clusterip_lock); 101 ASSERT_READ_LOCK(&clusterip_lock);
101 list_for_each(pos, &clusterip_configs) { 102 list_for_each(pos, &clusterip_configs) {
102 struct clusterip_config *c = list_entry(pos, 103 struct clusterip_config *c = list_entry(pos,
103 struct clusterip_config, list); 104 struct clusterip_config, list);
@@ -114,14 +115,14 @@ clusterip_config_find_get(u_int32_t clusterip)
114{ 115{
115 struct clusterip_config *c; 116 struct clusterip_config *c;
116 117
117 READ_LOCK(&clusterip_lock); 118 read_lock_bh(&clusterip_lock);
118 c = __clusterip_config_find(clusterip); 119 c = __clusterip_config_find(clusterip);
119 if (!c) { 120 if (!c) {
120 READ_UNLOCK(&clusterip_lock); 121 read_unlock_bh(&clusterip_lock);
121 return NULL; 122 return NULL;
122 } 123 }
123 atomic_inc(&c->refcount); 124 atomic_inc(&c->refcount);
124 READ_UNLOCK(&clusterip_lock); 125 read_unlock_bh(&clusterip_lock);
125 126
126 return c; 127 return c;
127} 128}
@@ -160,9 +161,9 @@ clusterip_config_init(struct ipt_clusterip_tgt_info *i, u_int32_t ip,
160 c->pde->data = c; 161 c->pde->data = c;
161#endif 162#endif
162 163
163 WRITE_LOCK(&clusterip_lock); 164 write_lock_bh(&clusterip_lock);
164 list_add(&c->list, &clusterip_configs); 165 list_add(&c->list, &clusterip_configs);
165 WRITE_UNLOCK(&clusterip_lock); 166 write_unlock_bh(&clusterip_lock);
166 167
167 return c; 168 return c;
168} 169}
@@ -172,25 +173,25 @@ clusterip_add_node(struct clusterip_config *c, u_int16_t nodenum)
172{ 173{
173 int i; 174 int i;
174 175
175 WRITE_LOCK(&clusterip_lock); 176 write_lock_bh(&clusterip_lock);
176 177
177 if (c->num_local_nodes >= CLUSTERIP_MAX_NODES 178 if (c->num_local_nodes >= CLUSTERIP_MAX_NODES
178 || nodenum > CLUSTERIP_MAX_NODES) { 179 || nodenum > CLUSTERIP_MAX_NODES) {
179 WRITE_UNLOCK(&clusterip_lock); 180 write_unlock_bh(&clusterip_lock);
180 return 1; 181 return 1;
181 } 182 }
182 183
183 /* check if we alrady have this number in our array */ 184 /* check if we alrady have this number in our array */
184 for (i = 0; i < c->num_local_nodes; i++) { 185 for (i = 0; i < c->num_local_nodes; i++) {
185 if (c->local_nodes[i] == nodenum) { 186 if (c->local_nodes[i] == nodenum) {
186 WRITE_UNLOCK(&clusterip_lock); 187 write_unlock_bh(&clusterip_lock);
187 return 1; 188 return 1;
188 } 189 }
189 } 190 }
190 191
191 c->local_nodes[c->num_local_nodes++] = nodenum; 192 c->local_nodes[c->num_local_nodes++] = nodenum;
192 193
193 WRITE_UNLOCK(&clusterip_lock); 194 write_unlock_bh(&clusterip_lock);
194 return 0; 195 return 0;
195} 196}
196 197
@@ -199,10 +200,10 @@ clusterip_del_node(struct clusterip_config *c, u_int16_t nodenum)
199{ 200{
200 int i; 201 int i;
201 202
202 WRITE_LOCK(&clusterip_lock); 203 write_lock_bh(&clusterip_lock);
203 204
204 if (c->num_local_nodes <= 1 || nodenum > CLUSTERIP_MAX_NODES) { 205 if (c->num_local_nodes <= 1 || nodenum > CLUSTERIP_MAX_NODES) {
205 WRITE_UNLOCK(&clusterip_lock); 206 write_unlock_bh(&clusterip_lock);
206 return 1; 207 return 1;
207 } 208 }
208 209
@@ -211,12 +212,12 @@ clusterip_del_node(struct clusterip_config *c, u_int16_t nodenum)
211 int size = sizeof(u_int16_t)*(c->num_local_nodes-(i+1)); 212 int size = sizeof(u_int16_t)*(c->num_local_nodes-(i+1));
212 memmove(&c->local_nodes[i], &c->local_nodes[i+1], size); 213 memmove(&c->local_nodes[i], &c->local_nodes[i+1], size);
213 c->num_local_nodes--; 214 c->num_local_nodes--;
214 WRITE_UNLOCK(&clusterip_lock); 215 write_unlock_bh(&clusterip_lock);
215 return 0; 216 return 0;
216 } 217 }
217 } 218 }
218 219
219 WRITE_UNLOCK(&clusterip_lock); 220 write_unlock_bh(&clusterip_lock);
220 return 1; 221 return 1;
221} 222}
222 223
@@ -286,21 +287,21 @@ clusterip_responsible(struct clusterip_config *config, u_int32_t hash)
286{ 287{
287 int i; 288 int i;
288 289
289 READ_LOCK(&clusterip_lock); 290 read_lock_bh(&clusterip_lock);
290 291
291 if (config->num_local_nodes == 0) { 292 if (config->num_local_nodes == 0) {
292 READ_UNLOCK(&clusterip_lock); 293 read_unlock_bh(&clusterip_lock);
293 return 0; 294 return 0;
294 } 295 }
295 296
296 for (i = 0; i < config->num_local_nodes; i++) { 297 for (i = 0; i < config->num_local_nodes; i++) {
297 if (config->local_nodes[i] == hash) { 298 if (config->local_nodes[i] == hash) {
298 READ_UNLOCK(&clusterip_lock); 299 read_unlock_bh(&clusterip_lock);
299 return 1; 300 return 1;
300 } 301 }
301 } 302 }
302 303
303 READ_UNLOCK(&clusterip_lock); 304 read_unlock_bh(&clusterip_lock);
304 305
305 return 0; 306 return 0;
306} 307}
@@ -578,7 +579,7 @@ static void *clusterip_seq_start(struct seq_file *s, loff_t *pos)
578 struct clusterip_config *c = pde->data; 579 struct clusterip_config *c = pde->data;
579 unsigned int *nodeidx; 580 unsigned int *nodeidx;
580 581
581 READ_LOCK(&clusterip_lock); 582 read_lock_bh(&clusterip_lock);
582 if (*pos >= c->num_local_nodes) 583 if (*pos >= c->num_local_nodes)
583 return NULL; 584 return NULL;
584 585
@@ -608,7 +609,7 @@ static void clusterip_seq_stop(struct seq_file *s, void *v)
608{ 609{
609 kfree(v); 610 kfree(v);
610 611
611 READ_UNLOCK(&clusterip_lock); 612 read_unlock_bh(&clusterip_lock);
612} 613}
613 614
614static int clusterip_seq_show(struct seq_file *s, void *v) 615static int clusterip_seq_show(struct seq_file *s, void *v)
diff --git a/net/ipv4/netfilter/ipt_MASQUERADE.c b/net/ipv4/netfilter/ipt_MASQUERADE.c
index 57e9f6cf1c36..91e74502c3d3 100644
--- a/net/ipv4/netfilter/ipt_MASQUERADE.c
+++ b/net/ipv4/netfilter/ipt_MASQUERADE.c
@@ -33,7 +33,7 @@ MODULE_DESCRIPTION("iptables MASQUERADE target module");
33#endif 33#endif
34 34
35/* Lock protects masq region inside conntrack */ 35/* Lock protects masq region inside conntrack */
36static DECLARE_RWLOCK(masq_lock); 36static DEFINE_RWLOCK(masq_lock);
37 37
38/* FIXME: Multiple targets. --RR */ 38/* FIXME: Multiple targets. --RR */
39static int 39static int
@@ -103,9 +103,9 @@ masquerade_target(struct sk_buff **pskb,
103 return NF_DROP; 103 return NF_DROP;
104 } 104 }
105 105
106 WRITE_LOCK(&masq_lock); 106 write_lock_bh(&masq_lock);
107 ct->nat.masq_index = out->ifindex; 107 ct->nat.masq_index = out->ifindex;
108 WRITE_UNLOCK(&masq_lock); 108 write_unlock_bh(&masq_lock);
109 109
110 /* Transfer from original range. */ 110 /* Transfer from original range. */
111 newrange = ((struct ip_nat_range) 111 newrange = ((struct ip_nat_range)
@@ -122,9 +122,9 @@ device_cmp(struct ip_conntrack *i, void *ifindex)
122{ 122{
123 int ret; 123 int ret;
124 124
125 READ_LOCK(&masq_lock); 125 read_lock_bh(&masq_lock);
126 ret = (i->nat.masq_index == (int)(long)ifindex); 126 ret = (i->nat.masq_index == (int)(long)ifindex);
127 READ_UNLOCK(&masq_lock); 127 read_unlock_bh(&masq_lock);
128 128
129 return ret; 129 return ret;
130} 130}
diff --git a/net/ipv4/netfilter/ipt_REJECT.c b/net/ipv4/netfilter/ipt_REJECT.c
index 266d64979286..915696446020 100644
--- a/net/ipv4/netfilter/ipt_REJECT.c
+++ b/net/ipv4/netfilter/ipt_REJECT.c
@@ -104,10 +104,12 @@ static inline struct rtable *route_reverse(struct sk_buff *skb,
104static void send_reset(struct sk_buff *oldskb, int hook) 104static void send_reset(struct sk_buff *oldskb, int hook)
105{ 105{
106 struct sk_buff *nskb; 106 struct sk_buff *nskb;
107 struct iphdr *iph = oldskb->nh.iph;
107 struct tcphdr _otcph, *oth, *tcph; 108 struct tcphdr _otcph, *oth, *tcph;
108 struct rtable *rt; 109 struct rtable *rt;
109 u_int16_t tmp_port; 110 u_int16_t tmp_port;
110 u_int32_t tmp_addr; 111 u_int32_t tmp_addr;
112 unsigned int tcplen;
111 int needs_ack; 113 int needs_ack;
112 int hh_len; 114 int hh_len;
113 115
@@ -124,7 +126,16 @@ static void send_reset(struct sk_buff *oldskb, int hook)
124 if (oth->rst) 126 if (oth->rst)
125 return; 127 return;
126 128
127 /* FIXME: Check checksum --RR */ 129 /* Check checksum */
130 tcplen = oldskb->len - iph->ihl * 4;
131 if (((hook != NF_IP_LOCAL_IN && oldskb->ip_summed != CHECKSUM_HW) ||
132 (hook == NF_IP_LOCAL_IN &&
133 oldskb->ip_summed != CHECKSUM_UNNECESSARY)) &&
134 csum_tcpudp_magic(iph->saddr, iph->daddr, tcplen, IPPROTO_TCP,
135 oldskb->ip_summed == CHECKSUM_HW ? oldskb->csum :
136 skb_checksum(oldskb, iph->ihl * 4, tcplen, 0)))
137 return;
138
128 if ((rt = route_reverse(oldskb, oth, hook)) == NULL) 139 if ((rt = route_reverse(oldskb, oth, hook)) == NULL)
129 return; 140 return;
130 141
diff --git a/net/ipv4/netfilter/ipt_ULOG.c b/net/ipv4/netfilter/ipt_ULOG.c
index 6f2cefbe16cd..52a0076302a7 100644
--- a/net/ipv4/netfilter/ipt_ULOG.c
+++ b/net/ipv4/netfilter/ipt_ULOG.c
@@ -56,7 +56,6 @@
56#include <linux/netfilter.h> 56#include <linux/netfilter.h>
57#include <linux/netfilter_ipv4/ip_tables.h> 57#include <linux/netfilter_ipv4/ip_tables.h>
58#include <linux/netfilter_ipv4/ipt_ULOG.h> 58#include <linux/netfilter_ipv4/ipt_ULOG.h>
59#include <linux/netfilter_ipv4/lockhelp.h>
60#include <net/sock.h> 59#include <net/sock.h>
61#include <linux/bitops.h> 60#include <linux/bitops.h>
62 61
@@ -99,8 +98,8 @@ typedef struct {
99 98
100static ulog_buff_t ulog_buffers[ULOG_MAXNLGROUPS]; /* array of buffers */ 99static ulog_buff_t ulog_buffers[ULOG_MAXNLGROUPS]; /* array of buffers */
101 100
102static struct sock *nflognl; /* our socket */ 101static struct sock *nflognl; /* our socket */
103static DECLARE_LOCK(ulog_lock); /* spinlock */ 102static DEFINE_SPINLOCK(ulog_lock); /* spinlock */
104 103
105/* send one ulog_buff_t to userspace */ 104/* send one ulog_buff_t to userspace */
106static void ulog_send(unsigned int nlgroupnum) 105static void ulog_send(unsigned int nlgroupnum)
@@ -135,9 +134,9 @@ static void ulog_timer(unsigned long data)
135 134
136 /* lock to protect against somebody modifying our structure 135 /* lock to protect against somebody modifying our structure
137 * from ipt_ulog_target at the same time */ 136 * from ipt_ulog_target at the same time */
138 LOCK_BH(&ulog_lock); 137 spin_lock_bh(&ulog_lock);
139 ulog_send(data); 138 ulog_send(data);
140 UNLOCK_BH(&ulog_lock); 139 spin_unlock_bh(&ulog_lock);
141} 140}
142 141
143static struct sk_buff *ulog_alloc_skb(unsigned int size) 142static struct sk_buff *ulog_alloc_skb(unsigned int size)
@@ -193,7 +192,7 @@ static void ipt_ulog_packet(unsigned int hooknum,
193 192
194 ub = &ulog_buffers[groupnum]; 193 ub = &ulog_buffers[groupnum];
195 194
196 LOCK_BH(&ulog_lock); 195 spin_lock_bh(&ulog_lock);
197 196
198 if (!ub->skb) { 197 if (!ub->skb) {
199 if (!(ub->skb = ulog_alloc_skb(size))) 198 if (!(ub->skb = ulog_alloc_skb(size)))
@@ -278,7 +277,7 @@ static void ipt_ulog_packet(unsigned int hooknum,
278 ulog_send(groupnum); 277 ulog_send(groupnum);
279 } 278 }
280 279
281 UNLOCK_BH(&ulog_lock); 280 spin_unlock_bh(&ulog_lock);
282 281
283 return; 282 return;
284 283
@@ -288,7 +287,7 @@ nlmsg_failure:
288alloc_failure: 287alloc_failure:
289 PRINTR("ipt_ULOG: Error building netlink message\n"); 288 PRINTR("ipt_ULOG: Error building netlink message\n");
290 289
291 UNLOCK_BH(&ulog_lock); 290 spin_unlock_bh(&ulog_lock);
292} 291}
293 292
294static unsigned int ipt_ulog_target(struct sk_buff **pskb, 293static unsigned int ipt_ulog_target(struct sk_buff **pskb,
diff --git a/net/ipv4/netfilter/ipt_hashlimit.c b/net/ipv4/netfilter/ipt_hashlimit.c
index f1937190cd77..564b49bfebcf 100644
--- a/net/ipv4/netfilter/ipt_hashlimit.c
+++ b/net/ipv4/netfilter/ipt_hashlimit.c
@@ -37,7 +37,6 @@
37 37
38#include <linux/netfilter_ipv4/ip_tables.h> 38#include <linux/netfilter_ipv4/ip_tables.h>
39#include <linux/netfilter_ipv4/ipt_hashlimit.h> 39#include <linux/netfilter_ipv4/ipt_hashlimit.h>
40#include <linux/netfilter_ipv4/lockhelp.h>
41 40
42/* FIXME: this is just for IP_NF_ASSERRT */ 41/* FIXME: this is just for IP_NF_ASSERRT */
43#include <linux/netfilter_ipv4/ip_conntrack.h> 42#include <linux/netfilter_ipv4/ip_conntrack.h>
@@ -92,7 +91,7 @@ struct ipt_hashlimit_htable {
92 struct hlist_head hash[0]; /* hashtable itself */ 91 struct hlist_head hash[0]; /* hashtable itself */
93}; 92};
94 93
95static DECLARE_LOCK(hashlimit_lock); /* protects htables list */ 94static DEFINE_SPINLOCK(hashlimit_lock); /* protects htables list */
96static DECLARE_MUTEX(hlimit_mutex); /* additional checkentry protection */ 95static DECLARE_MUTEX(hlimit_mutex); /* additional checkentry protection */
97static HLIST_HEAD(hashlimit_htables); 96static HLIST_HEAD(hashlimit_htables);
98static kmem_cache_t *hashlimit_cachep; 97static kmem_cache_t *hashlimit_cachep;
@@ -233,9 +232,9 @@ static int htable_create(struct ipt_hashlimit_info *minfo)
233 hinfo->timer.function = htable_gc; 232 hinfo->timer.function = htable_gc;
234 add_timer(&hinfo->timer); 233 add_timer(&hinfo->timer);
235 234
236 LOCK_BH(&hashlimit_lock); 235 spin_lock_bh(&hashlimit_lock);
237 hlist_add_head(&hinfo->node, &hashlimit_htables); 236 hlist_add_head(&hinfo->node, &hashlimit_htables);
238 UNLOCK_BH(&hashlimit_lock); 237 spin_unlock_bh(&hashlimit_lock);
239 238
240 return 0; 239 return 0;
241} 240}
@@ -301,15 +300,15 @@ static struct ipt_hashlimit_htable *htable_find_get(char *name)
301 struct ipt_hashlimit_htable *hinfo; 300 struct ipt_hashlimit_htable *hinfo;
302 struct hlist_node *pos; 301 struct hlist_node *pos;
303 302
304 LOCK_BH(&hashlimit_lock); 303 spin_lock_bh(&hashlimit_lock);
305 hlist_for_each_entry(hinfo, pos, &hashlimit_htables, node) { 304 hlist_for_each_entry(hinfo, pos, &hashlimit_htables, node) {
306 if (!strcmp(name, hinfo->pde->name)) { 305 if (!strcmp(name, hinfo->pde->name)) {
307 atomic_inc(&hinfo->use); 306 atomic_inc(&hinfo->use);
308 UNLOCK_BH(&hashlimit_lock); 307 spin_unlock_bh(&hashlimit_lock);
309 return hinfo; 308 return hinfo;
310 } 309 }
311 } 310 }
312 UNLOCK_BH(&hashlimit_lock); 311 spin_unlock_bh(&hashlimit_lock);
313 312
314 return NULL; 313 return NULL;
315} 314}
@@ -317,9 +316,9 @@ static struct ipt_hashlimit_htable *htable_find_get(char *name)
317static void htable_put(struct ipt_hashlimit_htable *hinfo) 316static void htable_put(struct ipt_hashlimit_htable *hinfo)
318{ 317{
319 if (atomic_dec_and_test(&hinfo->use)) { 318 if (atomic_dec_and_test(&hinfo->use)) {
320 LOCK_BH(&hashlimit_lock); 319 spin_lock_bh(&hashlimit_lock);
321 hlist_del(&hinfo->node); 320 hlist_del(&hinfo->node);
322 UNLOCK_BH(&hashlimit_lock); 321 spin_unlock_bh(&hashlimit_lock);
323 htable_destroy(hinfo); 322 htable_destroy(hinfo);
324 } 323 }
325} 324}
diff --git a/net/ipv4/netfilter/ipt_helper.c b/net/ipv4/netfilter/ipt_helper.c
index 33fdf364d3d3..3e7dd014de43 100644
--- a/net/ipv4/netfilter/ipt_helper.c
+++ b/net/ipv4/netfilter/ipt_helper.c
@@ -53,7 +53,7 @@ match(const struct sk_buff *skb,
53 return ret; 53 return ret;
54 } 54 }
55 55
56 READ_LOCK(&ip_conntrack_lock); 56 read_lock_bh(&ip_conntrack_lock);
57 if (!ct->master->helper) { 57 if (!ct->master->helper) {
58 DEBUGP("ipt_helper: master ct %p has no helper\n", 58 DEBUGP("ipt_helper: master ct %p has no helper\n",
59 exp->expectant); 59 exp->expectant);
@@ -69,7 +69,7 @@ match(const struct sk_buff *skb,
69 ret ^= !strncmp(ct->master->helper->name, info->name, 69 ret ^= !strncmp(ct->master->helper->name, info->name,
70 strlen(ct->master->helper->name)); 70 strlen(ct->master->helper->name));
71out_unlock: 71out_unlock:
72 READ_UNLOCK(&ip_conntrack_lock); 72 read_unlock_bh(&ip_conntrack_lock);
73 return ret; 73 return ret;
74} 74}
75 75
diff --git a/net/ipv4/xfrm4_output.c b/net/ipv4/xfrm4_output.c
index af2392ae5769..66620a95942a 100644
--- a/net/ipv4/xfrm4_output.c
+++ b/net/ipv4/xfrm4_output.c
@@ -33,6 +33,7 @@ static void xfrm4_encap(struct sk_buff *skb)
33 struct dst_entry *dst = skb->dst; 33 struct dst_entry *dst = skb->dst;
34 struct xfrm_state *x = dst->xfrm; 34 struct xfrm_state *x = dst->xfrm;
35 struct iphdr *iph, *top_iph; 35 struct iphdr *iph, *top_iph;
36 int flags;
36 37
37 iph = skb->nh.iph; 38 iph = skb->nh.iph;
38 skb->h.ipiph = iph; 39 skb->h.ipiph = iph;
@@ -51,10 +52,13 @@ static void xfrm4_encap(struct sk_buff *skb)
51 52
52 /* DS disclosed */ 53 /* DS disclosed */
53 top_iph->tos = INET_ECN_encapsulate(iph->tos, iph->tos); 54 top_iph->tos = INET_ECN_encapsulate(iph->tos, iph->tos);
54 if (x->props.flags & XFRM_STATE_NOECN) 55
56 flags = x->props.flags;
57 if (flags & XFRM_STATE_NOECN)
55 IP_ECN_clear(top_iph); 58 IP_ECN_clear(top_iph);
56 59
57 top_iph->frag_off = iph->frag_off & htons(IP_DF); 60 top_iph->frag_off = (flags & XFRM_STATE_NOPMTUDISC) ?
61 0 : (iph->frag_off & htons(IP_DF));
58 if (!top_iph->frag_off) 62 if (!top_iph->frag_off)
59 __ip_select_ident(top_iph, dst, 0); 63 __ip_select_ident(top_iph, dst, 0);
60 64
diff --git a/net/ipv4/xfrm4_state.c b/net/ipv4/xfrm4_state.c
index 223a2e83853f..050611d7a967 100644
--- a/net/ipv4/xfrm4_state.c
+++ b/net/ipv4/xfrm4_state.c
@@ -7,12 +7,20 @@
7 * 7 *
8 */ 8 */
9 9
10#include <net/ip.h>
10#include <net/xfrm.h> 11#include <net/xfrm.h>
11#include <linux/pfkeyv2.h> 12#include <linux/pfkeyv2.h>
12#include <linux/ipsec.h> 13#include <linux/ipsec.h>
13 14
14static struct xfrm_state_afinfo xfrm4_state_afinfo; 15static struct xfrm_state_afinfo xfrm4_state_afinfo;
15 16
17static int xfrm4_init_flags(struct xfrm_state *x)
18{
19 if (ipv4_config.no_pmtu_disc)
20 x->props.flags |= XFRM_STATE_NOPMTUDISC;
21 return 0;
22}
23
16static void 24static void
17__xfrm4_init_tempsel(struct xfrm_state *x, struct flowi *fl, 25__xfrm4_init_tempsel(struct xfrm_state *x, struct flowi *fl,
18 struct xfrm_tmpl *tmpl, 26 struct xfrm_tmpl *tmpl,
@@ -109,6 +117,7 @@ __xfrm4_find_acq(u8 mode, u32 reqid, u8 proto,
109static struct xfrm_state_afinfo xfrm4_state_afinfo = { 117static struct xfrm_state_afinfo xfrm4_state_afinfo = {
110 .family = AF_INET, 118 .family = AF_INET,
111 .lock = RW_LOCK_UNLOCKED, 119 .lock = RW_LOCK_UNLOCKED,
120 .init_flags = xfrm4_init_flags,
112 .init_tempsel = __xfrm4_init_tempsel, 121 .init_tempsel = __xfrm4_init_tempsel,
113 .state_lookup = __xfrm4_state_lookup, 122 .state_lookup = __xfrm4_state_lookup,
114 .find_acq = __xfrm4_find_acq, 123 .find_acq = __xfrm4_find_acq,
diff --git a/net/ipv4/xfrm4_tunnel.c b/net/ipv4/xfrm4_tunnel.c
index 413191f585f6..e1fe360ed27a 100644
--- a/net/ipv4/xfrm4_tunnel.c
+++ b/net/ipv4/xfrm4_tunnel.c
@@ -84,7 +84,7 @@ static void ipip_err(struct sk_buff *skb, u32 info)
84 handler->err_handler(skb, &arg); 84 handler->err_handler(skb, &arg);
85} 85}
86 86
87static int ipip_init_state(struct xfrm_state *x, void *args) 87static int ipip_init_state(struct xfrm_state *x)
88{ 88{
89 if (!x->props.mode) 89 if (!x->props.mode)
90 return -EINVAL; 90 return -EINVAL;
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 47a30c3188ea..14f5c53235fe 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -695,7 +695,7 @@ static void ipv6_del_addr(struct inet6_ifaddr *ifp)
695 695
696 if (rt && ((rt->rt6i_flags & (RTF_GATEWAY | RTF_DEFAULT)) == 0)) { 696 if (rt && ((rt->rt6i_flags & (RTF_GATEWAY | RTF_DEFAULT)) == 0)) {
697 if (onlink == 0) { 697 if (onlink == 0) {
698 ip6_del_rt(rt, NULL, NULL); 698 ip6_del_rt(rt, NULL, NULL, NULL);
699 rt = NULL; 699 rt = NULL;
700 } else if (!(rt->rt6i_flags & RTF_EXPIRES)) { 700 } else if (!(rt->rt6i_flags & RTF_EXPIRES)) {
701 rt->rt6i_expires = expires; 701 rt->rt6i_expires = expires;
@@ -1340,7 +1340,7 @@ addrconf_prefix_route(struct in6_addr *pfx, int plen, struct net_device *dev,
1340 if (dev->type == ARPHRD_SIT && (dev->flags&IFF_POINTOPOINT)) 1340 if (dev->type == ARPHRD_SIT && (dev->flags&IFF_POINTOPOINT))
1341 rtmsg.rtmsg_flags |= RTF_NONEXTHOP; 1341 rtmsg.rtmsg_flags |= RTF_NONEXTHOP;
1342 1342
1343 ip6_route_add(&rtmsg, NULL, NULL); 1343 ip6_route_add(&rtmsg, NULL, NULL, NULL);
1344} 1344}
1345 1345
1346/* Create "default" multicast route to the interface */ 1346/* Create "default" multicast route to the interface */
@@ -1357,7 +1357,7 @@ static void addrconf_add_mroute(struct net_device *dev)
1357 rtmsg.rtmsg_ifindex = dev->ifindex; 1357 rtmsg.rtmsg_ifindex = dev->ifindex;
1358 rtmsg.rtmsg_flags = RTF_UP; 1358 rtmsg.rtmsg_flags = RTF_UP;
1359 rtmsg.rtmsg_type = RTMSG_NEWROUTE; 1359 rtmsg.rtmsg_type = RTMSG_NEWROUTE;
1360 ip6_route_add(&rtmsg, NULL, NULL); 1360 ip6_route_add(&rtmsg, NULL, NULL, NULL);
1361} 1361}
1362 1362
1363static void sit_route_add(struct net_device *dev) 1363static void sit_route_add(struct net_device *dev)
@@ -1374,7 +1374,7 @@ static void sit_route_add(struct net_device *dev)
1374 rtmsg.rtmsg_flags = RTF_UP|RTF_NONEXTHOP; 1374 rtmsg.rtmsg_flags = RTF_UP|RTF_NONEXTHOP;
1375 rtmsg.rtmsg_ifindex = dev->ifindex; 1375 rtmsg.rtmsg_ifindex = dev->ifindex;
1376 1376
1377 ip6_route_add(&rtmsg, NULL, NULL); 1377 ip6_route_add(&rtmsg, NULL, NULL, NULL);
1378} 1378}
1379 1379
1380static void addrconf_add_lroute(struct net_device *dev) 1380static void addrconf_add_lroute(struct net_device *dev)
@@ -1467,7 +1467,7 @@ void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len)
1467 if (rt && ((rt->rt6i_flags & (RTF_GATEWAY | RTF_DEFAULT)) == 0)) { 1467 if (rt && ((rt->rt6i_flags & (RTF_GATEWAY | RTF_DEFAULT)) == 0)) {
1468 if (rt->rt6i_flags&RTF_EXPIRES) { 1468 if (rt->rt6i_flags&RTF_EXPIRES) {
1469 if (valid_lft == 0) { 1469 if (valid_lft == 0) {
1470 ip6_del_rt(rt, NULL, NULL); 1470 ip6_del_rt(rt, NULL, NULL, NULL);
1471 rt = NULL; 1471 rt = NULL;
1472 } else { 1472 } else {
1473 rt->rt6i_expires = rt_expires; 1473 rt->rt6i_expires = rt_expires;
@@ -3094,7 +3094,7 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
3094 switch (event) { 3094 switch (event) {
3095 case RTM_NEWADDR: 3095 case RTM_NEWADDR:
3096 dst_hold(&ifp->rt->u.dst); 3096 dst_hold(&ifp->rt->u.dst);
3097 if (ip6_ins_rt(ifp->rt, NULL, NULL)) 3097 if (ip6_ins_rt(ifp->rt, NULL, NULL, NULL))
3098 dst_release(&ifp->rt->u.dst); 3098 dst_release(&ifp->rt->u.dst);
3099 if (ifp->idev->cnf.forwarding) 3099 if (ifp->idev->cnf.forwarding)
3100 addrconf_join_anycast(ifp); 3100 addrconf_join_anycast(ifp);
@@ -3104,7 +3104,7 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
3104 addrconf_leave_anycast(ifp); 3104 addrconf_leave_anycast(ifp);
3105 addrconf_leave_solict(ifp->idev, &ifp->addr); 3105 addrconf_leave_solict(ifp->idev, &ifp->addr);
3106 dst_hold(&ifp->rt->u.dst); 3106 dst_hold(&ifp->rt->u.dst);
3107 if (ip6_del_rt(ifp->rt, NULL, NULL)) 3107 if (ip6_del_rt(ifp->rt, NULL, NULL, NULL))
3108 dst_free(&ifp->rt->u.dst); 3108 dst_free(&ifp->rt->u.dst);
3109 else 3109 else
3110 dst_release(&ifp->rt->u.dst); 3110 dst_release(&ifp->rt->u.dst);
diff --git a/net/ipv6/ah6.c b/net/ipv6/ah6.c
index e3ecf626cbf7..986fdfdccbcd 100644
--- a/net/ipv6/ah6.c
+++ b/net/ipv6/ah6.c
@@ -339,7 +339,7 @@ static void ah6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
339 xfrm_state_put(x); 339 xfrm_state_put(x);
340} 340}
341 341
342static int ah6_init_state(struct xfrm_state *x, void *args) 342static int ah6_init_state(struct xfrm_state *x)
343{ 343{
344 struct ah_data *ahp = NULL; 344 struct ah_data *ahp = NULL;
345 struct xfrm_algo_desc *aalg_desc; 345 struct xfrm_algo_desc *aalg_desc;
diff --git a/net/ipv6/anycast.c b/net/ipv6/anycast.c
index 5d22ca3cca2e..6b7294047238 100644
--- a/net/ipv6/anycast.c
+++ b/net/ipv6/anycast.c
@@ -337,7 +337,7 @@ int ipv6_dev_ac_inc(struct net_device *dev, struct in6_addr *addr)
337 write_unlock_bh(&idev->lock); 337 write_unlock_bh(&idev->lock);
338 338
339 dst_hold(&rt->u.dst); 339 dst_hold(&rt->u.dst);
340 if (ip6_ins_rt(rt, NULL, NULL)) 340 if (ip6_ins_rt(rt, NULL, NULL, NULL))
341 dst_release(&rt->u.dst); 341 dst_release(&rt->u.dst);
342 342
343 addrconf_join_solict(dev, &aca->aca_addr); 343 addrconf_join_solict(dev, &aca->aca_addr);
@@ -380,7 +380,7 @@ int __ipv6_dev_ac_dec(struct inet6_dev *idev, struct in6_addr *addr)
380 addrconf_leave_solict(idev, &aca->aca_addr); 380 addrconf_leave_solict(idev, &aca->aca_addr);
381 381
382 dst_hold(&aca->aca_rt->u.dst); 382 dst_hold(&aca->aca_rt->u.dst);
383 if (ip6_del_rt(aca->aca_rt, NULL, NULL)) 383 if (ip6_del_rt(aca->aca_rt, NULL, NULL, NULL))
384 dst_free(&aca->aca_rt->u.dst); 384 dst_free(&aca->aca_rt->u.dst);
385 else 385 else
386 dst_release(&aca->aca_rt->u.dst); 386 dst_release(&aca->aca_rt->u.dst);
diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c
index be7095d6babe..324db62515a2 100644
--- a/net/ipv6/esp6.c
+++ b/net/ipv6/esp6.c
@@ -296,7 +296,7 @@ static void esp6_destroy(struct xfrm_state *x)
296 kfree(esp); 296 kfree(esp);
297} 297}
298 298
299static int esp6_init_state(struct xfrm_state *x, void *args) 299static int esp6_init_state(struct xfrm_state *x)
300{ 300{
301 struct esp_data *esp = NULL; 301 struct esp_data *esp = NULL;
302 302
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index 405740b75abb..1b354aa97934 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -394,7 +394,7 @@ insert_above:
394 */ 394 */
395 395
396static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt, 396static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt,
397 struct nlmsghdr *nlh) 397 struct nlmsghdr *nlh, struct netlink_skb_parms *req)
398{ 398{
399 struct rt6_info *iter = NULL; 399 struct rt6_info *iter = NULL;
400 struct rt6_info **ins; 400 struct rt6_info **ins;
@@ -449,7 +449,7 @@ out:
449 *ins = rt; 449 *ins = rt;
450 rt->rt6i_node = fn; 450 rt->rt6i_node = fn;
451 atomic_inc(&rt->rt6i_ref); 451 atomic_inc(&rt->rt6i_ref);
452 inet6_rt_notify(RTM_NEWROUTE, rt, nlh); 452 inet6_rt_notify(RTM_NEWROUTE, rt, nlh, req);
453 rt6_stats.fib_rt_entries++; 453 rt6_stats.fib_rt_entries++;
454 454
455 if ((fn->fn_flags & RTN_RTINFO) == 0) { 455 if ((fn->fn_flags & RTN_RTINFO) == 0) {
@@ -479,7 +479,8 @@ void fib6_force_start_gc(void)
479 * with source addr info in sub-trees 479 * with source addr info in sub-trees
480 */ 480 */
481 481
482int fib6_add(struct fib6_node *root, struct rt6_info *rt, struct nlmsghdr *nlh, void *_rtattr) 482int fib6_add(struct fib6_node *root, struct rt6_info *rt,
483 struct nlmsghdr *nlh, void *_rtattr, struct netlink_skb_parms *req)
483{ 484{
484 struct fib6_node *fn; 485 struct fib6_node *fn;
485 int err = -ENOMEM; 486 int err = -ENOMEM;
@@ -552,7 +553,7 @@ int fib6_add(struct fib6_node *root, struct rt6_info *rt, struct nlmsghdr *nlh,
552 } 553 }
553#endif 554#endif
554 555
555 err = fib6_add_rt2node(fn, rt, nlh); 556 err = fib6_add_rt2node(fn, rt, nlh, req);
556 557
557 if (err == 0) { 558 if (err == 0) {
558 fib6_start_gc(rt); 559 fib6_start_gc(rt);
@@ -859,7 +860,7 @@ static struct fib6_node * fib6_repair_tree(struct fib6_node *fn)
859} 860}
860 861
861static void fib6_del_route(struct fib6_node *fn, struct rt6_info **rtp, 862static void fib6_del_route(struct fib6_node *fn, struct rt6_info **rtp,
862 struct nlmsghdr *nlh, void *_rtattr) 863 struct nlmsghdr *nlh, void *_rtattr, struct netlink_skb_parms *req)
863{ 864{
864 struct fib6_walker_t *w; 865 struct fib6_walker_t *w;
865 struct rt6_info *rt = *rtp; 866 struct rt6_info *rt = *rtp;
@@ -915,11 +916,11 @@ static void fib6_del_route(struct fib6_node *fn, struct rt6_info **rtp,
915 if (atomic_read(&rt->rt6i_ref) != 1) BUG(); 916 if (atomic_read(&rt->rt6i_ref) != 1) BUG();
916 } 917 }
917 918
918 inet6_rt_notify(RTM_DELROUTE, rt, nlh); 919 inet6_rt_notify(RTM_DELROUTE, rt, nlh, req);
919 rt6_release(rt); 920 rt6_release(rt);
920} 921}
921 922
922int fib6_del(struct rt6_info *rt, struct nlmsghdr *nlh, void *_rtattr) 923int fib6_del(struct rt6_info *rt, struct nlmsghdr *nlh, void *_rtattr, struct netlink_skb_parms *req)
923{ 924{
924 struct fib6_node *fn = rt->rt6i_node; 925 struct fib6_node *fn = rt->rt6i_node;
925 struct rt6_info **rtp; 926 struct rt6_info **rtp;
@@ -944,7 +945,7 @@ int fib6_del(struct rt6_info *rt, struct nlmsghdr *nlh, void *_rtattr)
944 945
945 for (rtp = &fn->leaf; *rtp; rtp = &(*rtp)->u.next) { 946 for (rtp = &fn->leaf; *rtp; rtp = &(*rtp)->u.next) {
946 if (*rtp == rt) { 947 if (*rtp == rt) {
947 fib6_del_route(fn, rtp, nlh, _rtattr); 948 fib6_del_route(fn, rtp, nlh, _rtattr, req);
948 return 0; 949 return 0;
949 } 950 }
950 } 951 }
@@ -1073,7 +1074,7 @@ static int fib6_clean_node(struct fib6_walker_t *w)
1073 res = c->func(rt, c->arg); 1074 res = c->func(rt, c->arg);
1074 if (res < 0) { 1075 if (res < 0) {
1075 w->leaf = rt; 1076 w->leaf = rt;
1076 res = fib6_del(rt, NULL, NULL); 1077 res = fib6_del(rt, NULL, NULL, NULL);
1077 if (res) { 1078 if (res) {
1078#if RT6_DEBUG >= 2 1079#if RT6_DEBUG >= 2
1079 printk(KERN_DEBUG "fib6_clean_node: del failed: rt=%p@%p err=%d\n", rt, rt->rt6i_node, res); 1080 printk(KERN_DEBUG "fib6_clean_node: del failed: rt=%p@%p err=%d\n", rt, rt->rt6i_node, res);
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index b78a53586804..06e7cdaeedc5 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -484,9 +484,6 @@ static void ip6_copy_metadata(struct sk_buff *to, struct sk_buff *from)
484 to->nf_bridge = from->nf_bridge; 484 to->nf_bridge = from->nf_bridge;
485 nf_bridge_get(to->nf_bridge); 485 nf_bridge_get(to->nf_bridge);
486#endif 486#endif
487#ifdef CONFIG_NETFILTER_DEBUG
488 to->nf_debug = from->nf_debug;
489#endif
490#endif 487#endif
491} 488}
492 489
diff --git a/net/ipv6/ipcomp6.c b/net/ipv6/ipcomp6.c
index 6cde5310cd76..423feb46ccc0 100644
--- a/net/ipv6/ipcomp6.c
+++ b/net/ipv6/ipcomp6.c
@@ -234,14 +234,9 @@ static struct xfrm_state *ipcomp6_tunnel_create(struct xfrm_state *x)
234 t->props.mode = 1; 234 t->props.mode = 1;
235 memcpy(t->props.saddr.a6, x->props.saddr.a6, sizeof(struct in6_addr)); 235 memcpy(t->props.saddr.a6, x->props.saddr.a6, sizeof(struct in6_addr));
236 236
237 t->type = xfrm_get_type(IPPROTO_IPV6, t->props.family); 237 if (xfrm_init_state(t))
238 if (t->type == NULL)
239 goto error; 238 goto error;
240 239
241 if (t->type->init_state(t, NULL))
242 goto error;
243
244 t->km.state = XFRM_STATE_VALID;
245 atomic_set(&t->tunnel_users, 1); 240 atomic_set(&t->tunnel_users, 1);
246 241
247out: 242out:
@@ -420,7 +415,7 @@ static void ipcomp6_destroy(struct xfrm_state *x)
420 xfrm6_tunnel_free_spi((xfrm_address_t *)&x->props.saddr); 415 xfrm6_tunnel_free_spi((xfrm_address_t *)&x->props.saddr);
421} 416}
422 417
423static int ipcomp6_init_state(struct xfrm_state *x, void *args) 418static int ipcomp6_init_state(struct xfrm_state *x)
424{ 419{
425 int err; 420 int err;
426 struct ipcomp_data *ipcd; 421 struct ipcomp_data *ipcd;
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index 279ab86be662..f3ef4c38d315 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -423,11 +423,12 @@ done:
423 psin6 = (struct sockaddr_in6 *)&greqs.gsr_group; 423 psin6 = (struct sockaddr_in6 *)&greqs.gsr_group;
424 retv = ipv6_sock_mc_join(sk, greqs.gsr_interface, 424 retv = ipv6_sock_mc_join(sk, greqs.gsr_interface,
425 &psin6->sin6_addr); 425 &psin6->sin6_addr);
426 if (retv) 426 /* prior join w/ different source is ok */
427 if (retv && retv != -EADDRINUSE)
427 break; 428 break;
428 omode = MCAST_INCLUDE; 429 omode = MCAST_INCLUDE;
429 add = 1; 430 add = 1;
430 } else /*IP_DROP_SOURCE_MEMBERSHIP */ { 431 } else /* MCAST_LEAVE_SOURCE_GROUP */ {
431 omode = MCAST_INCLUDE; 432 omode = MCAST_INCLUDE;
432 add = 0; 433 add = 0;
433 } 434 }
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
index 393b6e6f50a9..562fcd14fdea 100644
--- a/net/ipv6/mcast.c
+++ b/net/ipv6/mcast.c
@@ -188,6 +188,16 @@ int ipv6_sock_mc_join(struct sock *sk, int ifindex, struct in6_addr *addr)
188 if (!ipv6_addr_is_multicast(addr)) 188 if (!ipv6_addr_is_multicast(addr))
189 return -EINVAL; 189 return -EINVAL;
190 190
191 read_lock_bh(&ipv6_sk_mc_lock);
192 for (mc_lst=np->ipv6_mc_list; mc_lst; mc_lst=mc_lst->next) {
193 if ((ifindex == 0 || mc_lst->ifindex == ifindex) &&
194 ipv6_addr_equal(&mc_lst->addr, addr)) {
195 read_unlock_bh(&ipv6_sk_mc_lock);
196 return -EADDRINUSE;
197 }
198 }
199 read_unlock_bh(&ipv6_sk_mc_lock);
200
191 mc_lst = sock_kmalloc(sk, sizeof(struct ipv6_mc_socklist), GFP_KERNEL); 201 mc_lst = sock_kmalloc(sk, sizeof(struct ipv6_mc_socklist), GFP_KERNEL);
192 202
193 if (mc_lst == NULL) 203 if (mc_lst == NULL)
@@ -349,6 +359,7 @@ int ip6_mc_source(int add, int omode, struct sock *sk,
349 struct ipv6_pinfo *inet6 = inet6_sk(sk); 359 struct ipv6_pinfo *inet6 = inet6_sk(sk);
350 struct ip6_sf_socklist *psl; 360 struct ip6_sf_socklist *psl;
351 int i, j, rv; 361 int i, j, rv;
362 int leavegroup = 0;
352 int err; 363 int err;
353 364
354 if (pgsr->gsr_group.ss_family != AF_INET6 || 365 if (pgsr->gsr_group.ss_family != AF_INET6 ||
@@ -368,6 +379,7 @@ int ip6_mc_source(int add, int omode, struct sock *sk,
368 379
369 err = -EADDRNOTAVAIL; 380 err = -EADDRNOTAVAIL;
370 381
382 read_lock_bh(&ipv6_sk_mc_lock);
371 for (pmc=inet6->ipv6_mc_list; pmc; pmc=pmc->next) { 383 for (pmc=inet6->ipv6_mc_list; pmc; pmc=pmc->next) {
372 if (pgsr->gsr_interface && pmc->ifindex != pgsr->gsr_interface) 384 if (pgsr->gsr_interface && pmc->ifindex != pgsr->gsr_interface)
373 continue; 385 continue;
@@ -401,6 +413,12 @@ int ip6_mc_source(int add, int omode, struct sock *sk,
401 if (rv) /* source not found */ 413 if (rv) /* source not found */
402 goto done; 414 goto done;
403 415
416 /* special case - (INCLUDE, empty) == LEAVE_GROUP */
417 if (psl->sl_count == 1 && omode == MCAST_INCLUDE) {
418 leavegroup = 1;
419 goto done;
420 }
421
404 /* update the interface filter */ 422 /* update the interface filter */
405 ip6_mc_del_src(idev, group, omode, 1, source, 1); 423 ip6_mc_del_src(idev, group, omode, 1, source, 1);
406 424
@@ -453,9 +471,12 @@ int ip6_mc_source(int add, int omode, struct sock *sk,
453 /* update the interface list */ 471 /* update the interface list */
454 ip6_mc_add_src(idev, group, omode, 1, source, 1); 472 ip6_mc_add_src(idev, group, omode, 1, source, 1);
455done: 473done:
474 read_unlock_bh(&ipv6_sk_mc_lock);
456 read_unlock_bh(&idev->lock); 475 read_unlock_bh(&idev->lock);
457 in6_dev_put(idev); 476 in6_dev_put(idev);
458 dev_put(dev); 477 dev_put(dev);
478 if (leavegroup)
479 return ipv6_sock_mc_drop(sk, pgsr->gsr_interface, group);
459 return err; 480 return err;
460} 481}
461 482
@@ -1280,15 +1301,6 @@ static struct sk_buff *mld_newpack(struct net_device *dev, int size)
1280 return NULL; 1301 return NULL;
1281 1302
1282 skb_reserve(skb, LL_RESERVED_SPACE(dev)); 1303 skb_reserve(skb, LL_RESERVED_SPACE(dev));
1283 if (dev->hard_header) {
1284 unsigned char ha[MAX_ADDR_LEN];
1285
1286 ndisc_mc_map(&mld2_all_mcr, ha, dev, 1);
1287 if (dev->hard_header(skb, dev, ETH_P_IPV6,ha,NULL,size) < 0) {
1288 kfree_skb(skb);
1289 return NULL;
1290 }
1291 }
1292 1304
1293 if (ipv6_get_lladdr(dev, &addr_buf)) { 1305 if (ipv6_get_lladdr(dev, &addr_buf)) {
1294 /* <draft-ietf-magma-mld-source-05.txt>: 1306 /* <draft-ietf-magma-mld-source-05.txt>:
@@ -1312,6 +1324,30 @@ static struct sk_buff *mld_newpack(struct net_device *dev, int size)
1312 return skb; 1324 return skb;
1313} 1325}
1314 1326
1327static inline int mld_dev_queue_xmit2(struct sk_buff *skb)
1328{
1329 struct net_device *dev = skb->dev;
1330
1331 if (dev->hard_header) {
1332 unsigned char ha[MAX_ADDR_LEN];
1333 int err;
1334
1335 ndisc_mc_map(&skb->nh.ipv6h->daddr, ha, dev, 1);
1336 err = dev->hard_header(skb, dev, ETH_P_IPV6, ha, NULL, skb->len);
1337 if (err < 0) {
1338 kfree_skb(skb);
1339 return err;
1340 }
1341 }
1342 return dev_queue_xmit(skb);
1343}
1344
1345static inline int mld_dev_queue_xmit(struct sk_buff *skb)
1346{
1347 return NF_HOOK(PF_INET6, NF_IP6_POST_ROUTING, skb, NULL, skb->dev,
1348 mld_dev_queue_xmit2);
1349}
1350
1315static void mld_sendpack(struct sk_buff *skb) 1351static void mld_sendpack(struct sk_buff *skb)
1316{ 1352{
1317 struct ipv6hdr *pip6 = skb->nh.ipv6h; 1353 struct ipv6hdr *pip6 = skb->nh.ipv6h;
@@ -1329,7 +1365,7 @@ static void mld_sendpack(struct sk_buff *skb)
1329 pmr->csum = csum_ipv6_magic(&pip6->saddr, &pip6->daddr, mldlen, 1365 pmr->csum = csum_ipv6_magic(&pip6->saddr, &pip6->daddr, mldlen,
1330 IPPROTO_ICMPV6, csum_partial(skb->h.raw, mldlen, 0)); 1366 IPPROTO_ICMPV6, csum_partial(skb->h.raw, mldlen, 0));
1331 err = NF_HOOK(PF_INET6, NF_IP6_LOCAL_OUT, skb, NULL, skb->dev, 1367 err = NF_HOOK(PF_INET6, NF_IP6_LOCAL_OUT, skb, NULL, skb->dev,
1332 dev_queue_xmit); 1368 mld_dev_queue_xmit);
1333 if (!err) { 1369 if (!err) {
1334 ICMP6_INC_STATS(idev,ICMP6_MIB_OUTMSGS); 1370 ICMP6_INC_STATS(idev,ICMP6_MIB_OUTMSGS);
1335 IP6_INC_STATS(IPSTATS_MIB_OUTMCASTPKTS); 1371 IP6_INC_STATS(IPSTATS_MIB_OUTMCASTPKTS);
@@ -1635,12 +1671,6 @@ static void igmp6_send(struct in6_addr *addr, struct net_device *dev, int type)
1635 } 1671 }
1636 1672
1637 skb_reserve(skb, LL_RESERVED_SPACE(dev)); 1673 skb_reserve(skb, LL_RESERVED_SPACE(dev));
1638 if (dev->hard_header) {
1639 unsigned char ha[MAX_ADDR_LEN];
1640 ndisc_mc_map(snd_addr, ha, dev, 1);
1641 if (dev->hard_header(skb, dev, ETH_P_IPV6, ha, NULL, full_len) < 0)
1642 goto out;
1643 }
1644 1674
1645 if (ipv6_get_lladdr(dev, &addr_buf)) { 1675 if (ipv6_get_lladdr(dev, &addr_buf)) {
1646 /* <draft-ietf-magma-mld-source-05.txt>: 1676 /* <draft-ietf-magma-mld-source-05.txt>:
@@ -1668,7 +1698,7 @@ static void igmp6_send(struct in6_addr *addr, struct net_device *dev, int type)
1668 idev = in6_dev_get(skb->dev); 1698 idev = in6_dev_get(skb->dev);
1669 1699
1670 err = NF_HOOK(PF_INET6, NF_IP6_LOCAL_OUT, skb, NULL, skb->dev, 1700 err = NF_HOOK(PF_INET6, NF_IP6_LOCAL_OUT, skb, NULL, skb->dev,
1671 dev_queue_xmit); 1701 mld_dev_queue_xmit);
1672 if (!err) { 1702 if (!err) {
1673 if (type == ICMPV6_MGM_REDUCTION) 1703 if (type == ICMPV6_MGM_REDUCTION)
1674 ICMP6_INC_STATS(idev, ICMP6_MIB_OUTGROUPMEMBREDUCTIONS); 1704 ICMP6_INC_STATS(idev, ICMP6_MIB_OUTGROUPMEMBREDUCTIONS);
@@ -1682,10 +1712,6 @@ static void igmp6_send(struct in6_addr *addr, struct net_device *dev, int type)
1682 if (likely(idev != NULL)) 1712 if (likely(idev != NULL))
1683 in6_dev_put(idev); 1713 in6_dev_put(idev);
1684 return; 1714 return;
1685
1686out:
1687 IP6_INC_STATS(IPSTATS_MIB_OUTDISCARDS);
1688 kfree_skb(skb);
1689} 1715}
1690 1716
1691static int ip6_mc_del1_src(struct ifmcaddr6 *pmc, int sfmode, 1717static int ip6_mc_del1_src(struct ifmcaddr6 *pmc, int sfmode,
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index 7c291f4e9edc..7ae72d4c9bd2 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -955,7 +955,7 @@ static void ndisc_recv_na(struct sk_buff *skb)
955 struct rt6_info *rt; 955 struct rt6_info *rt;
956 rt = rt6_get_dflt_router(saddr, dev); 956 rt = rt6_get_dflt_router(saddr, dev);
957 if (rt) 957 if (rt)
958 ip6_del_rt(rt, NULL, NULL); 958 ip6_del_rt(rt, NULL, NULL, NULL);
959 } 959 }
960 960
961out: 961out:
@@ -1096,7 +1096,7 @@ static void ndisc_router_discovery(struct sk_buff *skb)
1096 1096
1097 if (rt && lifetime == 0) { 1097 if (rt && lifetime == 0) {
1098 neigh_clone(neigh); 1098 neigh_clone(neigh);
1099 ip6_del_rt(rt, NULL, NULL); 1099 ip6_del_rt(rt, NULL, NULL, NULL);
1100 rt = NULL; 1100 rt = NULL;
1101 } 1101 }
1102 1102
diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
index c735276fdd5f..73034511c8db 100644
--- a/net/ipv6/netfilter/ip6_tables.c
+++ b/net/ipv6/netfilter/ip6_tables.c
@@ -71,7 +71,6 @@ static DECLARE_MUTEX(ip6t_mutex);
71/* Must have mutex */ 71/* Must have mutex */
72#define ASSERT_READ_LOCK(x) IP_NF_ASSERT(down_trylock(&ip6t_mutex) != 0) 72#define ASSERT_READ_LOCK(x) IP_NF_ASSERT(down_trylock(&ip6t_mutex) != 0)
73#define ASSERT_WRITE_LOCK(x) IP_NF_ASSERT(down_trylock(&ip6t_mutex) != 0) 73#define ASSERT_WRITE_LOCK(x) IP_NF_ASSERT(down_trylock(&ip6t_mutex) != 0)
74#include <linux/netfilter_ipv4/lockhelp.h>
75#include <linux/netfilter_ipv4/listhelp.h> 74#include <linux/netfilter_ipv4/listhelp.h>
76 75
77#if 0 76#if 0
diff --git a/net/ipv6/netfilter/ip6t_LOG.c b/net/ipv6/netfilter/ip6t_LOG.c
index bfc3d0185d19..c44685e391b7 100644
--- a/net/ipv6/netfilter/ip6t_LOG.c
+++ b/net/ipv6/netfilter/ip6t_LOG.c
@@ -366,8 +366,6 @@ ip6t_log_packet(unsigned int hooknum,
366 const char *level_string, 366 const char *level_string,
367 const char *prefix) 367 const char *prefix)
368{ 368{
369 struct ipv6hdr *ipv6h = skb->nh.ipv6h;
370
371 spin_lock_bh(&log_lock); 369 spin_lock_bh(&log_lock);
372 printk(level_string); 370 printk(level_string);
373 printk("%sIN=%s OUT=%s ", 371 printk("%sIN=%s OUT=%s ",
@@ -377,39 +375,25 @@ ip6t_log_packet(unsigned int hooknum,
377 if (in && !out) { 375 if (in && !out) {
378 /* MAC logging for input chain only. */ 376 /* MAC logging for input chain only. */
379 printk("MAC="); 377 printk("MAC=");
380 if (skb->dev && skb->dev->hard_header_len && skb->mac.raw != (void*)ipv6h) { 378 if (skb->dev && skb->dev->hard_header_len &&
381 if (skb->dev->type != ARPHRD_SIT){ 379 skb->mac.raw != skb->nh.raw) {
382 int i; 380 unsigned char *p = skb->mac.raw;
383 unsigned char *p = skb->mac.raw; 381 int i;
384 for (i = 0; i < skb->dev->hard_header_len; i++,p++) 382
385 printk("%02x%c", *p, 383 if (skb->dev->type == ARPHRD_SIT &&
386 i==skb->dev->hard_header_len - 1 384 (p -= ETH_HLEN) < skb->head)
387 ? ' ':':'); 385 p = NULL;
388 } else { 386
389 int i; 387 if (p != NULL)
390 unsigned char *p = skb->mac.raw; 388 for (i = 0; i < skb->dev->hard_header_len; i++)
391 if ( p - (ETH_ALEN*2+2) > skb->head ){ 389 printk("%02x", p[i]);
392 p -= (ETH_ALEN+2); 390 printk(" ");
393 for (i = 0; i < (ETH_ALEN); i++,p++) 391
394 printk("%02x%s", *p, 392 if (skb->dev->type == ARPHRD_SIT) {
395 i == ETH_ALEN-1 ? "->" : ":"); 393 struct iphdr *iph = (struct iphdr *)skb->mac.raw;
396 p -= (ETH_ALEN*2); 394 printk("TUNNEL=%u.%u.%u.%u->%u.%u.%u.%u ",
397 for (i = 0; i < (ETH_ALEN); i++,p++) 395 NIPQUAD(iph->saddr),
398 printk("%02x%c", *p, 396 NIPQUAD(iph->daddr));
399 i == ETH_ALEN-1 ? ' ' : ':');
400 }
401
402 if ((skb->dev->addr_len == 4) &&
403 skb->dev->hard_header_len > 20){
404 printk("TUNNEL=");
405 p = skb->mac.raw + 12;
406 for (i = 0; i < 4; i++,p++)
407 printk("%3d%s", *p,
408 i == 3 ? "->" : ".");
409 for (i = 0; i < 4; i++,p++)
410 printk("%3d%c", *p,
411 i == 3 ? ' ' : '.');
412 }
413 } 397 }
414 } else 398 } else
415 printk(" "); 399 printk(" ");
diff --git a/net/ipv6/netfilter/ip6table_raw.c b/net/ipv6/netfilter/ip6table_raw.c
index 71407beaf790..c2982efd14af 100644
--- a/net/ipv6/netfilter/ip6table_raw.c
+++ b/net/ipv6/netfilter/ip6table_raw.c
@@ -129,13 +129,15 @@ static struct nf_hook_ops ip6t_ops[] = {
129 .hook = ip6t_hook, 129 .hook = ip6t_hook,
130 .pf = PF_INET6, 130 .pf = PF_INET6,
131 .hooknum = NF_IP6_PRE_ROUTING, 131 .hooknum = NF_IP6_PRE_ROUTING,
132 .priority = NF_IP6_PRI_FIRST 132 .priority = NF_IP6_PRI_FIRST,
133 .owner = THIS_MODULE,
133 }, 134 },
134 { 135 {
135 .hook = ip6t_hook, 136 .hook = ip6t_hook,
136 .pf = PF_INET6, 137 .pf = PF_INET6,
137 .hooknum = NF_IP6_LOCAL_OUT, 138 .hooknum = NF_IP6_LOCAL_OUT,
138 .priority = NF_IP6_PRI_FIRST 139 .priority = NF_IP6_PRI_FIRST,
140 .owner = THIS_MODULE,
139 }, 141 },
140}; 142};
141 143
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 1f5b226c3573..878789b3122d 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -384,12 +384,13 @@ struct rt6_info *rt6_lookup(struct in6_addr *daddr, struct in6_addr *saddr,
384 be destroyed. 384 be destroyed.
385 */ 385 */
386 386
387int ip6_ins_rt(struct rt6_info *rt, struct nlmsghdr *nlh, void *_rtattr) 387int ip6_ins_rt(struct rt6_info *rt, struct nlmsghdr *nlh,
388 void *_rtattr, struct netlink_skb_parms *req)
388{ 389{
389 int err; 390 int err;
390 391
391 write_lock_bh(&rt6_lock); 392 write_lock_bh(&rt6_lock);
392 err = fib6_add(&ip6_routing_table, rt, nlh, _rtattr); 393 err = fib6_add(&ip6_routing_table, rt, nlh, _rtattr, req);
393 write_unlock_bh(&rt6_lock); 394 write_unlock_bh(&rt6_lock);
394 395
395 return err; 396 return err;
@@ -400,7 +401,7 @@ int ip6_ins_rt(struct rt6_info *rt, struct nlmsghdr *nlh, void *_rtattr)
400 */ 401 */
401 402
402static struct rt6_info *rt6_cow(struct rt6_info *ort, struct in6_addr *daddr, 403static struct rt6_info *rt6_cow(struct rt6_info *ort, struct in6_addr *daddr,
403 struct in6_addr *saddr) 404 struct in6_addr *saddr, struct netlink_skb_parms *req)
404{ 405{
405 int err; 406 int err;
406 struct rt6_info *rt; 407 struct rt6_info *rt;
@@ -432,7 +433,7 @@ static struct rt6_info *rt6_cow(struct rt6_info *ort, struct in6_addr *daddr,
432 433
433 dst_hold(&rt->u.dst); 434 dst_hold(&rt->u.dst);
434 435
435 err = ip6_ins_rt(rt, NULL, NULL); 436 err = ip6_ins_rt(rt, NULL, NULL, req);
436 if (err == 0) 437 if (err == 0)
437 return rt; 438 return rt;
438 439
@@ -491,7 +492,8 @@ restart:
491 read_unlock_bh(&rt6_lock); 492 read_unlock_bh(&rt6_lock);
492 493
493 nrt = rt6_cow(rt, &skb->nh.ipv6h->daddr, 494 nrt = rt6_cow(rt, &skb->nh.ipv6h->daddr,
494 &skb->nh.ipv6h->saddr); 495 &skb->nh.ipv6h->saddr,
496 &NETLINK_CB(skb));
495 497
496 dst_release(&rt->u.dst); 498 dst_release(&rt->u.dst);
497 rt = nrt; 499 rt = nrt;
@@ -551,7 +553,7 @@ restart:
551 dst_hold(&rt->u.dst); 553 dst_hold(&rt->u.dst);
552 read_unlock_bh(&rt6_lock); 554 read_unlock_bh(&rt6_lock);
553 555
554 nrt = rt6_cow(rt, &fl->fl6_dst, &fl->fl6_src); 556 nrt = rt6_cow(rt, &fl->fl6_dst, &fl->fl6_src, NULL);
555 557
556 dst_release(&rt->u.dst); 558 dst_release(&rt->u.dst);
557 rt = nrt; 559 rt = nrt;
@@ -598,7 +600,7 @@ static struct dst_entry *ip6_negative_advice(struct dst_entry *dst)
598 600
599 if (rt) { 601 if (rt) {
600 if (rt->rt6i_flags & RTF_CACHE) 602 if (rt->rt6i_flags & RTF_CACHE)
601 ip6_del_rt(rt, NULL, NULL); 603 ip6_del_rt(rt, NULL, NULL, NULL);
602 else 604 else
603 dst_release(dst); 605 dst_release(dst);
604 } 606 }
@@ -787,7 +789,8 @@ int ipv6_get_hoplimit(struct net_device *dev)
787 * 789 *
788 */ 790 */
789 791
790int ip6_route_add(struct in6_rtmsg *rtmsg, struct nlmsghdr *nlh, void *_rtattr) 792int ip6_route_add(struct in6_rtmsg *rtmsg, struct nlmsghdr *nlh,
793 void *_rtattr, struct netlink_skb_parms *req)
791{ 794{
792 int err; 795 int err;
793 struct rtmsg *r; 796 struct rtmsg *r;
@@ -974,7 +977,7 @@ install_route:
974 rt->u.dst.metrics[RTAX_ADVMSS-1] = ipv6_advmss(dst_mtu(&rt->u.dst)); 977 rt->u.dst.metrics[RTAX_ADVMSS-1] = ipv6_advmss(dst_mtu(&rt->u.dst));
975 rt->u.dst.dev = dev; 978 rt->u.dst.dev = dev;
976 rt->rt6i_idev = idev; 979 rt->rt6i_idev = idev;
977 return ip6_ins_rt(rt, nlh, _rtattr); 980 return ip6_ins_rt(rt, nlh, _rtattr, req);
978 981
979out: 982out:
980 if (dev) 983 if (dev)
@@ -986,7 +989,7 @@ out:
986 return err; 989 return err;
987} 990}
988 991
989int ip6_del_rt(struct rt6_info *rt, struct nlmsghdr *nlh, void *_rtattr) 992int ip6_del_rt(struct rt6_info *rt, struct nlmsghdr *nlh, void *_rtattr, struct netlink_skb_parms *req)
990{ 993{
991 int err; 994 int err;
992 995
@@ -994,7 +997,7 @@ int ip6_del_rt(struct rt6_info *rt, struct nlmsghdr *nlh, void *_rtattr)
994 997
995 rt6_reset_dflt_pointer(NULL); 998 rt6_reset_dflt_pointer(NULL);
996 999
997 err = fib6_del(rt, nlh, _rtattr); 1000 err = fib6_del(rt, nlh, _rtattr, req);
998 dst_release(&rt->u.dst); 1001 dst_release(&rt->u.dst);
999 1002
1000 write_unlock_bh(&rt6_lock); 1003 write_unlock_bh(&rt6_lock);
@@ -1002,7 +1005,7 @@ int ip6_del_rt(struct rt6_info *rt, struct nlmsghdr *nlh, void *_rtattr)
1002 return err; 1005 return err;
1003} 1006}
1004 1007
1005static int ip6_route_del(struct in6_rtmsg *rtmsg, struct nlmsghdr *nlh, void *_rtattr) 1008static int ip6_route_del(struct in6_rtmsg *rtmsg, struct nlmsghdr *nlh, void *_rtattr, struct netlink_skb_parms *req)
1006{ 1009{
1007 struct fib6_node *fn; 1010 struct fib6_node *fn;
1008 struct rt6_info *rt; 1011 struct rt6_info *rt;
@@ -1029,7 +1032,7 @@ static int ip6_route_del(struct in6_rtmsg *rtmsg, struct nlmsghdr *nlh, void *_r
1029 dst_hold(&rt->u.dst); 1032 dst_hold(&rt->u.dst);
1030 read_unlock_bh(&rt6_lock); 1033 read_unlock_bh(&rt6_lock);
1031 1034
1032 return ip6_del_rt(rt, nlh, _rtattr); 1035 return ip6_del_rt(rt, nlh, _rtattr, req);
1033 } 1036 }
1034 } 1037 }
1035 read_unlock_bh(&rt6_lock); 1038 read_unlock_bh(&rt6_lock);
@@ -1136,11 +1139,11 @@ source_ok:
1136 nrt->u.dst.metrics[RTAX_MTU-1] = ipv6_get_mtu(neigh->dev); 1139 nrt->u.dst.metrics[RTAX_MTU-1] = ipv6_get_mtu(neigh->dev);
1137 nrt->u.dst.metrics[RTAX_ADVMSS-1] = ipv6_advmss(dst_mtu(&nrt->u.dst)); 1140 nrt->u.dst.metrics[RTAX_ADVMSS-1] = ipv6_advmss(dst_mtu(&nrt->u.dst));
1138 1141
1139 if (ip6_ins_rt(nrt, NULL, NULL)) 1142 if (ip6_ins_rt(nrt, NULL, NULL, NULL))
1140 goto out; 1143 goto out;
1141 1144
1142 if (rt->rt6i_flags&RTF_CACHE) { 1145 if (rt->rt6i_flags&RTF_CACHE) {
1143 ip6_del_rt(rt, NULL, NULL); 1146 ip6_del_rt(rt, NULL, NULL, NULL);
1144 return; 1147 return;
1145 } 1148 }
1146 1149
@@ -1204,7 +1207,7 @@ void rt6_pmtu_discovery(struct in6_addr *daddr, struct in6_addr *saddr,
1204 2. It is gatewayed route or NONEXTHOP route. Action: clone it. 1207 2. It is gatewayed route or NONEXTHOP route. Action: clone it.
1205 */ 1208 */
1206 if (!rt->rt6i_nexthop && !(rt->rt6i_flags & RTF_NONEXTHOP)) { 1209 if (!rt->rt6i_nexthop && !(rt->rt6i_flags & RTF_NONEXTHOP)) {
1207 nrt = rt6_cow(rt, daddr, saddr); 1210 nrt = rt6_cow(rt, daddr, saddr, NULL);
1208 if (!nrt->u.dst.error) { 1211 if (!nrt->u.dst.error) {
1209 nrt->u.dst.metrics[RTAX_MTU-1] = pmtu; 1212 nrt->u.dst.metrics[RTAX_MTU-1] = pmtu;
1210 if (allfrag) 1213 if (allfrag)
@@ -1232,7 +1235,7 @@ void rt6_pmtu_discovery(struct in6_addr *daddr, struct in6_addr *saddr,
1232 nrt->u.dst.metrics[RTAX_MTU-1] = pmtu; 1235 nrt->u.dst.metrics[RTAX_MTU-1] = pmtu;
1233 if (allfrag) 1236 if (allfrag)
1234 nrt->u.dst.metrics[RTAX_FEATURES-1] |= RTAX_FEATURE_ALLFRAG; 1237 nrt->u.dst.metrics[RTAX_FEATURES-1] |= RTAX_FEATURE_ALLFRAG;
1235 ip6_ins_rt(nrt, NULL, NULL); 1238 ip6_ins_rt(nrt, NULL, NULL, NULL);
1236 } 1239 }
1237 1240
1238out: 1241out:
@@ -1305,7 +1308,7 @@ struct rt6_info *rt6_add_dflt_router(struct in6_addr *gwaddr,
1305 1308
1306 rtmsg.rtmsg_ifindex = dev->ifindex; 1309 rtmsg.rtmsg_ifindex = dev->ifindex;
1307 1310
1308 ip6_route_add(&rtmsg, NULL, NULL); 1311 ip6_route_add(&rtmsg, NULL, NULL, NULL);
1309 return rt6_get_dflt_router(gwaddr, dev); 1312 return rt6_get_dflt_router(gwaddr, dev);
1310} 1313}
1311 1314
@@ -1323,7 +1326,7 @@ restart:
1323 1326
1324 read_unlock_bh(&rt6_lock); 1327 read_unlock_bh(&rt6_lock);
1325 1328
1326 ip6_del_rt(rt, NULL, NULL); 1329 ip6_del_rt(rt, NULL, NULL, NULL);
1327 1330
1328 goto restart; 1331 goto restart;
1329 } 1332 }
@@ -1349,10 +1352,10 @@ int ipv6_route_ioctl(unsigned int cmd, void __user *arg)
1349 rtnl_lock(); 1352 rtnl_lock();
1350 switch (cmd) { 1353 switch (cmd) {
1351 case SIOCADDRT: 1354 case SIOCADDRT:
1352 err = ip6_route_add(&rtmsg, NULL, NULL); 1355 err = ip6_route_add(&rtmsg, NULL, NULL, NULL);
1353 break; 1356 break;
1354 case SIOCDELRT: 1357 case SIOCDELRT:
1355 err = ip6_route_del(&rtmsg, NULL, NULL); 1358 err = ip6_route_del(&rtmsg, NULL, NULL, NULL);
1356 break; 1359 break;
1357 default: 1360 default:
1358 err = -EINVAL; 1361 err = -EINVAL;
@@ -1546,7 +1549,7 @@ int inet6_rtm_delroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
1546 1549
1547 if (inet6_rtm_to_rtmsg(r, arg, &rtmsg)) 1550 if (inet6_rtm_to_rtmsg(r, arg, &rtmsg))
1548 return -EINVAL; 1551 return -EINVAL;
1549 return ip6_route_del(&rtmsg, nlh, arg); 1552 return ip6_route_del(&rtmsg, nlh, arg, &NETLINK_CB(skb));
1550} 1553}
1551 1554
1552int inet6_rtm_newroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg) 1555int inet6_rtm_newroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
@@ -1556,7 +1559,7 @@ int inet6_rtm_newroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
1556 1559
1557 if (inet6_rtm_to_rtmsg(r, arg, &rtmsg)) 1560 if (inet6_rtm_to_rtmsg(r, arg, &rtmsg))
1558 return -EINVAL; 1561 return -EINVAL;
1559 return ip6_route_add(&rtmsg, nlh, arg); 1562 return ip6_route_add(&rtmsg, nlh, arg, &NETLINK_CB(skb));
1560} 1563}
1561 1564
1562struct rt6_rtnl_dump_arg 1565struct rt6_rtnl_dump_arg
@@ -1566,12 +1569,9 @@ struct rt6_rtnl_dump_arg
1566}; 1569};
1567 1570
1568static int rt6_fill_node(struct sk_buff *skb, struct rt6_info *rt, 1571static int rt6_fill_node(struct sk_buff *skb, struct rt6_info *rt,
1569 struct in6_addr *dst, 1572 struct in6_addr *dst, struct in6_addr *src,
1570 struct in6_addr *src, 1573 int iif, int type, u32 pid, u32 seq,
1571 int iif, 1574 int prefix, unsigned int flags)
1572 int type, u32 pid, u32 seq,
1573 struct nlmsghdr *in_nlh, int prefix,
1574 unsigned int flags)
1575{ 1575{
1576 struct rtmsg *rtm; 1576 struct rtmsg *rtm;
1577 struct nlmsghdr *nlh; 1577 struct nlmsghdr *nlh;
@@ -1585,10 +1585,6 @@ static int rt6_fill_node(struct sk_buff *skb, struct rt6_info *rt,
1585 } 1585 }
1586 } 1586 }
1587 1587
1588 if (!pid && in_nlh) {
1589 pid = in_nlh->nlmsg_pid;
1590 }
1591
1592 nlh = NLMSG_NEW(skb, pid, seq, type, sizeof(*rtm), flags); 1588 nlh = NLMSG_NEW(skb, pid, seq, type, sizeof(*rtm), flags);
1593 rtm = NLMSG_DATA(nlh); 1589 rtm = NLMSG_DATA(nlh);
1594 rtm->rtm_family = AF_INET6; 1590 rtm->rtm_family = AF_INET6;
@@ -1675,7 +1671,7 @@ static int rt6_dump_route(struct rt6_info *rt, void *p_arg)
1675 1671
1676 return rt6_fill_node(arg->skb, rt, NULL, NULL, 0, RTM_NEWROUTE, 1672 return rt6_fill_node(arg->skb, rt, NULL, NULL, 0, RTM_NEWROUTE,
1677 NETLINK_CB(arg->cb->skb).pid, arg->cb->nlh->nlmsg_seq, 1673 NETLINK_CB(arg->cb->skb).pid, arg->cb->nlh->nlmsg_seq,
1678 NULL, prefix, NLM_F_MULTI); 1674 prefix, NLM_F_MULTI);
1679} 1675}
1680 1676
1681static int fib6_dump_node(struct fib6_walker_t *w) 1677static int fib6_dump_node(struct fib6_walker_t *w)
@@ -1823,7 +1819,7 @@ int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void *arg)
1823 &fl.fl6_dst, &fl.fl6_src, 1819 &fl.fl6_dst, &fl.fl6_src,
1824 iif, 1820 iif,
1825 RTM_NEWROUTE, NETLINK_CB(in_skb).pid, 1821 RTM_NEWROUTE, NETLINK_CB(in_skb).pid,
1826 nlh->nlmsg_seq, nlh, 0, 0); 1822 nlh->nlmsg_seq, 0, 0);
1827 if (err < 0) { 1823 if (err < 0) {
1828 err = -EMSGSIZE; 1824 err = -EMSGSIZE;
1829 goto out_free; 1825 goto out_free;
@@ -1839,17 +1835,25 @@ out_free:
1839 goto out; 1835 goto out;
1840} 1836}
1841 1837
1842void inet6_rt_notify(int event, struct rt6_info *rt, struct nlmsghdr *nlh) 1838void inet6_rt_notify(int event, struct rt6_info *rt, struct nlmsghdr *nlh,
1839 struct netlink_skb_parms *req)
1843{ 1840{
1844 struct sk_buff *skb; 1841 struct sk_buff *skb;
1845 int size = NLMSG_SPACE(sizeof(struct rtmsg)+256); 1842 int size = NLMSG_SPACE(sizeof(struct rtmsg)+256);
1843 u32 pid = current->pid;
1844 u32 seq = 0;
1846 1845
1846 if (req)
1847 pid = req->pid;
1848 if (nlh)
1849 seq = nlh->nlmsg_seq;
1850
1847 skb = alloc_skb(size, gfp_any()); 1851 skb = alloc_skb(size, gfp_any());
1848 if (!skb) { 1852 if (!skb) {
1849 netlink_set_err(rtnl, 0, RTMGRP_IPV6_ROUTE, ENOBUFS); 1853 netlink_set_err(rtnl, 0, RTMGRP_IPV6_ROUTE, ENOBUFS);
1850 return; 1854 return;
1851 } 1855 }
1852 if (rt6_fill_node(skb, rt, NULL, NULL, 0, event, 0, 0, nlh, 0, 0) < 0) { 1856 if (rt6_fill_node(skb, rt, NULL, NULL, 0, event, pid, seq, 0, 0) < 0) {
1853 kfree_skb(skb); 1857 kfree_skb(skb);
1854 netlink_set_err(rtnl, 0, RTMGRP_IPV6_ROUTE, EINVAL); 1858 netlink_set_err(rtnl, 0, RTMGRP_IPV6_ROUTE, EINVAL);
1855 return; 1859 return;
diff --git a/net/ipv6/xfrm6_tunnel.c b/net/ipv6/xfrm6_tunnel.c
index ffcadd68b951..60c26c87277e 100644
--- a/net/ipv6/xfrm6_tunnel.c
+++ b/net/ipv6/xfrm6_tunnel.c
@@ -466,7 +466,7 @@ static void xfrm6_tunnel_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
466 return; 466 return;
467} 467}
468 468
469static int xfrm6_tunnel_init_state(struct xfrm_state *x, void *args) 469static int xfrm6_tunnel_init_state(struct xfrm_state *x)
470{ 470{
471 if (!x->props.mode) 471 if (!x->props.mode)
472 return -EINVAL; 472 return -EINVAL;
diff --git a/net/key/af_key.c b/net/key/af_key.c
index 98b72f2024ff..4879743b945a 100644
--- a/net/key/af_key.c
+++ b/net/key/af_key.c
@@ -690,6 +690,8 @@ static struct sk_buff * pfkey_xfrm_state2msg(struct xfrm_state *x, int add_keys,
690 sa->sadb_sa_flags |= SADB_SAFLAGS_NOECN; 690 sa->sadb_sa_flags |= SADB_SAFLAGS_NOECN;
691 if (x->props.flags & XFRM_STATE_DECAP_DSCP) 691 if (x->props.flags & XFRM_STATE_DECAP_DSCP)
692 sa->sadb_sa_flags |= SADB_SAFLAGS_DECAP_DSCP; 692 sa->sadb_sa_flags |= SADB_SAFLAGS_DECAP_DSCP;
693 if (x->props.flags & XFRM_STATE_NOPMTUDISC)
694 sa->sadb_sa_flags |= SADB_SAFLAGS_NOPMTUDISC;
693 695
694 /* hard time */ 696 /* hard time */
695 if (hsc & 2) { 697 if (hsc & 2) {
@@ -974,6 +976,8 @@ static struct xfrm_state * pfkey_msg2xfrm_state(struct sadb_msg *hdr,
974 x->props.flags |= XFRM_STATE_NOECN; 976 x->props.flags |= XFRM_STATE_NOECN;
975 if (sa->sadb_sa_flags & SADB_SAFLAGS_DECAP_DSCP) 977 if (sa->sadb_sa_flags & SADB_SAFLAGS_DECAP_DSCP)
976 x->props.flags |= XFRM_STATE_DECAP_DSCP; 978 x->props.flags |= XFRM_STATE_DECAP_DSCP;
979 if (sa->sadb_sa_flags & SADB_SAFLAGS_NOPMTUDISC)
980 x->props.flags |= XFRM_STATE_NOPMTUDISC;
977 981
978 lifetime = (struct sadb_lifetime*) ext_hdrs[SADB_EXT_LIFETIME_HARD-1]; 982 lifetime = (struct sadb_lifetime*) ext_hdrs[SADB_EXT_LIFETIME_HARD-1];
979 if (lifetime != NULL) { 983 if (lifetime != NULL) {
@@ -1096,17 +1100,11 @@ static struct xfrm_state * pfkey_msg2xfrm_state(struct sadb_msg *hdr,
1096 } 1100 }
1097 } 1101 }
1098 1102
1099 x->type = xfrm_get_type(proto, x->props.family); 1103 err = xfrm_init_state(x);
1100 if (x->type == NULL) { 1104 if (err)
1101 err = -ENOPROTOOPT;
1102 goto out;
1103 }
1104 if (x->type->init_state(x, NULL)) {
1105 err = -EINVAL;
1106 goto out; 1105 goto out;
1107 } 1106
1108 x->km.seq = hdr->sadb_msg_seq; 1107 x->km.seq = hdr->sadb_msg_seq;
1109 x->km.state = XFRM_STATE_VALID;
1110 return x; 1108 return x;
1111 1109
1112out: 1110out:
diff --git a/net/sctp/associola.c b/net/sctp/associola.c
index 663843d97a92..7ae6aa772dab 100644
--- a/net/sctp/associola.c
+++ b/net/sctp/associola.c
@@ -191,10 +191,6 @@ static struct sctp_association *sctp_association_init(struct sctp_association *a
191 asoc->last_cwr_tsn = asoc->ctsn_ack_point; 191 asoc->last_cwr_tsn = asoc->ctsn_ack_point;
192 asoc->unack_data = 0; 192 asoc->unack_data = 0;
193 193
194 SCTP_DEBUG_PRINTK("myctsnap for %s INIT as 0x%x.\n",
195 asoc->ep->debug_name,
196 asoc->ctsn_ack_point);
197
198 /* ADDIP Section 4.1 Asconf Chunk Procedures 194 /* ADDIP Section 4.1 Asconf Chunk Procedures
199 * 195 *
200 * When an endpoint has an ASCONF signaled change to be sent to the 196 * When an endpoint has an ASCONF signaled change to be sent to the
@@ -211,6 +207,7 @@ static struct sctp_association *sctp_association_init(struct sctp_association *a
211 207
212 /* Make an empty list of remote transport addresses. */ 208 /* Make an empty list of remote transport addresses. */
213 INIT_LIST_HEAD(&asoc->peer.transport_addr_list); 209 INIT_LIST_HEAD(&asoc->peer.transport_addr_list);
210 asoc->peer.transport_count = 0;
214 211
215 /* RFC 2960 5.1 Normal Establishment of an Association 212 /* RFC 2960 5.1 Normal Establishment of an Association
216 * 213 *
@@ -288,6 +285,7 @@ struct sctp_association *sctp_association_new(const struct sctp_endpoint *ep,
288 285
289 asoc->base.malloced = 1; 286 asoc->base.malloced = 1;
290 SCTP_DBG_OBJCNT_INC(assoc); 287 SCTP_DBG_OBJCNT_INC(assoc);
288 SCTP_DEBUG_PRINTK("Created asoc %p\n", asoc);
291 289
292 return asoc; 290 return asoc;
293 291
@@ -356,6 +354,8 @@ void sctp_association_free(struct sctp_association *asoc)
356 sctp_transport_free(transport); 354 sctp_transport_free(transport);
357 } 355 }
358 356
357 asoc->peer.transport_count = 0;
358
359 /* Free any cached ASCONF_ACK chunk. */ 359 /* Free any cached ASCONF_ACK chunk. */
360 if (asoc->addip_last_asconf_ack) 360 if (asoc->addip_last_asconf_ack)
361 sctp_chunk_free(asoc->addip_last_asconf_ack); 361 sctp_chunk_free(asoc->addip_last_asconf_ack);
@@ -400,7 +400,7 @@ void sctp_assoc_set_primary(struct sctp_association *asoc,
400 /* If the primary path is changing, assume that the 400 /* If the primary path is changing, assume that the
401 * user wants to use this new path. 401 * user wants to use this new path.
402 */ 402 */
403 if (transport->active) 403 if (transport->state != SCTP_INACTIVE)
404 asoc->peer.active_path = transport; 404 asoc->peer.active_path = transport;
405 405
406 /* 406 /*
@@ -428,10 +428,58 @@ void sctp_assoc_set_primary(struct sctp_association *asoc,
428 transport->cacc.next_tsn_at_change = asoc->next_tsn; 428 transport->cacc.next_tsn_at_change = asoc->next_tsn;
429} 429}
430 430
431/* Remove a transport from an association. */
432void sctp_assoc_rm_peer(struct sctp_association *asoc,
433 struct sctp_transport *peer)
434{
435 struct list_head *pos;
436 struct sctp_transport *transport;
437
438 SCTP_DEBUG_PRINTK_IPADDR("sctp_assoc_rm_peer:association %p addr: ",
439 " port: %d\n",
440 asoc,
441 (&peer->ipaddr),
442 peer->ipaddr.v4.sin_port);
443
444 /* If we are to remove the current retran_path, update it
445 * to the next peer before removing this peer from the list.
446 */
447 if (asoc->peer.retran_path == peer)
448 sctp_assoc_update_retran_path(asoc);
449
450 /* Remove this peer from the list. */
451 list_del(&peer->transports);
452
453 /* Get the first transport of asoc. */
454 pos = asoc->peer.transport_addr_list.next;
455 transport = list_entry(pos, struct sctp_transport, transports);
456
457 /* Update any entries that match the peer to be deleted. */
458 if (asoc->peer.primary_path == peer)
459 sctp_assoc_set_primary(asoc, transport);
460 if (asoc->peer.active_path == peer)
461 asoc->peer.active_path = transport;
462 if (asoc->peer.last_data_from == peer)
463 asoc->peer.last_data_from = transport;
464
465 /* If we remove the transport an INIT was last sent to, set it to
466 * NULL. Combined with the update of the retran path above, this
467 * will cause the next INIT to be sent to the next available
468 * transport, maintaining the cycle.
469 */
470 if (asoc->init_last_sent_to == peer)
471 asoc->init_last_sent_to = NULL;
472
473 asoc->peer.transport_count--;
474
475 sctp_transport_free(peer);
476}
477
431/* Add a transport address to an association. */ 478/* Add a transport address to an association. */
432struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc, 479struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc,
433 const union sctp_addr *addr, 480 const union sctp_addr *addr,
434 int gfp) 481 const int gfp,
482 const int peer_state)
435{ 483{
436 struct sctp_transport *peer; 484 struct sctp_transport *peer;
437 struct sctp_sock *sp; 485 struct sctp_sock *sp;
@@ -442,14 +490,25 @@ struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc,
442 /* AF_INET and AF_INET6 share common port field. */ 490 /* AF_INET and AF_INET6 share common port field. */
443 port = addr->v4.sin_port; 491 port = addr->v4.sin_port;
444 492
493 SCTP_DEBUG_PRINTK_IPADDR("sctp_assoc_add_peer:association %p addr: ",
494 " port: %d state:%s\n",
495 asoc,
496 addr,
497 addr->v4.sin_port,
498 peer_state == SCTP_UNKNOWN?"UNKNOWN":"ACTIVE");
499
445 /* Set the port if it has not been set yet. */ 500 /* Set the port if it has not been set yet. */
446 if (0 == asoc->peer.port) 501 if (0 == asoc->peer.port)
447 asoc->peer.port = port; 502 asoc->peer.port = port;
448 503
449 /* Check to see if this is a duplicate. */ 504 /* Check to see if this is a duplicate. */
450 peer = sctp_assoc_lookup_paddr(asoc, addr); 505 peer = sctp_assoc_lookup_paddr(asoc, addr);
451 if (peer) 506 if (peer) {
507 if (peer_state == SCTP_ACTIVE &&
508 peer->state == SCTP_UNKNOWN)
509 peer->state = SCTP_ACTIVE;
452 return peer; 510 return peer;
511 }
453 512
454 peer = sctp_transport_new(addr, gfp); 513 peer = sctp_transport_new(addr, gfp);
455 if (!peer) 514 if (!peer)
@@ -516,8 +575,12 @@ struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc,
516 /* Set the transport's RTO.initial value */ 575 /* Set the transport's RTO.initial value */
517 peer->rto = asoc->rto_initial; 576 peer->rto = asoc->rto_initial;
518 577
578 /* Set the peer's active state. */
579 peer->state = peer_state;
580
519 /* Attach the remote transport to our asoc. */ 581 /* Attach the remote transport to our asoc. */
520 list_add_tail(&peer->transports, &asoc->peer.transport_addr_list); 582 list_add_tail(&peer->transports, &asoc->peer.transport_addr_list);
583 asoc->peer.transport_count++;
521 584
522 /* If we do not yet have a primary path, set one. */ 585 /* If we do not yet have a primary path, set one. */
523 if (!asoc->peer.primary_path) { 586 if (!asoc->peer.primary_path) {
@@ -525,8 +588,9 @@ struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc,
525 asoc->peer.retran_path = peer; 588 asoc->peer.retran_path = peer;
526 } 589 }
527 590
528 if (asoc->peer.active_path == asoc->peer.retran_path) 591 if (asoc->peer.active_path == asoc->peer.retran_path) {
529 asoc->peer.retran_path = peer; 592 asoc->peer.retran_path = peer;
593 }
530 594
531 return peer; 595 return peer;
532} 596}
@@ -537,37 +601,16 @@ void sctp_assoc_del_peer(struct sctp_association *asoc,
537{ 601{
538 struct list_head *pos; 602 struct list_head *pos;
539 struct list_head *temp; 603 struct list_head *temp;
540 struct sctp_transport *peer = NULL;
541 struct sctp_transport *transport; 604 struct sctp_transport *transport;
542 605
543 list_for_each_safe(pos, temp, &asoc->peer.transport_addr_list) { 606 list_for_each_safe(pos, temp, &asoc->peer.transport_addr_list) {
544 transport = list_entry(pos, struct sctp_transport, transports); 607 transport = list_entry(pos, struct sctp_transport, transports);
545 if (sctp_cmp_addr_exact(addr, &transport->ipaddr)) { 608 if (sctp_cmp_addr_exact(addr, &transport->ipaddr)) {
546 peer = transport; 609 /* Do book keeping for removing the peer and free it. */
547 list_del(pos); 610 sctp_assoc_rm_peer(asoc, transport);
548 break; 611 break;
549 } 612 }
550 } 613 }
551
552 /* The address we want delete is not in the association. */
553 if (!peer)
554 return;
555
556 /* Get the first transport of asoc. */
557 pos = asoc->peer.transport_addr_list.next;
558 transport = list_entry(pos, struct sctp_transport, transports);
559
560 /* Update any entries that match the peer to be deleted. */
561 if (asoc->peer.primary_path == peer)
562 sctp_assoc_set_primary(asoc, transport);
563 if (asoc->peer.active_path == peer)
564 asoc->peer.active_path = transport;
565 if (asoc->peer.retran_path == peer)
566 asoc->peer.retran_path = transport;
567 if (asoc->peer.last_data_from == peer)
568 asoc->peer.last_data_from = transport;
569
570 sctp_transport_free(peer);
571} 614}
572 615
573/* Lookup a transport by address. */ 616/* Lookup a transport by address. */
@@ -608,12 +651,12 @@ void sctp_assoc_control_transport(struct sctp_association *asoc,
608 /* Record the transition on the transport. */ 651 /* Record the transition on the transport. */
609 switch (command) { 652 switch (command) {
610 case SCTP_TRANSPORT_UP: 653 case SCTP_TRANSPORT_UP:
611 transport->active = SCTP_ACTIVE; 654 transport->state = SCTP_ACTIVE;
612 spc_state = SCTP_ADDR_AVAILABLE; 655 spc_state = SCTP_ADDR_AVAILABLE;
613 break; 656 break;
614 657
615 case SCTP_TRANSPORT_DOWN: 658 case SCTP_TRANSPORT_DOWN:
616 transport->active = SCTP_INACTIVE; 659 transport->state = SCTP_INACTIVE;
617 spc_state = SCTP_ADDR_UNREACHABLE; 660 spc_state = SCTP_ADDR_UNREACHABLE;
618 break; 661 break;
619 662
@@ -643,7 +686,7 @@ void sctp_assoc_control_transport(struct sctp_association *asoc,
643 list_for_each(pos, &asoc->peer.transport_addr_list) { 686 list_for_each(pos, &asoc->peer.transport_addr_list) {
644 t = list_entry(pos, struct sctp_transport, transports); 687 t = list_entry(pos, struct sctp_transport, transports);
645 688
646 if (!t->active) 689 if (t->state == SCTP_INACTIVE)
647 continue; 690 continue;
648 if (!first || t->last_time_heard > first->last_time_heard) { 691 if (!first || t->last_time_heard > first->last_time_heard) {
649 second = first; 692 second = first;
@@ -663,7 +706,7 @@ void sctp_assoc_control_transport(struct sctp_association *asoc,
663 * [If the primary is active but not most recent, bump the most 706 * [If the primary is active but not most recent, bump the most
664 * recently used transport.] 707 * recently used transport.]
665 */ 708 */
666 if (asoc->peer.primary_path->active && 709 if (asoc->peer.primary_path->state != SCTP_INACTIVE &&
667 first != asoc->peer.primary_path) { 710 first != asoc->peer.primary_path) {
668 second = first; 711 second = first;
669 first = asoc->peer.primary_path; 712 first = asoc->peer.primary_path;
@@ -958,7 +1001,7 @@ void sctp_assoc_update(struct sctp_association *asoc,
958 transports); 1001 transports);
959 if (!sctp_assoc_lookup_paddr(asoc, &trans->ipaddr)) 1002 if (!sctp_assoc_lookup_paddr(asoc, &trans->ipaddr))
960 sctp_assoc_add_peer(asoc, &trans->ipaddr, 1003 sctp_assoc_add_peer(asoc, &trans->ipaddr,
961 GFP_ATOMIC); 1004 GFP_ATOMIC, SCTP_ACTIVE);
962 } 1005 }
963 1006
964 asoc->ctsn_ack_point = asoc->next_tsn - 1; 1007 asoc->ctsn_ack_point = asoc->next_tsn - 1;
@@ -998,7 +1041,7 @@ void sctp_assoc_update_retran_path(struct sctp_association *asoc)
998 1041
999 /* Try to find an active transport. */ 1042 /* Try to find an active transport. */
1000 1043
1001 if (t->active) { 1044 if (t->state != SCTP_INACTIVE) {
1002 break; 1045 break;
1003 } else { 1046 } else {
1004 /* Keep track of the next transport in case 1047 /* Keep track of the next transport in case
@@ -1019,6 +1062,40 @@ void sctp_assoc_update_retran_path(struct sctp_association *asoc)
1019 } 1062 }
1020 1063
1021 asoc->peer.retran_path = t; 1064 asoc->peer.retran_path = t;
1065
1066 SCTP_DEBUG_PRINTK_IPADDR("sctp_assoc_update_retran_path:association"
1067 " %p addr: ",
1068 " port: %d\n",
1069 asoc,
1070 (&t->ipaddr),
1071 t->ipaddr.v4.sin_port);
1072}
1073
1074/* Choose the transport for sending a INIT packet. */
1075struct sctp_transport *sctp_assoc_choose_init_transport(
1076 struct sctp_association *asoc)
1077{
1078 struct sctp_transport *t;
1079
1080 /* Use the retran path. If the last INIT was sent over the
1081 * retran path, update the retran path and use it.
1082 */
1083 if (!asoc->init_last_sent_to) {
1084 t = asoc->peer.active_path;
1085 } else {
1086 if (asoc->init_last_sent_to == asoc->peer.retran_path)
1087 sctp_assoc_update_retran_path(asoc);
1088 t = asoc->peer.retran_path;
1089 }
1090
1091 SCTP_DEBUG_PRINTK_IPADDR("sctp_assoc_update_retran_path:association"
1092 " %p addr: ",
1093 " port: %d\n",
1094 asoc,
1095 (&t->ipaddr),
1096 t->ipaddr.v4.sin_port);
1097
1098 return t;
1022} 1099}
1023 1100
1024/* Choose the transport for sending a SHUTDOWN packet. */ 1101/* Choose the transport for sending a SHUTDOWN packet. */
diff --git a/net/sctp/endpointola.c b/net/sctp/endpointola.c
index 334f61773e6d..2ec0320fac3b 100644
--- a/net/sctp/endpointola.c
+++ b/net/sctp/endpointola.c
@@ -134,7 +134,6 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep,
134 ep->last_key = ep->current_key = 0; 134 ep->last_key = ep->current_key = 0;
135 ep->key_changed_at = jiffies; 135 ep->key_changed_at = jiffies;
136 136
137 ep->debug_name = "unnamedEndpoint";
138 return ep; 137 return ep;
139} 138}
140 139
diff --git a/net/sctp/input.c b/net/sctp/input.c
index fffc880a646d..339f7acfdb64 100644
--- a/net/sctp/input.c
+++ b/net/sctp/input.c
@@ -353,7 +353,7 @@ void sctp_icmp_proto_unreachable(struct sock *sk,
353 353
354 sctp_do_sm(SCTP_EVENT_T_OTHER, 354 sctp_do_sm(SCTP_EVENT_T_OTHER,
355 SCTP_ST_OTHER(SCTP_EVENT_ICMP_PROTO_UNREACH), 355 SCTP_ST_OTHER(SCTP_EVENT_ICMP_PROTO_UNREACH),
356 asoc->state, asoc->ep, asoc, NULL, 356 asoc->state, asoc->ep, asoc, t,
357 GFP_ATOMIC); 357 GFP_ATOMIC);
358 358
359} 359}
diff --git a/net/sctp/outqueue.c b/net/sctp/outqueue.c
index 1b2d4adc4ddb..4eb81a1407b7 100644
--- a/net/sctp/outqueue.c
+++ b/net/sctp/outqueue.c
@@ -682,9 +682,9 @@ int sctp_outq_flush(struct sctp_outq *q, int rtx_timeout)
682 682
683 if (!new_transport) { 683 if (!new_transport) {
684 new_transport = asoc->peer.active_path; 684 new_transport = asoc->peer.active_path;
685 } else if (!new_transport->active) { 685 } else if (new_transport->state == SCTP_INACTIVE) {
686 /* If the chunk is Heartbeat or Heartbeat Ack, 686 /* If the chunk is Heartbeat or Heartbeat Ack,
687 * send it to chunk->transport, even if it's 687 * send it to chunk->transport, even if it's
688 * inactive. 688 * inactive.
689 * 689 *
690 * 3.3.6 Heartbeat Acknowledgement: 690 * 3.3.6 Heartbeat Acknowledgement:
@@ -840,7 +840,8 @@ int sctp_outq_flush(struct sctp_outq *q, int rtx_timeout)
840 * Otherwise, we want to use the active path. 840 * Otherwise, we want to use the active path.
841 */ 841 */
842 new_transport = chunk->transport; 842 new_transport = chunk->transport;
843 if (!new_transport || !new_transport->active) 843 if (!new_transport ||
844 new_transport->state == SCTP_INACTIVE)
844 new_transport = asoc->peer.active_path; 845 new_transport = asoc->peer.active_path;
845 846
846 /* Change packets if necessary. */ 847 /* Change packets if necessary. */
@@ -1454,7 +1455,7 @@ static void sctp_check_transmitted(struct sctp_outq *q,
1454 /* Mark the destination transport address as 1455 /* Mark the destination transport address as
1455 * active if it is not so marked. 1456 * active if it is not so marked.
1456 */ 1457 */
1457 if (!transport->active) { 1458 if (transport->state == SCTP_INACTIVE) {
1458 sctp_assoc_control_transport( 1459 sctp_assoc_control_transport(
1459 transport->asoc, 1460 transport->asoc,
1460 transport, 1461 transport,
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
index 33ac8bf47b0e..5baed9bb7de5 100644
--- a/net/sctp/sm_make_chunk.c
+++ b/net/sctp/sm_make_chunk.c
@@ -1830,7 +1830,7 @@ int sctp_process_init(struct sctp_association *asoc, sctp_cid_t cid,
1830 * be a a better choice than any of the embedded addresses. 1830 * be a a better choice than any of the embedded addresses.
1831 */ 1831 */
1832 if (peer_addr) 1832 if (peer_addr)
1833 if(!sctp_assoc_add_peer(asoc, peer_addr, gfp)) 1833 if(!sctp_assoc_add_peer(asoc, peer_addr, gfp, SCTP_ACTIVE))
1834 goto nomem; 1834 goto nomem;
1835 1835
1836 /* Process the initialization parameters. */ 1836 /* Process the initialization parameters. */
@@ -1841,6 +1841,14 @@ int sctp_process_init(struct sctp_association *asoc, sctp_cid_t cid,
1841 goto clean_up; 1841 goto clean_up;
1842 } 1842 }
1843 1843
1844 /* Walk list of transports, removing transports in the UNKNOWN state. */
1845 list_for_each_safe(pos, temp, &asoc->peer.transport_addr_list) {
1846 transport = list_entry(pos, struct sctp_transport, transports);
1847 if (transport->state == SCTP_UNKNOWN) {
1848 sctp_assoc_rm_peer(asoc, transport);
1849 }
1850 }
1851
1844 /* The fixed INIT headers are always in network byte 1852 /* The fixed INIT headers are always in network byte
1845 * order. 1853 * order.
1846 */ 1854 */
@@ -1906,7 +1914,8 @@ int sctp_process_init(struct sctp_association *asoc, sctp_cid_t cid,
1906 * stream sequence number shall be set to 0. 1914 * stream sequence number shall be set to 0.
1907 */ 1915 */
1908 1916
1909 /* Allocate storage for the negotiated streams if it is not a temporary * association. 1917 /* Allocate storage for the negotiated streams if it is not a temporary
1918 * association.
1910 */ 1919 */
1911 if (!asoc->temp) { 1920 if (!asoc->temp) {
1912 int assoc_id; 1921 int assoc_id;
@@ -1952,6 +1961,9 @@ clean_up:
1952 list_del_init(pos); 1961 list_del_init(pos);
1953 sctp_transport_free(transport); 1962 sctp_transport_free(transport);
1954 } 1963 }
1964
1965 asoc->peer.transport_count = 0;
1966
1955nomem: 1967nomem:
1956 return 0; 1968 return 0;
1957} 1969}
@@ -1995,7 +2007,7 @@ static int sctp_process_param(struct sctp_association *asoc,
1995 af->from_addr_param(&addr, param.addr, asoc->peer.port, 0); 2007 af->from_addr_param(&addr, param.addr, asoc->peer.port, 0);
1996 scope = sctp_scope(peer_addr); 2008 scope = sctp_scope(peer_addr);
1997 if (sctp_in_scope(&addr, scope)) 2009 if (sctp_in_scope(&addr, scope))
1998 if (!sctp_assoc_add_peer(asoc, &addr, gfp)) 2010 if (!sctp_assoc_add_peer(asoc, &addr, gfp, SCTP_ACTIVE))
1999 return 0; 2011 return 0;
2000 break; 2012 break;
2001 2013
@@ -2396,7 +2408,7 @@ static __u16 sctp_process_asconf_param(struct sctp_association *asoc,
2396 * Due to Resource Shortage'. 2408 * Due to Resource Shortage'.
2397 */ 2409 */
2398 2410
2399 peer = sctp_assoc_add_peer(asoc, &addr, GFP_ATOMIC); 2411 peer = sctp_assoc_add_peer(asoc, &addr, GFP_ATOMIC, SCTP_ACTIVE);
2400 if (!peer) 2412 if (!peer)
2401 return SCTP_ERROR_RSRC_LOW; 2413 return SCTP_ERROR_RSRC_LOW;
2402 2414
diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
index f65fa441952f..778639db125a 100644
--- a/net/sctp/sm_sideeffect.c
+++ b/net/sctp/sm_sideeffect.c
@@ -414,11 +414,13 @@ static void sctp_do_8_2_transport_strike(struct sctp_association *asoc,
414 */ 414 */
415 asoc->overall_error_count++; 415 asoc->overall_error_count++;
416 416
417 if (transport->active && 417 if (transport->state != SCTP_INACTIVE &&
418 (transport->error_count++ >= transport->max_retrans)) { 418 (transport->error_count++ >= transport->max_retrans)) {
419 SCTP_DEBUG_PRINTK("transport_strike: transport " 419 SCTP_DEBUG_PRINTK_IPADDR("transport_strike:association %p",
420 "IP:%d.%d.%d.%d failed.\n", 420 " transport IP: port:%d failed.\n",
421 NIPQUAD(transport->ipaddr.v4.sin_addr)); 421 asoc,
422 (&transport->ipaddr),
423 transport->ipaddr.v4.sin_port);
422 sctp_assoc_control_transport(asoc, transport, 424 sctp_assoc_control_transport(asoc, transport,
423 SCTP_TRANSPORT_DOWN, 425 SCTP_TRANSPORT_DOWN,
424 SCTP_FAILED_THRESHOLD); 426 SCTP_FAILED_THRESHOLD);
@@ -593,7 +595,7 @@ static void sctp_cmd_transport_on(sctp_cmd_seq_t *cmds,
593 /* Mark the destination transport address as active if it is not so 595 /* Mark the destination transport address as active if it is not so
594 * marked. 596 * marked.
595 */ 597 */
596 if (!t->active) 598 if (t->state == SCTP_INACTIVE)
597 sctp_assoc_control_transport(asoc, t, SCTP_TRANSPORT_UP, 599 sctp_assoc_control_transport(asoc, t, SCTP_TRANSPORT_UP,
598 SCTP_HEARTBEAT_SUCCESS); 600 SCTP_HEARTBEAT_SUCCESS);
599 601
@@ -665,8 +667,11 @@ static void sctp_cmd_new_state(sctp_cmd_seq_t *cmds,
665 667
666 asoc->state = state; 668 asoc->state = state;
667 669
670 SCTP_DEBUG_PRINTK("sctp_cmd_new_state: asoc %p[%s]\n",
671 asoc, sctp_state_tbl[state]);
672
668 if (sctp_style(sk, TCP)) { 673 if (sctp_style(sk, TCP)) {
669 /* Change the sk->sk_state of a TCP-style socket that has 674 /* Change the sk->sk_state of a TCP-style socket that has
670 * sucessfully completed a connect() call. 675 * sucessfully completed a connect() call.
671 */ 676 */
672 if (sctp_state(asoc, ESTABLISHED) && sctp_sstate(sk, CLOSED)) 677 if (sctp_state(asoc, ESTABLISHED) && sctp_sstate(sk, CLOSED))
@@ -678,6 +683,16 @@ static void sctp_cmd_new_state(sctp_cmd_seq_t *cmds,
678 sk->sk_shutdown |= RCV_SHUTDOWN; 683 sk->sk_shutdown |= RCV_SHUTDOWN;
679 } 684 }
680 685
686 if (sctp_state(asoc, COOKIE_WAIT)) {
687 /* Reset init timeouts since they may have been
688 * increased due to timer expirations.
689 */
690 asoc->timeouts[SCTP_EVENT_TIMEOUT_T1_INIT] =
691 asoc->ep->timeouts[SCTP_EVENT_TIMEOUT_T1_INIT];
692 asoc->timeouts[SCTP_EVENT_TIMEOUT_T1_COOKIE] =
693 asoc->ep->timeouts[SCTP_EVENT_TIMEOUT_T1_COOKIE];
694 }
695
681 if (sctp_state(asoc, ESTABLISHED) || 696 if (sctp_state(asoc, ESTABLISHED) ||
682 sctp_state(asoc, CLOSED) || 697 sctp_state(asoc, CLOSED) ||
683 sctp_state(asoc, SHUTDOWN_RECEIVED)) { 698 sctp_state(asoc, SHUTDOWN_RECEIVED)) {
@@ -1120,10 +1135,10 @@ static int sctp_cmd_interpreter(sctp_event_t event_type,
1120 * to be executed only during failed attempts of 1135 * to be executed only during failed attempts of
1121 * association establishment. 1136 * association establishment.
1122 */ 1137 */
1123 if ((asoc->peer.retran_path != 1138 if ((asoc->peer.retran_path !=
1124 asoc->peer.primary_path) && 1139 asoc->peer.primary_path) &&
1125 (asoc->counters[SCTP_COUNTER_INIT_ERROR] > 0)) { 1140 (asoc->init_err_counter > 0)) {
1126 sctp_add_cmd_sf(commands, 1141 sctp_add_cmd_sf(commands,
1127 SCTP_CMD_FORCE_PRIM_RETRAN, 1142 SCTP_CMD_FORCE_PRIM_RETRAN,
1128 SCTP_NULL()); 1143 SCTP_NULL());
1129 } 1144 }
@@ -1237,18 +1252,67 @@ static int sctp_cmd_interpreter(sctp_event_t event_type,
1237 sctp_association_put(asoc); 1252 sctp_association_put(asoc);
1238 break; 1253 break;
1239 1254
1255 case SCTP_CMD_INIT_CHOOSE_TRANSPORT:
1256 chunk = cmd->obj.ptr;
1257 t = sctp_assoc_choose_init_transport(asoc);
1258 asoc->init_last_sent_to = t;
1259 chunk->transport = t;
1260 t->init_sent_count++;
1261 break;
1262
1240 case SCTP_CMD_INIT_RESTART: 1263 case SCTP_CMD_INIT_RESTART:
1241 /* Do the needed accounting and updates 1264 /* Do the needed accounting and updates
1242 * associated with restarting an initialization 1265 * associated with restarting an initialization
1243 * timer. 1266 * timer. Only multiply the timeout by two if
1267 * all transports have been tried at the current
1268 * timeout.
1269 */
1270 t = asoc->init_last_sent_to;
1271 asoc->init_err_counter++;
1272
1273 if (t->init_sent_count > (asoc->init_cycle + 1)) {
1274 asoc->timeouts[SCTP_EVENT_TIMEOUT_T1_INIT] *= 2;
1275 if (asoc->timeouts[SCTP_EVENT_TIMEOUT_T1_INIT] >
1276 asoc->max_init_timeo) {
1277 asoc->timeouts[SCTP_EVENT_TIMEOUT_T1_INIT] =
1278 asoc->max_init_timeo;
1279 }
1280 asoc->init_cycle++;
1281 SCTP_DEBUG_PRINTK(
1282 "T1 INIT Timeout adjustment"
1283 " init_err_counter: %d"
1284 " cycle: %d"
1285 " timeout: %d\n",
1286 asoc->init_err_counter,
1287 asoc->init_cycle,
1288 asoc->timeouts[SCTP_EVENT_TIMEOUT_T1_INIT]);
1289 }
1290
1291 sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_RESTART,
1292 SCTP_TO(SCTP_EVENT_TIMEOUT_T1_INIT));
1293 break;
1294
1295 case SCTP_CMD_COOKIEECHO_RESTART:
1296 /* Do the needed accounting and updates
1297 * associated with restarting an initialization
1298 * timer. Only multiply the timeout by two if
1299 * all transports have been tried at the current
1300 * timeout.
1244 */ 1301 */
1245 asoc->counters[SCTP_COUNTER_INIT_ERROR]++; 1302 asoc->init_err_counter++;
1246 asoc->timeouts[cmd->obj.to] *= 2; 1303
1247 if (asoc->timeouts[cmd->obj.to] > 1304 asoc->timeouts[SCTP_EVENT_TIMEOUT_T1_COOKIE] *= 2;
1305 if (asoc->timeouts[SCTP_EVENT_TIMEOUT_T1_COOKIE] >
1248 asoc->max_init_timeo) { 1306 asoc->max_init_timeo) {
1249 asoc->timeouts[cmd->obj.to] = 1307 asoc->timeouts[SCTP_EVENT_TIMEOUT_T1_COOKIE] =
1250 asoc->max_init_timeo; 1308 asoc->max_init_timeo;
1251 } 1309 }
1310 SCTP_DEBUG_PRINTK(
1311 "T1 COOKIE Timeout adjustment"
1312 " init_err_counter: %d"
1313 " timeout: %d\n",
1314 asoc->init_err_counter,
1315 asoc->timeouts[SCTP_EVENT_TIMEOUT_T1_COOKIE]);
1252 1316
1253 /* If we've sent any data bundled with 1317 /* If we've sent any data bundled with
1254 * COOKIE-ECHO we need to resend. 1318 * COOKIE-ECHO we need to resend.
@@ -1261,7 +1325,7 @@ static int sctp_cmd_interpreter(sctp_event_t event_type,
1261 1325
1262 sctp_add_cmd_sf(commands, 1326 sctp_add_cmd_sf(commands,
1263 SCTP_CMD_TIMER_RESTART, 1327 SCTP_CMD_TIMER_RESTART,
1264 SCTP_TO(cmd->obj.to)); 1328 SCTP_TO(SCTP_EVENT_TIMEOUT_T1_COOKIE));
1265 break; 1329 break;
1266 1330
1267 case SCTP_CMD_INIT_FAILED: 1331 case SCTP_CMD_INIT_FAILED:
@@ -1273,12 +1337,13 @@ static int sctp_cmd_interpreter(sctp_event_t event_type,
1273 subtype, chunk, cmd->obj.u32); 1337 subtype, chunk, cmd->obj.u32);
1274 break; 1338 break;
1275 1339
1276 case SCTP_CMD_COUNTER_INC: 1340 case SCTP_CMD_INIT_COUNTER_INC:
1277 asoc->counters[cmd->obj.counter]++; 1341 asoc->init_err_counter++;
1278 break; 1342 break;
1279 1343
1280 case SCTP_CMD_COUNTER_RESET: 1344 case SCTP_CMD_INIT_COUNTER_RESET:
1281 asoc->counters[cmd->obj.counter] = 0; 1345 asoc->init_err_counter = 0;
1346 asoc->init_cycle = 0;
1282 break; 1347 break;
1283 1348
1284 case SCTP_CMD_REPORT_DUP: 1349 case SCTP_CMD_REPORT_DUP:
diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
index 8e01b8f09ac2..058189684c7c 100644
--- a/net/sctp/sm_statefuns.c
+++ b/net/sctp/sm_statefuns.c
@@ -533,6 +533,9 @@ sctp_disposition_t sctp_sf_do_5_1C_ack(const struct sctp_endpoint *ep,
533 sctp_add_cmd_sf(commands, SCTP_CMD_PEER_INIT, 533 sctp_add_cmd_sf(commands, SCTP_CMD_PEER_INIT,
534 SCTP_PEER_INIT(initchunk)); 534 SCTP_PEER_INIT(initchunk));
535 535
536 /* Reset init error count upon receipt of INIT-ACK. */
537 sctp_add_cmd_sf(commands, SCTP_CMD_INIT_COUNTER_RESET, SCTP_NULL());
538
536 /* 5.1 C) "A" shall stop the T1-init timer and leave 539 /* 5.1 C) "A" shall stop the T1-init timer and leave
537 * COOKIE-WAIT state. "A" shall then ... start the T1-cookie 540 * COOKIE-WAIT state. "A" shall then ... start the T1-cookie
538 * timer, and enter the COOKIE-ECHOED state. 541 * timer, and enter the COOKIE-ECHOED state.
@@ -775,8 +778,7 @@ sctp_disposition_t sctp_sf_do_5_1E_ca(const struct sctp_endpoint *ep,
775 * from the COOKIE-ECHOED state to the COOKIE-WAIT 778 * from the COOKIE-ECHOED state to the COOKIE-WAIT
776 * state is performed. 779 * state is performed.
777 */ 780 */
778 sctp_add_cmd_sf(commands, SCTP_CMD_COUNTER_RESET, 781 sctp_add_cmd_sf(commands, SCTP_CMD_INIT_COUNTER_RESET, SCTP_NULL());
779 SCTP_COUNTER(SCTP_COUNTER_INIT_ERROR));
780 782
781 /* RFC 2960 5.1 Normal Establishment of an Association 783 /* RFC 2960 5.1 Normal Establishment of an Association
782 * 784 *
@@ -1019,10 +1021,22 @@ sctp_disposition_t sctp_sf_backbeat_8_3(const struct sctp_endpoint *ep,
1019 link = sctp_assoc_lookup_paddr(asoc, &from_addr); 1021 link = sctp_assoc_lookup_paddr(asoc, &from_addr);
1020 1022
1021 /* This should never happen, but lets log it if so. */ 1023 /* This should never happen, but lets log it if so. */
1022 if (!link) { 1024 if (unlikely(!link)) {
1023 printk(KERN_WARNING 1025 if (from_addr.sa.sa_family == AF_INET6) {
1024 "%s: Could not find address %d.%d.%d.%d\n", 1026 printk(KERN_WARNING
1025 __FUNCTION__, NIPQUAD(from_addr.v4.sin_addr)); 1027 "%s association %p could not find address "
1028 "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n",
1029 __FUNCTION__,
1030 asoc,
1031 NIP6(from_addr.v6.sin6_addr));
1032 } else {
1033 printk(KERN_WARNING
1034 "%s association %p could not find address "
1035 "%u.%u.%u.%u\n",
1036 __FUNCTION__,
1037 asoc,
1038 NIPQUAD(from_addr.v4.sin_addr.s_addr));
1039 }
1026 return SCTP_DISPOSITION_DISCARD; 1040 return SCTP_DISPOSITION_DISCARD;
1027 } 1041 }
1028 1042
@@ -2095,9 +2109,7 @@ static sctp_disposition_t sctp_sf_do_5_2_6_stale(const struct sctp_endpoint *ep,
2095 sctp_errhdr_t *err; 2109 sctp_errhdr_t *err;
2096 struct sctp_chunk *reply; 2110 struct sctp_chunk *reply;
2097 struct sctp_bind_addr *bp; 2111 struct sctp_bind_addr *bp;
2098 int attempts; 2112 int attempts = asoc->init_err_counter + 1;
2099
2100 attempts = asoc->counters[SCTP_COUNTER_INIT_ERROR] + 1;
2101 2113
2102 if (attempts >= asoc->max_init_attempts) { 2114 if (attempts >= asoc->max_init_attempts) {
2103 sctp_add_cmd_sf(commands, SCTP_CMD_INIT_FAILED, 2115 sctp_add_cmd_sf(commands, SCTP_CMD_INIT_FAILED,
@@ -2157,8 +2169,7 @@ static sctp_disposition_t sctp_sf_do_5_2_6_stale(const struct sctp_endpoint *ep,
2157 /* Cast away the const modifier, as we want to just 2169 /* Cast away the const modifier, as we want to just
2158 * rerun it through as a sideffect. 2170 * rerun it through as a sideffect.
2159 */ 2171 */
2160 sctp_add_cmd_sf(commands, SCTP_CMD_COUNTER_INC, 2172 sctp_add_cmd_sf(commands, SCTP_CMD_INIT_COUNTER_INC, SCTP_NULL());
2161 SCTP_COUNTER(SCTP_COUNTER_INIT_ERROR));
2162 2173
2163 sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP, 2174 sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP,
2164 SCTP_TO(SCTP_EVENT_TIMEOUT_T1_COOKIE)); 2175 SCTP_TO(SCTP_EVENT_TIMEOUT_T1_COOKIE));
@@ -2281,8 +2292,7 @@ sctp_disposition_t sctp_sf_cookie_wait_abort(const struct sctp_endpoint *ep,
2281 if (len >= sizeof(struct sctp_chunkhdr) + sizeof(struct sctp_errhdr)) 2292 if (len >= sizeof(struct sctp_chunkhdr) + sizeof(struct sctp_errhdr))
2282 error = ((sctp_errhdr_t *)chunk->skb->data)->cause; 2293 error = ((sctp_errhdr_t *)chunk->skb->data)->cause;
2283 2294
2284 sctp_stop_t1_and_abort(commands, error); 2295 return sctp_stop_t1_and_abort(commands, error, asoc, chunk->transport);
2285 return SCTP_DISPOSITION_ABORT;
2286} 2296}
2287 2297
2288/* 2298/*
@@ -2294,8 +2304,8 @@ sctp_disposition_t sctp_sf_cookie_wait_icmp_abort(const struct sctp_endpoint *ep
2294 void *arg, 2304 void *arg,
2295 sctp_cmd_seq_t *commands) 2305 sctp_cmd_seq_t *commands)
2296{ 2306{
2297 sctp_stop_t1_and_abort(commands, SCTP_ERROR_NO_ERROR); 2307 return sctp_stop_t1_and_abort(commands, SCTP_ERROR_NO_ERROR, asoc,
2298 return SCTP_DISPOSITION_ABORT; 2308 (struct sctp_transport *)arg);
2299} 2309}
2300 2310
2301/* 2311/*
@@ -2318,8 +2328,12 @@ sctp_disposition_t sctp_sf_cookie_echoed_abort(const struct sctp_endpoint *ep,
2318 * 2328 *
2319 * This is common code called by several sctp_sf_*_abort() functions above. 2329 * This is common code called by several sctp_sf_*_abort() functions above.
2320 */ 2330 */
2321void sctp_stop_t1_and_abort(sctp_cmd_seq_t *commands, __u16 error) 2331sctp_disposition_t sctp_stop_t1_and_abort(sctp_cmd_seq_t *commands,
2332 __u16 error,
2333 const struct sctp_association *asoc,
2334 struct sctp_transport *transport)
2322{ 2335{
2336 SCTP_DEBUG_PRINTK("ABORT received (INIT).\n");
2323 sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, 2337 sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE,
2324 SCTP_STATE(SCTP_STATE_CLOSED)); 2338 SCTP_STATE(SCTP_STATE_CLOSED));
2325 SCTP_INC_STATS(SCTP_MIB_ABORTEDS); 2339 SCTP_INC_STATS(SCTP_MIB_ABORTEDS);
@@ -2328,6 +2342,7 @@ void sctp_stop_t1_and_abort(sctp_cmd_seq_t *commands, __u16 error)
2328 /* CMD_INIT_FAILED will DELETE_TCB. */ 2342 /* CMD_INIT_FAILED will DELETE_TCB. */
2329 sctp_add_cmd_sf(commands, SCTP_CMD_INIT_FAILED, 2343 sctp_add_cmd_sf(commands, SCTP_CMD_INIT_FAILED,
2330 SCTP_U32(error)); 2344 SCTP_U32(error));
2345 return SCTP_DISPOSITION_ABORT;
2331} 2346}
2332 2347
2333/* 2348/*
@@ -3805,6 +3820,10 @@ sctp_disposition_t sctp_sf_do_prm_asoc(const struct sctp_endpoint *ep,
3805 sctp_add_cmd_sf(commands, SCTP_CMD_NEW_ASOC, 3820 sctp_add_cmd_sf(commands, SCTP_CMD_NEW_ASOC,
3806 SCTP_ASOC((struct sctp_association *) asoc)); 3821 SCTP_ASOC((struct sctp_association *) asoc));
3807 3822
3823 /* Choose transport for INIT. */
3824 sctp_add_cmd_sf(commands, SCTP_CMD_INIT_CHOOSE_TRANSPORT,
3825 SCTP_CHUNK(repl));
3826
3808 /* After sending the INIT, "A" starts the T1-init timer and 3827 /* After sending the INIT, "A" starts the T1-init timer and
3809 * enters the COOKIE-WAIT state. 3828 * enters the COOKIE-WAIT state.
3810 */ 3829 */
@@ -4589,7 +4608,7 @@ sctp_disposition_t sctp_sf_do_6_2_sack(const struct sctp_endpoint *ep,
4589} 4608}
4590 4609
4591/* 4610/*
4592 * sctp_sf_t1_timer_expire 4611 * sctp_sf_t1_init_timer_expire
4593 * 4612 *
4594 * Section: 4 Note: 2 4613 * Section: 4 Note: 2
4595 * Verification Tag: 4614 * Verification Tag:
@@ -4603,7 +4622,59 @@ sctp_disposition_t sctp_sf_do_6_2_sack(const struct sctp_endpoint *ep,
4603 * endpoint MUST abort the initialization process and report the 4622 * endpoint MUST abort the initialization process and report the
4604 * error to SCTP user. 4623 * error to SCTP user.
4605 * 4624 *
4606 * 3) If the T1-cookie timer expires, the endpoint MUST retransmit 4625 * Outputs
4626 * (timers, events)
4627 *
4628 */
4629sctp_disposition_t sctp_sf_t1_init_timer_expire(const struct sctp_endpoint *ep,
4630 const struct sctp_association *asoc,
4631 const sctp_subtype_t type,
4632 void *arg,
4633 sctp_cmd_seq_t *commands)
4634{
4635 struct sctp_chunk *repl = NULL;
4636 struct sctp_bind_addr *bp;
4637 int attempts = asoc->init_err_counter + 1;
4638
4639 SCTP_DEBUG_PRINTK("Timer T1 expired (INIT).\n");
4640
4641 if (attempts < asoc->max_init_attempts) {
4642 bp = (struct sctp_bind_addr *) &asoc->base.bind_addr;
4643 repl = sctp_make_init(asoc, bp, GFP_ATOMIC, 0);
4644 if (!repl)
4645 return SCTP_DISPOSITION_NOMEM;
4646
4647 /* Choose transport for INIT. */
4648 sctp_add_cmd_sf(commands, SCTP_CMD_INIT_CHOOSE_TRANSPORT,
4649 SCTP_CHUNK(repl));
4650
4651 /* Issue a sideeffect to do the needed accounting. */
4652 sctp_add_cmd_sf(commands, SCTP_CMD_INIT_RESTART,
4653 SCTP_TO(SCTP_EVENT_TIMEOUT_T1_INIT));
4654
4655 sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(repl));
4656 } else {
4657 SCTP_DEBUG_PRINTK("Giving up on INIT, attempts: %d"
4658 " max_init_attempts: %d\n",
4659 attempts, asoc->max_init_attempts);
4660 sctp_add_cmd_sf(commands, SCTP_CMD_INIT_FAILED,
4661 SCTP_U32(SCTP_ERROR_NO_ERROR));
4662 return SCTP_DISPOSITION_DELETE_TCB;
4663 }
4664
4665 return SCTP_DISPOSITION_CONSUME;
4666}
4667
4668/*
4669 * sctp_sf_t1_cookie_timer_expire
4670 *
4671 * Section: 4 Note: 2
4672 * Verification Tag:
4673 * Inputs
4674 * (endpoint, asoc)
4675 *
4676 * RFC 2960 Section 4 Notes
4677 * 3) If the T1-cookie timer expires, the endpoint MUST retransmit
4607 * COOKIE ECHO and re-start the T1-cookie timer without changing 4678 * COOKIE ECHO and re-start the T1-cookie timer without changing
4608 * state. This MUST be repeated up to 'Max.Init.Retransmits' times. 4679 * state. This MUST be repeated up to 'Max.Init.Retransmits' times.
4609 * After that, the endpoint MUST abort the initialization process and 4680 * After that, the endpoint MUST abort the initialization process and
@@ -4613,46 +4684,26 @@ sctp_disposition_t sctp_sf_do_6_2_sack(const struct sctp_endpoint *ep,
4613 * (timers, events) 4684 * (timers, events)
4614 * 4685 *
4615 */ 4686 */
4616sctp_disposition_t sctp_sf_t1_timer_expire(const struct sctp_endpoint *ep, 4687sctp_disposition_t sctp_sf_t1_cookie_timer_expire(const struct sctp_endpoint *ep,
4617 const struct sctp_association *asoc, 4688 const struct sctp_association *asoc,
4618 const sctp_subtype_t type, 4689 const sctp_subtype_t type,
4619 void *arg, 4690 void *arg,
4620 sctp_cmd_seq_t *commands) 4691 sctp_cmd_seq_t *commands)
4621{ 4692{
4622 struct sctp_chunk *repl; 4693 struct sctp_chunk *repl = NULL;
4623 struct sctp_bind_addr *bp; 4694 int attempts = asoc->init_err_counter + 1;
4624 sctp_event_timeout_t timer = (sctp_event_timeout_t) arg;
4625 int timeout;
4626 int attempts;
4627
4628 timeout = asoc->timeouts[timer];
4629 attempts = asoc->counters[SCTP_COUNTER_INIT_ERROR] + 1;
4630 repl = NULL;
4631 4695
4632 SCTP_DEBUG_PRINTK("Timer T1 expired.\n"); 4696 SCTP_DEBUG_PRINTK("Timer T1 expired (COOKIE-ECHO).\n");
4633 4697
4634 if (attempts < asoc->max_init_attempts) { 4698 if (attempts < asoc->max_init_attempts) {
4635 switch (timer) { 4699 repl = sctp_make_cookie_echo(asoc, NULL);
4636 case SCTP_EVENT_TIMEOUT_T1_INIT:
4637 bp = (struct sctp_bind_addr *) &asoc->base.bind_addr;
4638 repl = sctp_make_init(asoc, bp, GFP_ATOMIC, 0);
4639 break;
4640
4641 case SCTP_EVENT_TIMEOUT_T1_COOKIE:
4642 repl = sctp_make_cookie_echo(asoc, NULL);
4643 break;
4644
4645 default:
4646 BUG();
4647 break;
4648 };
4649
4650 if (!repl) 4700 if (!repl)
4651 goto nomem; 4701 return SCTP_DISPOSITION_NOMEM;
4652 4702
4653 /* Issue a sideeffect to do the needed accounting. */ 4703 /* Issue a sideeffect to do the needed accounting. */
4654 sctp_add_cmd_sf(commands, SCTP_CMD_INIT_RESTART, 4704 sctp_add_cmd_sf(commands, SCTP_CMD_COOKIEECHO_RESTART,
4655 SCTP_TO(timer)); 4705 SCTP_TO(SCTP_EVENT_TIMEOUT_T1_COOKIE));
4706
4656 sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(repl)); 4707 sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(repl));
4657 } else { 4708 } else {
4658 sctp_add_cmd_sf(commands, SCTP_CMD_INIT_FAILED, 4709 sctp_add_cmd_sf(commands, SCTP_CMD_INIT_FAILED,
@@ -4661,9 +4712,6 @@ sctp_disposition_t sctp_sf_t1_timer_expire(const struct sctp_endpoint *ep,
4661 } 4712 }
4662 4713
4663 return SCTP_DISPOSITION_CONSUME; 4714 return SCTP_DISPOSITION_CONSUME;
4664
4665nomem:
4666 return SCTP_DISPOSITION_NOMEM;
4667} 4715}
4668 4716
4669/* RFC2960 9.2 If the timer expires, the endpoint must re-send the SHUTDOWN 4717/* RFC2960 9.2 If the timer expires, the endpoint must re-send the SHUTDOWN
diff --git a/net/sctp/sm_statetable.c b/net/sctp/sm_statetable.c
index 8967846f69e8..75ef10408764 100644
--- a/net/sctp/sm_statetable.c
+++ b/net/sctp/sm_statetable.c
@@ -783,7 +783,8 @@ static const sctp_sm_table_entry_t other_event_table[SCTP_NUM_OTHER_TYPES][SCTP_
783 /* SCTP_STATE_COOKIE_WAIT */ \ 783 /* SCTP_STATE_COOKIE_WAIT */ \
784 {.fn = sctp_sf_bug, .name = "sctp_sf_bug"}, \ 784 {.fn = sctp_sf_bug, .name = "sctp_sf_bug"}, \
785 /* SCTP_STATE_COOKIE_ECHOED */ \ 785 /* SCTP_STATE_COOKIE_ECHOED */ \
786 {.fn = sctp_sf_t1_timer_expire, .name = "sctp_sf_t1_timer_expire"}, \ 786 {.fn = sctp_sf_t1_cookie_timer_expire, \
787 .name = "sctp_sf_t1_cookie_timer_expire"}, \
787 /* SCTP_STATE_ESTABLISHED */ \ 788 /* SCTP_STATE_ESTABLISHED */ \
788 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 789 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \
789 /* SCTP_STATE_SHUTDOWN_PENDING */ \ 790 /* SCTP_STATE_SHUTDOWN_PENDING */ \
@@ -802,7 +803,8 @@ static const sctp_sm_table_entry_t other_event_table[SCTP_NUM_OTHER_TYPES][SCTP_
802 /* SCTP_STATE_CLOSED */ \ 803 /* SCTP_STATE_CLOSED */ \
803 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 804 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \
804 /* SCTP_STATE_COOKIE_WAIT */ \ 805 /* SCTP_STATE_COOKIE_WAIT */ \
805 {.fn = sctp_sf_t1_timer_expire, .name = "sctp_sf_t1_timer_expire"}, \ 806 {.fn = sctp_sf_t1_init_timer_expire, \
807 .name = "sctp_sf_t1_init_timer_expire"}, \
806 /* SCTP_STATE_COOKIE_ECHOED */ \ 808 /* SCTP_STATE_COOKIE_ECHOED */ \
807 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 809 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \
808 /* SCTP_STATE_ESTABLISHED */ \ 810 /* SCTP_STATE_ESTABLISHED */ \
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index e6926cb19420..aad55dc3792b 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -262,18 +262,18 @@ static struct sctp_transport *sctp_addr_id2transport(struct sock *sk,
262 * sockaddr_in6 [RFC 2553]), 262 * sockaddr_in6 [RFC 2553]),
263 * addr_len - the size of the address structure. 263 * addr_len - the size of the address structure.
264 */ 264 */
265SCTP_STATIC int sctp_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len) 265SCTP_STATIC int sctp_bind(struct sock *sk, struct sockaddr *addr, int addr_len)
266{ 266{
267 int retval = 0; 267 int retval = 0;
268 268
269 sctp_lock_sock(sk); 269 sctp_lock_sock(sk);
270 270
271 SCTP_DEBUG_PRINTK("sctp_bind(sk: %p, uaddr: %p, addr_len: %d)\n", 271 SCTP_DEBUG_PRINTK("sctp_bind(sk: %p, addr: %p, addr_len: %d)\n",
272 sk, uaddr, addr_len); 272 sk, addr, addr_len);
273 273
274 /* Disallow binding twice. */ 274 /* Disallow binding twice. */
275 if (!sctp_sk(sk)->ep->base.bind_addr.port) 275 if (!sctp_sk(sk)->ep->base.bind_addr.port)
276 retval = sctp_do_bind(sk, (union sctp_addr *)uaddr, 276 retval = sctp_do_bind(sk, (union sctp_addr *)addr,
277 addr_len); 277 addr_len);
278 else 278 else
279 retval = -EINVAL; 279 retval = -EINVAL;
@@ -318,23 +318,27 @@ SCTP_STATIC int sctp_do_bind(struct sock *sk, union sctp_addr *addr, int len)
318 unsigned short snum; 318 unsigned short snum;
319 int ret = 0; 319 int ret = 0;
320 320
321 SCTP_DEBUG_PRINTK("sctp_do_bind(sk: %p, newaddr: %p, len: %d)\n",
322 sk, addr, len);
323
324 /* Common sockaddr verification. */ 321 /* Common sockaddr verification. */
325 af = sctp_sockaddr_af(sp, addr, len); 322 af = sctp_sockaddr_af(sp, addr, len);
326 if (!af) 323 if (!af) {
324 SCTP_DEBUG_PRINTK("sctp_do_bind(sk: %p, newaddr: %p, len: %d) EINVAL\n",
325 sk, addr, len);
327 return -EINVAL; 326 return -EINVAL;
327 }
328
329 snum = ntohs(addr->v4.sin_port);
330
331 SCTP_DEBUG_PRINTK_IPADDR("sctp_do_bind(sk: %p, new addr: ",
332 ", port: %d, new port: %d, len: %d)\n",
333 sk,
334 addr,
335 bp->port, snum,
336 len);
328 337
329 /* PF specific bind() address verification. */ 338 /* PF specific bind() address verification. */
330 if (!sp->pf->bind_verify(sp, addr)) 339 if (!sp->pf->bind_verify(sp, addr))
331 return -EADDRNOTAVAIL; 340 return -EADDRNOTAVAIL;
332 341
333 snum= ntohs(addr->v4.sin_port);
334
335 SCTP_DEBUG_PRINTK("sctp_do_bind: port: %d, new port: %d\n",
336 bp->port, snum);
337
338 /* We must either be unbound, or bind to the same port. */ 342 /* We must either be unbound, or bind to the same port. */
339 if (bp->port && (snum != bp->port)) { 343 if (bp->port && (snum != bp->port)) {
340 SCTP_DEBUG_PRINTK("sctp_do_bind:" 344 SCTP_DEBUG_PRINTK("sctp_do_bind:"
@@ -816,7 +820,8 @@ out:
816 * 820 *
817 * Basically do nothing but copying the addresses from user to kernel 821 * Basically do nothing but copying the addresses from user to kernel
818 * land and invoking either sctp_bindx_add() or sctp_bindx_rem() on the sk. 822 * land and invoking either sctp_bindx_add() or sctp_bindx_rem() on the sk.
819 * This is used for tunneling the sctp_bindx() request through sctp_setsockopt() * from userspace. 823 * This is used for tunneling the sctp_bindx() request through sctp_setsockopt()
824 * from userspace.
820 * 825 *
821 * We don't use copy_from_user() for optimization: we first do the 826 * We don't use copy_from_user() for optimization: we first do the
822 * sanity checks (buffer size -fast- and access check-healthy 827 * sanity checks (buffer size -fast- and access check-healthy
@@ -913,6 +918,243 @@ out:
913 return err; 918 return err;
914} 919}
915 920
921/* __sctp_connect(struct sock* sk, struct sockaddr *kaddrs, int addrs_size)
922 *
923 * Common routine for handling connect() and sctp_connectx().
924 * Connect will come in with just a single address.
925 */
926static int __sctp_connect(struct sock* sk,
927 struct sockaddr *kaddrs,
928 int addrs_size)
929{
930 struct sctp_sock *sp;
931 struct sctp_endpoint *ep;
932 struct sctp_association *asoc = NULL;
933 struct sctp_association *asoc2;
934 struct sctp_transport *transport;
935 union sctp_addr to;
936 struct sctp_af *af;
937 sctp_scope_t scope;
938 long timeo;
939 int err = 0;
940 int addrcnt = 0;
941 int walk_size = 0;
942 struct sockaddr *sa_addr;
943 void *addr_buf;
944
945 sp = sctp_sk(sk);
946 ep = sp->ep;
947
948 /* connect() cannot be done on a socket that is already in ESTABLISHED
949 * state - UDP-style peeled off socket or a TCP-style socket that
950 * is already connected.
951 * It cannot be done even on a TCP-style listening socket.
952 */
953 if (sctp_sstate(sk, ESTABLISHED) ||
954 (sctp_style(sk, TCP) && sctp_sstate(sk, LISTENING))) {
955 err = -EISCONN;
956 goto out_free;
957 }
958
959 /* Walk through the addrs buffer and count the number of addresses. */
960 addr_buf = kaddrs;
961 while (walk_size < addrs_size) {
962 sa_addr = (struct sockaddr *)addr_buf;
963 af = sctp_get_af_specific(sa_addr->sa_family);
964
965 /* If the address family is not supported or if this address
966 * causes the address buffer to overflow return EINVAL.
967 */
968 if (!af || (walk_size + af->sockaddr_len) > addrs_size) {
969 err = -EINVAL;
970 goto out_free;
971 }
972
973 err = sctp_verify_addr(sk, (union sctp_addr *)sa_addr,
974 af->sockaddr_len);
975 if (err)
976 goto out_free;
977
978 memcpy(&to, sa_addr, af->sockaddr_len);
979 to.v4.sin_port = ntohs(to.v4.sin_port);
980
981 /* Check if there already is a matching association on the
982 * endpoint (other than the one created here).
983 */
984 asoc2 = sctp_endpoint_lookup_assoc(ep, &to, &transport);
985 if (asoc2 && asoc2 != asoc) {
986 if (asoc2->state >= SCTP_STATE_ESTABLISHED)
987 err = -EISCONN;
988 else
989 err = -EALREADY;
990 goto out_free;
991 }
992
993 /* If we could not find a matching association on the endpoint,
994 * make sure that there is no peeled-off association matching
995 * the peer address even on another socket.
996 */
997 if (sctp_endpoint_is_peeled_off(ep, &to)) {
998 err = -EADDRNOTAVAIL;
999 goto out_free;
1000 }
1001
1002 if (!asoc) {
1003 /* If a bind() or sctp_bindx() is not called prior to
1004 * an sctp_connectx() call, the system picks an
1005 * ephemeral port and will choose an address set
1006 * equivalent to binding with a wildcard address.
1007 */
1008 if (!ep->base.bind_addr.port) {
1009 if (sctp_autobind(sk)) {
1010 err = -EAGAIN;
1011 goto out_free;
1012 }
1013 }
1014
1015 scope = sctp_scope(&to);
1016 asoc = sctp_association_new(ep, sk, scope, GFP_KERNEL);
1017 if (!asoc) {
1018 err = -ENOMEM;
1019 goto out_free;
1020 }
1021 }
1022
1023 /* Prime the peer's transport structures. */
1024 transport = sctp_assoc_add_peer(asoc, &to, GFP_KERNEL,
1025 SCTP_UNKNOWN);
1026 if (!transport) {
1027 err = -ENOMEM;
1028 goto out_free;
1029 }
1030
1031 addrcnt++;
1032 addr_buf += af->sockaddr_len;
1033 walk_size += af->sockaddr_len;
1034 }
1035
1036 err = sctp_assoc_set_bind_addr_from_ep(asoc, GFP_KERNEL);
1037 if (err < 0) {
1038 goto out_free;
1039 }
1040
1041 err = sctp_primitive_ASSOCIATE(asoc, NULL);
1042 if (err < 0) {
1043 goto out_free;
1044 }
1045
1046 /* Initialize sk's dport and daddr for getpeername() */
1047 inet_sk(sk)->dport = htons(asoc->peer.port);
1048 af = sctp_get_af_specific(to.sa.sa_family);
1049 af->to_sk_daddr(&to, sk);
1050
1051 timeo = sock_sndtimeo(sk, sk->sk_socket->file->f_flags & O_NONBLOCK);
1052 err = sctp_wait_for_connect(asoc, &timeo);
1053
1054 /* Don't free association on exit. */
1055 asoc = NULL;
1056
1057out_free:
1058
1059 SCTP_DEBUG_PRINTK("About to exit __sctp_connect() free asoc: %p"
1060 " kaddrs: %p err: %d\n",
1061 asoc, kaddrs, err);
1062 if (asoc)
1063 sctp_association_free(asoc);
1064 return err;
1065}
1066
1067/* Helper for tunneling sctp_connectx() requests through sctp_setsockopt()
1068 *
1069 * API 8.9
1070 * int sctp_connectx(int sd, struct sockaddr *addrs, int addrcnt);
1071 *
1072 * If sd is an IPv4 socket, the addresses passed must be IPv4 addresses.
1073 * If the sd is an IPv6 socket, the addresses passed can either be IPv4
1074 * or IPv6 addresses.
1075 *
1076 * A single address may be specified as INADDR_ANY or IN6ADDR_ANY, see
1077 * Section 3.1.2 for this usage.
1078 *
1079 * addrs is a pointer to an array of one or more socket addresses. Each
1080 * address is contained in its appropriate structure (i.e. struct
1081 * sockaddr_in or struct sockaddr_in6) the family of the address type
1082 * must be used to distengish the address length (note that this
1083 * representation is termed a "packed array" of addresses). The caller
1084 * specifies the number of addresses in the array with addrcnt.
1085 *
1086 * On success, sctp_connectx() returns 0. On failure, sctp_connectx() returns
1087 * -1, and sets errno to the appropriate error code.
1088 *
1089 * For SCTP, the port given in each socket address must be the same, or
1090 * sctp_connectx() will fail, setting errno to EINVAL.
1091 *
1092 * An application can use sctp_connectx to initiate an association with
1093 * an endpoint that is multi-homed. Much like sctp_bindx() this call
1094 * allows a caller to specify multiple addresses at which a peer can be
1095 * reached. The way the SCTP stack uses the list of addresses to set up
1096 * the association is implementation dependant. This function only
1097 * specifies that the stack will try to make use of all the addresses in
1098 * the list when needed.
1099 *
1100 * Note that the list of addresses passed in is only used for setting up
1101 * the association. It does not necessarily equal the set of addresses
1102 * the peer uses for the resulting association. If the caller wants to
1103 * find out the set of peer addresses, it must use sctp_getpaddrs() to
1104 * retrieve them after the association has been set up.
1105 *
1106 * Basically do nothing but copying the addresses from user to kernel
1107 * land and invoking either sctp_connectx(). This is used for tunneling
1108 * the sctp_connectx() request through sctp_setsockopt() from userspace.
1109 *
1110 * We don't use copy_from_user() for optimization: we first do the
1111 * sanity checks (buffer size -fast- and access check-healthy
1112 * pointer); if all of those succeed, then we can alloc the memory
1113 * (expensive operation) needed to copy the data to kernel. Then we do
1114 * the copying without checking the user space area
1115 * (__copy_from_user()).
1116 *
1117 * On exit there is no need to do sockfd_put(), sys_setsockopt() does
1118 * it.
1119 *
1120 * sk The sk of the socket
1121 * addrs The pointer to the addresses in user land
1122 * addrssize Size of the addrs buffer
1123 *
1124 * Returns 0 if ok, <0 errno code on error.
1125 */
1126SCTP_STATIC int sctp_setsockopt_connectx(struct sock* sk,
1127 struct sockaddr __user *addrs,
1128 int addrs_size)
1129{
1130 int err = 0;
1131 struct sockaddr *kaddrs;
1132
1133 SCTP_DEBUG_PRINTK("%s - sk %p addrs %p addrs_size %d\n",
1134 __FUNCTION__, sk, addrs, addrs_size);
1135
1136 if (unlikely(addrs_size <= 0))
1137 return -EINVAL;
1138
1139 /* Check the user passed a healthy pointer. */
1140 if (unlikely(!access_ok(VERIFY_READ, addrs, addrs_size)))
1141 return -EFAULT;
1142
1143 /* Alloc space for the address array in kernel memory. */
1144 kaddrs = (struct sockaddr *)kmalloc(addrs_size, GFP_KERNEL);
1145 if (unlikely(!kaddrs))
1146 return -ENOMEM;
1147
1148 if (__copy_from_user(kaddrs, addrs, addrs_size)) {
1149 err = -EFAULT;
1150 } else {
1151 err = __sctp_connect(sk, kaddrs, addrs_size);
1152 }
1153
1154 kfree(kaddrs);
1155 return err;
1156}
1157
916/* API 3.1.4 close() - UDP Style Syntax 1158/* API 3.1.4 close() - UDP Style Syntax
917 * Applications use close() to perform graceful shutdown (as described in 1159 * Applications use close() to perform graceful shutdown (as described in
918 * Section 10.1 of [SCTP]) on ALL the associations currently represented 1160 * Section 10.1 of [SCTP]) on ALL the associations currently represented
@@ -1095,7 +1337,7 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk,
1095 sp = sctp_sk(sk); 1337 sp = sctp_sk(sk);
1096 ep = sp->ep; 1338 ep = sp->ep;
1097 1339
1098 SCTP_DEBUG_PRINTK("Using endpoint: %s.\n", ep->debug_name); 1340 SCTP_DEBUG_PRINTK("Using endpoint: %p.\n", ep);
1099 1341
1100 /* We cannot send a message over a TCP-style listening socket. */ 1342 /* We cannot send a message over a TCP-style listening socket. */
1101 if (sctp_style(sk, TCP) && sctp_sstate(sk, LISTENING)) { 1343 if (sctp_style(sk, TCP) && sctp_sstate(sk, LISTENING)) {
@@ -1306,7 +1548,7 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk,
1306 } 1548 }
1307 1549
1308 /* Prime the peer's transport structures. */ 1550 /* Prime the peer's transport structures. */
1309 transport = sctp_assoc_add_peer(asoc, &to, GFP_KERNEL); 1551 transport = sctp_assoc_add_peer(asoc, &to, GFP_KERNEL, SCTP_UNKNOWN);
1310 if (!transport) { 1552 if (!transport) {
1311 err = -ENOMEM; 1553 err = -ENOMEM;
1312 goto out_free; 1554 goto out_free;
@@ -2208,6 +2450,12 @@ SCTP_STATIC int sctp_setsockopt(struct sock *sk, int level, int optname,
2208 optlen, SCTP_BINDX_REM_ADDR); 2450 optlen, SCTP_BINDX_REM_ADDR);
2209 break; 2451 break;
2210 2452
2453 case SCTP_SOCKOPT_CONNECTX:
2454 /* 'optlen' is the size of the addresses buffer. */
2455 retval = sctp_setsockopt_connectx(sk, (struct sockaddr __user *)optval,
2456 optlen);
2457 break;
2458
2211 case SCTP_DISABLE_FRAGMENTS: 2459 case SCTP_DISABLE_FRAGMENTS:
2212 retval = sctp_setsockopt_disable_fragments(sk, optval, optlen); 2460 retval = sctp_setsockopt_disable_fragments(sk, optval, optlen);
2213 break; 2461 break;
@@ -2283,112 +2531,29 @@ out_nounlock:
2283 * 2531 *
2284 * len: the size of the address. 2532 * len: the size of the address.
2285 */ 2533 */
2286SCTP_STATIC int sctp_connect(struct sock *sk, struct sockaddr *uaddr, 2534SCTP_STATIC int sctp_connect(struct sock *sk, struct sockaddr *addr,
2287 int addr_len) 2535 int addr_len)
2288{ 2536{
2289 struct sctp_sock *sp;
2290 struct sctp_endpoint *ep;
2291 struct sctp_association *asoc;
2292 struct sctp_transport *transport;
2293 union sctp_addr to;
2294 struct sctp_af *af;
2295 sctp_scope_t scope;
2296 long timeo;
2297 int err = 0; 2537 int err = 0;
2538 struct sctp_af *af;
2298 2539
2299 sctp_lock_sock(sk); 2540 sctp_lock_sock(sk);
2300 2541
2301 SCTP_DEBUG_PRINTK("%s - sk: %p, sockaddr: %p, addr_len: %d)\n", 2542 SCTP_DEBUG_PRINTK("%s - sk: %p, sockaddr: %p, addr_len: %d\n",
2302 __FUNCTION__, sk, uaddr, addr_len); 2543 __FUNCTION__, sk, addr, addr_len);
2303
2304 sp = sctp_sk(sk);
2305 ep = sp->ep;
2306
2307 /* connect() cannot be done on a socket that is already in ESTABLISHED
2308 * state - UDP-style peeled off socket or a TCP-style socket that
2309 * is already connected.
2310 * It cannot be done even on a TCP-style listening socket.
2311 */
2312 if (sctp_sstate(sk, ESTABLISHED) ||
2313 (sctp_style(sk, TCP) && sctp_sstate(sk, LISTENING))) {
2314 err = -EISCONN;
2315 goto out_unlock;
2316 }
2317
2318 err = sctp_verify_addr(sk, (union sctp_addr *)uaddr, addr_len);
2319 if (err)
2320 goto out_unlock;
2321
2322 if (addr_len > sizeof(to))
2323 addr_len = sizeof(to);
2324 memcpy(&to, uaddr, addr_len);
2325 to.v4.sin_port = ntohs(to.v4.sin_port);
2326
2327 asoc = sctp_endpoint_lookup_assoc(ep, &to, &transport);
2328 if (asoc) {
2329 if (asoc->state >= SCTP_STATE_ESTABLISHED)
2330 err = -EISCONN;
2331 else
2332 err = -EALREADY;
2333 goto out_unlock;
2334 }
2335
2336 /* If we could not find a matching association on the endpoint,
2337 * make sure that there is no peeled-off association matching the
2338 * peer address even on another socket.
2339 */
2340 if (sctp_endpoint_is_peeled_off(ep, &to)) {
2341 err = -EADDRNOTAVAIL;
2342 goto out_unlock;
2343 }
2344
2345 /* If a bind() or sctp_bindx() is not called prior to a connect()
2346 * call, the system picks an ephemeral port and will choose an address
2347 * set equivalent to binding with a wildcard address.
2348 */
2349 if (!ep->base.bind_addr.port) {
2350 if (sctp_autobind(sk)) {
2351 err = -EAGAIN;
2352 goto out_unlock;
2353 }
2354 }
2355
2356 scope = sctp_scope(&to);
2357 asoc = sctp_association_new(ep, sk, scope, GFP_KERNEL);
2358 if (!asoc) {
2359 err = -ENOMEM;
2360 goto out_unlock;
2361 }
2362 2544
2363 /* Prime the peer's transport structures. */ 2545 /* Validate addr_len before calling common connect/connectx routine. */
2364 transport = sctp_assoc_add_peer(asoc, &to, GFP_KERNEL); 2546 af = sctp_get_af_specific(addr->sa_family);
2365 if (!transport) { 2547 if (!af || addr_len < af->sockaddr_len) {
2366 sctp_association_free(asoc); 2548 err = -EINVAL;
2367 goto out_unlock; 2549 } else {
2368 } 2550 /* Pass correct addr len to common routine (so it knows there
2369 err = sctp_assoc_set_bind_addr_from_ep(asoc, GFP_KERNEL); 2551 * is only one address being passed.
2370 if (err < 0) { 2552 */
2371 sctp_association_free(asoc); 2553 err = __sctp_connect(sk, addr, af->sockaddr_len);
2372 goto out_unlock;
2373 }
2374
2375 err = sctp_primitive_ASSOCIATE(asoc, NULL);
2376 if (err < 0) {
2377 sctp_association_free(asoc);
2378 goto out_unlock;
2379 } 2554 }
2380 2555
2381 /* Initialize sk's dport and daddr for getpeername() */
2382 inet_sk(sk)->dport = htons(asoc->peer.port);
2383 af = sctp_get_af_specific(to.sa.sa_family);
2384 af->to_sk_daddr(&to, sk);
2385
2386 timeo = sock_sndtimeo(sk, sk->sk_socket->file->f_flags & O_NONBLOCK);
2387 err = sctp_wait_for_connect(asoc, &timeo);
2388
2389out_unlock:
2390 sctp_release_sock(sk); 2556 sctp_release_sock(sk);
2391
2392 return err; 2557 return err;
2393} 2558}
2394 2559
@@ -2677,12 +2842,15 @@ static int sctp_getsockopt_sctp_status(struct sock *sk, int len,
2677 /* Map ipv4 address into v4-mapped-on-v6 address. */ 2842 /* Map ipv4 address into v4-mapped-on-v6 address. */
2678 sctp_get_pf_specific(sk->sk_family)->addr_v4map(sctp_sk(sk), 2843 sctp_get_pf_specific(sk->sk_family)->addr_v4map(sctp_sk(sk),
2679 (union sctp_addr *)&status.sstat_primary.spinfo_address); 2844 (union sctp_addr *)&status.sstat_primary.spinfo_address);
2680 status.sstat_primary.spinfo_state = transport->active; 2845 status.sstat_primary.spinfo_state = transport->state;
2681 status.sstat_primary.spinfo_cwnd = transport->cwnd; 2846 status.sstat_primary.spinfo_cwnd = transport->cwnd;
2682 status.sstat_primary.spinfo_srtt = transport->srtt; 2847 status.sstat_primary.spinfo_srtt = transport->srtt;
2683 status.sstat_primary.spinfo_rto = jiffies_to_msecs(transport->rto); 2848 status.sstat_primary.spinfo_rto = jiffies_to_msecs(transport->rto);
2684 status.sstat_primary.spinfo_mtu = transport->pmtu; 2849 status.sstat_primary.spinfo_mtu = transport->pmtu;
2685 2850
2851 if (status.sstat_primary.spinfo_state == SCTP_UNKNOWN)
2852 status.sstat_primary.spinfo_state = SCTP_ACTIVE;
2853
2686 if (put_user(len, optlen)) { 2854 if (put_user(len, optlen)) {
2687 retval = -EFAULT; 2855 retval = -EFAULT;
2688 goto out; 2856 goto out;
@@ -2733,12 +2901,15 @@ static int sctp_getsockopt_peer_addr_info(struct sock *sk, int len,
2733 return -EINVAL; 2901 return -EINVAL;
2734 2902
2735 pinfo.spinfo_assoc_id = sctp_assoc2id(transport->asoc); 2903 pinfo.spinfo_assoc_id = sctp_assoc2id(transport->asoc);
2736 pinfo.spinfo_state = transport->active; 2904 pinfo.spinfo_state = transport->state;
2737 pinfo.spinfo_cwnd = transport->cwnd; 2905 pinfo.spinfo_cwnd = transport->cwnd;
2738 pinfo.spinfo_srtt = transport->srtt; 2906 pinfo.spinfo_srtt = transport->srtt;
2739 pinfo.spinfo_rto = jiffies_to_msecs(transport->rto); 2907 pinfo.spinfo_rto = jiffies_to_msecs(transport->rto);
2740 pinfo.spinfo_mtu = transport->pmtu; 2908 pinfo.spinfo_mtu = transport->pmtu;
2741 2909
2910 if (pinfo.spinfo_state == SCTP_UNKNOWN)
2911 pinfo.spinfo_state = SCTP_ACTIVE;
2912
2742 if (put_user(len, optlen)) { 2913 if (put_user(len, optlen)) {
2743 retval = -EFAULT; 2914 retval = -EFAULT;
2744 goto out; 2915 goto out;
@@ -3591,7 +3762,8 @@ SCTP_STATIC int sctp_getsockopt(struct sock *sk, int level, int optname,
3591 int retval = 0; 3762 int retval = 0;
3592 int len; 3763 int len;
3593 3764
3594 SCTP_DEBUG_PRINTK("sctp_getsockopt(sk: %p, ...)\n", sk); 3765 SCTP_DEBUG_PRINTK("sctp_getsockopt(sk: %p... optname: %d)\n",
3766 sk, optname);
3595 3767
3596 /* I can hardly begin to describe how wrong this is. This is 3768 /* I can hardly begin to describe how wrong this is. This is
3597 * so broken as to be worse than useless. The API draft 3769 * so broken as to be worse than useless. The API draft
@@ -4596,8 +4768,7 @@ out:
4596 return err; 4768 return err;
4597 4769
4598do_error: 4770do_error:
4599 if (asoc->counters[SCTP_COUNTER_INIT_ERROR] + 1 >= 4771 if (asoc->init_err_counter + 1 >= asoc->max_init_attempts)
4600 asoc->max_init_attempts)
4601 err = -ETIMEDOUT; 4772 err = -ETIMEDOUT;
4602 else 4773 else
4603 err = -ECONNREFUSED; 4774 err = -ECONNREFUSED;
diff --git a/net/sctp/transport.c b/net/sctp/transport.c
index f30882e1e96a..0ec0fde6e6c5 100644
--- a/net/sctp/transport.c
+++ b/net/sctp/transport.c
@@ -83,7 +83,9 @@ static struct sctp_transport *sctp_transport_init(struct sctp_transport *peer,
83 peer->last_time_used = jiffies; 83 peer->last_time_used = jiffies;
84 peer->last_time_ecne_reduced = jiffies; 84 peer->last_time_ecne_reduced = jiffies;
85 85
86 peer->active = SCTP_ACTIVE; 86 peer->init_sent_count = 0;
87
88 peer->state = SCTP_ACTIVE;
87 peer->hb_allowed = 0; 89 peer->hb_allowed = 0;
88 90
89 /* Initialize the default path max_retrans. */ 91 /* Initialize the default path max_retrans. */
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 0a4260719a12..d65ed8684fc1 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -118,7 +118,6 @@ retry:
118 xfrm_policy_put_afinfo(afinfo); 118 xfrm_policy_put_afinfo(afinfo);
119 return type; 119 return type;
120} 120}
121EXPORT_SYMBOL(xfrm_get_type);
122 121
123int xfrm_dst_lookup(struct xfrm_dst **dst, struct flowi *fl, 122int xfrm_dst_lookup(struct xfrm_dst **dst, struct flowi *fl,
124 unsigned short family) 123 unsigned short family)
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 2537f26f097c..9d206c282cf1 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -1055,6 +1055,43 @@ int xfrm_state_mtu(struct xfrm_state *x, int mtu)
1055} 1055}
1056 1056
1057EXPORT_SYMBOL(xfrm_state_mtu); 1057EXPORT_SYMBOL(xfrm_state_mtu);
1058
1059int xfrm_init_state(struct xfrm_state *x)
1060{
1061 struct xfrm_state_afinfo *afinfo;
1062 int family = x->props.family;
1063 int err;
1064
1065 err = -EAFNOSUPPORT;
1066 afinfo = xfrm_state_get_afinfo(family);
1067 if (!afinfo)
1068 goto error;
1069
1070 err = 0;
1071 if (afinfo->init_flags)
1072 err = afinfo->init_flags(x);
1073
1074 xfrm_state_put_afinfo(afinfo);
1075
1076 if (err)
1077 goto error;
1078
1079 err = -EPROTONOSUPPORT;
1080 x->type = xfrm_get_type(x->id.proto, family);
1081 if (x->type == NULL)
1082 goto error;
1083
1084 err = x->type->init_state(x);
1085 if (err)
1086 goto error;
1087
1088 x->km.state = XFRM_STATE_VALID;
1089
1090error:
1091 return err;
1092}
1093
1094EXPORT_SYMBOL(xfrm_init_state);
1058 1095
1059void __init xfrm_state_init(void) 1096void __init xfrm_state_init(void)
1060{ 1097{
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index 5ce8558eac91..ecade4893a13 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -249,17 +249,10 @@ static struct xfrm_state *xfrm_state_construct(struct xfrm_usersa_info *p,
249 if ((err = attach_encap_tmpl(&x->encap, xfrma[XFRMA_ENCAP-1]))) 249 if ((err = attach_encap_tmpl(&x->encap, xfrma[XFRMA_ENCAP-1])))
250 goto error; 250 goto error;
251 251
252 err = -ENOENT; 252 err = xfrm_init_state(x);
253 x->type = xfrm_get_type(x->id.proto, x->props.family);
254 if (x->type == NULL)
255 goto error;
256
257 err = x->type->init_state(x, NULL);
258 if (err) 253 if (err)
259 goto error; 254 goto error;
260 255
261 x->curlft.add_time = (unsigned long) xtime.tv_sec;
262 x->km.state = XFRM_STATE_VALID;
263 x->km.seq = p->seq; 256 x->km.seq = p->seq;
264 257
265 return x; 258 return x;
diff --git a/security/seclvl.c b/security/seclvl.c
index 8a0ab0d7949e..c8e87b22c9bd 100644
--- a/security/seclvl.c
+++ b/security/seclvl.c
@@ -155,7 +155,7 @@ seclvl_attr_store(struct kobject *kobj,
155 struct seclvl_obj *obj = container_of(kobj, struct seclvl_obj, kobj); 155 struct seclvl_obj *obj = container_of(kobj, struct seclvl_obj, kobj);
156 struct seclvl_attribute *attribute = 156 struct seclvl_attribute *attribute =
157 container_of(attr, struct seclvl_attribute, attr); 157 container_of(attr, struct seclvl_attribute, attr);
158 return (attribute->store ? attribute->store(obj, buf, len) : 0); 158 return attribute->store ? attribute->store(obj, buf, len) : -EIO;
159} 159}
160 160
161static ssize_t 161static ssize_t
@@ -164,7 +164,7 @@ seclvl_attr_show(struct kobject *kobj, struct attribute *attr, char *buf)
164 struct seclvl_obj *obj = container_of(kobj, struct seclvl_obj, kobj); 164 struct seclvl_obj *obj = container_of(kobj, struct seclvl_obj, kobj);
165 struct seclvl_attribute *attribute = 165 struct seclvl_attribute *attribute =
166 container_of(attr, struct seclvl_attribute, attr); 166 container_of(attr, struct seclvl_attribute, attr);
167 return (attribute->show ? attribute->show(obj, buf) : 0); 167 return attribute->show ? attribute->show(obj, buf) : -EIO;
168} 168}
169 169
170/** 170/**
diff --git a/sound/core/sound.c b/sound/core/sound.c
index 88e052079f85..33eaa5e5d284 100644
--- a/sound/core/sound.c
+++ b/sound/core/sound.c
@@ -64,7 +64,7 @@ static struct list_head snd_minors_hash[SNDRV_CARDS];
64 64
65static DECLARE_MUTEX(sound_mutex); 65static DECLARE_MUTEX(sound_mutex);
66 66
67extern struct class_simple *sound_class; 67extern struct class *sound_class;
68 68
69 69
70#ifdef CONFIG_KMOD 70#ifdef CONFIG_KMOD
@@ -231,7 +231,7 @@ int snd_register_device(int type, snd_card_t * card, int dev, snd_minor_t * reg,
231 devfs_mk_cdev(MKDEV(major, minor), S_IFCHR | device_mode, "snd/%s", name); 231 devfs_mk_cdev(MKDEV(major, minor), S_IFCHR | device_mode, "snd/%s", name);
232 if (card) 232 if (card)
233 device = card->dev; 233 device = card->dev;
234 class_simple_device_add(sound_class, MKDEV(major, minor), device, name); 234 class_device_create(sound_class, MKDEV(major, minor), device, "%s", name);
235 235
236 up(&sound_mutex); 236 up(&sound_mutex);
237 return 0; 237 return 0;
@@ -263,7 +263,7 @@ int snd_unregister_device(int type, snd_card_t * card, int dev)
263 263
264 if (strncmp(mptr->name, "controlC", 8) || card->number >= cards_limit) /* created in sound.c */ 264 if (strncmp(mptr->name, "controlC", 8) || card->number >= cards_limit) /* created in sound.c */
265 devfs_remove("snd/%s", mptr->name); 265 devfs_remove("snd/%s", mptr->name);
266 class_simple_device_remove(MKDEV(major, minor)); 266 class_device_destroy(sound_class, MKDEV(major, minor));
267 267
268 list_del(&mptr->list); 268 list_del(&mptr->list);
269 up(&sound_mutex); 269 up(&sound_mutex);
diff --git a/sound/oss/soundcard.c b/sound/oss/soundcard.c
index de91c90a0112..a686be936aff 100644
--- a/sound/oss/soundcard.c
+++ b/sound/oss/soundcard.c
@@ -73,7 +73,7 @@ static char dma_alloc_map[MAX_DMA_CHANNELS];
73 73
74 74
75unsigned long seq_time = 0; /* Time for /dev/sequencer */ 75unsigned long seq_time = 0; /* Time for /dev/sequencer */
76extern struct class_simple *sound_class; 76extern struct class *sound_class;
77 77
78/* 78/*
79 * Table for configurable mixer volume handling 79 * Table for configurable mixer volume handling
@@ -567,9 +567,9 @@ static int __init oss_init(void)
567 devfs_mk_cdev(MKDEV(SOUND_MAJOR, dev_list[i].minor), 567 devfs_mk_cdev(MKDEV(SOUND_MAJOR, dev_list[i].minor),
568 S_IFCHR | dev_list[i].mode, 568 S_IFCHR | dev_list[i].mode,
569 "sound/%s", dev_list[i].name); 569 "sound/%s", dev_list[i].name);
570 class_simple_device_add(sound_class, 570 class_device_create(sound_class,
571 MKDEV(SOUND_MAJOR, dev_list[i].minor), 571 MKDEV(SOUND_MAJOR, dev_list[i].minor),
572 NULL, "%s", dev_list[i].name); 572 NULL, "%s", dev_list[i].name);
573 573
574 if (!dev_list[i].num) 574 if (!dev_list[i].num)
575 continue; 575 continue;
@@ -579,10 +579,9 @@ static int __init oss_init(void)
579 dev_list[i].minor + (j*0x10)), 579 dev_list[i].minor + (j*0x10)),
580 S_IFCHR | dev_list[i].mode, 580 S_IFCHR | dev_list[i].mode,
581 "sound/%s%d", dev_list[i].name, j); 581 "sound/%s%d", dev_list[i].name, j);
582 class_simple_device_add(sound_class, 582 class_device_create(sound_class,
583 MKDEV(SOUND_MAJOR, dev_list[i].minor + (j*0x10)), 583 MKDEV(SOUND_MAJOR, dev_list[i].minor + (j*0x10)),
584 NULL, 584 NULL, "%s%d", dev_list[i].name, j);
585 "%s%d", dev_list[i].name, j);
586 } 585 }
587 } 586 }
588 587
@@ -598,12 +597,12 @@ static void __exit oss_cleanup(void)
598 597
599 for (i = 0; i < sizeof (dev_list) / sizeof *dev_list; i++) { 598 for (i = 0; i < sizeof (dev_list) / sizeof *dev_list; i++) {
600 devfs_remove("sound/%s", dev_list[i].name); 599 devfs_remove("sound/%s", dev_list[i].name);
601 class_simple_device_remove(MKDEV(SOUND_MAJOR, dev_list[i].minor)); 600 class_device_destroy(sound_class, MKDEV(SOUND_MAJOR, dev_list[i].minor));
602 if (!dev_list[i].num) 601 if (!dev_list[i].num)
603 continue; 602 continue;
604 for (j = 1; j < *dev_list[i].num; j++) { 603 for (j = 1; j < *dev_list[i].num; j++) {
605 devfs_remove("sound/%s%d", dev_list[i].name, j); 604 devfs_remove("sound/%s%d", dev_list[i].name, j);
606 class_simple_device_remove(MKDEV(SOUND_MAJOR, dev_list[i].minor + (j*0x10))); 605 class_device_destroy(sound_class, MKDEV(SOUND_MAJOR, dev_list[i].minor + (j*0x10)));
607 } 606 }
608 } 607 }
609 608
diff --git a/sound/sound_core.c b/sound/sound_core.c
index 30f75c9288cb..21a69e096225 100644
--- a/sound/sound_core.c
+++ b/sound/sound_core.c
@@ -65,7 +65,7 @@ extern int msnd_classic_init(void);
65extern int msnd_pinnacle_init(void); 65extern int msnd_pinnacle_init(void);
66#endif 66#endif
67 67
68struct class_simple *sound_class; 68struct class *sound_class;
69EXPORT_SYMBOL(sound_class); 69EXPORT_SYMBOL(sound_class);
70 70
71/* 71/*
@@ -174,7 +174,7 @@ static int sound_insert_unit(struct sound_unit **list, struct file_operations *f
174 174
175 devfs_mk_cdev(MKDEV(SOUND_MAJOR, s->unit_minor), 175 devfs_mk_cdev(MKDEV(SOUND_MAJOR, s->unit_minor),
176 S_IFCHR | mode, s->name); 176 S_IFCHR | mode, s->name);
177 class_simple_device_add(sound_class, MKDEV(SOUND_MAJOR, s->unit_minor), 177 class_device_create(sound_class, MKDEV(SOUND_MAJOR, s->unit_minor),
178 NULL, s->name+6); 178 NULL, s->name+6);
179 return r; 179 return r;
180 180
@@ -198,7 +198,7 @@ static void sound_remove_unit(struct sound_unit **list, int unit)
198 spin_unlock(&sound_loader_lock); 198 spin_unlock(&sound_loader_lock);
199 if (p) { 199 if (p) {
200 devfs_remove(p->name); 200 devfs_remove(p->name);
201 class_simple_device_remove(MKDEV(SOUND_MAJOR, p->unit_minor)); 201 class_device_destroy(sound_class, MKDEV(SOUND_MAJOR, p->unit_minor));
202 kfree(p); 202 kfree(p);
203 } 203 }
204} 204}
@@ -562,7 +562,7 @@ static void __exit cleanup_soundcore(void)
562 empty */ 562 empty */
563 unregister_chrdev(SOUND_MAJOR, "sound"); 563 unregister_chrdev(SOUND_MAJOR, "sound");
564 devfs_remove("sound"); 564 devfs_remove("sound");
565 class_simple_destroy(sound_class); 565 class_destroy(sound_class);
566} 566}
567 567
568static int __init init_soundcore(void) 568static int __init init_soundcore(void)
@@ -572,7 +572,7 @@ static int __init init_soundcore(void)
572 return -EBUSY; 572 return -EBUSY;
573 } 573 }
574 devfs_mk_dir ("sound"); 574 devfs_mk_dir ("sound");
575 sound_class = class_simple_create(THIS_MODULE, "sound"); 575 sound_class = class_create(THIS_MODULE, "sound");
576 if (IS_ERR(sound_class)) 576 if (IS_ERR(sound_class))
577 return PTR_ERR(sound_class); 577 return PTR_ERR(sound_class);
578 578