aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2008-10-28 11:26:12 -0400
committerIngo Molnar <mingo@elte.hu>2008-10-28 11:26:12 -0400
commit7a9787e1eba95a166265e6a260cf30af04ef0a99 (patch)
treee730a4565e0318140d2fbd2f0415d18a339d7336 /include/linux
parent41b9eb264c8407655db57b60b4457fe1b2ec9977 (diff)
parent0173a3265b228da319ceb9c1ec6a5682fd1b2d92 (diff)
Merge commit 'v2.6.28-rc2' into x86/pci-ioapic-boot-irq-quirks
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/Kbuild18
-rw-r--r--include/linux/acct.h3
-rw-r--r--include/linux/acpi.h9
-rw-r--r--include/linux/aer.h5
-rw-r--r--include/linux/agp_backend.h5
-rw-r--r--include/linux/aio.h10
-rw-r--r--include/linux/anon_inodes.h2
-rw-r--r--include/linux/async_tx.h11
-rw-r--r--include/linux/ata.h282
-rw-r--r--include/linux/atmel-pwm-bl.h43
-rw-r--r--include/linux/audit.h1
-rw-r--r--include/linux/auto_dev-ioctl.h157
-rw-r--r--include/linux/auto_fs4.h9
-rw-r--r--include/linux/auxvec.h8
-rw-r--r--include/linux/backing-dev.h13
-rw-r--r--include/linux/bcd.h17
-rw-r--r--include/linux/binfmts.h7
-rw-r--r--include/linux/bio.h129
-rw-r--r--include/linux/bitmap.h1
-rw-r--r--include/linux/blkdev.h211
-rw-r--r--include/linux/blktrace_api.h94
-rw-r--r--include/linux/bootmem.h108
-rw-r--r--include/linux/brcmphy.h6
-rw-r--r--include/linux/buffer_head.h10
-rw-r--r--include/linux/byteorder.h372
-rw-r--r--include/linux/byteorder/Kbuild1
-rw-r--r--include/linux/byteorder/big_endian.h13
-rw-r--r--include/linux/byteorder/little_endian.h13
-rw-r--r--include/linux/capability.h15
-rw-r--r--include/linux/cdrom.h10
-rw-r--r--include/linux/cgroup.h82
-rw-r--r--include/linux/cgroup_subsys.h6
-rw-r--r--include/linux/clk.h4
-rw-r--r--include/linux/clockchips.h2
-rw-r--r--include/linux/clocksource.h14
-rw-r--r--include/linux/cnt32_to_63.h80
-rw-r--r--include/linux/coda.h43
-rw-r--r--include/linux/coda_linux.h2
-rw-r--r--include/linux/compat.h6
-rw-r--r--include/linux/compiler.h6
-rw-r--r--include/linux/completion.h44
-rw-r--r--include/linux/configfs.h75
-rw-r--r--include/linux/connector.h3
-rw-r--r--include/linux/console_struct.h1
-rw-r--r--include/linux/consolemap.h14
-rw-r--r--include/linux/cpu.h16
-rw-r--r--include/linux/cpufreq.h11
-rw-r--r--include/linux/cpumask.h179
-rw-r--r--include/linux/cpuset.h7
-rw-r--r--include/linux/crash_dump.h46
-rw-r--r--include/linux/cred.h50
-rw-r--r--include/linux/crypto.h35
-rw-r--r--include/linux/cyclades.h13
-rw-r--r--include/linux/dca.h7
-rw-r--r--include/linux/dcache.h4
-rw-r--r--include/linux/dccp.h6
-rw-r--r--include/linux/debugfs.h6
-rw-r--r--include/linux/delayacct.h19
-rw-r--r--include/linux/device-mapper.h36
-rw-r--r--include/linux/device.h95
-rw-r--r--include/linux/devpts_fs.h31
-rw-r--r--include/linux/dirent.h20
-rw-r--r--include/linux/dlm.h5
-rw-r--r--include/linux/dlm_device.h2
-rw-r--r--include/linux/dm-ioctl.h4
-rw-r--r--include/linux/dm-region-hash.h104
-rw-r--r--include/linux/dm9000.h2
-rw-r--r--include/linux/dma-attrs.h1
-rw-r--r--include/linux/dma-mapping.h12
-rw-r--r--include/linux/dma_remapping.h156
-rw-r--r--include/linux/dmaengine.h69
-rw-r--r--include/linux/dmar.h126
-rw-r--r--include/linux/dmi.h41
-rw-r--r--include/linux/ds1286.h2
-rw-r--r--include/linux/dvb/frontend.h112
-rw-r--r--include/linux/dvb/version.h4
-rw-r--r--include/linux/dw_dmac.h62
-rw-r--r--include/linux/dynamic_printk.h93
-rw-r--r--include/linux/efi.h4
-rw-r--r--include/linux/eisa.h2
-rw-r--r--include/linux/elevator.h9
-rw-r--r--include/linux/elf.h1
-rw-r--r--include/linux/ethtool.h50
-rw-r--r--include/linux/eventfd.h7
-rw-r--r--include/linux/eventpoll.h4
-rw-r--r--include/linux/exportfs.h21
-rw-r--r--include/linux/ext2_fs.h6
-rw-r--r--include/linux/ext3_fs.h9
-rw-r--r--include/linux/ext3_jbd.h14
-rw-r--r--include/linux/fb.h9
-rw-r--r--include/linux/fd.h8
-rw-r--r--include/linux/fd1772.h80
-rw-r--r--include/linux/fiemap.h64
-rw-r--r--include/linux/file.h7
-rw-r--r--include/linux/firewire-cdev.h9
-rw-r--r--include/linux/firmware-map.h26
-rw-r--r--include/linux/freezer.h43
-rw-r--r--include/linux/fs.h277
-rw-r--r--include/linux/fs_enet_pd.h8
-rw-r--r--include/linux/fs_struct.h3
-rw-r--r--include/linux/fs_uart_pd.h1
-rw-r--r--include/linux/fsl_devices.h7
-rw-r--r--include/linux/fsnotify.h2
-rw-r--r--include/linux/ftrace.h101
-rw-r--r--include/linux/fuse.h15
-rw-r--r--include/linux/gameport.h8
-rw-r--r--include/linux/generic_serial.h8
-rw-r--r--include/linux/genhd.h360
-rw-r--r--include/linux/gfp.h24
-rw-r--r--include/linux/gfs2_ondisk.h6
-rw-r--r--include/linux/gpio.h16
-rw-r--r--include/linux/gpio_keys.h1
-rw-r--r--include/linux/harrier_defs.h212
-rw-r--r--include/linux/hayesesp.h9
-rw-r--r--include/linux/hdlc.h7
-rw-r--r--include/linux/hid.h375
-rw-r--r--include/linux/hiddev.h46
-rw-r--r--include/linux/hpet.h14
-rw-r--r--include/linux/hrtimer.h133
-rw-r--r--include/linux/hugetlb.h152
-rw-r--r--include/linux/i2c-algo-pcf.h5
-rw-r--r--include/linux/i2c-id.h13
-rw-r--r--include/linux/i2c-pnx.h4
-rw-r--r--include/linux/i2c.h175
-rw-r--r--include/linux/i2c/max732x.h19
-rw-r--r--include/linux/i2c/twl4030.h343
-rw-r--r--include/linux/i2o.h292
-rw-r--r--include/linux/icmpv6.h6
-rw-r--r--include/linux/ide.h1130
-rw-r--r--include/linux/idr.h24
-rw-r--r--include/linux/ieee80211.h540
-rw-r--r--include/linux/if.h1
-rw-r--r--include/linux/if_bridge.h2
-rw-r--r--include/linux/if_ether.h8
-rw-r--r--include/linux/if_fddi.h2
-rw-r--r--include/linux/if_hippi.h2
-rw-r--r--include/linux/if_link.h1
-rw-r--r--include/linux/if_packet.h24
-rw-r--r--include/linux/if_phonet.h19
-rw-r--r--include/linux/if_ppp.h2
-rw-r--r--include/linux/if_tun.h35
-rw-r--r--include/linux/if_tunnel.h19
-rw-r--r--include/linux/if_vlan.h238
-rw-r--r--include/linux/igmp.h3
-rw-r--r--include/linux/ihex.h2
-rw-r--r--include/linux/in.h1
-rw-r--r--include/linux/inetdevice.h1
-rw-r--r--include/linux/init.h22
-rw-r--r--include/linux/init_task.h3
-rw-r--r--include/linux/inotify.h6
-rw-r--r--include/linux/input.h24
-rw-r--r--include/linux/intel-iommu.h363
-rw-r--r--include/linux/interrupt.h53
-rw-r--r--include/linux/iommu-helper.h19
-rw-r--r--include/linux/ioport.h20
-rw-r--r--include/linux/iova.h52
-rw-r--r--include/linux/ip6_tunnel.h4
-rw-r--r--include/linux/ip_vs.h405
-rw-r--r--include/linux/ipc_namespace.h3
-rw-r--r--include/linux/ipv6.h6
-rw-r--r--include/linux/irq.h57
-rw-r--r--include/linux/irqflags.h54
-rw-r--r--include/linux/irqnr.h24
-rw-r--r--include/linux/isdn_ppp.h2
-rw-r--r--include/linux/istallion.h6
-rw-r--r--include/linux/ivtv.h7
-rw-r--r--include/linux/ivtvfb.h6
-rw-r--r--include/linux/jbd.h9
-rw-r--r--include/linux/jbd2.h21
-rw-r--r--include/linux/jffs2.h3
-rw-r--r--include/linux/journal-head.h2
-rw-r--r--include/linux/joystick.h2
-rw-r--r--include/linux/kallsyms.h26
-rw-r--r--include/linux/kernel.h116
-rw-r--r--include/linux/kernel_stat.h21
-rw-r--r--include/linux/kexec.h25
-rw-r--r--include/linux/key.h1
-rw-r--r--include/linux/klist.h3
-rw-r--r--include/linux/kmod.h19
-rw-r--r--include/linux/kobject.h5
-rw-r--r--include/linux/kprobes.h12
-rw-r--r--include/linux/kthread.h3
-rw-r--r--include/linux/kvm.h102
-rw-r--r--include/linux/kvm_host.h117
-rw-r--r--include/linux/lcd.h5
-rw-r--r--include/linux/leds-pca9532.h45
-rw-r--r--include/linux/leds.h18
-rw-r--r--include/linux/libata.h103
-rw-r--r--include/linux/libps2.h1
-rw-r--r--include/linux/linkage.h2
-rw-r--r--include/linux/list.h104
-rw-r--r--include/linux/lockd/bind.h11
-rw-r--r--include/linux/lockd/lockd.h143
-rw-r--r--include/linux/lockd/xdr.h2
-rw-r--r--include/linux/lockdep.h70
-rw-r--r--include/linux/mISDNdsp.h37
-rw-r--r--include/linux/mISDNhw.h193
-rw-r--r--include/linux/mISDNif.h509
-rw-r--r--include/linux/magic.h4
-rw-r--r--include/linux/major.h4
-rw-r--r--include/linux/map_to_7segment.h187
-rw-r--r--include/linux/maple.h16
-rw-r--r--include/linux/marker.h7
-rw-r--r--include/linux/memcontrol.h58
-rw-r--r--include/linux/memory_hotplug.h20
-rw-r--r--include/linux/mempolicy.h19
-rw-r--r--include/linux/memstick.h103
-rw-r--r--include/linux/mfd/asic3.h185
-rw-r--r--include/linux/mfd/core.h55
-rw-r--r--include/linux/mfd/da903x.h201
-rw-r--r--include/linux/mfd/t7l66xb.h34
-rw-r--r--include/linux/mfd/tc6387xb.h20
-rw-r--r--include/linux/mfd/tc6393xb.h59
-rw-r--r--include/linux/mfd/tmio.h47
-rw-r--r--include/linux/mfd/wm8350/audio.h598
-rw-r--r--include/linux/mfd/wm8350/comparator.h167
-rw-r--r--include/linux/mfd/wm8350/core.h631
-rw-r--r--include/linux/mfd/wm8350/gpio.h342
-rw-r--r--include/linux/mfd/wm8350/pmic.h741
-rw-r--r--include/linux/mfd/wm8350/rtc.h266
-rw-r--r--include/linux/mfd/wm8350/supply.h111
-rw-r--r--include/linux/mfd/wm8350/wdt.h28
-rw-r--r--include/linux/mfd/wm8400-audio.h1186
-rw-r--r--include/linux/mfd/wm8400-private.h936
-rw-r--r--include/linux/mfd/wm8400.h40
-rw-r--r--include/linux/migrate.h24
-rw-r--r--include/linux/mlx4/cmd.h9
-rw-r--r--include/linux/mlx4/cq.h36
-rw-r--r--include/linux/mlx4/device.h68
-rw-r--r--include/linux/mlx4/qp.h22
-rw-r--r--include/linux/mm.h74
-rw-r--r--include/linux/mm_inline.h98
-rw-r--r--include/linux/mm_types.h34
-rw-r--r--include/linux/mmc/card.h2
-rw-r--r--include/linux/mmc/host.h4
-rw-r--r--include/linux/mmdebug.h18
-rw-r--r--include/linux/mmiotrace.h20
-rw-r--r--include/linux/mmu_notifier.h279
-rw-r--r--include/linux/mmzone.h117
-rw-r--r--include/linux/mod_devicetable.h59
-rw-r--r--include/linux/module.h74
-rw-r--r--include/linux/moduleparam.h25
-rw-r--r--include/linux/mount.h7
-rw-r--r--include/linux/mroute.h30
-rw-r--r--include/linux/mroute6.h36
-rw-r--r--include/linux/msdos_fs.h56
-rw-r--r--include/linux/mtd/blktrans.h4
-rw-r--r--include/linux/mtd/cfi.h10
-rw-r--r--include/linux/mtd/cfi_endian.h5
-rw-r--r--include/linux/mtd/concat.h2
-rw-r--r--include/linux/mtd/doc2000.h2
-rw-r--r--include/linux/mtd/flashchip.h7
-rw-r--r--include/linux/mtd/ftl.h2
-rw-r--r--include/linux/mtd/gen_probe.h1
-rw-r--r--include/linux/mtd/inftl.h4
-rw-r--r--include/linux/mtd/map.h3
-rw-r--r--include/linux/mtd/mtd.h14
-rw-r--r--include/linux/mtd/nand-gpio.h19
-rw-r--r--include/linux/mtd/nand.h10
-rw-r--r--include/linux/mtd/nand_ecc.h2
-rw-r--r--include/linux/mtd/nftl.h2
-rw-r--r--include/linux/mtd/onenand_regs.h2
-rw-r--r--include/linux/mtd/partitions.h3
-rw-r--r--include/linux/mtd/physmap.h2
-rw-r--r--include/linux/mtd/plat-ram.h2
-rw-r--r--include/linux/mtd/pmc551.h4
-rw-r--r--include/linux/mtd/sh_flctl.h125
-rw-r--r--include/linux/mtd/ubi.h5
-rw-r--r--include/linux/mtd/xip.h2
-rw-r--r--include/linux/mv643xx_eth.h70
-rw-r--r--include/linux/namei.h27
-rw-r--r--include/linux/net.h34
-rw-r--r--include/linux/netdevice.h427
-rw-r--r--include/linux/netfilter.h97
-rw-r--r--include/linux/netfilter/Kbuild1
-rw-r--r--include/linux/netfilter/nf_conntrack_common.h8
-rw-r--r--include/linux/netfilter/nf_conntrack_proto_gre.h2
-rw-r--r--include/linux/netfilter/nf_conntrack_tcp.h3
-rw-r--r--include/linux/netfilter/nfnetlink.h3
-rw-r--r--include/linux/netfilter/nfnetlink_conntrack.h18
-rw-r--r--include/linux/netfilter/nfnetlink_log.h3
-rw-r--r--include/linux/netfilter/x_tables.h161
-rw-r--r--include/linux/netfilter/xt_TPROXY.h14
-rw-r--r--include/linux/netfilter/xt_recent.h26
-rw-r--r--include/linux/netfilter/xt_string.h15
-rw-r--r--include/linux/netfilter_bridge/ebt_ip6.h40
-rw-r--r--include/linux/netfilter_bridge/ebt_log.h3
-rw-r--r--include/linux/netfilter_bridge/ebtables.h76
-rw-r--r--include/linux/netfilter_ipv4.h1
-rw-r--r--include/linux/netfilter_ipv4/ipt_recent.h28
-rw-r--r--include/linux/netfilter_ipv6.h5
-rw-r--r--include/linux/netlink.h2
-rw-r--r--include/linux/nfs4.h3
-rw-r--r--include/linux/nfs_fs.h30
-rw-r--r--include/linux/nfs_fs_sb.h1
-rw-r--r--include/linux/nfs_mount.h4
-rw-r--r--include/linux/nfs_xdr.h11
-rw-r--r--include/linux/nfsd/nfsd.h31
-rw-r--r--include/linux/nfsd/state.h2
-rw-r--r--include/linux/nl80211.h144
-rw-r--r--include/linux/notifier.h13
-rw-r--r--include/linux/nsproxy.h7
-rw-r--r--include/linux/of.h4
-rw-r--r--include/linux/of_gpio.h2
-rw-r--r--include/linux/of_spi.h18
-rw-r--r--include/linux/oprofile.h18
-rw-r--r--include/linux/page-flags.h89
-rw-r--r--include/linux/page_cgroup.h108
-rw-r--r--include/linux/pagemap.h198
-rw-r--r--include/linux/pagevec.h34
-rw-r--r--include/linux/parport.h5
-rw-r--r--include/linux/parser.h2
-rw-r--r--include/linux/pci-acpi.h11
-rw-r--r--include/linux/pci-aspm.h5
-rw-r--r--include/linux/pci.h69
-rw-r--r--include/linux/pci_hotplug.h11
-rw-r--r--include/linux/pci_ids.h90
-rw-r--r--include/linux/pci_regs.h17
-rw-r--r--include/linux/percpu.h36
-rw-r--r--include/linux/percpu_counter.h12
-rw-r--r--include/linux/pfkeyv2.h13
-rw-r--r--include/linux/pfn.h6
-rw-r--r--include/linux/phonet.h170
-rw-r--r--include/linux/phy.h52
-rw-r--r--include/linux/pid.h17
-rw-r--r--include/linux/pid_namespace.h12
-rw-r--r--include/linux/pim.h18
-rw-r--r--include/linux/pkt_cls.h1
-rw-r--r--include/linux/pkt_sched.h32
-rw-r--r--include/linux/platform_device.h2
-rw-r--r--include/linux/pm.h111
-rw-r--r--include/linux/pm_legacy.h35
-rw-r--r--include/linux/pm_qos_params.h2
-rw-r--r--include/linux/pnp.h21
-rw-r--r--include/linux/poll.h8
-rw-r--r--include/linux/posix-timers.h4
-rw-r--r--include/linux/power_supply.h7
-rw-r--r--include/linux/ppp-comp.h2
-rw-r--r--include/linux/ppp_defs.h2
-rw-r--r--include/linux/prctl.h7
-rw-r--r--include/linux/proc_fs.h15
-rw-r--r--include/linux/profile.h67
-rw-r--r--include/linux/proportions.h2
-rw-r--r--include/linux/ptrace.h73
-rw-r--r--include/linux/quicklist.h7
-rw-r--r--include/linux/quota.h35
-rw-r--r--include/linux/quotaops.h286
-rw-r--r--include/linux/radix-tree.h12
-rw-r--r--include/linux/raid/bitmap.h1
-rw-r--r--include/linux/raid/linear.h12
-rw-r--r--include/linux/raid/md.h34
-rw-r--r--include/linux/raid/md_k.h18
-rw-r--r--include/linux/raid/md_p.h3
-rw-r--r--include/linux/raid/raid5.h64
-rw-r--r--include/linux/ramfs.h1
-rw-r--r--include/linux/ratelimit.h27
-rw-r--r--include/linux/rcuclassic.h39
-rw-r--r--include/linux/rculist.h42
-rw-r--r--include/linux/rcupdate.h20
-rw-r--r--include/linux/rcupreempt.h20
-rw-r--r--include/linux/reboot.h1
-rw-r--r--include/linux/regulator/bq24022.h21
-rw-r--r--include/linux/regulator/consumer.h284
-rw-r--r--include/linux/regulator/driver.h101
-rw-r--r--include/linux/regulator/fixed.h22
-rw-r--r--include/linux/regulator/machine.h122
-rw-r--r--include/linux/reiserfs_fs.h6
-rw-r--r--include/linux/reiserfs_fs_sb.h7
-rw-r--r--include/linux/reiserfs_xattr.h2
-rw-r--r--include/linux/relay.h5
-rw-r--r--include/linux/res_counter.h33
-rw-r--r--include/linux/rfkill.h61
-rw-r--r--include/linux/ring_buffer.h127
-rw-r--r--include/linux/rmap.h39
-rw-r--r--include/linux/rtc.h19
-rw-r--r--include/linux/rtc/m48t59.h47
-rw-r--r--include/linux/rtmutex.h2
-rw-r--r--include/linux/rtnetlink.h12
-rw-r--r--include/linux/scatterlist.h38
-rw-r--r--include/linux/sched.h242
-rw-r--r--include/linux/security.h102
-rw-r--r--include/linux/sem.h30
-rw-r--r--include/linux/semaphore.h6
-rw-r--r--include/linux/seq_file.h25
-rw-r--r--include/linux/seq_file_net.h3
-rw-r--r--include/linux/serial.h16
-rw-r--r--include/linux/serial_core.h32
-rw-r--r--include/linux/serio.h7
-rw-r--r--include/linux/sh_intc.h91
-rw-r--r--include/linux/shmem_fs.h2
-rw-r--r--include/linux/signalfd.h6
-rw-r--r--include/linux/skbuff.h218
-rw-r--r--include/linux/slab.h10
-rw-r--r--include/linux/slub_def.h3
-rw-r--r--include/linux/sm501.h39
-rw-r--r--include/linux/smb.h2
-rw-r--r--include/linux/smb_fs.h19
-rw-r--r--include/linux/smc911x.h13
-rw-r--r--include/linux/smc91x.h23
-rw-r--r--include/linux/smp.h9
-rw-r--r--include/linux/snmp.h2
-rw-r--r--include/linux/socket.h13
-rw-r--r--include/linux/sonet.h2
-rw-r--r--include/linux/spi/ads7846.h3
-rw-r--r--include/linux/spi/corgi_lcd.h20
-rw-r--r--include/linux/spi/ds1305.h35
-rw-r--r--include/linux/spi/max7301.h9
-rw-r--r--include/linux/spi/mcp23s08.h25
-rw-r--r--include/linux/spi/orion_spi.h18
-rw-r--r--include/linux/spi/spi.h16
-rw-r--r--include/linux/spinlock.h78
-rw-r--r--include/linux/spinlock_api_smp.h2
-rw-r--r--include/linux/ssb/ssb.h144
-rw-r--r--include/linux/ssb/ssb_regs.h19
-rw-r--r--include/linux/stacktrace.h2
-rw-r--r--include/linux/stallion.h6
-rw-r--r--include/linux/stop_machine.h35
-rw-r--r--include/linux/string.h3
-rw-r--r--include/linux/string_helpers.h16
-rw-r--r--include/linux/sunrpc/auth_gss.h2
-rw-r--r--include/linux/sunrpc/clnt.h5
-rw-r--r--include/linux/sunrpc/gss_api.h2
-rw-r--r--include/linux/sunrpc/gss_krb5.h3
-rw-r--r--include/linux/sunrpc/svc.h22
-rw-r--r--include/linux/sunrpc/svc_rdma.h62
-rw-r--r--include/linux/sunrpc/svcauth_gss.h3
-rw-r--r--include/linux/sunrpc/svcsock.h5
-rw-r--r--include/linux/sunrpc/xprtrdma.h4
-rw-r--r--include/linux/suspend.h6
-rw-r--r--include/linux/swab.h299
-rw-r--r--include/linux/swap.h72
-rw-r--r--include/linux/swiotlb.h83
-rw-r--r--include/linux/synclink.h1
-rw-r--r--include/linux/syscalls.h9
-rw-r--r--include/linux/sysctl.h27
-rw-r--r--include/linux/sysdev.h39
-rw-r--r--include/linux/sysfs.h51
-rw-r--r--include/linux/task_io_accounting.h20
-rw-r--r--include/linux/task_io_accounting_ops.h46
-rw-r--r--include/linux/taskstats.h6
-rw-r--r--include/linux/tc_act/Kbuild1
-rw-r--r--include/linux/tc_act/tc_skbedit.h44
-rw-r--r--include/linux/tcp.h58
-rw-r--r--include/linux/telephony.h4
-rw-r--r--include/linux/termios.h15
-rw-r--r--include/linux/textsearch.h13
-rw-r--r--include/linux/thread_info.h8
-rw-r--r--include/linux/tick.h19
-rw-r--r--include/linux/time.h11
-rw-r--r--include/linux/timerfd.h6
-rw-r--r--include/linux/timex.h11
-rw-r--r--include/linux/tipc_config.h10
-rw-r--r--include/linux/tracehook.h582
-rw-r--r--include/linux/tracepoint.h137
-rw-r--r--include/linux/tty.h258
-rw-r--r--include/linux/tty_driver.h84
-rw-r--r--include/linux/tty_ldisc.h7
-rw-r--r--include/linux/typecheck.h24
-rw-r--r--include/linux/types.h9
-rw-r--r--include/linux/ucb1400.h161
-rw-r--r--include/linux/udp.h6
-rw-r--r--include/linux/uio_driver.h8
-rw-r--r--include/linux/usb.h24
-rw-r--r--include/linux/usb/Kbuild3
-rw-r--r--include/linux/usb/cdc.h9
-rw-r--r--include/linux/usb/composite.h345
-rw-r--r--include/linux/usb/ehci_def.h160
-rw-r--r--include/linux/usb/gadget.h27
-rw-r--r--include/linux/usb/irda.h151
-rw-r--r--include/linux/usb/musb.h98
-rw-r--r--include/linux/usb/rndis_host.h3
-rw-r--r--include/linux/usb/serial.h61
-rw-r--r--include/linux/usb/tmc.h43
-rw-r--r--include/linux/usb/vstusb.h71
-rw-r--r--include/linux/usb/wusb-wa.h271
-rw-r--r--include/linux/usb/wusb.h376
-rw-r--r--include/linux/usbdevice_fs.h2
-rw-r--r--include/linux/uwb.h765
-rw-r--r--include/linux/uwb/debug-cmd.h57
-rw-r--r--include/linux/uwb/debug.h82
-rw-r--r--include/linux/uwb/spec.h727
-rw-r--r--include/linux/uwb/umc.h194
-rw-r--r--include/linux/uwb/whci.h117
-rw-r--r--include/linux/videodev.h15
-rw-r--r--include/linux/videodev2.h433
-rw-r--r--include/linux/videotext.h16
-rw-r--r--include/linux/virtio_9p.h2
-rw-r--r--include/linux/virtio_balloon.h2
-rw-r--r--include/linux/virtio_blk.h5
-rw-r--r--include/linux/virtio_config.h16
-rw-r--r--include/linux/virtio_console.h2
-rw-r--r--include/linux/virtio_net.h2
-rw-r--r--include/linux/virtio_pci.h5
-rw-r--r--include/linux/virtio_ring.h2
-rw-r--r--include/linux/virtio_rng.h2
-rw-r--r--include/linux/vmalloc.h21
-rw-r--r--include/linux/vmstat.h22
-rw-r--r--include/linux/vt_kern.h23
-rw-r--r--include/linux/wait.h9
-rw-r--r--include/linux/wanrouter.h2
-rw-r--r--include/linux/wireless.h30
-rw-r--r--include/linux/wlp.h735
-rw-r--r--include/linux/wm97xx_batt.h26
-rw-r--r--include/linux/workqueue.h23
-rw-r--r--include/linux/writeback.h10
-rw-r--r--include/linux/xfrm.h10
506 files changed, 26501 insertions, 5040 deletions
diff --git a/include/linux/Kbuild b/include/linux/Kbuild
index 71d70d1fbce2..e531783e5d78 100644
--- a/include/linux/Kbuild
+++ b/include/linux/Kbuild
@@ -97,6 +97,7 @@ header-y += ioctl.h
97header-y += ip6_tunnel.h 97header-y += ip6_tunnel.h
98header-y += ipmi_msgdefs.h 98header-y += ipmi_msgdefs.h
99header-y += ipsec.h 99header-y += ipsec.h
100header-y += ip_vs.h
100header-y += ipx.h 101header-y += ipx.h
101header-y += irda.h 102header-y += irda.h
102header-y += iso_fs.h 103header-y += iso_fs.h
@@ -106,6 +107,7 @@ header-y += keyctl.h
106header-y += limits.h 107header-y += limits.h
107header-y += magic.h 108header-y += magic.h
108header-y += major.h 109header-y += major.h
110header-y += map_to_7segment.h
109header-y += matroxfb.h 111header-y += matroxfb.h
110header-y += meye.h 112header-y += meye.h
111header-y += minix_fs.h 113header-y += minix_fs.h
@@ -125,6 +127,7 @@ header-y += pci_regs.h
125header-y += pfkeyv2.h 127header-y += pfkeyv2.h
126header-y += pg.h 128header-y += pg.h
127header-y += phantom.h 129header-y += phantom.h
130header-y += phonet.h
128header-y += pkt_cls.h 131header-y += pkt_cls.h
129header-y += pkt_sched.h 132header-y += pkt_sched.h
130header-y += posix_types.h 133header-y += posix_types.h
@@ -166,7 +169,8 @@ unifdef-y += acct.h
166unifdef-y += adb.h 169unifdef-y += adb.h
167unifdef-y += adfs_fs.h 170unifdef-y += adfs_fs.h
168unifdef-y += agpgart.h 171unifdef-y += agpgart.h
169ifneq ($(wildcard $(srctree)/include/asm-$(SRCARCH)/a.out.h),) 172ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/a.out.h \
173 $(srctree)/include/asm-$(SRCARCH)/a.out.h),)
170unifdef-y += a.out.h 174unifdef-y += a.out.h
171endif 175endif
172unifdef-y += apm_bios.h 176unifdef-y += apm_bios.h
@@ -178,6 +182,8 @@ unifdef-y += audit.h
178unifdef-y += auto_fs.h 182unifdef-y += auto_fs.h
179unifdef-y += auxvec.h 183unifdef-y += auxvec.h
180unifdef-y += binfmts.h 184unifdef-y += binfmts.h
185unifdef-y += blktrace_api.h
186unifdef-y += byteorder.h
181unifdef-y += capability.h 187unifdef-y += capability.h
182unifdef-y += capi.h 188unifdef-y += capi.h
183unifdef-y += cciss_ioctl.h 189unifdef-y += cciss_ioctl.h
@@ -189,7 +195,6 @@ unifdef-y += connector.h
189unifdef-y += cuda.h 195unifdef-y += cuda.h
190unifdef-y += cyclades.h 196unifdef-y += cyclades.h
191unifdef-y += dccp.h 197unifdef-y += dccp.h
192unifdef-y += dirent.h
193unifdef-y += dlm.h 198unifdef-y += dlm.h
194unifdef-y += dlm_plock.h 199unifdef-y += dlm_plock.h
195unifdef-y += edd.h 200unifdef-y += edd.h
@@ -231,6 +236,7 @@ unifdef-y += if_fddi.h
231unifdef-y += if_frad.h 236unifdef-y += if_frad.h
232unifdef-y += if_ltalk.h 237unifdef-y += if_ltalk.h
233unifdef-y += if_link.h 238unifdef-y += if_link.h
239unifdef-y += if_phonet.h
234unifdef-y += if_pppol2tp.h 240unifdef-y += if_pppol2tp.h
235unifdef-y += if_pppox.h 241unifdef-y += if_pppox.h
236unifdef-y += if_tr.h 242unifdef-y += if_tr.h
@@ -250,13 +256,18 @@ unifdef-y += isdn.h
250unifdef-y += isdnif.h 256unifdef-y += isdnif.h
251unifdef-y += isdn_divertif.h 257unifdef-y += isdn_divertif.h
252unifdef-y += isdn_ppp.h 258unifdef-y += isdn_ppp.h
259unifdef-y += ivtv.h
260unifdef-y += ivtvfb.h
253unifdef-y += joystick.h 261unifdef-y += joystick.h
254unifdef-y += kdev_t.h 262unifdef-y += kdev_t.h
255unifdef-y += kd.h 263unifdef-y += kd.h
256unifdef-y += kernelcapi.h 264unifdef-y += kernelcapi.h
257unifdef-y += kernel.h 265unifdef-y += kernel.h
258unifdef-y += keyboard.h 266unifdef-y += keyboard.h
267ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/kvm.h \
268 $(srctree)/include/asm-$(SRCARCH)/kvm.h),)
259unifdef-y += kvm.h 269unifdef-y += kvm.h
270endif
260unifdef-y += llc.h 271unifdef-y += llc.h
261unifdef-y += loop.h 272unifdef-y += loop.h
262unifdef-y += lp.h 273unifdef-y += lp.h
@@ -293,7 +304,6 @@ unifdef-y += parport.h
293unifdef-y += patchkey.h 304unifdef-y += patchkey.h
294unifdef-y += pci.h 305unifdef-y += pci.h
295unifdef-y += personality.h 306unifdef-y += personality.h
296unifdef-y += pim.h
297unifdef-y += pktcdvd.h 307unifdef-y += pktcdvd.h
298unifdef-y += pmu.h 308unifdef-y += pmu.h
299unifdef-y += poll.h 309unifdef-y += poll.h
@@ -331,6 +341,7 @@ unifdef-y += soundcard.h
331unifdef-y += stat.h 341unifdef-y += stat.h
332unifdef-y += stddef.h 342unifdef-y += stddef.h
333unifdef-y += string.h 343unifdef-y += string.h
344unifdef-y += swab.h
334unifdef-y += synclink.h 345unifdef-y += synclink.h
335unifdef-y += sysctl.h 346unifdef-y += sysctl.h
336unifdef-y += tcp.h 347unifdef-y += tcp.h
@@ -354,6 +365,7 @@ unifdef-y += virtio_balloon.h
354unifdef-y += virtio_console.h 365unifdef-y += virtio_console.h
355unifdef-y += virtio_pci.h 366unifdef-y += virtio_pci.h
356unifdef-y += virtio_ring.h 367unifdef-y += virtio_ring.h
368unifdef-y += virtio_rng.h
357unifdef-y += vt.h 369unifdef-y += vt.h
358unifdef-y += wait.h 370unifdef-y += wait.h
359unifdef-y += wanrouter.h 371unifdef-y += wanrouter.h
diff --git a/include/linux/acct.h b/include/linux/acct.h
index e8cae54e8d88..882dc7248766 100644
--- a/include/linux/acct.h
+++ b/include/linux/acct.h
@@ -120,17 +120,20 @@ struct acct_v3
120struct vfsmount; 120struct vfsmount;
121struct super_block; 121struct super_block;
122struct pacct_struct; 122struct pacct_struct;
123struct pid_namespace;
123extern void acct_auto_close_mnt(struct vfsmount *m); 124extern void acct_auto_close_mnt(struct vfsmount *m);
124extern void acct_auto_close(struct super_block *sb); 125extern void acct_auto_close(struct super_block *sb);
125extern void acct_init_pacct(struct pacct_struct *pacct); 126extern void acct_init_pacct(struct pacct_struct *pacct);
126extern void acct_collect(long exitcode, int group_dead); 127extern void acct_collect(long exitcode, int group_dead);
127extern void acct_process(void); 128extern void acct_process(void);
129extern void acct_exit_ns(struct pid_namespace *);
128#else 130#else
129#define acct_auto_close_mnt(x) do { } while (0) 131#define acct_auto_close_mnt(x) do { } while (0)
130#define acct_auto_close(x) do { } while (0) 132#define acct_auto_close(x) do { } while (0)
131#define acct_init_pacct(x) do { } while (0) 133#define acct_init_pacct(x) do { } while (0)
132#define acct_collect(x,y) do { } while (0) 134#define acct_collect(x,y) do { } while (0)
133#define acct_process() do { } while (0) 135#define acct_process() do { } while (0)
136#define acct_exit_ns(ns) do { } while (0)
134#endif 137#endif
135 138
136/* 139/*
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index a17177639376..fd6a452b0ceb 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -94,18 +94,10 @@ int acpi_parse_mcfg (struct acpi_table_header *header);
94void acpi_table_print_madt_entry (struct acpi_subtable_header *madt); 94void acpi_table_print_madt_entry (struct acpi_subtable_header *madt);
95 95
96/* the following four functions are architecture-dependent */ 96/* the following four functions are architecture-dependent */
97#ifdef CONFIG_HAVE_ARCH_PARSE_SRAT
98#define NR_NODE_MEMBLKS MAX_NUMNODES
99#define acpi_numa_slit_init(slit) do {} while (0)
100#define acpi_numa_processor_affinity_init(pa) do {} while (0)
101#define acpi_numa_memory_affinity_init(ma) do {} while (0)
102#define acpi_numa_arch_fixup() do {} while (0)
103#else
104void acpi_numa_slit_init (struct acpi_table_slit *slit); 97void acpi_numa_slit_init (struct acpi_table_slit *slit);
105void acpi_numa_processor_affinity_init (struct acpi_srat_cpu_affinity *pa); 98void acpi_numa_processor_affinity_init (struct acpi_srat_cpu_affinity *pa);
106void acpi_numa_memory_affinity_init (struct acpi_srat_mem_affinity *ma); 99void acpi_numa_memory_affinity_init (struct acpi_srat_mem_affinity *ma);
107void acpi_numa_arch_fixup(void); 100void acpi_numa_arch_fixup(void);
108#endif
109 101
110#ifdef CONFIG_ACPI_HOTPLUG_CPU 102#ifdef CONFIG_ACPI_HOTPLUG_CPU
111/* Arch dependent functions for cpu hotplug support */ 103/* Arch dependent functions for cpu hotplug support */
@@ -236,6 +228,7 @@ int acpi_check_mem_region(resource_size_t start, resource_size_t n,
236 const char *name); 228 const char *name);
237 229
238#ifdef CONFIG_PM_SLEEP 230#ifdef CONFIG_PM_SLEEP
231void __init acpi_no_s4_hw_signature(void);
239void __init acpi_old_suspend_ordering(void); 232void __init acpi_old_suspend_ordering(void);
240#endif /* CONFIG_PM_SLEEP */ 233#endif /* CONFIG_PM_SLEEP */
241#else /* CONFIG_ACPI */ 234#else /* CONFIG_ACPI */
diff --git a/include/linux/aer.h b/include/linux/aer.h
index f2518141de88..f7df1eefc107 100644
--- a/include/linux/aer.h
+++ b/include/linux/aer.h
@@ -10,7 +10,6 @@
10#if defined(CONFIG_PCIEAER) 10#if defined(CONFIG_PCIEAER)
11/* pci-e port driver needs this function to enable aer */ 11/* pci-e port driver needs this function to enable aer */
12extern int pci_enable_pcie_error_reporting(struct pci_dev *dev); 12extern int pci_enable_pcie_error_reporting(struct pci_dev *dev);
13extern int pci_find_aer_capability(struct pci_dev *dev);
14extern int pci_disable_pcie_error_reporting(struct pci_dev *dev); 13extern int pci_disable_pcie_error_reporting(struct pci_dev *dev);
15extern int pci_cleanup_aer_uncorrect_error_status(struct pci_dev *dev); 14extern int pci_cleanup_aer_uncorrect_error_status(struct pci_dev *dev);
16#else 15#else
@@ -18,10 +17,6 @@ static inline int pci_enable_pcie_error_reporting(struct pci_dev *dev)
18{ 17{
19 return -EINVAL; 18 return -EINVAL;
20} 19}
21static inline int pci_find_aer_capability(struct pci_dev *dev)
22{
23 return 0;
24}
25static inline int pci_disable_pcie_error_reporting(struct pci_dev *dev) 20static inline int pci_disable_pcie_error_reporting(struct pci_dev *dev)
26{ 21{
27 return -EINVAL; 22 return -EINVAL;
diff --git a/include/linux/agp_backend.h b/include/linux/agp_backend.h
index 972b12bcfb36..2b8df8b420fd 100644
--- a/include/linux/agp_backend.h
+++ b/include/linux/agp_backend.h
@@ -30,6 +30,8 @@
30#ifndef _AGP_BACKEND_H 30#ifndef _AGP_BACKEND_H
31#define _AGP_BACKEND_H 1 31#define _AGP_BACKEND_H 1
32 32
33#include <linux/list.h>
34
33enum chipset_type { 35enum chipset_type {
34 NOT_SUPPORTED, 36 NOT_SUPPORTED,
35 SUPPORTED, 37 SUPPORTED,
@@ -78,6 +80,8 @@ struct agp_memory {
78 bool is_bound; 80 bool is_bound;
79 bool is_flushed; 81 bool is_flushed;
80 bool vmalloc_flag; 82 bool vmalloc_flag;
83 /* list of agp_memory mapped to the aperture */
84 struct list_head mapped_list;
81}; 85};
82 86
83#define AGP_NORMAL_MEMORY 0 87#define AGP_NORMAL_MEMORY 0
@@ -96,6 +100,7 @@ extern struct agp_memory *agp_allocate_memory(struct agp_bridge_data *, size_t,
96extern int agp_copy_info(struct agp_bridge_data *, struct agp_kern_info *); 100extern int agp_copy_info(struct agp_bridge_data *, struct agp_kern_info *);
97extern int agp_bind_memory(struct agp_memory *, off_t); 101extern int agp_bind_memory(struct agp_memory *, off_t);
98extern int agp_unbind_memory(struct agp_memory *); 102extern int agp_unbind_memory(struct agp_memory *);
103extern int agp_rebind_memory(void);
99extern void agp_enable(struct agp_bridge_data *, u32); 104extern void agp_enable(struct agp_bridge_data *, u32);
100extern struct agp_bridge_data *agp_backend_acquire(struct pci_dev *); 105extern struct agp_bridge_data *agp_backend_acquire(struct pci_dev *);
101extern void agp_backend_release(struct agp_bridge_data *); 106extern void agp_backend_release(struct agp_bridge_data *);
diff --git a/include/linux/aio.h b/include/linux/aio.h
index b51ddd28444e..f6b8cf99b596 100644
--- a/include/linux/aio.h
+++ b/include/linux/aio.h
@@ -7,7 +7,6 @@
7#include <linux/uio.h> 7#include <linux/uio.h>
8 8
9#include <asm/atomic.h> 9#include <asm/atomic.h>
10#include <linux/uio.h>
11 10
12#define AIO_MAXSEGS 4 11#define AIO_MAXSEGS 4
13#define AIO_KIOGRP_NR_ATOMIC 8 12#define AIO_KIOGRP_NR_ATOMIC 8
@@ -205,12 +204,21 @@ struct kioctx {
205/* prototypes */ 204/* prototypes */
206extern unsigned aio_max_size; 205extern unsigned aio_max_size;
207 206
207#ifdef CONFIG_AIO
208extern ssize_t wait_on_sync_kiocb(struct kiocb *iocb); 208extern ssize_t wait_on_sync_kiocb(struct kiocb *iocb);
209extern int aio_put_req(struct kiocb *iocb); 209extern int aio_put_req(struct kiocb *iocb);
210extern void kick_iocb(struct kiocb *iocb); 210extern void kick_iocb(struct kiocb *iocb);
211extern int aio_complete(struct kiocb *iocb, long res, long res2); 211extern int aio_complete(struct kiocb *iocb, long res, long res2);
212struct mm_struct; 212struct mm_struct;
213extern void exit_aio(struct mm_struct *mm); 213extern void exit_aio(struct mm_struct *mm);
214#else
215static inline ssize_t wait_on_sync_kiocb(struct kiocb *iocb) { return 0; }
216static inline int aio_put_req(struct kiocb *iocb) { return 0; }
217static inline void kick_iocb(struct kiocb *iocb) { }
218static inline int aio_complete(struct kiocb *iocb, long res, long res2) { return 0; }
219struct mm_struct;
220static inline void exit_aio(struct mm_struct *mm) { }
221#endif /* CONFIG_AIO */
214 222
215#define io_wait_to_kiocb(wait) container_of(wait, struct kiocb, ki_wait) 223#define io_wait_to_kiocb(wait) container_of(wait, struct kiocb, ki_wait)
216 224
diff --git a/include/linux/anon_inodes.h b/include/linux/anon_inodes.h
index 6129e58ca7c9..e0a0cdc2da43 100644
--- a/include/linux/anon_inodes.h
+++ b/include/linux/anon_inodes.h
@@ -9,7 +9,7 @@
9#define _LINUX_ANON_INODES_H 9#define _LINUX_ANON_INODES_H
10 10
11int anon_inode_getfd(const char *name, const struct file_operations *fops, 11int anon_inode_getfd(const char *name, const struct file_operations *fops,
12 void *priv); 12 void *priv, int flags);
13 13
14#endif /* _LINUX_ANON_INODES_H */ 14#endif /* _LINUX_ANON_INODES_H */
15 15
diff --git a/include/linux/async_tx.h b/include/linux/async_tx.h
index eb640f0acfac..0f50d4cc4360 100644
--- a/include/linux/async_tx.h
+++ b/include/linux/async_tx.h
@@ -101,21 +101,14 @@ async_tx_find_channel(struct dma_async_tx_descriptor *depend_tx,
101 101
102/** 102/**
103 * async_tx_sync_epilog - actions to take if an operation is run synchronously 103 * async_tx_sync_epilog - actions to take if an operation is run synchronously
104 * @flags: async_tx flags
105 * @depend_tx: transaction depends on depend_tx
106 * @cb_fn: function to call when the transaction completes 104 * @cb_fn: function to call when the transaction completes
107 * @cb_fn_param: parameter to pass to the callback routine 105 * @cb_fn_param: parameter to pass to the callback routine
108 */ 106 */
109static inline void 107static inline void
110async_tx_sync_epilog(unsigned long flags, 108async_tx_sync_epilog(dma_async_tx_callback cb_fn, void *cb_fn_param)
111 struct dma_async_tx_descriptor *depend_tx,
112 dma_async_tx_callback cb_fn, void *cb_fn_param)
113{ 109{
114 if (cb_fn) 110 if (cb_fn)
115 cb_fn(cb_fn_param); 111 cb_fn(cb_fn_param);
116
117 if (depend_tx && (flags & ASYNC_TX_DEP_ACK))
118 async_tx_ack(depend_tx);
119} 112}
120 113
121void 114void
@@ -152,4 +145,6 @@ struct dma_async_tx_descriptor *
152async_trigger_callback(enum async_tx_flags flags, 145async_trigger_callback(enum async_tx_flags flags,
153 struct dma_async_tx_descriptor *depend_tx, 146 struct dma_async_tx_descriptor *depend_tx,
154 dma_async_tx_callback cb_fn, void *cb_fn_param); 147 dma_async_tx_callback cb_fn, void *cb_fn_param);
148
149void async_tx_quiesce(struct dma_async_tx_descriptor **tx);
155#endif /* _ASYNC_TX_H_ */ 150#endif /* _ASYNC_TX_H_ */
diff --git a/include/linux/ata.h b/include/linux/ata.h
index 1c622e2b0504..a53318b8cbd0 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -30,6 +30,7 @@
30#define __LINUX_ATA_H__ 30#define __LINUX_ATA_H__
31 31
32#include <linux/types.h> 32#include <linux/types.h>
33#include <asm/byteorder.h>
33 34
34/* defines only for the constants which don't work well as enums */ 35/* defines only for the constants which don't work well as enums */
35#define ATA_DMA_BOUNDARY 0xffffUL 36#define ATA_DMA_BOUNDARY 0xffffUL
@@ -46,18 +47,49 @@ enum {
46 ATA_MAX_SECTORS_TAPE = 65535, 47 ATA_MAX_SECTORS_TAPE = 65535,
47 48
48 ATA_ID_WORDS = 256, 49 ATA_ID_WORDS = 256,
50 ATA_ID_CONFIG = 0,
51 ATA_ID_CYLS = 1,
52 ATA_ID_HEADS = 3,
53 ATA_ID_SECTORS = 6,
49 ATA_ID_SERNO = 10, 54 ATA_ID_SERNO = 10,
55 ATA_ID_BUF_SIZE = 21,
50 ATA_ID_FW_REV = 23, 56 ATA_ID_FW_REV = 23,
51 ATA_ID_PROD = 27, 57 ATA_ID_PROD = 27,
58 ATA_ID_MAX_MULTSECT = 47,
59 ATA_ID_DWORD_IO = 48,
60 ATA_ID_CAPABILITY = 49,
52 ATA_ID_OLD_PIO_MODES = 51, 61 ATA_ID_OLD_PIO_MODES = 51,
62 ATA_ID_OLD_DMA_MODES = 52,
53 ATA_ID_FIELD_VALID = 53, 63 ATA_ID_FIELD_VALID = 53,
64 ATA_ID_CUR_CYLS = 54,
65 ATA_ID_CUR_HEADS = 55,
66 ATA_ID_CUR_SECTORS = 56,
67 ATA_ID_MULTSECT = 59,
68 ATA_ID_LBA_CAPACITY = 60,
69 ATA_ID_SWDMA_MODES = 62,
54 ATA_ID_MWDMA_MODES = 63, 70 ATA_ID_MWDMA_MODES = 63,
55 ATA_ID_PIO_MODES = 64, 71 ATA_ID_PIO_MODES = 64,
56 ATA_ID_EIDE_DMA_MIN = 65, 72 ATA_ID_EIDE_DMA_MIN = 65,
73 ATA_ID_EIDE_DMA_TIME = 66,
57 ATA_ID_EIDE_PIO = 67, 74 ATA_ID_EIDE_PIO = 67,
58 ATA_ID_EIDE_PIO_IORDY = 68, 75 ATA_ID_EIDE_PIO_IORDY = 68,
59 ATA_ID_UDMA_MODES = 88, 76 ATA_ID_QUEUE_DEPTH = 75,
60 ATA_ID_MAJOR_VER = 80, 77 ATA_ID_MAJOR_VER = 80,
78 ATA_ID_COMMAND_SET_1 = 82,
79 ATA_ID_COMMAND_SET_2 = 83,
80 ATA_ID_CFSSE = 84,
81 ATA_ID_CFS_ENABLE_1 = 85,
82 ATA_ID_CFS_ENABLE_2 = 86,
83 ATA_ID_CSF_DEFAULT = 87,
84 ATA_ID_UDMA_MODES = 88,
85 ATA_ID_HW_CONFIG = 93,
86 ATA_ID_SPG = 98,
87 ATA_ID_LBA_CAPACITY_2 = 100,
88 ATA_ID_LAST_LUN = 126,
89 ATA_ID_DLF = 128,
90 ATA_ID_CSFO = 129,
91 ATA_ID_CFA_POWER = 160,
92 ATA_ID_ROT_SPEED = 217,
61 ATA_ID_PIO4 = (1 << 1), 93 ATA_ID_PIO4 = (1 << 1),
62 94
63 ATA_ID_SERNO_LEN = 20, 95 ATA_ID_SERNO_LEN = 20,
@@ -123,13 +155,26 @@ enum {
123 ATA_BUSY = (1 << 7), /* BSY status bit */ 155 ATA_BUSY = (1 << 7), /* BSY status bit */
124 ATA_DRDY = (1 << 6), /* device ready */ 156 ATA_DRDY = (1 << 6), /* device ready */
125 ATA_DF = (1 << 5), /* device fault */ 157 ATA_DF = (1 << 5), /* device fault */
158 ATA_DSC = (1 << 4), /* drive seek complete */
126 ATA_DRQ = (1 << 3), /* data request i/o */ 159 ATA_DRQ = (1 << 3), /* data request i/o */
160 ATA_CORR = (1 << 2), /* corrected data error */
161 ATA_IDX = (1 << 1), /* index */
127 ATA_ERR = (1 << 0), /* have an error */ 162 ATA_ERR = (1 << 0), /* have an error */
128 ATA_SRST = (1 << 2), /* software reset */ 163 ATA_SRST = (1 << 2), /* software reset */
129 ATA_ICRC = (1 << 7), /* interface CRC error */ 164 ATA_ICRC = (1 << 7), /* interface CRC error */
165 ATA_BBK = ATA_ICRC, /* pre-EIDE: block marked bad */
130 ATA_UNC = (1 << 6), /* uncorrectable media error */ 166 ATA_UNC = (1 << 6), /* uncorrectable media error */
167 ATA_MC = (1 << 5), /* media changed */
131 ATA_IDNF = (1 << 4), /* ID not found */ 168 ATA_IDNF = (1 << 4), /* ID not found */
169 ATA_MCR = (1 << 3), /* media change requested */
132 ATA_ABORTED = (1 << 2), /* command aborted */ 170 ATA_ABORTED = (1 << 2), /* command aborted */
171 ATA_TRK0NF = (1 << 1), /* track 0 not found */
172 ATA_AMNF = (1 << 0), /* address mark not found */
173 ATAPI_LFS = 0xF0, /* last failed sense */
174 ATAPI_EOM = ATA_TRK0NF, /* end of media */
175 ATAPI_ILI = ATA_AMNF, /* illegal length indication */
176 ATAPI_IO = (1 << 1),
177 ATAPI_COD = (1 << 0),
133 178
134 /* ATA command block registers */ 179 /* ATA command block registers */
135 ATA_REG_DATA = 0x00, 180 ATA_REG_DATA = 0x00,
@@ -192,6 +237,13 @@ enum {
192 ATA_CMD_PMP_WRITE = 0xE8, 237 ATA_CMD_PMP_WRITE = 0xE8,
193 ATA_CMD_CONF_OVERLAY = 0xB1, 238 ATA_CMD_CONF_OVERLAY = 0xB1,
194 ATA_CMD_SEC_FREEZE_LOCK = 0xF5, 239 ATA_CMD_SEC_FREEZE_LOCK = 0xF5,
240 ATA_CMD_SMART = 0xB0,
241 ATA_CMD_MEDIA_LOCK = 0xDE,
242 ATA_CMD_MEDIA_UNLOCK = 0xDF,
243 /* marked obsolete in the ATA/ATAPI-7 spec */
244 ATA_CMD_RESTORE = 0x10,
245 /* EXABYTE specific */
246 ATA_EXABYTE_ENABLE_NEST = 0xF0,
195 247
196 /* READ_LOG_EXT pages */ 248 /* READ_LOG_EXT pages */
197 ATA_LOG_SATA_NCQ = 0x10, 249 ATA_LOG_SATA_NCQ = 0x10,
@@ -232,6 +284,10 @@ enum {
232 SETFEATURES_WC_ON = 0x02, /* Enable write cache */ 284 SETFEATURES_WC_ON = 0x02, /* Enable write cache */
233 SETFEATURES_WC_OFF = 0x82, /* Disable write cache */ 285 SETFEATURES_WC_OFF = 0x82, /* Disable write cache */
234 286
287 /* Enable/Disable Automatic Acoustic Management */
288 SETFEATURES_AAM_ON = 0x42,
289 SETFEATURES_AAM_OFF = 0xC2,
290
235 SETFEATURES_SPINUP = 0x07, /* Spin-up drive */ 291 SETFEATURES_SPINUP = 0x07, /* Spin-up drive */
236 292
237 SETFEATURES_SATA_ENABLE = 0x10, /* Enable use of SATA feature */ 293 SETFEATURES_SATA_ENABLE = 0x10, /* Enable use of SATA feature */
@@ -254,6 +310,15 @@ enum {
254 ATA_DCO_IDENTIFY = 0xC2, 310 ATA_DCO_IDENTIFY = 0xC2,
255 ATA_DCO_SET = 0xC3, 311 ATA_DCO_SET = 0xC3,
256 312
313 /* feature values for SMART */
314 ATA_SMART_ENABLE = 0xD8,
315 ATA_SMART_READ_VALUES = 0xD0,
316 ATA_SMART_READ_THRESHOLDS = 0xD1,
317
318 /* password used in LBA Mid / LBA High for executing SMART commands */
319 ATA_SMART_LBAM_PASS = 0x4F,
320 ATA_SMART_LBAH_PASS = 0xC2,
321
257 /* ATAPI stuff */ 322 /* ATAPI stuff */
258 ATAPI_PKT_DMA = (1 << 0), 323 ATAPI_PKT_DMA = (1 << 0),
259 ATAPI_DMADIR = (1 << 2), /* ATAPI data dir: 324 ATAPI_DMADIR = (1 << 2), /* ATAPI data dir:
@@ -438,17 +503,17 @@ static inline int ata_is_data(u8 prot)
438/* 503/*
439 * id tests 504 * id tests
440 */ 505 */
441#define ata_id_is_ata(id) (((id)[0] & (1 << 15)) == 0) 506#define ata_id_is_ata(id) (((id)[ATA_ID_CONFIG] & (1 << 15)) == 0)
442#define ata_id_has_lba(id) ((id)[49] & (1 << 9)) 507#define ata_id_has_lba(id) ((id)[ATA_ID_CAPABILITY] & (1 << 9))
443#define ata_id_has_dma(id) ((id)[49] & (1 << 8)) 508#define ata_id_has_dma(id) ((id)[ATA_ID_CAPABILITY] & (1 << 8))
444#define ata_id_has_ncq(id) ((id)[76] & (1 << 8)) 509#define ata_id_has_ncq(id) ((id)[76] & (1 << 8))
445#define ata_id_queue_depth(id) (((id)[75] & 0x1f) + 1) 510#define ata_id_queue_depth(id) (((id)[ATA_ID_QUEUE_DEPTH] & 0x1f) + 1)
446#define ata_id_removeable(id) ((id)[0] & (1 << 7)) 511#define ata_id_removeable(id) ((id)[ATA_ID_CONFIG] & (1 << 7))
447#define ata_id_has_atapi_AN(id) \ 512#define ata_id_has_atapi_AN(id) \
448 ( (((id)[76] != 0x0000) && ((id)[76] != 0xffff)) && \ 513 ( (((id)[76] != 0x0000) && ((id)[76] != 0xffff)) && \
449 ((id)[78] & (1 << 5)) ) 514 ((id)[78] & (1 << 5)) )
450#define ata_id_iordy_disable(id) ((id)[49] & (1 << 10)) 515#define ata_id_iordy_disable(id) ((id)[ATA_ID_CAPABILITY] & (1 << 10))
451#define ata_id_has_iordy(id) ((id)[49] & (1 << 11)) 516#define ata_id_has_iordy(id) ((id)[ATA_ID_CAPABILITY] & (1 << 11))
452#define ata_id_u32(id,n) \ 517#define ata_id_u32(id,n) \
453 (((u32) (id)[(n) + 1] << 16) | ((u32) (id)[(n)])) 518 (((u32) (id)[(n) + 1] << 16) | ((u32) (id)[(n)]))
454#define ata_id_u64(id,n) \ 519#define ata_id_u64(id,n) \
@@ -457,7 +522,7 @@ static inline int ata_is_data(u8 prot)
457 ((u64) (id)[(n) + 1] << 16) | \ 522 ((u64) (id)[(n) + 1] << 16) | \
458 ((u64) (id)[(n) + 0]) ) 523 ((u64) (id)[(n) + 0]) )
459 524
460#define ata_id_cdb_intr(id) (((id)[0] & 0x60) == 0x20) 525#define ata_id_cdb_intr(id) (((id)[ATA_ID_CONFIG] & 0x60) == 0x20)
461 526
462static inline bool ata_id_has_hipm(const u16 *id) 527static inline bool ata_id_has_hipm(const u16 *id)
463{ 528{
@@ -482,75 +547,106 @@ static inline bool ata_id_has_dipm(const u16 *id)
482 547
483static inline int ata_id_has_fua(const u16 *id) 548static inline int ata_id_has_fua(const u16 *id)
484{ 549{
485 if ((id[84] & 0xC000) != 0x4000) 550 if ((id[ATA_ID_CFSSE] & 0xC000) != 0x4000)
486 return 0; 551 return 0;
487 return id[84] & (1 << 6); 552 return id[ATA_ID_CFSSE] & (1 << 6);
488} 553}
489 554
490static inline int ata_id_has_flush(const u16 *id) 555static inline int ata_id_has_flush(const u16 *id)
491{ 556{
492 if ((id[83] & 0xC000) != 0x4000) 557 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000)
558 return 0;
559 return id[ATA_ID_COMMAND_SET_2] & (1 << 12);
560}
561
562static inline int ata_id_flush_enabled(const u16 *id)
563{
564 if (ata_id_has_flush(id) == 0)
493 return 0; 565 return 0;
494 return id[83] & (1 << 12); 566 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000)
567 return 0;
568 return id[ATA_ID_CFS_ENABLE_2] & (1 << 12);
495} 569}
496 570
497static inline int ata_id_has_flush_ext(const u16 *id) 571static inline int ata_id_has_flush_ext(const u16 *id)
498{ 572{
499 if ((id[83] & 0xC000) != 0x4000) 573 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000)
500 return 0; 574 return 0;
501 return id[83] & (1 << 13); 575 return id[ATA_ID_COMMAND_SET_2] & (1 << 13);
576}
577
578static inline int ata_id_flush_ext_enabled(const u16 *id)
579{
580 if (ata_id_has_flush_ext(id) == 0)
581 return 0;
582 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000)
583 return 0;
584 /*
585 * some Maxtor disks have bit 13 defined incorrectly
586 * so check bit 10 too
587 */
588 return (id[ATA_ID_CFS_ENABLE_2] & 0x2400) == 0x2400;
502} 589}
503 590
504static inline int ata_id_has_lba48(const u16 *id) 591static inline int ata_id_has_lba48(const u16 *id)
505{ 592{
506 if ((id[83] & 0xC000) != 0x4000) 593 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000)
507 return 0; 594 return 0;
508 if (!ata_id_u64(id, 100)) 595 if (!ata_id_u64(id, ATA_ID_LBA_CAPACITY_2))
509 return 0; 596 return 0;
510 return id[83] & (1 << 10); 597 return id[ATA_ID_COMMAND_SET_2] & (1 << 10);
598}
599
600static inline int ata_id_lba48_enabled(const u16 *id)
601{
602 if (ata_id_has_lba48(id) == 0)
603 return 0;
604 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000)
605 return 0;
606 return id[ATA_ID_CFS_ENABLE_2] & (1 << 10);
511} 607}
512 608
513static inline int ata_id_hpa_enabled(const u16 *id) 609static inline int ata_id_hpa_enabled(const u16 *id)
514{ 610{
515 /* Yes children, word 83 valid bits cover word 82 data */ 611 /* Yes children, word 83 valid bits cover word 82 data */
516 if ((id[83] & 0xC000) != 0x4000) 612 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000)
517 return 0; 613 return 0;
518 /* And 87 covers 85-87 */ 614 /* And 87 covers 85-87 */
519 if ((id[87] & 0xC000) != 0x4000) 615 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000)
520 return 0; 616 return 0;
521 /* Check command sets enabled as well as supported */ 617 /* Check command sets enabled as well as supported */
522 if ((id[85] & ( 1 << 10)) == 0) 618 if ((id[ATA_ID_CFS_ENABLE_1] & (1 << 10)) == 0)
523 return 0; 619 return 0;
524 return id[82] & (1 << 10); 620 return id[ATA_ID_COMMAND_SET_1] & (1 << 10);
525} 621}
526 622
527static inline int ata_id_has_wcache(const u16 *id) 623static inline int ata_id_has_wcache(const u16 *id)
528{ 624{
529 /* Yes children, word 83 valid bits cover word 82 data */ 625 /* Yes children, word 83 valid bits cover word 82 data */
530 if ((id[83] & 0xC000) != 0x4000) 626 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000)
531 return 0; 627 return 0;
532 return id[82] & (1 << 5); 628 return id[ATA_ID_COMMAND_SET_1] & (1 << 5);
533} 629}
534 630
535static inline int ata_id_has_pm(const u16 *id) 631static inline int ata_id_has_pm(const u16 *id)
536{ 632{
537 if ((id[83] & 0xC000) != 0x4000) 633 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000)
538 return 0; 634 return 0;
539 return id[82] & (1 << 3); 635 return id[ATA_ID_COMMAND_SET_1] & (1 << 3);
540} 636}
541 637
542static inline int ata_id_rahead_enabled(const u16 *id) 638static inline int ata_id_rahead_enabled(const u16 *id)
543{ 639{
544 if ((id[87] & 0xC000) != 0x4000) 640 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000)
545 return 0; 641 return 0;
546 return id[85] & (1 << 6); 642 return id[ATA_ID_CFS_ENABLE_1] & (1 << 6);
547} 643}
548 644
549static inline int ata_id_wcache_enabled(const u16 *id) 645static inline int ata_id_wcache_enabled(const u16 *id)
550{ 646{
551 if ((id[87] & 0xC000) != 0x4000) 647 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000)
552 return 0; 648 return 0;
553 return id[85] & (1 << 5); 649 return id[ATA_ID_CFS_ENABLE_1] & (1 << 5);
554} 650}
555 651
556/** 652/**
@@ -581,7 +677,15 @@ static inline unsigned int ata_id_major_version(const u16 *id)
581 677
582static inline int ata_id_is_sata(const u16 *id) 678static inline int ata_id_is_sata(const u16 *id)
583{ 679{
584 return ata_id_major_version(id) >= 5 && id[93] == 0; 680 /*
681 * See if word 93 is 0 AND drive is at least ATA-5 compatible
682 * verifying that word 80 by casting it to a signed type --
683 * this trick allows us to filter out the reserved values of
684 * 0x0000 and 0xffff along with the earlier ATA revisions...
685 */
686 if (id[ATA_ID_HW_CONFIG] == 0 && (short)id[ATA_ID_MAJOR_VER] >= 0x0020)
687 return 1;
688 return 0;
585} 689}
586 690
587static inline int ata_id_has_tpm(const u16 *id) 691static inline int ata_id_has_tpm(const u16 *id)
@@ -599,7 +703,16 @@ static inline int ata_id_has_dword_io(const u16 *id)
599 /* ATA 8 reuses this flag for "trusted" computing */ 703 /* ATA 8 reuses this flag for "trusted" computing */
600 if (ata_id_major_version(id) > 7) 704 if (ata_id_major_version(id) > 7)
601 return 0; 705 return 0;
602 if (id[48] & (1 << 0)) 706 if (id[ATA_ID_DWORD_IO] & (1 << 0))
707 return 1;
708 return 0;
709}
710
711static inline int ata_id_has_unload(const u16 *id)
712{
713 if (ata_id_major_version(id) >= 7 &&
714 (id[ATA_ID_CFSSE] & 0xC000) == 0x4000 &&
715 id[ATA_ID_CFSSE] & (1 << 13))
603 return 1; 716 return 1;
604 return 0; 717 return 0;
605} 718}
@@ -608,45 +721,50 @@ static inline int ata_id_current_chs_valid(const u16 *id)
608{ 721{
609 /* For ATA-1 devices, if the INITIALIZE DEVICE PARAMETERS command 722 /* For ATA-1 devices, if the INITIALIZE DEVICE PARAMETERS command
610 has not been issued to the device then the values of 723 has not been issued to the device then the values of
611 id[54] to id[56] are vendor specific. */ 724 id[ATA_ID_CUR_CYLS] to id[ATA_ID_CUR_SECTORS] are vendor specific. */
612 return (id[53] & 0x01) && /* Current translation valid */ 725 return (id[ATA_ID_FIELD_VALID] & 1) && /* Current translation valid */
613 id[54] && /* cylinders in current translation */ 726 id[ATA_ID_CUR_CYLS] && /* cylinders in current translation */
614 id[55] && /* heads in current translation */ 727 id[ATA_ID_CUR_HEADS] && /* heads in current translation */
615 id[55] <= 16 && 728 id[ATA_ID_CUR_HEADS] <= 16 &&
616 id[56]; /* sectors in current translation */ 729 id[ATA_ID_CUR_SECTORS]; /* sectors in current translation */
617} 730}
618 731
619static inline int ata_id_is_cfa(const u16 *id) 732static inline int ata_id_is_cfa(const u16 *id)
620{ 733{
621 u16 v = id[0]; 734 if (id[ATA_ID_CONFIG] == 0x848A) /* Standard CF */
622 if (v == 0x848A) /* Standard CF */
623 return 1; 735 return 1;
624 /* Could be CF hiding as standard ATA */ 736 /* Could be CF hiding as standard ATA */
625 if (ata_id_major_version(id) >= 3 && id[82] != 0xFFFF && 737 if (ata_id_major_version(id) >= 3 &&
626 (id[82] & ( 1 << 2))) 738 id[ATA_ID_COMMAND_SET_1] != 0xFFFF &&
739 (id[ATA_ID_COMMAND_SET_1] & (1 << 2)))
627 return 1; 740 return 1;
628 return 0; 741 return 0;
629} 742}
630 743
744static inline int ata_id_is_ssd(const u16 *id)
745{
746 return id[ATA_ID_ROT_SPEED] == 0x01;
747}
748
631static inline int ata_drive_40wire(const u16 *dev_id) 749static inline int ata_drive_40wire(const u16 *dev_id)
632{ 750{
633 if (ata_id_is_sata(dev_id)) 751 if (ata_id_is_sata(dev_id))
634 return 0; /* SATA */ 752 return 0; /* SATA */
635 if ((dev_id[93] & 0xE000) == 0x6000) 753 if ((dev_id[ATA_ID_HW_CONFIG] & 0xE000) == 0x6000)
636 return 0; /* 80 wire */ 754 return 0; /* 80 wire */
637 return 1; 755 return 1;
638} 756}
639 757
640static inline int ata_drive_40wire_relaxed(const u16 *dev_id) 758static inline int ata_drive_40wire_relaxed(const u16 *dev_id)
641{ 759{
642 if ((dev_id[93] & 0x2000) == 0x2000) 760 if ((dev_id[ATA_ID_HW_CONFIG] & 0x2000) == 0x2000)
643 return 0; /* 80 wire */ 761 return 0; /* 80 wire */
644 return 1; 762 return 1;
645} 763}
646 764
647static inline int atapi_cdb_len(const u16 *dev_id) 765static inline int atapi_cdb_len(const u16 *dev_id)
648{ 766{
649 u16 tmp = dev_id[0] & 0x3; 767 u16 tmp = dev_id[ATA_ID_CONFIG] & 0x3;
650 switch (tmp) { 768 switch (tmp) {
651 case 0: return 12; 769 case 0: return 12;
652 case 1: return 16; 770 case 1: return 16;
@@ -656,7 +774,7 @@ static inline int atapi_cdb_len(const u16 *dev_id)
656 774
657static inline int atapi_command_packet_set(const u16 *dev_id) 775static inline int atapi_command_packet_set(const u16 *dev_id)
658{ 776{
659 return (dev_id[0] >> 8) & 0x1f; 777 return (dev_id[ATA_ID_CONFIG] >> 8) & 0x1f;
660} 778}
661 779
662static inline int atapi_id_dmadir(const u16 *dev_id) 780static inline int atapi_id_dmadir(const u16 *dev_id)
@@ -664,6 +782,76 @@ static inline int atapi_id_dmadir(const u16 *dev_id)
664 return ata_id_major_version(dev_id) >= 7 && (dev_id[62] & 0x8000); 782 return ata_id_major_version(dev_id) >= 7 && (dev_id[62] & 0x8000);
665} 783}
666 784
785/*
786 * ata_id_is_lba_capacity_ok() performs a sanity check on
787 * the claimed LBA capacity value for the device.
788 *
789 * Returns 1 if LBA capacity looks sensible, 0 otherwise.
790 *
791 * It is called only once for each device.
792 */
793static inline int ata_id_is_lba_capacity_ok(u16 *id)
794{
795 unsigned long lba_sects, chs_sects, head, tail;
796
797 /* No non-LBA info .. so valid! */
798 if (id[ATA_ID_CYLS] == 0)
799 return 1;
800
801 lba_sects = ata_id_u32(id, ATA_ID_LBA_CAPACITY);
802
803 /*
804 * The ATA spec tells large drives to return
805 * C/H/S = 16383/16/63 independent of their size.
806 * Some drives can be jumpered to use 15 heads instead of 16.
807 * Some drives can be jumpered to use 4092 cyls instead of 16383.
808 */
809 if ((id[ATA_ID_CYLS] == 16383 ||
810 (id[ATA_ID_CYLS] == 4092 && id[ATA_ID_CUR_CYLS] == 16383)) &&
811 id[ATA_ID_SECTORS] == 63 &&
812 (id[ATA_ID_HEADS] == 15 || id[ATA_ID_HEADS] == 16) &&
813 (lba_sects >= 16383 * 63 * id[ATA_ID_HEADS]))
814 return 1;
815
816 chs_sects = id[ATA_ID_CYLS] * id[ATA_ID_HEADS] * id[ATA_ID_SECTORS];
817
818 /* perform a rough sanity check on lba_sects: within 10% is OK */
819 if (lba_sects - chs_sects < chs_sects/10)
820 return 1;
821
822 /* some drives have the word order reversed */
823 head = (lba_sects >> 16) & 0xffff;
824 tail = lba_sects & 0xffff;
825 lba_sects = head | (tail << 16);
826
827 if (lba_sects - chs_sects < chs_sects/10) {
828 *(__le32 *)&id[ATA_ID_LBA_CAPACITY] = __cpu_to_le32(lba_sects);
829 return 1; /* LBA capacity is (now) good */
830 }
831
832 return 0; /* LBA capacity value may be bad */
833}
834
835static inline void ata_id_to_hd_driveid(u16 *id)
836{
837#ifdef __BIG_ENDIAN
838 /* accessed in struct hd_driveid as 8-bit values */
839 id[ATA_ID_MAX_MULTSECT] = __cpu_to_le16(id[ATA_ID_MAX_MULTSECT]);
840 id[ATA_ID_CAPABILITY] = __cpu_to_le16(id[ATA_ID_CAPABILITY]);
841 id[ATA_ID_OLD_PIO_MODES] = __cpu_to_le16(id[ATA_ID_OLD_PIO_MODES]);
842 id[ATA_ID_OLD_DMA_MODES] = __cpu_to_le16(id[ATA_ID_OLD_DMA_MODES]);
843 id[ATA_ID_MULTSECT] = __cpu_to_le16(id[ATA_ID_MULTSECT]);
844
845 /* as 32-bit values */
846 *(u32 *)&id[ATA_ID_LBA_CAPACITY] = ata_id_u32(id, ATA_ID_LBA_CAPACITY);
847 *(u32 *)&id[ATA_ID_SPG] = ata_id_u32(id, ATA_ID_SPG);
848
849 /* as 64-bit value */
850 *(u64 *)&id[ATA_ID_LBA_CAPACITY_2] =
851 ata_id_u64(id, ATA_ID_LBA_CAPACITY_2);
852#endif
853}
854
667static inline int is_multi_taskfile(struct ata_taskfile *tf) 855static inline int is_multi_taskfile(struct ata_taskfile *tf)
668{ 856{
669 return (tf->command == ATA_CMD_READ_MULTI) || 857 return (tf->command == ATA_CMD_READ_MULTI) ||
@@ -682,7 +870,7 @@ static inline int ata_ok(u8 status)
682static inline int lba_28_ok(u64 block, u32 n_block) 870static inline int lba_28_ok(u64 block, u32 n_block)
683{ 871{
684 /* check the ending block number */ 872 /* check the ending block number */
685 return ((block + n_block - 1) < ((u64)1 << 28)) && (n_block <= 256); 873 return ((block + n_block) < ((u64)1 << 28)) && (n_block <= 256);
686} 874}
687 875
688static inline int lba_48_ok(u64 block, u32 n_block) 876static inline int lba_48_ok(u64 block, u32 n_block)
diff --git a/include/linux/atmel-pwm-bl.h b/include/linux/atmel-pwm-bl.h
new file mode 100644
index 000000000000..0153a47806c2
--- /dev/null
+++ b/include/linux/atmel-pwm-bl.h
@@ -0,0 +1,43 @@
1/*
2 * Copyright (C) 2007 Atmel Corporation
3 *
4 * Driver for the AT32AP700X PS/2 controller (PSIF).
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation.
9 */
10
11#ifndef __INCLUDE_ATMEL_PWM_BL_H
12#define __INCLUDE_ATMEL_PWM_BL_H
13
14/**
15 * struct atmel_pwm_bl_platform_data
16 * @pwm_channel: which PWM channel in the PWM module to use.
17 * @pwm_frequency: PWM frequency to generate, the driver will try to be as
18 * close as the prescaler allows.
19 * @pwm_compare_max: value to use in the PWM channel compare register.
20 * @pwm_duty_max: maximum duty cycle value, must be less than or equal to
21 * pwm_compare_max.
22 * @pwm_duty_min: minimum duty cycle value, must be less than pwm_duty_max.
23 * @pwm_active_low: set to one if the low part of the PWM signal increases the
24 * brightness of the backlight.
25 * @gpio_on: GPIO line to control the backlight on/off, set to -1 if not used.
26 * @on_active_low: set to one if the on/off signal is on when GPIO is low.
27 *
28 * This struct must be added to the platform device in the board code. It is
29 * used by the atmel-pwm-bl driver to setup the GPIO to control on/off and the
30 * PWM device.
31 */
32struct atmel_pwm_bl_platform_data {
33 unsigned int pwm_channel;
34 unsigned int pwm_frequency;
35 unsigned int pwm_compare_max;
36 unsigned int pwm_duty_max;
37 unsigned int pwm_duty_min;
38 unsigned int pwm_active_low;
39 int gpio_on;
40 unsigned int on_active_low;
41};
42
43#endif /* __INCLUDE_ATMEL_PWM_BL_H */
diff --git a/include/linux/audit.h b/include/linux/audit.h
index 8b82974bdc12..6272a395d43c 100644
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -286,7 +286,6 @@
286#define AUDIT_ARCH_SHEL64 (EM_SH|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE) 286#define AUDIT_ARCH_SHEL64 (EM_SH|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
287#define AUDIT_ARCH_SPARC (EM_SPARC) 287#define AUDIT_ARCH_SPARC (EM_SPARC)
288#define AUDIT_ARCH_SPARC64 (EM_SPARCV9|__AUDIT_ARCH_64BIT) 288#define AUDIT_ARCH_SPARC64 (EM_SPARCV9|__AUDIT_ARCH_64BIT)
289#define AUDIT_ARCH_V850 (EM_V850|__AUDIT_ARCH_LE)
290#define AUDIT_ARCH_X86_64 (EM_X86_64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE) 289#define AUDIT_ARCH_X86_64 (EM_X86_64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
291 290
292#define AUDIT_PERM_EXEC 1 291#define AUDIT_PERM_EXEC 1
diff --git a/include/linux/auto_dev-ioctl.h b/include/linux/auto_dev-ioctl.h
new file mode 100644
index 000000000000..f4d05ccd731f
--- /dev/null
+++ b/include/linux/auto_dev-ioctl.h
@@ -0,0 +1,157 @@
1/*
2 * Copyright 2008 Red Hat, Inc. All rights reserved.
3 * Copyright 2008 Ian Kent <raven@themaw.net>
4 *
5 * This file is part of the Linux kernel and is made available under
6 * the terms of the GNU General Public License, version 2, or at your
7 * option, any later version, incorporated herein by reference.
8 */
9
10#ifndef _LINUX_AUTO_DEV_IOCTL_H
11#define _LINUX_AUTO_DEV_IOCTL_H
12
13#include <linux/types.h>
14
15#define AUTOFS_DEVICE_NAME "autofs"
16
17#define AUTOFS_DEV_IOCTL_VERSION_MAJOR 1
18#define AUTOFS_DEV_IOCTL_VERSION_MINOR 0
19
20#define AUTOFS_DEVID_LEN 16
21
22#define AUTOFS_DEV_IOCTL_SIZE sizeof(struct autofs_dev_ioctl)
23
24/*
25 * An ioctl interface for autofs mount point control.
26 */
27
28/*
29 * All the ioctls use this structure.
30 * When sending a path size must account for the total length
31 * of the chunk of memory otherwise is is the size of the
32 * structure.
33 */
34
35struct autofs_dev_ioctl {
36 __u32 ver_major;
37 __u32 ver_minor;
38 __u32 size; /* total size of data passed in
39 * including this struct */
40 __s32 ioctlfd; /* automount command fd */
41
42 __u32 arg1; /* Command parameters */
43 __u32 arg2;
44
45 char path[0];
46};
47
48static inline void init_autofs_dev_ioctl(struct autofs_dev_ioctl *in)
49{
50 in->ver_major = AUTOFS_DEV_IOCTL_VERSION_MAJOR;
51 in->ver_minor = AUTOFS_DEV_IOCTL_VERSION_MINOR;
52 in->size = sizeof(struct autofs_dev_ioctl);
53 in->ioctlfd = -1;
54 in->arg1 = 0;
55 in->arg2 = 0;
56 return;
57}
58
59/*
60 * If you change this make sure you make the corresponding change
61 * to autofs-dev-ioctl.c:lookup_ioctl()
62 */
63enum {
64 /* Get various version info */
65 AUTOFS_DEV_IOCTL_VERSION_CMD = 0x71,
66 AUTOFS_DEV_IOCTL_PROTOVER_CMD,
67 AUTOFS_DEV_IOCTL_PROTOSUBVER_CMD,
68
69 /* Open mount ioctl fd */
70 AUTOFS_DEV_IOCTL_OPENMOUNT_CMD,
71
72 /* Close mount ioctl fd */
73 AUTOFS_DEV_IOCTL_CLOSEMOUNT_CMD,
74
75 /* Mount/expire status returns */
76 AUTOFS_DEV_IOCTL_READY_CMD,
77 AUTOFS_DEV_IOCTL_FAIL_CMD,
78
79 /* Activate/deactivate autofs mount */
80 AUTOFS_DEV_IOCTL_SETPIPEFD_CMD,
81 AUTOFS_DEV_IOCTL_CATATONIC_CMD,
82
83 /* Expiry timeout */
84 AUTOFS_DEV_IOCTL_TIMEOUT_CMD,
85
86 /* Get mount last requesting uid and gid */
87 AUTOFS_DEV_IOCTL_REQUESTER_CMD,
88
89 /* Check for eligible expire candidates */
90 AUTOFS_DEV_IOCTL_EXPIRE_CMD,
91
92 /* Request busy status */
93 AUTOFS_DEV_IOCTL_ASKUMOUNT_CMD,
94
95 /* Check if path is a mountpoint */
96 AUTOFS_DEV_IOCTL_ISMOUNTPOINT_CMD,
97};
98
99#define AUTOFS_IOCTL 0x93
100
101#define AUTOFS_DEV_IOCTL_VERSION \
102 _IOWR(AUTOFS_IOCTL, \
103 AUTOFS_DEV_IOCTL_VERSION_CMD, struct autofs_dev_ioctl)
104
105#define AUTOFS_DEV_IOCTL_PROTOVER \
106 _IOWR(AUTOFS_IOCTL, \
107 AUTOFS_DEV_IOCTL_PROTOVER_CMD, struct autofs_dev_ioctl)
108
109#define AUTOFS_DEV_IOCTL_PROTOSUBVER \
110 _IOWR(AUTOFS_IOCTL, \
111 AUTOFS_DEV_IOCTL_PROTOSUBVER_CMD, struct autofs_dev_ioctl)
112
113#define AUTOFS_DEV_IOCTL_OPENMOUNT \
114 _IOWR(AUTOFS_IOCTL, \
115 AUTOFS_DEV_IOCTL_OPENMOUNT_CMD, struct autofs_dev_ioctl)
116
117#define AUTOFS_DEV_IOCTL_CLOSEMOUNT \
118 _IOWR(AUTOFS_IOCTL, \
119 AUTOFS_DEV_IOCTL_CLOSEMOUNT_CMD, struct autofs_dev_ioctl)
120
121#define AUTOFS_DEV_IOCTL_READY \
122 _IOWR(AUTOFS_IOCTL, \
123 AUTOFS_DEV_IOCTL_READY_CMD, struct autofs_dev_ioctl)
124
125#define AUTOFS_DEV_IOCTL_FAIL \
126 _IOWR(AUTOFS_IOCTL, \
127 AUTOFS_DEV_IOCTL_FAIL_CMD, struct autofs_dev_ioctl)
128
129#define AUTOFS_DEV_IOCTL_SETPIPEFD \
130 _IOWR(AUTOFS_IOCTL, \
131 AUTOFS_DEV_IOCTL_SETPIPEFD_CMD, struct autofs_dev_ioctl)
132
133#define AUTOFS_DEV_IOCTL_CATATONIC \
134 _IOWR(AUTOFS_IOCTL, \
135 AUTOFS_DEV_IOCTL_CATATONIC_CMD, struct autofs_dev_ioctl)
136
137#define AUTOFS_DEV_IOCTL_TIMEOUT \
138 _IOWR(AUTOFS_IOCTL, \
139 AUTOFS_DEV_IOCTL_TIMEOUT_CMD, struct autofs_dev_ioctl)
140
141#define AUTOFS_DEV_IOCTL_REQUESTER \
142 _IOWR(AUTOFS_IOCTL, \
143 AUTOFS_DEV_IOCTL_REQUESTER_CMD, struct autofs_dev_ioctl)
144
145#define AUTOFS_DEV_IOCTL_EXPIRE \
146 _IOWR(AUTOFS_IOCTL, \
147 AUTOFS_DEV_IOCTL_EXPIRE_CMD, struct autofs_dev_ioctl)
148
149#define AUTOFS_DEV_IOCTL_ASKUMOUNT \
150 _IOWR(AUTOFS_IOCTL, \
151 AUTOFS_DEV_IOCTL_ASKUMOUNT_CMD, struct autofs_dev_ioctl)
152
153#define AUTOFS_DEV_IOCTL_ISMOUNTPOINT \
154 _IOWR(AUTOFS_IOCTL, \
155 AUTOFS_DEV_IOCTL_ISMOUNTPOINT_CMD, struct autofs_dev_ioctl)
156
157#endif /* _LINUX_AUTO_DEV_IOCTL_H */
diff --git a/include/linux/auto_fs4.h b/include/linux/auto_fs4.h
index 31a29541b504..2253716d4b92 100644
--- a/include/linux/auto_fs4.h
+++ b/include/linux/auto_fs4.h
@@ -23,12 +23,17 @@
23#define AUTOFS_MIN_PROTO_VERSION 3 23#define AUTOFS_MIN_PROTO_VERSION 3
24#define AUTOFS_MAX_PROTO_VERSION 5 24#define AUTOFS_MAX_PROTO_VERSION 5
25 25
26#define AUTOFS_PROTO_SUBVERSION 0 26#define AUTOFS_PROTO_SUBVERSION 1
27 27
28/* Mask for expire behaviour */ 28/* Mask for expire behaviour */
29#define AUTOFS_EXP_IMMEDIATE 1 29#define AUTOFS_EXP_IMMEDIATE 1
30#define AUTOFS_EXP_LEAVES 2 30#define AUTOFS_EXP_LEAVES 2
31 31
32#define AUTOFS_TYPE_ANY 0x0000
33#define AUTOFS_TYPE_INDIRECT 0x0001
34#define AUTOFS_TYPE_DIRECT 0x0002
35#define AUTOFS_TYPE_OFFSET 0x0004
36
32/* Daemon notification packet types */ 37/* Daemon notification packet types */
33enum autofs_notify { 38enum autofs_notify {
34 NFY_NONE, 39 NFY_NONE,
@@ -98,8 +103,6 @@ union autofs_v5_packet_union {
98#define AUTOFS_IOC_EXPIRE_INDIRECT AUTOFS_IOC_EXPIRE_MULTI 103#define AUTOFS_IOC_EXPIRE_INDIRECT AUTOFS_IOC_EXPIRE_MULTI
99#define AUTOFS_IOC_EXPIRE_DIRECT AUTOFS_IOC_EXPIRE_MULTI 104#define AUTOFS_IOC_EXPIRE_DIRECT AUTOFS_IOC_EXPIRE_MULTI
100#define AUTOFS_IOC_PROTOSUBVER _IOR(0x93,0x67,int) 105#define AUTOFS_IOC_PROTOSUBVER _IOR(0x93,0x67,int)
101#define AUTOFS_IOC_ASKREGHOST _IOR(0x93,0x68,int)
102#define AUTOFS_IOC_TOGGLEREGHOST _IOR(0x93,0x69,int)
103#define AUTOFS_IOC_ASKUMOUNT _IOR(0x93,0x70,int) 106#define AUTOFS_IOC_ASKUMOUNT _IOR(0x93,0x70,int)
104 107
105 108
diff --git a/include/linux/auxvec.h b/include/linux/auxvec.h
index ad895455ab72..d7afa9dd6635 100644
--- a/include/linux/auxvec.h
+++ b/include/linux/auxvec.h
@@ -26,8 +26,14 @@
26 26
27#define AT_SECURE 23 /* secure mode boolean */ 27#define AT_SECURE 23 /* secure mode boolean */
28 28
29#define AT_BASE_PLATFORM 24 /* string identifying real platform, may
30 * differ from AT_PLATFORM. */
31
32#define AT_EXECFN 31 /* filename of program */
33
29#ifdef __KERNEL__ 34#ifdef __KERNEL__
30#define AT_VECTOR_SIZE_BASE (14 + 2) /* NEW_AUX_ENT entries in auxiliary table */ 35#define AT_VECTOR_SIZE_BASE 18 /* NEW_AUX_ENT entries in auxiliary table */
36 /* number of "#define AT_.*" above, minus {AT_NULL, AT_IGNORE, AT_NOTELF} */
31#endif 37#endif
32 38
33#endif /* _LINUX_AUXVEC_H */ 39#endif /* _LINUX_AUXVEC_H */
diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h
index 0a24d5550eb3..bee52abb8a4d 100644
--- a/include/linux/backing-dev.h
+++ b/include/linux/backing-dev.h
@@ -175,6 +175,8 @@ int bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned int max_ratio);
175 * BDI_CAP_READ_MAP: Can be mapped for reading 175 * BDI_CAP_READ_MAP: Can be mapped for reading
176 * BDI_CAP_WRITE_MAP: Can be mapped for writing 176 * BDI_CAP_WRITE_MAP: Can be mapped for writing
177 * BDI_CAP_EXEC_MAP: Can be mapped for execution 177 * BDI_CAP_EXEC_MAP: Can be mapped for execution
178 *
179 * BDI_CAP_SWAP_BACKED: Count shmem/tmpfs objects as swap-backed.
178 */ 180 */
179#define BDI_CAP_NO_ACCT_DIRTY 0x00000001 181#define BDI_CAP_NO_ACCT_DIRTY 0x00000001
180#define BDI_CAP_NO_WRITEBACK 0x00000002 182#define BDI_CAP_NO_WRITEBACK 0x00000002
@@ -184,6 +186,7 @@ int bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned int max_ratio);
184#define BDI_CAP_WRITE_MAP 0x00000020 186#define BDI_CAP_WRITE_MAP 0x00000020
185#define BDI_CAP_EXEC_MAP 0x00000040 187#define BDI_CAP_EXEC_MAP 0x00000040
186#define BDI_CAP_NO_ACCT_WB 0x00000080 188#define BDI_CAP_NO_ACCT_WB 0x00000080
189#define BDI_CAP_SWAP_BACKED 0x00000100
187 190
188#define BDI_CAP_VMFLAGS \ 191#define BDI_CAP_VMFLAGS \
189 (BDI_CAP_READ_MAP | BDI_CAP_WRITE_MAP | BDI_CAP_EXEC_MAP) 192 (BDI_CAP_READ_MAP | BDI_CAP_WRITE_MAP | BDI_CAP_EXEC_MAP)
@@ -248,6 +251,11 @@ static inline bool bdi_cap_account_writeback(struct backing_dev_info *bdi)
248 BDI_CAP_NO_WRITEBACK)); 251 BDI_CAP_NO_WRITEBACK));
249} 252}
250 253
254static inline bool bdi_cap_swap_backed(struct backing_dev_info *bdi)
255{
256 return bdi->capabilities & BDI_CAP_SWAP_BACKED;
257}
258
251static inline bool mapping_cap_writeback_dirty(struct address_space *mapping) 259static inline bool mapping_cap_writeback_dirty(struct address_space *mapping)
252{ 260{
253 return bdi_cap_writeback_dirty(mapping->backing_dev_info); 261 return bdi_cap_writeback_dirty(mapping->backing_dev_info);
@@ -258,4 +266,9 @@ static inline bool mapping_cap_account_dirty(struct address_space *mapping)
258 return bdi_cap_account_dirty(mapping->backing_dev_info); 266 return bdi_cap_account_dirty(mapping->backing_dev_info);
259} 267}
260 268
269static inline bool mapping_cap_swap_backed(struct address_space *mapping)
270{
271 return bdi_cap_swap_backed(mapping->backing_dev_info);
272}
273
261#endif /* _LINUX_BACKING_DEV_H */ 274#endif /* _LINUX_BACKING_DEV_H */
diff --git a/include/linux/bcd.h b/include/linux/bcd.h
index c545308125b0..22ea563ba3eb 100644
--- a/include/linux/bcd.h
+++ b/include/linux/bcd.h
@@ -1,20 +1,9 @@
1/* Permission is hereby granted to copy, modify and redistribute this code
2 * in terms of the GNU Library General Public License, Version 2 or later,
3 * at your option.
4 */
5
6/* macros to translate to/from binary and binary-coded decimal (frequently
7 * found in RTC chips).
8 */
9
10#ifndef _BCD_H 1#ifndef _BCD_H
11#define _BCD_H 2#define _BCD_H
12 3
13#define BCD2BIN(val) (((val) & 0x0f) + ((val)>>4)*10) 4#include <linux/compiler.h>
14#define BIN2BCD(val) ((((val)/10)<<4) + (val)%10)
15 5
16/* backwards compat */ 6unsigned bcd2bin(unsigned char val) __attribute_const__;
17#define BCD_TO_BIN(val) ((val)=BCD2BIN(val)) 7unsigned char bin2bcd(unsigned val) __attribute_const__;
18#define BIN_TO_BCD(val) ((val)=BIN2BCD(val))
19 8
20#endif /* _BCD_H */ 9#endif /* _BCD_H */
diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
index ee0ed48e8348..7394b5b349ff 100644
--- a/include/linux/binfmts.h
+++ b/include/linux/binfmts.h
@@ -36,9 +36,13 @@ struct linux_binprm{
36 unsigned long p; /* current top of mem */ 36 unsigned long p; /* current top of mem */
37 unsigned int sh_bang:1, 37 unsigned int sh_bang:1,
38 misc_bang:1; 38 misc_bang:1;
39#ifdef __alpha__
40 unsigned int taso:1;
41#endif
42 unsigned int recursion_depth;
39 struct file * file; 43 struct file * file;
40 int e_uid, e_gid; 44 int e_uid, e_gid;
41 kernel_cap_t cap_inheritable, cap_permitted; 45 kernel_cap_t cap_post_exec_permitted;
42 bool cap_effective; 46 bool cap_effective;
43 void *security; 47 void *security;
44 int argc, envc; 48 int argc, envc;
@@ -58,6 +62,7 @@ struct linux_binprm{
58#define BINPRM_FLAGS_EXECFD_BIT 1 62#define BINPRM_FLAGS_EXECFD_BIT 1
59#define BINPRM_FLAGS_EXECFD (1 << BINPRM_FLAGS_EXECFD_BIT) 63#define BINPRM_FLAGS_EXECFD (1 << BINPRM_FLAGS_EXECFD_BIT)
60 64
65#define BINPRM_MAX_RECURSION 4
61 66
62/* 67/*
63 * This structure defines the functions that are used to load the binary formats that 68 * This structure defines the functions that are used to load the binary formats that
diff --git a/include/linux/bio.h b/include/linux/bio.h
index 0933a14e6414..1c91a176b9ae 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -26,21 +26,8 @@
26 26
27#ifdef CONFIG_BLOCK 27#ifdef CONFIG_BLOCK
28 28
29/* Platforms may set this to teach the BIO layer about IOMMU hardware. */
30#include <asm/io.h> 29#include <asm/io.h>
31 30
32#if defined(BIO_VMERGE_MAX_SIZE) && defined(BIO_VMERGE_BOUNDARY)
33#define BIOVEC_VIRT_START_SIZE(x) (bvec_to_phys(x) & (BIO_VMERGE_BOUNDARY - 1))
34#define BIOVEC_VIRT_OVERSIZE(x) ((x) > BIO_VMERGE_MAX_SIZE)
35#else
36#define BIOVEC_VIRT_START_SIZE(x) 0
37#define BIOVEC_VIRT_OVERSIZE(x) 0
38#endif
39
40#ifndef BIO_VMERGE_BOUNDARY
41#define BIO_VMERGE_BOUNDARY 0
42#endif
43
44#define BIO_DEBUG 31#define BIO_DEBUG
45 32
46#ifdef BIO_DEBUG 33#ifdef BIO_DEBUG
@@ -88,25 +75,21 @@ struct bio {
88 /* Number of segments in this BIO after 75 /* Number of segments in this BIO after
89 * physical address coalescing is performed. 76 * physical address coalescing is performed.
90 */ 77 */
91 unsigned short bi_phys_segments; 78 unsigned int bi_phys_segments;
92
93 /* Number of segments after physical and DMA remapping
94 * hardware coalescing is performed.
95 */
96 unsigned short bi_hw_segments;
97 79
98 unsigned int bi_size; /* residual I/O count */ 80 unsigned int bi_size; /* residual I/O count */
99 81
100 /* 82 /*
101 * To keep track of the max hw size, we account for the 83 * To keep track of the max segment size, we account for the
102 * sizes of the first and last virtually mergeable segments 84 * sizes of the first and last mergeable segments in this bio.
103 * in this bio
104 */ 85 */
105 unsigned int bi_hw_front_size; 86 unsigned int bi_seg_front_size;
106 unsigned int bi_hw_back_size; 87 unsigned int bi_seg_back_size;
107 88
108 unsigned int bi_max_vecs; /* max bvl_vecs we can hold */ 89 unsigned int bi_max_vecs; /* max bvl_vecs we can hold */
109 90
91 unsigned int bi_comp_cpu; /* completion CPU */
92
110 struct bio_vec *bi_io_vec; /* the actual vec list */ 93 struct bio_vec *bi_io_vec; /* the actual vec list */
111 94
112 bio_end_io_t *bi_end_io; 95 bio_end_io_t *bi_end_io;
@@ -126,11 +109,14 @@ struct bio {
126#define BIO_UPTODATE 0 /* ok after I/O completion */ 109#define BIO_UPTODATE 0 /* ok after I/O completion */
127#define BIO_RW_BLOCK 1 /* RW_AHEAD set, and read/write would block */ 110#define BIO_RW_BLOCK 1 /* RW_AHEAD set, and read/write would block */
128#define BIO_EOF 2 /* out-out-bounds error */ 111#define BIO_EOF 2 /* out-out-bounds error */
129#define BIO_SEG_VALID 3 /* nr_hw_seg valid */ 112#define BIO_SEG_VALID 3 /* bi_phys_segments valid */
130#define BIO_CLONED 4 /* doesn't own data */ 113#define BIO_CLONED 4 /* doesn't own data */
131#define BIO_BOUNCED 5 /* bio is a bounce bio */ 114#define BIO_BOUNCED 5 /* bio is a bounce bio */
132#define BIO_USER_MAPPED 6 /* contains user pages */ 115#define BIO_USER_MAPPED 6 /* contains user pages */
133#define BIO_EOPNOTSUPP 7 /* not supported */ 116#define BIO_EOPNOTSUPP 7 /* not supported */
117#define BIO_CPU_AFFINE 8 /* complete bio on same CPU as submitted */
118#define BIO_NULL_MAPPED 9 /* contains invalid user pages */
119#define BIO_FS_INTEGRITY 10 /* fs owns integrity data, not block layer */
134#define bio_flagged(bio, flag) ((bio)->bi_flags & (1 << (flag))) 120#define bio_flagged(bio, flag) ((bio)->bi_flags & (1 << (flag)))
135 121
136/* 122/*
@@ -144,18 +130,36 @@ struct bio {
144/* 130/*
145 * bio bi_rw flags 131 * bio bi_rw flags
146 * 132 *
147 * bit 0 -- read (not set) or write (set) 133 * bit 0 -- data direction
134 * If not set, bio is a read from device. If set, it's a write to device.
148 * bit 1 -- rw-ahead when set 135 * bit 1 -- rw-ahead when set
149 * bit 2 -- barrier 136 * bit 2 -- barrier
150 * bit 3 -- fail fast, don't want low level driver retries 137 * Insert a serialization point in the IO queue, forcing previously
151 * bit 4 -- synchronous I/O hint: the block layer will unplug immediately 138 * submitted IO to be completed before this oen is issued.
139 * bit 3 -- synchronous I/O hint: the block layer will unplug immediately
140 * Note that this does NOT indicate that the IO itself is sync, just
141 * that the block layer will not postpone issue of this IO by plugging.
142 * bit 4 -- metadata request
143 * Used for tracing to differentiate metadata and data IO. May also
144 * get some preferential treatment in the IO scheduler
145 * bit 5 -- discard sectors
146 * Informs the lower level device that this range of sectors is no longer
147 * used by the file system and may thus be freed by the device. Used
148 * for flash based storage.
149 * bit 6 -- fail fast device errors
150 * bit 7 -- fail fast transport errors
151 * bit 8 -- fail fast driver errors
152 * Don't want driver retries for any fast fail whatever the reason.
152 */ 153 */
153#define BIO_RW 0 154#define BIO_RW 0 /* Must match RW in req flags (blkdev.h) */
154#define BIO_RW_AHEAD 1 155#define BIO_RW_AHEAD 1 /* Must match FAILFAST in req flags */
155#define BIO_RW_BARRIER 2 156#define BIO_RW_BARRIER 2
156#define BIO_RW_FAILFAST 3 157#define BIO_RW_SYNC 3
157#define BIO_RW_SYNC 4 158#define BIO_RW_META 4
158#define BIO_RW_META 5 159#define BIO_RW_DISCARD 5
160#define BIO_RW_FAILFAST_DEV 6
161#define BIO_RW_FAILFAST_TRANSPORT 7
162#define BIO_RW_FAILFAST_DRIVER 8
159 163
160/* 164/*
161 * upper 16 bits of bi_rw define the io priority of this bio 165 * upper 16 bits of bi_rw define the io priority of this bio
@@ -182,17 +186,21 @@ struct bio {
182#define bio_sectors(bio) ((bio)->bi_size >> 9) 186#define bio_sectors(bio) ((bio)->bi_size >> 9)
183#define bio_barrier(bio) ((bio)->bi_rw & (1 << BIO_RW_BARRIER)) 187#define bio_barrier(bio) ((bio)->bi_rw & (1 << BIO_RW_BARRIER))
184#define bio_sync(bio) ((bio)->bi_rw & (1 << BIO_RW_SYNC)) 188#define bio_sync(bio) ((bio)->bi_rw & (1 << BIO_RW_SYNC))
185#define bio_failfast(bio) ((bio)->bi_rw & (1 << BIO_RW_FAILFAST)) 189#define bio_failfast_dev(bio) ((bio)->bi_rw & (1 << BIO_RW_FAILFAST_DEV))
190#define bio_failfast_transport(bio) \
191 ((bio)->bi_rw & (1 << BIO_RW_FAILFAST_TRANSPORT))
192#define bio_failfast_driver(bio) ((bio)->bi_rw & (1 << BIO_RW_FAILFAST_DRIVER))
186#define bio_rw_ahead(bio) ((bio)->bi_rw & (1 << BIO_RW_AHEAD)) 193#define bio_rw_ahead(bio) ((bio)->bi_rw & (1 << BIO_RW_AHEAD))
187#define bio_rw_meta(bio) ((bio)->bi_rw & (1 << BIO_RW_META)) 194#define bio_rw_meta(bio) ((bio)->bi_rw & (1 << BIO_RW_META))
188#define bio_empty_barrier(bio) (bio_barrier(bio) && !(bio)->bi_size) 195#define bio_discard(bio) ((bio)->bi_rw & (1 << BIO_RW_DISCARD))
196#define bio_empty_barrier(bio) (bio_barrier(bio) && !bio_has_data(bio) && !bio_discard(bio))
189 197
190static inline unsigned int bio_cur_sectors(struct bio *bio) 198static inline unsigned int bio_cur_sectors(struct bio *bio)
191{ 199{
192 if (bio->bi_vcnt) 200 if (bio->bi_vcnt)
193 return bio_iovec(bio)->bv_len >> 9; 201 return bio_iovec(bio)->bv_len >> 9;
194 202 else /* dataless requests such as discard */
195 return 0; 203 return bio->bi_size >> 9;
196} 204}
197 205
198static inline void *bio_data(struct bio *bio) 206static inline void *bio_data(struct bio *bio)
@@ -236,8 +244,6 @@ static inline void *bio_data(struct bio *bio)
236 ((bvec_to_phys((vec1)) + (vec1)->bv_len) == bvec_to_phys((vec2))) 244 ((bvec_to_phys((vec1)) + (vec1)->bv_len) == bvec_to_phys((vec2)))
237#endif 245#endif
238 246
239#define BIOVEC_VIRT_MERGEABLE(vec1, vec2) \
240 ((((bvec_to_phys((vec1)) + (vec1)->bv_len) | bvec_to_phys((vec2))) & (BIO_VMERGE_BOUNDARY - 1)) == 0)
241#define __BIO_SEG_BOUNDARY(addr1, addr2, mask) \ 247#define __BIO_SEG_BOUNDARY(addr1, addr2, mask) \
242 (((addr1) | (mask)) == (((addr2) - 1) | (mask))) 248 (((addr1) | (mask)) == (((addr2) - 1) | (mask)))
243#define BIOVEC_SEG_BOUNDARY(q, b1, b2) \ 249#define BIOVEC_SEG_BOUNDARY(q, b1, b2) \
@@ -319,15 +325,14 @@ struct bio_pair {
319 atomic_t cnt; 325 atomic_t cnt;
320 int error; 326 int error;
321}; 327};
322extern struct bio_pair *bio_split(struct bio *bi, mempool_t *pool, 328extern struct bio_pair *bio_split(struct bio *bi, int first_sectors);
323 int first_sectors);
324extern mempool_t *bio_split_pool;
325extern void bio_pair_release(struct bio_pair *dbio); 329extern void bio_pair_release(struct bio_pair *dbio);
326 330
327extern struct bio_set *bioset_create(int, int); 331extern struct bio_set *bioset_create(int, int);
328extern void bioset_free(struct bio_set *); 332extern void bioset_free(struct bio_set *);
329 333
330extern struct bio *bio_alloc(gfp_t, int); 334extern struct bio *bio_alloc(gfp_t, int);
335extern struct bio *bio_kmalloc(gfp_t, int);
331extern struct bio *bio_alloc_bioset(gfp_t, int, struct bio_set *); 336extern struct bio *bio_alloc_bioset(gfp_t, int, struct bio_set *);
332extern void bio_put(struct bio *); 337extern void bio_put(struct bio *);
333extern void bio_free(struct bio *, struct bio_set *); 338extern void bio_free(struct bio *, struct bio_set *);
@@ -335,7 +340,6 @@ extern void bio_free(struct bio *, struct bio_set *);
335extern void bio_endio(struct bio *, int); 340extern void bio_endio(struct bio *, int);
336struct request_queue; 341struct request_queue;
337extern int bio_phys_segments(struct request_queue *, struct bio *); 342extern int bio_phys_segments(struct request_queue *, struct bio *);
338extern int bio_hw_segments(struct request_queue *, struct bio *);
339 343
340extern void __bio_clone(struct bio *, struct bio *); 344extern void __bio_clone(struct bio *, struct bio *);
341extern struct bio *bio_clone(struct bio *, gfp_t); 345extern struct bio *bio_clone(struct bio *, gfp_t);
@@ -346,12 +350,14 @@ extern int bio_add_page(struct bio *, struct page *, unsigned int,unsigned int);
346extern int bio_add_pc_page(struct request_queue *, struct bio *, struct page *, 350extern int bio_add_pc_page(struct request_queue *, struct bio *, struct page *,
347 unsigned int, unsigned int); 351 unsigned int, unsigned int);
348extern int bio_get_nr_vecs(struct block_device *); 352extern int bio_get_nr_vecs(struct block_device *);
353extern sector_t bio_sector_offset(struct bio *, unsigned short, unsigned int);
349extern struct bio *bio_map_user(struct request_queue *, struct block_device *, 354extern struct bio *bio_map_user(struct request_queue *, struct block_device *,
350 unsigned long, unsigned int, int); 355 unsigned long, unsigned int, int, gfp_t);
351struct sg_iovec; 356struct sg_iovec;
357struct rq_map_data;
352extern struct bio *bio_map_user_iov(struct request_queue *, 358extern struct bio *bio_map_user_iov(struct request_queue *,
353 struct block_device *, 359 struct block_device *,
354 struct sg_iovec *, int, int); 360 struct sg_iovec *, int, int, gfp_t);
355extern void bio_unmap_user(struct bio *); 361extern void bio_unmap_user(struct bio *);
356extern struct bio *bio_map_kern(struct request_queue *, void *, unsigned int, 362extern struct bio *bio_map_kern(struct request_queue *, void *, unsigned int,
357 gfp_t); 363 gfp_t);
@@ -359,15 +365,25 @@ extern struct bio *bio_copy_kern(struct request_queue *, void *, unsigned int,
359 gfp_t, int); 365 gfp_t, int);
360extern void bio_set_pages_dirty(struct bio *bio); 366extern void bio_set_pages_dirty(struct bio *bio);
361extern void bio_check_pages_dirty(struct bio *bio); 367extern void bio_check_pages_dirty(struct bio *bio);
362extern struct bio *bio_copy_user(struct request_queue *, unsigned long, unsigned int, int); 368extern struct bio *bio_copy_user(struct request_queue *, struct rq_map_data *,
363extern struct bio *bio_copy_user_iov(struct request_queue *, struct sg_iovec *, 369 unsigned long, unsigned int, int, gfp_t);
364 int, int); 370extern struct bio *bio_copy_user_iov(struct request_queue *,
371 struct rq_map_data *, struct sg_iovec *,
372 int, int, gfp_t);
365extern int bio_uncopy_user(struct bio *); 373extern int bio_uncopy_user(struct bio *);
366void zero_fill_bio(struct bio *bio); 374void zero_fill_bio(struct bio *bio);
367extern struct bio_vec *bvec_alloc_bs(gfp_t, int, unsigned long *, struct bio_set *); 375extern struct bio_vec *bvec_alloc_bs(gfp_t, int, unsigned long *, struct bio_set *);
368extern unsigned int bvec_nr_vecs(unsigned short idx); 376extern unsigned int bvec_nr_vecs(unsigned short idx);
369 377
370/* 378/*
379 * Allow queuer to specify a completion CPU for this bio
380 */
381static inline void bio_set_completion_cpu(struct bio *bio, unsigned int cpu)
382{
383 bio->bi_comp_cpu = cpu;
384}
385
386/*
371 * bio_set is used to allow other portions of the IO system to 387 * bio_set is used to allow other portions of the IO system to
372 * allocate their own private memory pools for bio and iovec structures. 388 * allocate their own private memory pools for bio and iovec structures.
373 * These memory pools in turn all allocate from the bio_slab 389 * These memory pools in turn all allocate from the bio_slab
@@ -445,6 +461,14 @@ static inline char *__bio_kmap_irq(struct bio *bio, unsigned short idx,
445 __bio_kmap_irq((bio), (bio)->bi_idx, (flags)) 461 __bio_kmap_irq((bio), (bio)->bi_idx, (flags))
446#define bio_kunmap_irq(buf,flags) __bio_kunmap_irq(buf, flags) 462#define bio_kunmap_irq(buf,flags) __bio_kunmap_irq(buf, flags)
447 463
464/*
465 * Check whether this bio carries any data or not. A NULL bio is allowed.
466 */
467static inline int bio_has_data(struct bio *bio)
468{
469 return bio && bio->bi_io_vec != NULL;
470}
471
448#if defined(CONFIG_BLK_DEV_INTEGRITY) 472#if defined(CONFIG_BLK_DEV_INTEGRITY)
449 473
450#define bip_vec_idx(bip, idx) (&(bip->bip_vec[(idx)])) 474#define bip_vec_idx(bip, idx) (&(bip->bip_vec[(idx)]))
@@ -458,14 +482,7 @@ static inline char *__bio_kmap_irq(struct bio *bio, unsigned short idx,
458#define bip_for_each_vec(bvl, bip, i) \ 482#define bip_for_each_vec(bvl, bip, i) \
459 __bip_for_each_vec(bvl, bip, i, (bip)->bip_idx) 483 __bip_for_each_vec(bvl, bip, i, (bip)->bip_idx)
460 484
461static inline int bio_integrity(struct bio *bio) 485#define bio_integrity(bio) (bio->bi_integrity != NULL)
462{
463#if defined(CONFIG_BLK_DEV_INTEGRITY)
464 return bio->bi_integrity != NULL;
465#else
466 return 0;
467#endif
468}
469 486
470extern struct bio_integrity_payload *bio_integrity_alloc_bioset(struct bio *, gfp_t, unsigned int, struct bio_set *); 487extern struct bio_integrity_payload *bio_integrity_alloc_bioset(struct bio *, gfp_t, unsigned int, struct bio_set *);
471extern struct bio_integrity_payload *bio_integrity_alloc(struct bio *, gfp_t, unsigned int); 488extern struct bio_integrity_payload *bio_integrity_alloc(struct bio *, gfp_t, unsigned int);
diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
index 1abfe664c444..a08c33a26ca9 100644
--- a/include/linux/bitmap.h
+++ b/include/linux/bitmap.h
@@ -129,6 +129,7 @@ extern void bitmap_fold(unsigned long *dst, const unsigned long *orig,
129extern int bitmap_find_free_region(unsigned long *bitmap, int bits, int order); 129extern int bitmap_find_free_region(unsigned long *bitmap, int bits, int order);
130extern void bitmap_release_region(unsigned long *bitmap, int pos, int order); 130extern void bitmap_release_region(unsigned long *bitmap, int pos, int order);
131extern int bitmap_allocate_region(unsigned long *bitmap, int pos, int order); 131extern int bitmap_allocate_region(unsigned long *bitmap, int pos, int order);
132extern void bitmap_copy_le(void *dst, const unsigned long *src, int nbits);
132 133
133#define BITMAP_LAST_WORD_MASK(nbits) \ 134#define BITMAP_LAST_WORD_MASK(nbits) \
134( \ 135( \
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 88d68081a0f1..a135256b272c 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -16,7 +16,9 @@
16#include <linux/bio.h> 16#include <linux/bio.h>
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/stringify.h> 18#include <linux/stringify.h>
19#include <linux/gfp.h>
19#include <linux/bsg.h> 20#include <linux/bsg.h>
21#include <linux/smp.h>
20 22
21#include <asm/scatterlist.h> 23#include <asm/scatterlist.h>
22 24
@@ -54,7 +56,6 @@ enum rq_cmd_type_bits {
54 REQ_TYPE_PM_SUSPEND, /* suspend request */ 56 REQ_TYPE_PM_SUSPEND, /* suspend request */
55 REQ_TYPE_PM_RESUME, /* resume request */ 57 REQ_TYPE_PM_RESUME, /* resume request */
56 REQ_TYPE_PM_SHUTDOWN, /* shutdown request */ 58 REQ_TYPE_PM_SHUTDOWN, /* shutdown request */
57 REQ_TYPE_FLUSH, /* flush request */
58 REQ_TYPE_SPECIAL, /* driver defined type */ 59 REQ_TYPE_SPECIAL, /* driver defined type */
59 REQ_TYPE_LINUX_BLOCK, /* generic block layer message */ 60 REQ_TYPE_LINUX_BLOCK, /* generic block layer message */
60 /* 61 /*
@@ -76,19 +77,20 @@ enum rq_cmd_type_bits {
76 * 77 *
77 */ 78 */
78enum { 79enum {
79 /*
80 * just examples for now
81 */
82 REQ_LB_OP_EJECT = 0x40, /* eject request */ 80 REQ_LB_OP_EJECT = 0x40, /* eject request */
83 REQ_LB_OP_FLUSH = 0x41, /* flush device */ 81 REQ_LB_OP_FLUSH = 0x41, /* flush request */
82 REQ_LB_OP_DISCARD = 0x42, /* discard sectors */
84}; 83};
85 84
86/* 85/*
87 * request type modified bits. first three bits match BIO_RW* bits, important 86 * request type modified bits. first two bits match BIO_RW* bits, important
88 */ 87 */
89enum rq_flag_bits { 88enum rq_flag_bits {
90 __REQ_RW, /* not set, read. set, write */ 89 __REQ_RW, /* not set, read. set, write */
91 __REQ_FAILFAST, /* no low level driver retries */ 90 __REQ_FAILFAST_DEV, /* no driver retries of device errors */
91 __REQ_FAILFAST_TRANSPORT, /* no driver retries of transport errors */
92 __REQ_FAILFAST_DRIVER, /* no driver retries of driver errors */
93 __REQ_DISCARD, /* request to discard sectors */
92 __REQ_SORTED, /* elevator knows about this request */ 94 __REQ_SORTED, /* elevator knows about this request */
93 __REQ_SOFTBARRIER, /* may not be passed by ioscheduler */ 95 __REQ_SOFTBARRIER, /* may not be passed by ioscheduler */
94 __REQ_HARDBARRIER, /* may not be passed by drive either */ 96 __REQ_HARDBARRIER, /* may not be passed by drive either */
@@ -111,7 +113,10 @@ enum rq_flag_bits {
111}; 113};
112 114
113#define REQ_RW (1 << __REQ_RW) 115#define REQ_RW (1 << __REQ_RW)
114#define REQ_FAILFAST (1 << __REQ_FAILFAST) 116#define REQ_FAILFAST_DEV (1 << __REQ_FAILFAST_DEV)
117#define REQ_FAILFAST_TRANSPORT (1 << __REQ_FAILFAST_TRANSPORT)
118#define REQ_FAILFAST_DRIVER (1 << __REQ_FAILFAST_DRIVER)
119#define REQ_DISCARD (1 << __REQ_DISCARD)
115#define REQ_SORTED (1 << __REQ_SORTED) 120#define REQ_SORTED (1 << __REQ_SORTED)
116#define REQ_SOFTBARRIER (1 << __REQ_SOFTBARRIER) 121#define REQ_SOFTBARRIER (1 << __REQ_SOFTBARRIER)
117#define REQ_HARDBARRIER (1 << __REQ_HARDBARRIER) 122#define REQ_HARDBARRIER (1 << __REQ_HARDBARRIER)
@@ -140,12 +145,14 @@ enum rq_flag_bits {
140 */ 145 */
141struct request { 146struct request {
142 struct list_head queuelist; 147 struct list_head queuelist;
143 struct list_head donelist; 148 struct call_single_data csd;
149 int cpu;
144 150
145 struct request_queue *q; 151 struct request_queue *q;
146 152
147 unsigned int cmd_flags; 153 unsigned int cmd_flags;
148 enum rq_cmd_type_bits cmd_type; 154 enum rq_cmd_type_bits cmd_type;
155 unsigned long atomic_flags;
149 156
150 /* Maintain bio traversal state for part by part I/O submission. 157 /* Maintain bio traversal state for part by part I/O submission.
151 * hard_* are block layer internals, no driver should touch them! 158 * hard_* are block layer internals, no driver should touch them!
@@ -190,13 +197,6 @@ struct request {
190 */ 197 */
191 unsigned short nr_phys_segments; 198 unsigned short nr_phys_segments;
192 199
193 /* Number of scatter-gather addr+len pairs after
194 * physical and DMA remapping hardware coalescing is performed.
195 * This is the number of scatter-gather entries the driver
196 * will actually have to deal with after DMA mapping is done.
197 */
198 unsigned short nr_hw_segments;
199
200 unsigned short ioprio; 200 unsigned short ioprio;
201 201
202 void *special; 202 void *special;
@@ -220,6 +220,8 @@ struct request {
220 void *data; 220 void *data;
221 void *sense; 221 void *sense;
222 222
223 unsigned long deadline;
224 struct list_head timeout_list;
223 unsigned int timeout; 225 unsigned int timeout;
224 int retries; 226 int retries;
225 227
@@ -233,6 +235,11 @@ struct request {
233 struct request *next_rq; 235 struct request *next_rq;
234}; 236};
235 237
238static inline unsigned short req_get_ioprio(struct request *req)
239{
240 return req->ioprio;
241}
242
236/* 243/*
237 * State information carried for REQ_TYPE_PM_SUSPEND and REQ_TYPE_PM_RESUME 244 * State information carried for REQ_TYPE_PM_SUSPEND and REQ_TYPE_PM_RESUME
238 * requests. Some step values could eventually be made generic. 245 * requests. Some step values could eventually be made generic.
@@ -252,6 +259,7 @@ typedef void (request_fn_proc) (struct request_queue *q);
252typedef int (make_request_fn) (struct request_queue *q, struct bio *bio); 259typedef int (make_request_fn) (struct request_queue *q, struct bio *bio);
253typedef int (prep_rq_fn) (struct request_queue *, struct request *); 260typedef int (prep_rq_fn) (struct request_queue *, struct request *);
254typedef void (unplug_fn) (struct request_queue *); 261typedef void (unplug_fn) (struct request_queue *);
262typedef int (prepare_discard_fn) (struct request_queue *, struct request *);
255 263
256struct bio_vec; 264struct bio_vec;
257struct bvec_merge_data { 265struct bvec_merge_data {
@@ -265,6 +273,15 @@ typedef int (merge_bvec_fn) (struct request_queue *, struct bvec_merge_data *,
265typedef void (prepare_flush_fn) (struct request_queue *, struct request *); 273typedef void (prepare_flush_fn) (struct request_queue *, struct request *);
266typedef void (softirq_done_fn)(struct request *); 274typedef void (softirq_done_fn)(struct request *);
267typedef int (dma_drain_needed_fn)(struct request *); 275typedef int (dma_drain_needed_fn)(struct request *);
276typedef int (lld_busy_fn) (struct request_queue *q);
277
278enum blk_eh_timer_return {
279 BLK_EH_NOT_HANDLED,
280 BLK_EH_HANDLED,
281 BLK_EH_RESET_TIMER,
282};
283
284typedef enum blk_eh_timer_return (rq_timed_out_fn)(struct request *);
268 285
269enum blk_queue_state { 286enum blk_queue_state {
270 Queue_down, 287 Queue_down,
@@ -280,6 +297,15 @@ struct blk_queue_tag {
280 atomic_t refcnt; /* map can be shared */ 297 atomic_t refcnt; /* map can be shared */
281}; 298};
282 299
300#define BLK_SCSI_MAX_CMDS (256)
301#define BLK_SCSI_CMD_PER_LONG (BLK_SCSI_MAX_CMDS / (sizeof(long) * 8))
302
303struct blk_cmd_filter {
304 unsigned long read_ok[BLK_SCSI_CMD_PER_LONG];
305 unsigned long write_ok[BLK_SCSI_CMD_PER_LONG];
306 struct kobject kobj;
307};
308
283struct request_queue 309struct request_queue
284{ 310{
285 /* 311 /*
@@ -298,10 +324,13 @@ struct request_queue
298 make_request_fn *make_request_fn; 324 make_request_fn *make_request_fn;
299 prep_rq_fn *prep_rq_fn; 325 prep_rq_fn *prep_rq_fn;
300 unplug_fn *unplug_fn; 326 unplug_fn *unplug_fn;
327 prepare_discard_fn *prepare_discard_fn;
301 merge_bvec_fn *merge_bvec_fn; 328 merge_bvec_fn *merge_bvec_fn;
302 prepare_flush_fn *prepare_flush_fn; 329 prepare_flush_fn *prepare_flush_fn;
303 softirq_done_fn *softirq_done_fn; 330 softirq_done_fn *softirq_done_fn;
331 rq_timed_out_fn *rq_timed_out_fn;
304 dma_drain_needed_fn *dma_drain_needed; 332 dma_drain_needed_fn *dma_drain_needed;
333 lld_busy_fn *lld_busy_fn;
305 334
306 /* 335 /*
307 * Dispatch queue sorting 336 * Dispatch queue sorting
@@ -376,6 +405,10 @@ struct request_queue
376 unsigned int nr_sorted; 405 unsigned int nr_sorted;
377 unsigned int in_flight; 406 unsigned int in_flight;
378 407
408 unsigned int rq_timeout;
409 struct timer_list timeout;
410 struct list_head timeout_list;
411
379 /* 412 /*
380 * sg stuff 413 * sg stuff
381 */ 414 */
@@ -398,6 +431,7 @@ struct request_queue
398#if defined(CONFIG_BLK_DEV_BSG) 431#if defined(CONFIG_BLK_DEV_BSG)
399 struct bsg_class_device bsg_dev; 432 struct bsg_class_device bsg_dev;
400#endif 433#endif
434 struct blk_cmd_filter cmd_filter;
401}; 435};
402 436
403#define QUEUE_FLAG_CLUSTER 0 /* cluster several segments into 1 */ 437#define QUEUE_FLAG_CLUSTER 0 /* cluster several segments into 1 */
@@ -411,6 +445,10 @@ struct request_queue
411#define QUEUE_FLAG_ELVSWITCH 8 /* don't use elevator, just do FIFO */ 445#define QUEUE_FLAG_ELVSWITCH 8 /* don't use elevator, just do FIFO */
412#define QUEUE_FLAG_BIDI 9 /* queue supports bidi requests */ 446#define QUEUE_FLAG_BIDI 9 /* queue supports bidi requests */
413#define QUEUE_FLAG_NOMERGES 10 /* disable merge attempts */ 447#define QUEUE_FLAG_NOMERGES 10 /* disable merge attempts */
448#define QUEUE_FLAG_SAME_COMP 11 /* force complete on same CPU */
449#define QUEUE_FLAG_FAIL_IO 12 /* fake timeout */
450#define QUEUE_FLAG_STACKABLE 13 /* supports request stacking */
451#define QUEUE_FLAG_NONROT 14 /* non-rotational device (SSD) */
414 452
415static inline int queue_is_locked(struct request_queue *q) 453static inline int queue_is_locked(struct request_queue *q)
416{ 454{
@@ -516,26 +554,36 @@ enum {
516#define blk_queue_tagged(q) test_bit(QUEUE_FLAG_QUEUED, &(q)->queue_flags) 554#define blk_queue_tagged(q) test_bit(QUEUE_FLAG_QUEUED, &(q)->queue_flags)
517#define blk_queue_stopped(q) test_bit(QUEUE_FLAG_STOPPED, &(q)->queue_flags) 555#define blk_queue_stopped(q) test_bit(QUEUE_FLAG_STOPPED, &(q)->queue_flags)
518#define blk_queue_nomerges(q) test_bit(QUEUE_FLAG_NOMERGES, &(q)->queue_flags) 556#define blk_queue_nomerges(q) test_bit(QUEUE_FLAG_NOMERGES, &(q)->queue_flags)
557#define blk_queue_nonrot(q) test_bit(QUEUE_FLAG_NONROT, &(q)->queue_flags)
519#define blk_queue_flushing(q) ((q)->ordseq) 558#define blk_queue_flushing(q) ((q)->ordseq)
559#define blk_queue_stackable(q) \
560 test_bit(QUEUE_FLAG_STACKABLE, &(q)->queue_flags)
520 561
521#define blk_fs_request(rq) ((rq)->cmd_type == REQ_TYPE_FS) 562#define blk_fs_request(rq) ((rq)->cmd_type == REQ_TYPE_FS)
522#define blk_pc_request(rq) ((rq)->cmd_type == REQ_TYPE_BLOCK_PC) 563#define blk_pc_request(rq) ((rq)->cmd_type == REQ_TYPE_BLOCK_PC)
523#define blk_special_request(rq) ((rq)->cmd_type == REQ_TYPE_SPECIAL) 564#define blk_special_request(rq) ((rq)->cmd_type == REQ_TYPE_SPECIAL)
524#define blk_sense_request(rq) ((rq)->cmd_type == REQ_TYPE_SENSE) 565#define blk_sense_request(rq) ((rq)->cmd_type == REQ_TYPE_SENSE)
525 566
526#define blk_noretry_request(rq) ((rq)->cmd_flags & REQ_FAILFAST) 567#define blk_failfast_dev(rq) ((rq)->cmd_flags & REQ_FAILFAST_DEV)
568#define blk_failfast_transport(rq) ((rq)->cmd_flags & REQ_FAILFAST_TRANSPORT)
569#define blk_failfast_driver(rq) ((rq)->cmd_flags & REQ_FAILFAST_DRIVER)
570#define blk_noretry_request(rq) (blk_failfast_dev(rq) || \
571 blk_failfast_transport(rq) || \
572 blk_failfast_driver(rq))
527#define blk_rq_started(rq) ((rq)->cmd_flags & REQ_STARTED) 573#define blk_rq_started(rq) ((rq)->cmd_flags & REQ_STARTED)
528 574
529#define blk_account_rq(rq) (blk_rq_started(rq) && blk_fs_request(rq)) 575#define blk_account_rq(rq) (blk_rq_started(rq) && (blk_fs_request(rq) || blk_discard_rq(rq)))
530 576
531#define blk_pm_suspend_request(rq) ((rq)->cmd_type == REQ_TYPE_PM_SUSPEND) 577#define blk_pm_suspend_request(rq) ((rq)->cmd_type == REQ_TYPE_PM_SUSPEND)
532#define blk_pm_resume_request(rq) ((rq)->cmd_type == REQ_TYPE_PM_RESUME) 578#define blk_pm_resume_request(rq) ((rq)->cmd_type == REQ_TYPE_PM_RESUME)
533#define blk_pm_request(rq) \ 579#define blk_pm_request(rq) \
534 (blk_pm_suspend_request(rq) || blk_pm_resume_request(rq)) 580 (blk_pm_suspend_request(rq) || blk_pm_resume_request(rq))
535 581
582#define blk_rq_cpu_valid(rq) ((rq)->cpu != -1)
536#define blk_sorted_rq(rq) ((rq)->cmd_flags & REQ_SORTED) 583#define blk_sorted_rq(rq) ((rq)->cmd_flags & REQ_SORTED)
537#define blk_barrier_rq(rq) ((rq)->cmd_flags & REQ_HARDBARRIER) 584#define blk_barrier_rq(rq) ((rq)->cmd_flags & REQ_HARDBARRIER)
538#define blk_fua_rq(rq) ((rq)->cmd_flags & REQ_FUA) 585#define blk_fua_rq(rq) ((rq)->cmd_flags & REQ_FUA)
586#define blk_discard_rq(rq) ((rq)->cmd_flags & REQ_DISCARD)
539#define blk_bidi_rq(rq) ((rq)->next_rq != NULL) 587#define blk_bidi_rq(rq) ((rq)->next_rq != NULL)
540#define blk_empty_barrier(rq) (blk_barrier_rq(rq) && blk_fs_request(rq) && !(rq)->hard_nr_sectors) 588#define blk_empty_barrier(rq) (blk_barrier_rq(rq) && blk_fs_request(rq) && !(rq)->hard_nr_sectors)
541/* rq->queuelist of dequeued request must be list_empty() */ 589/* rq->queuelist of dequeued request must be list_empty() */
@@ -582,7 +630,8 @@ static inline void blk_clear_queue_full(struct request_queue *q, int rw)
582#define RQ_NOMERGE_FLAGS \ 630#define RQ_NOMERGE_FLAGS \
583 (REQ_NOMERGE | REQ_STARTED | REQ_HARDBARRIER | REQ_SOFTBARRIER) 631 (REQ_NOMERGE | REQ_STARTED | REQ_HARDBARRIER | REQ_SOFTBARRIER)
584#define rq_mergeable(rq) \ 632#define rq_mergeable(rq) \
585 (!((rq)->cmd_flags & RQ_NOMERGE_FLAGS) && blk_fs_request((rq))) 633 (!((rq)->cmd_flags & RQ_NOMERGE_FLAGS) && \
634 (blk_discard_rq(rq) || blk_fs_request((rq))))
586 635
587/* 636/*
588 * q->prep_rq_fn return values 637 * q->prep_rq_fn return values
@@ -627,6 +676,12 @@ static inline void blk_queue_bounce(struct request_queue *q, struct bio **bio)
627} 676}
628#endif /* CONFIG_MMU */ 677#endif /* CONFIG_MMU */
629 678
679struct rq_map_data {
680 struct page **pages;
681 int page_order;
682 int nr_entries;
683};
684
630struct req_iterator { 685struct req_iterator {
631 int i; 686 int i;
632 struct bio *bio; 687 struct bio *bio;
@@ -654,13 +709,18 @@ extern void __blk_put_request(struct request_queue *, struct request *);
654extern struct request *blk_get_request(struct request_queue *, int, gfp_t); 709extern struct request *blk_get_request(struct request_queue *, int, gfp_t);
655extern void blk_insert_request(struct request_queue *, struct request *, int, void *); 710extern void blk_insert_request(struct request_queue *, struct request *, int, void *);
656extern void blk_requeue_request(struct request_queue *, struct request *); 711extern void blk_requeue_request(struct request_queue *, struct request *);
712extern int blk_rq_check_limits(struct request_queue *q, struct request *rq);
713extern int blk_lld_busy(struct request_queue *q);
714extern int blk_insert_cloned_request(struct request_queue *q,
715 struct request *rq);
657extern void blk_plug_device(struct request_queue *); 716extern void blk_plug_device(struct request_queue *);
717extern void blk_plug_device_unlocked(struct request_queue *);
658extern int blk_remove_plug(struct request_queue *); 718extern int blk_remove_plug(struct request_queue *);
659extern void blk_recount_segments(struct request_queue *, struct bio *); 719extern void blk_recount_segments(struct request_queue *, struct bio *);
660extern int scsi_cmd_ioctl(struct file *, struct request_queue *, 720extern int scsi_cmd_ioctl(struct request_queue *, struct gendisk *, fmode_t,
661 struct gendisk *, unsigned int, void __user *); 721 unsigned int, void __user *);
662extern int sg_scsi_ioctl(struct file *, struct request_queue *, 722extern int sg_scsi_ioctl(struct request_queue *, struct gendisk *, fmode_t,
663 struct gendisk *, struct scsi_ioctl_command __user *); 723 struct scsi_ioctl_command __user *);
664 724
665/* 725/*
666 * Temporary export, until SCSI gets fixed up. 726 * Temporary export, until SCSI gets fixed up.
@@ -694,11 +754,14 @@ extern void __blk_stop_queue(struct request_queue *q);
694extern void __blk_run_queue(struct request_queue *); 754extern void __blk_run_queue(struct request_queue *);
695extern void blk_run_queue(struct request_queue *); 755extern void blk_run_queue(struct request_queue *);
696extern void blk_start_queueing(struct request_queue *); 756extern void blk_start_queueing(struct request_queue *);
697extern int blk_rq_map_user(struct request_queue *, struct request *, void __user *, unsigned long); 757extern int blk_rq_map_user(struct request_queue *, struct request *,
758 struct rq_map_data *, void __user *, unsigned long,
759 gfp_t);
698extern int blk_rq_unmap_user(struct bio *); 760extern int blk_rq_unmap_user(struct bio *);
699extern int blk_rq_map_kern(struct request_queue *, struct request *, void *, unsigned int, gfp_t); 761extern int blk_rq_map_kern(struct request_queue *, struct request *, void *, unsigned int, gfp_t);
700extern int blk_rq_map_user_iov(struct request_queue *, struct request *, 762extern int blk_rq_map_user_iov(struct request_queue *, struct request *,
701 struct sg_iovec *, int, unsigned int); 763 struct rq_map_data *, struct sg_iovec *, int,
764 unsigned int, gfp_t);
702extern int blk_execute_rq(struct request_queue *, struct gendisk *, 765extern int blk_execute_rq(struct request_queue *, struct gendisk *,
703 struct request *, int); 766 struct request *, int);
704extern void blk_execute_rq_nowait(struct request_queue *, struct gendisk *, 767extern void blk_execute_rq_nowait(struct request_queue *, struct gendisk *,
@@ -739,12 +802,15 @@ extern int __blk_end_request(struct request *rq, int error,
739extern int blk_end_bidi_request(struct request *rq, int error, 802extern int blk_end_bidi_request(struct request *rq, int error,
740 unsigned int nr_bytes, unsigned int bidi_bytes); 803 unsigned int nr_bytes, unsigned int bidi_bytes);
741extern void end_request(struct request *, int); 804extern void end_request(struct request *, int);
742extern void end_queued_request(struct request *, int);
743extern void end_dequeued_request(struct request *, int);
744extern int blk_end_request_callback(struct request *rq, int error, 805extern int blk_end_request_callback(struct request *rq, int error,
745 unsigned int nr_bytes, 806 unsigned int nr_bytes,
746 int (drv_callback)(struct request *)); 807 int (drv_callback)(struct request *));
747extern void blk_complete_request(struct request *); 808extern void blk_complete_request(struct request *);
809extern void __blk_complete_request(struct request *);
810extern void blk_abort_request(struct request *);
811extern void blk_abort_queue(struct request_queue *);
812extern void blk_update_request(struct request *rq, int error,
813 unsigned int nr_bytes);
748 814
749/* 815/*
750 * blk_end_request() takes bytes instead of sectors as a complete size. 816 * blk_end_request() takes bytes instead of sectors as a complete size.
@@ -779,12 +845,16 @@ extern void blk_queue_update_dma_pad(struct request_queue *, unsigned int);
779extern int blk_queue_dma_drain(struct request_queue *q, 845extern int blk_queue_dma_drain(struct request_queue *q,
780 dma_drain_needed_fn *dma_drain_needed, 846 dma_drain_needed_fn *dma_drain_needed,
781 void *buf, unsigned int size); 847 void *buf, unsigned int size);
848extern void blk_queue_lld_busy(struct request_queue *q, lld_busy_fn *fn);
782extern void blk_queue_segment_boundary(struct request_queue *, unsigned long); 849extern void blk_queue_segment_boundary(struct request_queue *, unsigned long);
783extern void blk_queue_prep_rq(struct request_queue *, prep_rq_fn *pfn); 850extern void blk_queue_prep_rq(struct request_queue *, prep_rq_fn *pfn);
784extern void blk_queue_merge_bvec(struct request_queue *, merge_bvec_fn *); 851extern void blk_queue_merge_bvec(struct request_queue *, merge_bvec_fn *);
785extern void blk_queue_dma_alignment(struct request_queue *, int); 852extern void blk_queue_dma_alignment(struct request_queue *, int);
786extern void blk_queue_update_dma_alignment(struct request_queue *, int); 853extern void blk_queue_update_dma_alignment(struct request_queue *, int);
787extern void blk_queue_softirq_done(struct request_queue *, softirq_done_fn *); 854extern void blk_queue_softirq_done(struct request_queue *, softirq_done_fn *);
855extern void blk_queue_set_discard(struct request_queue *, prepare_discard_fn *);
856extern void blk_queue_rq_timed_out(struct request_queue *, rq_timed_out_fn *);
857extern void blk_queue_rq_timeout(struct request_queue *, unsigned int);
788extern struct backing_dev_info *blk_get_backing_dev_info(struct block_device *bdev); 858extern struct backing_dev_info *blk_get_backing_dev_info(struct block_device *bdev);
789extern int blk_queue_ordered(struct request_queue *, unsigned, prepare_flush_fn *); 859extern int blk_queue_ordered(struct request_queue *, unsigned, prepare_flush_fn *);
790extern int blk_do_ordered(struct request_queue *, struct request **); 860extern int blk_do_ordered(struct request_queue *, struct request **);
@@ -795,7 +865,6 @@ extern void blk_ordered_complete_seq(struct request_queue *, unsigned, int);
795extern int blk_rq_map_sg(struct request_queue *, struct request *, struct scatterlist *); 865extern int blk_rq_map_sg(struct request_queue *, struct request *, struct scatterlist *);
796extern void blk_dump_rq_flags(struct request *, char *); 866extern void blk_dump_rq_flags(struct request *, char *);
797extern void generic_unplug_device(struct request_queue *); 867extern void generic_unplug_device(struct request_queue *);
798extern void __generic_unplug_device(struct request_queue *);
799extern long nr_blockdev_pages(void); 868extern long nr_blockdev_pages(void);
800 869
801int blk_get_queue(struct request_queue *); 870int blk_get_queue(struct request_queue *);
@@ -806,8 +875,6 @@ extern void blk_put_queue(struct request_queue *);
806/* 875/*
807 * tag stuff 876 * tag stuff
808 */ 877 */
809#define blk_queue_tag_depth(q) ((q)->queue_tags->busy)
810#define blk_queue_tag_queue(q) ((q)->queue_tags->busy < (q)->queue_tags->max_depth)
811#define blk_rq_tagged(rq) ((rq)->cmd_flags & REQ_QUEUED) 878#define blk_rq_tagged(rq) ((rq)->cmd_flags & REQ_QUEUED)
812extern int blk_queue_start_tag(struct request_queue *, struct request *); 879extern int blk_queue_start_tag(struct request_queue *, struct request *);
813extern struct request *blk_queue_find_tag(struct request_queue *, int); 880extern struct request *blk_queue_find_tag(struct request_queue *, int);
@@ -828,15 +895,24 @@ static inline struct request *blk_map_queue_find_tag(struct blk_queue_tag *bqt,
828} 895}
829 896
830extern int blkdev_issue_flush(struct block_device *, sector_t *); 897extern int blkdev_issue_flush(struct block_device *, sector_t *);
898extern int blkdev_issue_discard(struct block_device *,
899 sector_t sector, sector_t nr_sects, gfp_t);
900
901static inline int sb_issue_discard(struct super_block *sb,
902 sector_t block, sector_t nr_blocks)
903{
904 block <<= (sb->s_blocksize_bits - 9);
905 nr_blocks <<= (sb->s_blocksize_bits - 9);
906 return blkdev_issue_discard(sb->s_bdev, block, nr_blocks, GFP_KERNEL);
907}
831 908
832/* 909/*
833* command filter functions 910* command filter functions
834*/ 911*/
835extern int blk_verify_command(struct file *file, unsigned char *cmd); 912extern int blk_verify_command(struct blk_cmd_filter *filter,
836extern int blk_cmd_filter_verify_command(struct blk_scsi_cmd_filter *filter, 913 unsigned char *cmd, fmode_t has_write_perm);
837 unsigned char *cmd, mode_t *f_mode);
838extern int blk_register_filter(struct gendisk *disk);
839extern void blk_unregister_filter(struct gendisk *disk); 914extern void blk_unregister_filter(struct gendisk *disk);
915extern void blk_set_cmd_filter_defaults(struct blk_cmd_filter *filter);
840 916
841#define MAX_PHYS_SEGMENTS 128 917#define MAX_PHYS_SEGMENTS 128
842#define MAX_HW_SEGMENTS 128 918#define MAX_HW_SEGMENTS 128
@@ -867,6 +943,13 @@ static inline int queue_dma_alignment(struct request_queue *q)
867 return q ? q->dma_alignment : 511; 943 return q ? q->dma_alignment : 511;
868} 944}
869 945
946static inline int blk_rq_aligned(struct request_queue *q, void *addr,
947 unsigned int len)
948{
949 unsigned int alignment = queue_dma_alignment(q) | q->dma_pad_mask;
950 return !((unsigned long)addr & alignment) && !(len & alignment);
951}
952
870/* assumes size > 256 */ 953/* assumes size > 256 */
871static inline unsigned int blksize_bits(unsigned int size) 954static inline unsigned int blksize_bits(unsigned int size)
872{ 955{
@@ -893,7 +976,7 @@ static inline void put_dev_sector(Sector p)
893} 976}
894 977
895struct work_struct; 978struct work_struct;
896int kblockd_schedule_work(struct work_struct *work); 979int kblockd_schedule_work(struct request_queue *q, struct work_struct *work);
897void kblockd_flush_work(struct work_struct *work); 980void kblockd_flush_work(struct work_struct *work);
898 981
899#define MODULE_ALIAS_BLOCKDEV(major,minor) \ 982#define MODULE_ALIAS_BLOCKDEV(major,minor) \
@@ -938,49 +1021,19 @@ struct blk_integrity {
938 1021
939extern int blk_integrity_register(struct gendisk *, struct blk_integrity *); 1022extern int blk_integrity_register(struct gendisk *, struct blk_integrity *);
940extern void blk_integrity_unregister(struct gendisk *); 1023extern void blk_integrity_unregister(struct gendisk *);
941extern int blk_integrity_compare(struct block_device *, struct block_device *); 1024extern int blk_integrity_compare(struct gendisk *, struct gendisk *);
942extern int blk_rq_map_integrity_sg(struct request *, struct scatterlist *); 1025extern int blk_rq_map_integrity_sg(struct request *, struct scatterlist *);
943extern int blk_rq_count_integrity_sg(struct request *); 1026extern int blk_rq_count_integrity_sg(struct request *);
944 1027
945static inline unsigned short blk_integrity_tuple_size(struct blk_integrity *bi) 1028static inline
946{ 1029struct blk_integrity *bdev_get_integrity(struct block_device *bdev)
947 if (bi)
948 return bi->tuple_size;
949
950 return 0;
951}
952
953static inline struct blk_integrity *bdev_get_integrity(struct block_device *bdev)
954{ 1030{
955 return bdev->bd_disk->integrity; 1031 return bdev->bd_disk->integrity;
956} 1032}
957 1033
958static inline unsigned int bdev_get_tag_size(struct block_device *bdev) 1034static inline struct blk_integrity *blk_get_integrity(struct gendisk *disk)
959{
960 struct blk_integrity *bi = bdev_get_integrity(bdev);
961
962 if (bi)
963 return bi->tag_size;
964
965 return 0;
966}
967
968static inline int bdev_integrity_enabled(struct block_device *bdev, int rw)
969{ 1035{
970 struct blk_integrity *bi = bdev_get_integrity(bdev); 1036 return disk->integrity;
971
972 if (bi == NULL)
973 return 0;
974
975 if (rw == READ && bi->verify_fn != NULL &&
976 (bi->flags & INTEGRITY_FLAG_READ))
977 return 1;
978
979 if (rw == WRITE && bi->generate_fn != NULL &&
980 (bi->flags & INTEGRITY_FLAG_WRITE))
981 return 1;
982
983 return 0;
984} 1037}
985 1038
986static inline int blk_integrity_rq(struct request *rq) 1039static inline int blk_integrity_rq(struct request *rq)
@@ -997,13 +1050,29 @@ static inline int blk_integrity_rq(struct request *rq)
997#define blk_rq_count_integrity_sg(a) (0) 1050#define blk_rq_count_integrity_sg(a) (0)
998#define blk_rq_map_integrity_sg(a, b) (0) 1051#define blk_rq_map_integrity_sg(a, b) (0)
999#define bdev_get_integrity(a) (0) 1052#define bdev_get_integrity(a) (0)
1000#define bdev_get_tag_size(a) (0) 1053#define blk_get_integrity(a) (0)
1001#define blk_integrity_compare(a, b) (0) 1054#define blk_integrity_compare(a, b) (0)
1002#define blk_integrity_register(a, b) (0) 1055#define blk_integrity_register(a, b) (0)
1003#define blk_integrity_unregister(a) do { } while (0); 1056#define blk_integrity_unregister(a) do { } while (0);
1004 1057
1005#endif /* CONFIG_BLK_DEV_INTEGRITY */ 1058#endif /* CONFIG_BLK_DEV_INTEGRITY */
1006 1059
1060struct block_device_operations {
1061 int (*open) (struct block_device *, fmode_t);
1062 int (*release) (struct gendisk *, fmode_t);
1063 int (*locked_ioctl) (struct block_device *, fmode_t, unsigned, unsigned long);
1064 int (*ioctl) (struct block_device *, fmode_t, unsigned, unsigned long);
1065 int (*compat_ioctl) (struct block_device *, fmode_t, unsigned, unsigned long);
1066 int (*direct_access) (struct block_device *, sector_t,
1067 void **, unsigned long *);
1068 int (*media_changed) (struct gendisk *);
1069 int (*revalidate_disk) (struct gendisk *);
1070 int (*getgeo)(struct block_device *, struct hd_geometry *);
1071 struct module *owner;
1072};
1073
1074extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
1075 unsigned long);
1007#else /* CONFIG_BLOCK */ 1076#else /* CONFIG_BLOCK */
1008/* 1077/*
1009 * stubs for when the block layer is configured out 1078 * stubs for when the block layer is configured out
diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
index d084b8d227a5..bdf505d33e77 100644
--- a/include/linux/blktrace_api.h
+++ b/include/linux/blktrace_api.h
@@ -1,8 +1,10 @@
1#ifndef BLKTRACE_H 1#ifndef BLKTRACE_H
2#define BLKTRACE_H 2#define BLKTRACE_H
3 3
4#ifdef __KERNEL__
4#include <linux/blkdev.h> 5#include <linux/blkdev.h>
5#include <linux/relay.h> 6#include <linux/relay.h>
7#endif
6 8
7/* 9/*
8 * Trace categories 10 * Trace categories
@@ -21,6 +23,8 @@ enum blktrace_cat {
21 BLK_TC_NOTIFY = 1 << 10, /* special message */ 23 BLK_TC_NOTIFY = 1 << 10, /* special message */
22 BLK_TC_AHEAD = 1 << 11, /* readahead */ 24 BLK_TC_AHEAD = 1 << 11, /* readahead */
23 BLK_TC_META = 1 << 12, /* metadata */ 25 BLK_TC_META = 1 << 12, /* metadata */
26 BLK_TC_DISCARD = 1 << 13, /* discard requests */
27 BLK_TC_DRV_DATA = 1 << 14, /* binary per-driver data */
24 28
25 BLK_TC_END = 1 << 15, /* only 16-bits, reminder */ 29 BLK_TC_END = 1 << 15, /* only 16-bits, reminder */
26}; 30};
@@ -47,6 +51,8 @@ enum blktrace_act {
47 __BLK_TA_SPLIT, /* bio was split */ 51 __BLK_TA_SPLIT, /* bio was split */
48 __BLK_TA_BOUNCE, /* bio was bounced */ 52 __BLK_TA_BOUNCE, /* bio was bounced */
49 __BLK_TA_REMAP, /* bio was remapped */ 53 __BLK_TA_REMAP, /* bio was remapped */
54 __BLK_TA_ABORT, /* request aborted */
55 __BLK_TA_DRV_DATA, /* driver-specific binary data */
50}; 56};
51 57
52/* 58/*
@@ -77,6 +83,8 @@ enum blktrace_notify {
77#define BLK_TA_SPLIT (__BLK_TA_SPLIT) 83#define BLK_TA_SPLIT (__BLK_TA_SPLIT)
78#define BLK_TA_BOUNCE (__BLK_TA_BOUNCE) 84#define BLK_TA_BOUNCE (__BLK_TA_BOUNCE)
79#define BLK_TA_REMAP (__BLK_TA_REMAP | BLK_TC_ACT(BLK_TC_QUEUE)) 85#define BLK_TA_REMAP (__BLK_TA_REMAP | BLK_TC_ACT(BLK_TC_QUEUE))
86#define BLK_TA_ABORT (__BLK_TA_ABORT | BLK_TC_ACT(BLK_TC_QUEUE))
87#define BLK_TA_DRV_DATA (__BLK_TA_DRV_DATA | BLK_TC_ACT(BLK_TC_DRV_DATA))
80 88
81#define BLK_TN_PROCESS (__BLK_TN_PROCESS | BLK_TC_ACT(BLK_TC_NOTIFY)) 89#define BLK_TN_PROCESS (__BLK_TN_PROCESS | BLK_TC_ACT(BLK_TC_NOTIFY))
82#define BLK_TN_TIMESTAMP (__BLK_TN_TIMESTAMP | BLK_TC_ACT(BLK_TC_NOTIFY)) 90#define BLK_TN_TIMESTAMP (__BLK_TN_TIMESTAMP | BLK_TC_ACT(BLK_TC_NOTIFY))
@@ -89,17 +97,17 @@ enum blktrace_notify {
89 * The trace itself 97 * The trace itself
90 */ 98 */
91struct blk_io_trace { 99struct blk_io_trace {
92 u32 magic; /* MAGIC << 8 | version */ 100 __u32 magic; /* MAGIC << 8 | version */
93 u32 sequence; /* event number */ 101 __u32 sequence; /* event number */
94 u64 time; /* in microseconds */ 102 __u64 time; /* in microseconds */
95 u64 sector; /* disk offset */ 103 __u64 sector; /* disk offset */
96 u32 bytes; /* transfer length */ 104 __u32 bytes; /* transfer length */
97 u32 action; /* what happened */ 105 __u32 action; /* what happened */
98 u32 pid; /* who did it */ 106 __u32 pid; /* who did it */
99 u32 device; /* device number */ 107 __u32 device; /* device number */
100 u32 cpu; /* on what cpu did it happen */ 108 __u32 cpu; /* on what cpu did it happen */
101 u16 error; /* completion error */ 109 __u16 error; /* completion error */
102 u16 pdu_len; /* length of data after this trace */ 110 __u16 pdu_len; /* length of data after this trace */
103}; 111};
104 112
105/* 113/*
@@ -117,6 +125,23 @@ enum {
117 Blktrace_stopped, 125 Blktrace_stopped,
118}; 126};
119 127
128#define BLKTRACE_BDEV_SIZE 32
129
130/*
131 * User setup structure passed with BLKTRACESTART
132 */
133struct blk_user_trace_setup {
134 char name[BLKTRACE_BDEV_SIZE]; /* output */
135 __u16 act_mask; /* input */
136 __u32 buf_size; /* input */
137 __u32 buf_nr; /* input */
138 __u64 start_lba;
139 __u64 end_lba;
140 __u32 pid;
141};
142
143#ifdef __KERNEL__
144#if defined(CONFIG_BLK_DEV_IO_TRACE)
120struct blk_trace { 145struct blk_trace {
121 int trace_state; 146 int trace_state;
122 struct rchan *rchan; 147 struct rchan *rchan;
@@ -133,21 +158,6 @@ struct blk_trace {
133 atomic_t dropped; 158 atomic_t dropped;
134}; 159};
135 160
136/*
137 * User setup structure passed with BLKTRACESTART
138 */
139struct blk_user_trace_setup {
140 char name[BDEVNAME_SIZE]; /* output */
141 u16 act_mask; /* input */
142 u32 buf_size; /* input */
143 u32 buf_nr; /* input */
144 u64 start_lba;
145 u64 end_lba;
146 u32 pid;
147};
148
149#ifdef __KERNEL__
150#if defined(CONFIG_BLK_DEV_IO_TRACE)
151extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *); 161extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
152extern void blk_trace_shutdown(struct request_queue *); 162extern void blk_trace_shutdown(struct request_queue *);
153extern void __blk_add_trace(struct blk_trace *, sector_t, int, int, u32, int, int, void *); 163extern void __blk_add_trace(struct blk_trace *, sector_t, int, int, u32, int, int, void *);
@@ -195,6 +205,9 @@ static inline void blk_add_trace_rq(struct request_queue *q, struct request *rq,
195 if (likely(!bt)) 205 if (likely(!bt))
196 return; 206 return;
197 207
208 if (blk_discard_rq(rq))
209 rw |= (1 << BIO_RW_DISCARD);
210
198 if (blk_pc_request(rq)) { 211 if (blk_pc_request(rq)) {
199 what |= BLK_TC_ACT(BLK_TC_PC); 212 what |= BLK_TC_ACT(BLK_TC_PC);
200 __blk_add_trace(bt, 0, rq->data_len, rw, what, rq->errors, sizeof(rq->cmd), rq->cmd); 213 __blk_add_trace(bt, 0, rq->data_len, rw, what, rq->errors, sizeof(rq->cmd), rq->cmd);
@@ -307,6 +320,34 @@ static inline void blk_add_trace_remap(struct request_queue *q, struct bio *bio,
307 __blk_add_trace(bt, from, bio->bi_size, bio->bi_rw, BLK_TA_REMAP, !bio_flagged(bio, BIO_UPTODATE), sizeof(r), &r); 320 __blk_add_trace(bt, from, bio->bi_size, bio->bi_rw, BLK_TA_REMAP, !bio_flagged(bio, BIO_UPTODATE), sizeof(r), &r);
308} 321}
309 322
323/**
324 * blk_add_driver_data - Add binary message with driver-specific data
325 * @q: queue the io is for
326 * @rq: io request
327 * @data: driver-specific data
328 * @len: length of driver-specific data
329 *
330 * Description:
331 * Some drivers might want to write driver-specific data per request.
332 *
333 **/
334static inline void blk_add_driver_data(struct request_queue *q,
335 struct request *rq,
336 void *data, size_t len)
337{
338 struct blk_trace *bt = q->blk_trace;
339
340 if (likely(!bt))
341 return;
342
343 if (blk_pc_request(rq))
344 __blk_add_trace(bt, 0, rq->data_len, 0, BLK_TA_DRV_DATA,
345 rq->errors, len, data);
346 else
347 __blk_add_trace(bt, rq->hard_sector, rq->hard_nr_sectors << 9,
348 0, BLK_TA_DRV_DATA, rq->errors, len, data);
349}
350
310extern int blk_trace_setup(struct request_queue *q, char *name, dev_t dev, 351extern int blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
311 char __user *arg); 352 char __user *arg);
312extern int blk_trace_startstop(struct request_queue *q, int start); 353extern int blk_trace_startstop(struct request_queue *q, int start);
@@ -320,6 +361,7 @@ extern int blk_trace_remove(struct request_queue *q);
320#define blk_add_trace_generic(q, rq, rw, what) do { } while (0) 361#define blk_add_trace_generic(q, rq, rw, what) do { } while (0)
321#define blk_add_trace_pdu_int(q, what, bio, pdu) do { } while (0) 362#define blk_add_trace_pdu_int(q, what, bio, pdu) do { } while (0)
322#define blk_add_trace_remap(q, bio, dev, f, t) do {} while (0) 363#define blk_add_trace_remap(q, bio, dev, f, t) do {} while (0)
364#define blk_add_driver_data(q, rq, data, len) do {} while (0)
323#define do_blk_trace_setup(q, name, dev, buts) (-ENOTTY) 365#define do_blk_trace_setup(q, name, dev, buts) (-ENOTTY)
324#define blk_trace_setup(q, name, dev, arg) (-ENOTTY) 366#define blk_trace_setup(q, name, dev, arg) (-ENOTTY)
325#define blk_trace_startstop(q, start) (-ENOTTY) 367#define blk_trace_startstop(q, start) (-ENOTTY)
diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h
index a1d9b79078ea..95837bfb5256 100644
--- a/include/linux/bootmem.h
+++ b/include/linux/bootmem.h
@@ -28,85 +28,85 @@ extern unsigned long saved_max_pfn;
28 * memory pages (including holes) on the node. 28 * memory pages (including holes) on the node.
29 */ 29 */
30typedef struct bootmem_data { 30typedef struct bootmem_data {
31 unsigned long node_boot_start; 31 unsigned long node_min_pfn;
32 unsigned long node_low_pfn; 32 unsigned long node_low_pfn;
33 void *node_bootmem_map; 33 void *node_bootmem_map;
34 unsigned long last_offset; 34 unsigned long last_end_off;
35 unsigned long last_pos; 35 unsigned long hint_idx;
36 unsigned long last_success; /* Previous allocation point. To speed
37 * up searching */
38 struct list_head list; 36 struct list_head list;
39} bootmem_data_t; 37} bootmem_data_t;
40 38
39extern bootmem_data_t bootmem_node_data[];
40
41extern unsigned long bootmem_bootmap_pages(unsigned long); 41extern unsigned long bootmem_bootmap_pages(unsigned long);
42
43extern unsigned long init_bootmem_node(pg_data_t *pgdat,
44 unsigned long freepfn,
45 unsigned long startpfn,
46 unsigned long endpfn);
42extern unsigned long init_bootmem(unsigned long addr, unsigned long memend); 47extern unsigned long init_bootmem(unsigned long addr, unsigned long memend);
48
49extern unsigned long free_all_bootmem_node(pg_data_t *pgdat);
50extern unsigned long free_all_bootmem(void);
51
52extern void free_bootmem_node(pg_data_t *pgdat,
53 unsigned long addr,
54 unsigned long size);
43extern void free_bootmem(unsigned long addr, unsigned long size); 55extern void free_bootmem(unsigned long addr, unsigned long size);
44extern void *__alloc_bootmem(unsigned long size, 56
57/*
58 * Flags for reserve_bootmem (also if CONFIG_HAVE_ARCH_BOOTMEM_NODE,
59 * the architecture-specific code should honor this).
60 *
61 * If flags is 0, then the return value is always 0 (success). If
62 * flags contains BOOTMEM_EXCLUSIVE, then -EBUSY is returned if the
63 * memory already was reserved.
64 */
65#define BOOTMEM_DEFAULT 0
66#define BOOTMEM_EXCLUSIVE (1<<0)
67
68extern int reserve_bootmem_node(pg_data_t *pgdat,
69 unsigned long physaddr,
70 unsigned long size,
71 int flags);
72#ifndef CONFIG_HAVE_ARCH_BOOTMEM_NODE
73extern int reserve_bootmem(unsigned long addr, unsigned long size, int flags);
74#endif
75
76extern void *__alloc_bootmem_nopanic(unsigned long size,
45 unsigned long align, 77 unsigned long align,
46 unsigned long goal); 78 unsigned long goal);
47extern void *__alloc_bootmem_nopanic(unsigned long size, 79extern void *__alloc_bootmem(unsigned long size,
48 unsigned long align, 80 unsigned long align,
49 unsigned long goal); 81 unsigned long goal);
50extern void *__alloc_bootmem_low(unsigned long size, 82extern void *__alloc_bootmem_low(unsigned long size,
51 unsigned long align, 83 unsigned long align,
52 unsigned long goal); 84 unsigned long goal);
85extern void *__alloc_bootmem_node(pg_data_t *pgdat,
86 unsigned long size,
87 unsigned long align,
88 unsigned long goal);
89extern void *__alloc_bootmem_node_nopanic(pg_data_t *pgdat,
90 unsigned long size,
91 unsigned long align,
92 unsigned long goal);
53extern void *__alloc_bootmem_low_node(pg_data_t *pgdat, 93extern void *__alloc_bootmem_low_node(pg_data_t *pgdat,
54 unsigned long size, 94 unsigned long size,
55 unsigned long align, 95 unsigned long align,
56 unsigned long goal); 96 unsigned long goal);
57extern void *__alloc_bootmem_core(struct bootmem_data *bdata,
58 unsigned long size,
59 unsigned long align,
60 unsigned long goal,
61 unsigned long limit);
62
63/*
64 * flags for reserve_bootmem (also if CONFIG_HAVE_ARCH_BOOTMEM_NODE,
65 * the architecture-specific code should honor this)
66 */
67#define BOOTMEM_DEFAULT 0
68#define BOOTMEM_EXCLUSIVE (1<<0)
69
70#ifndef CONFIG_HAVE_ARCH_BOOTMEM_NODE 97#ifndef CONFIG_HAVE_ARCH_BOOTMEM_NODE
71/*
72 * If flags is 0, then the return value is always 0 (success). If
73 * flags contains BOOTMEM_EXCLUSIVE, then -EBUSY is returned if the
74 * memory already was reserved.
75 */
76extern int reserve_bootmem(unsigned long addr, unsigned long size, int flags);
77#define alloc_bootmem(x) \ 98#define alloc_bootmem(x) \
78 __alloc_bootmem(x, SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS)) 99 __alloc_bootmem(x, SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS))
100#define alloc_bootmem_nopanic(x) \
101 __alloc_bootmem_nopanic(x, SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS))
79#define alloc_bootmem_low(x) \ 102#define alloc_bootmem_low(x) \
80 __alloc_bootmem_low(x, SMP_CACHE_BYTES, 0) 103 __alloc_bootmem_low(x, SMP_CACHE_BYTES, 0)
81#define alloc_bootmem_pages(x) \ 104#define alloc_bootmem_pages(x) \
82 __alloc_bootmem(x, PAGE_SIZE, __pa(MAX_DMA_ADDRESS)) 105 __alloc_bootmem(x, PAGE_SIZE, __pa(MAX_DMA_ADDRESS))
106#define alloc_bootmem_pages_nopanic(x) \
107 __alloc_bootmem_nopanic(x, PAGE_SIZE, __pa(MAX_DMA_ADDRESS))
83#define alloc_bootmem_low_pages(x) \ 108#define alloc_bootmem_low_pages(x) \
84 __alloc_bootmem_low(x, PAGE_SIZE, 0) 109 __alloc_bootmem_low(x, PAGE_SIZE, 0)
85#endif /* !CONFIG_HAVE_ARCH_BOOTMEM_NODE */
86
87extern int reserve_bootmem_generic(unsigned long addr, unsigned long size,
88 int flags);
89extern unsigned long free_all_bootmem(void);
90extern unsigned long free_all_bootmem_node(pg_data_t *pgdat);
91extern void *__alloc_bootmem_node(pg_data_t *pgdat,
92 unsigned long size,
93 unsigned long align,
94 unsigned long goal);
95extern unsigned long init_bootmem_node(pg_data_t *pgdat,
96 unsigned long freepfn,
97 unsigned long startpfn,
98 unsigned long endpfn);
99extern int reserve_bootmem_node(pg_data_t *pgdat,
100 unsigned long physaddr,
101 unsigned long size,
102 int flags);
103extern void free_bootmem_node(pg_data_t *pgdat,
104 unsigned long addr,
105 unsigned long size);
106extern void *alloc_bootmem_section(unsigned long size,
107 unsigned long section_nr);
108
109#ifndef CONFIG_HAVE_ARCH_BOOTMEM_NODE
110#define alloc_bootmem_node(pgdat, x) \ 110#define alloc_bootmem_node(pgdat, x) \
111 __alloc_bootmem_node(pgdat, x, SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS)) 111 __alloc_bootmem_node(pgdat, x, SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS))
112#define alloc_bootmem_pages_node(pgdat, x) \ 112#define alloc_bootmem_pages_node(pgdat, x) \
@@ -115,6 +115,12 @@ extern void *alloc_bootmem_section(unsigned long size,
115 __alloc_bootmem_low_node(pgdat, x, PAGE_SIZE, 0) 115 __alloc_bootmem_low_node(pgdat, x, PAGE_SIZE, 0)
116#endif /* !CONFIG_HAVE_ARCH_BOOTMEM_NODE */ 116#endif /* !CONFIG_HAVE_ARCH_BOOTMEM_NODE */
117 117
118extern int reserve_bootmem_generic(unsigned long addr, unsigned long size,
119 int flags);
120
121extern void *alloc_bootmem_section(unsigned long size,
122 unsigned long section_nr);
123
118#ifdef CONFIG_HAVE_ARCH_ALLOC_REMAP 124#ifdef CONFIG_HAVE_ARCH_ALLOC_REMAP
119extern void *alloc_remap(int nid, unsigned long size); 125extern void *alloc_remap(int nid, unsigned long size);
120#else 126#else
diff --git a/include/linux/brcmphy.h b/include/linux/brcmphy.h
new file mode 100644
index 000000000000..9b64b6d67873
--- /dev/null
+++ b/include/linux/brcmphy.h
@@ -0,0 +1,6 @@
1#define PHY_BRCM_WIRESPEED_ENABLE 0x00000001
2#define PHY_BRCM_AUTO_PWRDWN_ENABLE 0x00000002
3#define PHY_BRCM_APD_CLK125_ENABLE 0x00000004
4#define PHY_BRCM_STD_IBND_DISABLE 0x00000008
5#define PHY_BRCM_EXT_IBND_RX_ENABLE 0x00000010
6#define PHY_BRCM_EXT_IBND_TX_ENABLE 0x00000020
diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h
index 82aa36c53ea7..3ce64b90118c 100644
--- a/include/linux/buffer_head.h
+++ b/include/linux/buffer_head.h
@@ -115,7 +115,6 @@ BUFFER_FNS(Uptodate, uptodate)
115BUFFER_FNS(Dirty, dirty) 115BUFFER_FNS(Dirty, dirty)
116TAS_BUFFER_FNS(Dirty, dirty) 116TAS_BUFFER_FNS(Dirty, dirty)
117BUFFER_FNS(Lock, locked) 117BUFFER_FNS(Lock, locked)
118TAS_BUFFER_FNS(Lock, locked)
119BUFFER_FNS(Req, req) 118BUFFER_FNS(Req, req)
120TAS_BUFFER_FNS(Req, req) 119TAS_BUFFER_FNS(Req, req)
121BUFFER_FNS(Mapped, mapped) 120BUFFER_FNS(Mapped, mapped)
@@ -205,6 +204,8 @@ void block_invalidatepage(struct page *page, unsigned long offset);
205int block_write_full_page(struct page *page, get_block_t *get_block, 204int block_write_full_page(struct page *page, get_block_t *get_block,
206 struct writeback_control *wbc); 205 struct writeback_control *wbc);
207int block_read_full_page(struct page*, get_block_t*); 206int block_read_full_page(struct page*, get_block_t*);
207int block_is_partially_uptodate(struct page *page, read_descriptor_t *desc,
208 unsigned long from);
208int block_write_begin(struct file *, struct address_space *, 209int block_write_begin(struct file *, struct address_space *,
209 loff_t, unsigned, unsigned, 210 loff_t, unsigned, unsigned,
210 struct page **, void **, get_block_t*); 211 struct page **, void **, get_block_t*);
@@ -319,10 +320,15 @@ static inline void wait_on_buffer(struct buffer_head *bh)
319 __wait_on_buffer(bh); 320 __wait_on_buffer(bh);
320} 321}
321 322
323static inline int trylock_buffer(struct buffer_head *bh)
324{
325 return likely(!test_and_set_bit_lock(BH_Lock, &bh->b_state));
326}
327
322static inline void lock_buffer(struct buffer_head *bh) 328static inline void lock_buffer(struct buffer_head *bh)
323{ 329{
324 might_sleep(); 330 might_sleep();
325 if (test_set_buffer_locked(bh)) 331 if (!trylock_buffer(bh))
326 __lock_buffer(bh); 332 __lock_buffer(bh);
327} 333}
328 334
diff --git a/include/linux/byteorder.h b/include/linux/byteorder.h
new file mode 100644
index 000000000000..29f002d73d98
--- /dev/null
+++ b/include/linux/byteorder.h
@@ -0,0 +1,372 @@
1#ifndef _LINUX_BYTEORDER_H
2#define _LINUX_BYTEORDER_H
3
4#include <linux/types.h>
5#include <linux/swab.h>
6
7#if defined(__LITTLE_ENDIAN) && defined(__BIG_ENDIAN)
8# error Fix asm/byteorder.h to define one endianness
9#endif
10
11#if !defined(__LITTLE_ENDIAN) && !defined(__BIG_ENDIAN)
12# error Fix asm/byteorder.h to define arch endianness
13#endif
14
15#ifdef __LITTLE_ENDIAN
16# undef __LITTLE_ENDIAN
17# define __LITTLE_ENDIAN 1234
18#endif
19
20#ifdef __BIG_ENDIAN
21# undef __BIG_ENDIAN
22# define __BIG_ENDIAN 4321
23#endif
24
25#if defined(__LITTLE_ENDIAN) && !defined(__LITTLE_ENDIAN_BITFIELD)
26# define __LITTLE_ENDIAN_BITFIELD
27#endif
28
29#if defined(__BIG_ENDIAN) && !defined(__BIG_ENDIAN_BITFIELD)
30# define __BIG_ENDIAN_BITFIELD
31#endif
32
33#ifdef __LITTLE_ENDIAN
34# define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
35# define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
36# define __le64_to_cpu(x) ((__force __u64)(__le64)(x))
37# define __cpu_to_le16(x) ((__force __le16)(__u16)(x))
38# define __cpu_to_le32(x) ((__force __le32)(__u32)(x))
39# define __cpu_to_le64(x) ((__force __le64)(__u64)(x))
40
41# define __be16_to_cpu(x) __swab16((__force __u16)(__be16)(x))
42# define __be32_to_cpu(x) __swab32((__force __u32)(__be32)(x))
43# define __be64_to_cpu(x) __swab64((__force __u64)(__be64)(x))
44# define __cpu_to_be16(x) ((__force __be16)__swab16(x))
45# define __cpu_to_be32(x) ((__force __be32)__swab32(x))
46# define __cpu_to_be64(x) ((__force __be64)__swab64(x))
47#endif
48
49#ifdef __BIG_ENDIAN
50# define __be16_to_cpu(x) ((__force __u16)(__be16)(x))
51# define __be32_to_cpu(x) ((__force __u32)(__be32)(x))
52# define __be64_to_cpu(x) ((__force __u64)(__be64)(x))
53# define __cpu_to_be16(x) ((__force __be16)(__u16)(x))
54# define __cpu_to_be32(x) ((__force __be32)(__u32)(x))
55# define __cpu_to_be64(x) ((__force __be64)(__u64)(x))
56
57# define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
58# define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
59# define __le64_to_cpu(x) __swab64((__force __u64)(__le64)(x))
60# define __cpu_to_le16(x) ((__force __le16)__swab16(x))
61# define __cpu_to_le32(x) ((__force __le32)__swab32(x))
62# define __cpu_to_le64(x) ((__force __le64)__swab64(x))
63#endif
64
65/*
66 * These helpers could be phased out over time as the base version
67 * handles constant folding.
68 */
69#define __constant_htonl(x) __cpu_to_be32(x)
70#define __constant_ntohl(x) __be32_to_cpu(x)
71#define __constant_htons(x) __cpu_to_be16(x)
72#define __constant_ntohs(x) __be16_to_cpu(x)
73
74#define __constant_le16_to_cpu(x) __le16_to_cpu(x)
75#define __constant_le32_to_cpu(x) __le32_to_cpu(x)
76#define __constant_le64_to_cpu(x) __le64_to_cpu(x)
77#define __constant_be16_to_cpu(x) __be16_to_cpu(x)
78#define __constant_be32_to_cpu(x) __be32_to_cpu(x)
79#define __constant_be64_to_cpu(x) __be64_to_cpu(x)
80
81#define __constant_cpu_to_le16(x) __cpu_to_le16(x)
82#define __constant_cpu_to_le32(x) __cpu_to_le32(x)
83#define __constant_cpu_to_le64(x) __cpu_to_le64(x)
84#define __constant_cpu_to_be16(x) __cpu_to_be16(x)
85#define __constant_cpu_to_be32(x) __cpu_to_be32(x)
86#define __constant_cpu_to_be64(x) __cpu_to_be64(x)
87
88static inline void __le16_to_cpus(__u16 *p)
89{
90#ifdef __BIG_ENDIAN
91 __swab16s(p);
92#endif
93}
94
95static inline void __cpu_to_le16s(__u16 *p)
96{
97#ifdef __BIG_ENDIAN
98 __swab16s(p);
99#endif
100}
101
102static inline void __le32_to_cpus(__u32 *p)
103{
104#ifdef __BIG_ENDIAN
105 __swab32s(p);
106#endif
107}
108
109static inline void __cpu_to_le32s(__u32 *p)
110{
111#ifdef __BIG_ENDIAN
112 __swab32s(p);
113#endif
114}
115
116static inline void __le64_to_cpus(__u64 *p)
117{
118#ifdef __BIG_ENDIAN
119 __swab64s(p);
120#endif
121}
122
123static inline void __cpu_to_le64s(__u64 *p)
124{
125#ifdef __BIG_ENDIAN
126 __swab64s(p);
127#endif
128}
129
130static inline void __be16_to_cpus(__u16 *p)
131{
132#ifdef __LITTLE_ENDIAN
133 __swab16s(p);
134#endif
135}
136
137static inline void __cpu_to_be16s(__u16 *p)
138{
139#ifdef __LITTLE_ENDIAN
140 __swab16s(p);
141#endif
142}
143
144static inline void __be32_to_cpus(__u32 *p)
145{
146#ifdef __LITTLE_ENDIAN
147 __swab32s(p);
148#endif
149}
150
151static inline void __cpu_to_be32s(__u32 *p)
152{
153#ifdef __LITTLE_ENDIAN
154 __swab32s(p);
155#endif
156}
157
158static inline void __be64_to_cpus(__u64 *p)
159{
160#ifdef __LITTLE_ENDIAN
161 __swab64s(p);
162#endif
163}
164
165static inline void __cpu_to_be64s(__u64 *p)
166{
167#ifdef __LITTLE_ENDIAN
168 __swab64s(p);
169#endif
170}
171
172static inline __u16 __le16_to_cpup(const __le16 *p)
173{
174#ifdef __LITTLE_ENDIAN
175 return (__force __u16)*p;
176#else
177 return __swab16p((__force __u16 *)p);
178#endif
179}
180
181static inline __u32 __le32_to_cpup(const __le32 *p)
182{
183#ifdef __LITTLE_ENDIAN
184 return (__force __u32)*p;
185#else
186 return __swab32p((__force __u32 *)p);
187#endif
188}
189
190static inline __u64 __le64_to_cpup(const __le64 *p)
191{
192#ifdef __LITTLE_ENDIAN
193 return (__force __u64)*p;
194#else
195 return __swab64p((__force __u64 *)p);
196#endif
197}
198
199static inline __le16 __cpu_to_le16p(const __u16 *p)
200{
201#ifdef __LITTLE_ENDIAN
202 return (__force __le16)*p;
203#else
204 return (__force __le16)__swab16p(p);
205#endif
206}
207
208static inline __le32 __cpu_to_le32p(const __u32 *p)
209{
210#ifdef __LITTLE_ENDIAN
211 return (__force __le32)*p;
212#else
213 return (__force __le32)__swab32p(p);
214#endif
215}
216
217static inline __le64 __cpu_to_le64p(const __u64 *p)
218{
219#ifdef __LITTLE_ENDIAN
220 return (__force __le64)*p;
221#else
222 return (__force __le64)__swab64p(p);
223#endif
224}
225
226static inline __u16 __be16_to_cpup(const __be16 *p)
227{
228#ifdef __BIG_ENDIAN
229 return (__force __u16)*p;
230#else
231 return __swab16p((__force __u16 *)p);
232#endif
233}
234
235static inline __u32 __be32_to_cpup(const __be32 *p)
236{
237#ifdef __BIG_ENDIAN
238 return (__force __u32)*p;
239#else
240 return __swab32p((__force __u32 *)p);
241#endif
242}
243
244static inline __u64 __be64_to_cpup(const __be64 *p)
245{
246#ifdef __BIG_ENDIAN
247 return (__force __u64)*p;
248#else
249 return __swab64p((__force __u64 *)p);
250#endif
251}
252
253static inline __be16 __cpu_to_be16p(const __u16 *p)
254{
255#ifdef __BIG_ENDIAN
256 return (__force __be16)*p;
257#else
258 return (__force __be16)__swab16p(p);
259#endif
260}
261
262static inline __be32 __cpu_to_be32p(const __u32 *p)
263{
264#ifdef __BIG_ENDIAN
265 return (__force __be32)*p;
266#else
267 return (__force __be32)__swab32p(p);
268#endif
269}
270
271static inline __be64 __cpu_to_be64p(const __u64 *p)
272{
273#ifdef __BIG_ENDIAN
274 return (__force __be64)*p;
275#else
276 return (__force __be64)__swab64p(p);
277#endif
278}
279
280#ifdef __KERNEL__
281
282# define le16_to_cpu __le16_to_cpu
283# define le32_to_cpu __le32_to_cpu
284# define le64_to_cpu __le64_to_cpu
285# define be16_to_cpu __be16_to_cpu
286# define be32_to_cpu __be32_to_cpu
287# define be64_to_cpu __be64_to_cpu
288# define cpu_to_le16 __cpu_to_le16
289# define cpu_to_le32 __cpu_to_le32
290# define cpu_to_le64 __cpu_to_le64
291# define cpu_to_be16 __cpu_to_be16
292# define cpu_to_be32 __cpu_to_be32
293# define cpu_to_be64 __cpu_to_be64
294
295# define le16_to_cpup __le16_to_cpup
296# define le32_to_cpup __le32_to_cpup
297# define le64_to_cpup __le64_to_cpup
298# define be16_to_cpup __be16_to_cpup
299# define be32_to_cpup __be32_to_cpup
300# define be64_to_cpup __be64_to_cpup
301# define cpu_to_le16p __cpu_to_le16p
302# define cpu_to_le32p __cpu_to_le32p
303# define cpu_to_le64p __cpu_to_le64p
304# define cpu_to_be16p __cpu_to_be16p
305# define cpu_to_be32p __cpu_to_be32p
306# define cpu_to_be64p __cpu_to_be64p
307
308# define le16_to_cpus __le16_to_cpus
309# define le32_to_cpus __le32_to_cpus
310# define le64_to_cpus __le64_to_cpus
311# define be16_to_cpus __be16_to_cpus
312# define be32_to_cpus __be32_to_cpus
313# define be64_to_cpus __be64_to_cpus
314# define cpu_to_le16s __cpu_to_le16s
315# define cpu_to_le32s __cpu_to_le32s
316# define cpu_to_le64s __cpu_to_le64s
317# define cpu_to_be16s __cpu_to_be16s
318# define cpu_to_be32s __cpu_to_be32s
319# define cpu_to_be64s __cpu_to_be64s
320
321/*
322 * They have to be macros in order to do the constant folding
323 * correctly - if the argument passed into a inline function
324 * it is no longer constant according to gcc..
325 */
326# undef ntohl
327# undef ntohs
328# undef htonl
329# undef htons
330
331# define ___htonl(x) __cpu_to_be32(x)
332# define ___htons(x) __cpu_to_be16(x)
333# define ___ntohl(x) __be32_to_cpu(x)
334# define ___ntohs(x) __be16_to_cpu(x)
335
336# define htonl(x) ___htonl(x)
337# define ntohl(x) ___ntohl(x)
338# define htons(x) ___htons(x)
339# define ntohs(x) ___ntohs(x)
340
341static inline void le16_add_cpu(__le16 *var, u16 val)
342{
343 *var = cpu_to_le16(le16_to_cpup(var) + val);
344}
345
346static inline void le32_add_cpu(__le32 *var, u32 val)
347{
348 *var = cpu_to_le32(le32_to_cpup(var) + val);
349}
350
351static inline void le64_add_cpu(__le64 *var, u64 val)
352{
353 *var = cpu_to_le64(le64_to_cpup(var) + val);
354}
355
356static inline void be16_add_cpu(__be16 *var, u16 val)
357{
358 *var = cpu_to_be16(be16_to_cpup(var) + val);
359}
360
361static inline void be32_add_cpu(__be32 *var, u32 val)
362{
363 *var = cpu_to_be32(be32_to_cpup(var) + val);
364}
365
366static inline void be64_add_cpu(__be64 *var, u64 val)
367{
368 *var = cpu_to_be64(be64_to_cpup(var) + val);
369}
370
371#endif /* __KERNEL__ */
372#endif /* _LINUX_BYTEORDER_H */
diff --git a/include/linux/byteorder/Kbuild b/include/linux/byteorder/Kbuild
index 1133d5f9d818..fbaa7f9cee32 100644
--- a/include/linux/byteorder/Kbuild
+++ b/include/linux/byteorder/Kbuild
@@ -1,3 +1,4 @@
1unifdef-y += big_endian.h 1unifdef-y += big_endian.h
2unifdef-y += little_endian.h 2unifdef-y += little_endian.h
3unifdef-y += swab.h 3unifdef-y += swab.h
4unifdef-y += swabb.h
diff --git a/include/linux/byteorder/big_endian.h b/include/linux/byteorder/big_endian.h
index 961ed4b48d8e..1cba3f3efe5f 100644
--- a/include/linux/byteorder/big_endian.h
+++ b/include/linux/byteorder/big_endian.h
@@ -10,6 +10,7 @@
10 10
11#include <linux/types.h> 11#include <linux/types.h>
12#include <linux/byteorder/swab.h> 12#include <linux/byteorder/swab.h>
13#include <linux/byteorder/swabb.h>
13 14
14#define __constant_htonl(x) ((__force __be32)(__u32)(x)) 15#define __constant_htonl(x) ((__force __be32)(__u32)(x))
15#define __constant_ntohl(x) ((__force __u32)(__be32)(x)) 16#define __constant_ntohl(x) ((__force __u32)(__be32)(x))
@@ -94,12 +95,12 @@ static inline __u16 __be16_to_cpup(const __be16 *p)
94#define __le32_to_cpus(x) __swab32s((x)) 95#define __le32_to_cpus(x) __swab32s((x))
95#define __cpu_to_le16s(x) __swab16s((x)) 96#define __cpu_to_le16s(x) __swab16s((x))
96#define __le16_to_cpus(x) __swab16s((x)) 97#define __le16_to_cpus(x) __swab16s((x))
97#define __cpu_to_be64s(x) do {} while (0) 98#define __cpu_to_be64s(x) do { (void)(x); } while (0)
98#define __be64_to_cpus(x) do {} while (0) 99#define __be64_to_cpus(x) do { (void)(x); } while (0)
99#define __cpu_to_be32s(x) do {} while (0) 100#define __cpu_to_be32s(x) do { (void)(x); } while (0)
100#define __be32_to_cpus(x) do {} while (0) 101#define __be32_to_cpus(x) do { (void)(x); } while (0)
101#define __cpu_to_be16s(x) do {} while (0) 102#define __cpu_to_be16s(x) do { (void)(x); } while (0)
102#define __be16_to_cpus(x) do {} while (0) 103#define __be16_to_cpus(x) do { (void)(x); } while (0)
103 104
104#ifdef __KERNEL__ 105#ifdef __KERNEL__
105#include <linux/byteorder/generic.h> 106#include <linux/byteorder/generic.h>
diff --git a/include/linux/byteorder/little_endian.h b/include/linux/byteorder/little_endian.h
index 05dc7c35b3b2..cedc1b5a289c 100644
--- a/include/linux/byteorder/little_endian.h
+++ b/include/linux/byteorder/little_endian.h
@@ -10,6 +10,7 @@
10 10
11#include <linux/types.h> 11#include <linux/types.h>
12#include <linux/byteorder/swab.h> 12#include <linux/byteorder/swab.h>
13#include <linux/byteorder/swabb.h>
13 14
14#define __constant_htonl(x) ((__force __be32)___constant_swab32((x))) 15#define __constant_htonl(x) ((__force __be32)___constant_swab32((x)))
15#define __constant_ntohl(x) ___constant_swab32((__force __be32)(x)) 16#define __constant_ntohl(x) ___constant_swab32((__force __be32)(x))
@@ -88,12 +89,12 @@ static inline __u16 __be16_to_cpup(const __be16 *p)
88{ 89{
89 return __swab16p((__u16 *)p); 90 return __swab16p((__u16 *)p);
90} 91}
91#define __cpu_to_le64s(x) do {} while (0) 92#define __cpu_to_le64s(x) do { (void)(x); } while (0)
92#define __le64_to_cpus(x) do {} while (0) 93#define __le64_to_cpus(x) do { (void)(x); } while (0)
93#define __cpu_to_le32s(x) do {} while (0) 94#define __cpu_to_le32s(x) do { (void)(x); } while (0)
94#define __le32_to_cpus(x) do {} while (0) 95#define __le32_to_cpus(x) do { (void)(x); } while (0)
95#define __cpu_to_le16s(x) do {} while (0) 96#define __cpu_to_le16s(x) do { (void)(x); } while (0)
96#define __le16_to_cpus(x) do {} while (0) 97#define __le16_to_cpus(x) do { (void)(x); } while (0)
97#define __cpu_to_be64s(x) __swab64s((x)) 98#define __cpu_to_be64s(x) __swab64s((x))
98#define __be64_to_cpus(x) __swab64s((x)) 99#define __be64_to_cpus(x) __swab64s((x))
99#define __cpu_to_be32s(x) __swab32s((x)) 100#define __cpu_to_be32s(x) __swab32s((x))
diff --git a/include/linux/capability.h b/include/linux/capability.h
index 02673846d205..9d1fe30b6f6c 100644
--- a/include/linux/capability.h
+++ b/include/linux/capability.h
@@ -503,8 +503,19 @@ extern const kernel_cap_t __cap_init_eff_set;
503 503
504kernel_cap_t cap_set_effective(const kernel_cap_t pE_new); 504kernel_cap_t cap_set_effective(const kernel_cap_t pE_new);
505 505
506int capable(int cap); 506/**
507int __capable(struct task_struct *t, int cap); 507 * has_capability - Determine if a task has a superior capability available
508 * @t: The task in question
509 * @cap: The capability to be tested for
510 *
511 * Return true if the specified task has the given superior capability
512 * currently in effect, false if not.
513 *
514 * Note that this does not set PF_SUPERPRIV on the task.
515 */
516#define has_capability(t, cap) (security_capable((t), (cap)) == 0)
517
518extern int capable(int cap);
508 519
509#endif /* __KERNEL__ */ 520#endif /* __KERNEL__ */
510 521
diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
index 5db265ea60f6..0b49e08d3cb0 100644
--- a/include/linux/cdrom.h
+++ b/include/linux/cdrom.h
@@ -987,11 +987,11 @@ struct cdrom_device_ops {
987}; 987};
988 988
989/* the general block_device operations structure: */ 989/* the general block_device operations structure: */
990extern int cdrom_open(struct cdrom_device_info *cdi, struct inode *ip, 990extern int cdrom_open(struct cdrom_device_info *cdi, struct block_device *bdev,
991 struct file *fp); 991 fmode_t mode);
992extern int cdrom_release(struct cdrom_device_info *cdi, struct file *fp); 992extern void cdrom_release(struct cdrom_device_info *cdi, fmode_t mode);
993extern int cdrom_ioctl(struct file *file, struct cdrom_device_info *cdi, 993extern int cdrom_ioctl(struct cdrom_device_info *cdi, struct block_device *bdev,
994 struct inode *ip, unsigned int cmd, unsigned long arg); 994 fmode_t mode, unsigned int cmd, unsigned long arg);
995extern int cdrom_media_changed(struct cdrom_device_info *); 995extern int cdrom_media_changed(struct cdrom_device_info *);
996 996
997extern int register_cdrom(struct cdrom_device_info *cdi); 997extern int register_cdrom(struct cdrom_device_info *cdi);
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index e155aa78d859..8b00f6643e93 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -9,23 +9,25 @@
9 */ 9 */
10 10
11#include <linux/sched.h> 11#include <linux/sched.h>
12#include <linux/kref.h>
13#include <linux/cpumask.h> 12#include <linux/cpumask.h>
14#include <linux/nodemask.h> 13#include <linux/nodemask.h>
15#include <linux/rcupdate.h> 14#include <linux/rcupdate.h>
16#include <linux/cgroupstats.h> 15#include <linux/cgroupstats.h>
17#include <linux/prio_heap.h> 16#include <linux/prio_heap.h>
17#include <linux/rwsem.h>
18 18
19#ifdef CONFIG_CGROUPS 19#ifdef CONFIG_CGROUPS
20 20
21struct cgroupfs_root; 21struct cgroupfs_root;
22struct cgroup_subsys; 22struct cgroup_subsys;
23struct inode; 23struct inode;
24struct cgroup;
24 25
25extern int cgroup_init_early(void); 26extern int cgroup_init_early(void);
26extern int cgroup_init(void); 27extern int cgroup_init(void);
27extern void cgroup_init_smp(void); 28extern void cgroup_init_smp(void);
28extern void cgroup_lock(void); 29extern void cgroup_lock(void);
30extern bool cgroup_lock_live_group(struct cgroup *cgrp);
29extern void cgroup_unlock(void); 31extern void cgroup_unlock(void);
30extern void cgroup_fork(struct task_struct *p); 32extern void cgroup_fork(struct task_struct *p);
31extern void cgroup_fork_callbacks(struct task_struct *p); 33extern void cgroup_fork_callbacks(struct task_struct *p);
@@ -135,6 +137,15 @@ struct cgroup {
135 * release_list_lock 137 * release_list_lock
136 */ 138 */
137 struct list_head release_list; 139 struct list_head release_list;
140
141 /* pids_mutex protects the fields below */
142 struct rw_semaphore pids_mutex;
143 /* Array of process ids in the cgroup */
144 pid_t *tasks_pids;
145 /* How many files are using the current tasks_pids array */
146 int pids_use_count;
147 /* Length of the current tasks_pids array */
148 int pids_length;
138}; 149};
139 150
140/* A css_set is a structure holding pointers to a set of 151/* A css_set is a structure holding pointers to a set of
@@ -147,7 +158,7 @@ struct cgroup {
147struct css_set { 158struct css_set {
148 159
149 /* Reference count */ 160 /* Reference count */
150 struct kref ref; 161 atomic_t refcount;
151 162
152 /* 163 /*
153 * List running through all cgroup groups in the same hash 164 * List running through all cgroup groups in the same hash
@@ -205,50 +216,64 @@ struct cftype {
205 * subsystem, followed by a period */ 216 * subsystem, followed by a period */
206 char name[MAX_CFTYPE_NAME]; 217 char name[MAX_CFTYPE_NAME];
207 int private; 218 int private;
208 int (*open) (struct inode *inode, struct file *file); 219
209 ssize_t (*read) (struct cgroup *cgrp, struct cftype *cft, 220 /*
210 struct file *file, 221 * If non-zero, defines the maximum length of string that can
211 char __user *buf, size_t nbytes, loff_t *ppos); 222 * be passed to write_string; defaults to 64
223 */
224 size_t max_write_len;
225
226 int (*open)(struct inode *inode, struct file *file);
227 ssize_t (*read)(struct cgroup *cgrp, struct cftype *cft,
228 struct file *file,
229 char __user *buf, size_t nbytes, loff_t *ppos);
212 /* 230 /*
213 * read_u64() is a shortcut for the common case of returning a 231 * read_u64() is a shortcut for the common case of returning a
214 * single integer. Use it in place of read() 232 * single integer. Use it in place of read()
215 */ 233 */
216 u64 (*read_u64) (struct cgroup *cgrp, struct cftype *cft); 234 u64 (*read_u64)(struct cgroup *cgrp, struct cftype *cft);
217 /* 235 /*
218 * read_s64() is a signed version of read_u64() 236 * read_s64() is a signed version of read_u64()
219 */ 237 */
220 s64 (*read_s64) (struct cgroup *cgrp, struct cftype *cft); 238 s64 (*read_s64)(struct cgroup *cgrp, struct cftype *cft);
221 /* 239 /*
222 * read_map() is used for defining a map of key/value 240 * read_map() is used for defining a map of key/value
223 * pairs. It should call cb->fill(cb, key, value) for each 241 * pairs. It should call cb->fill(cb, key, value) for each
224 * entry. The key/value pairs (and their ordering) should not 242 * entry. The key/value pairs (and their ordering) should not
225 * change between reboots. 243 * change between reboots.
226 */ 244 */
227 int (*read_map) (struct cgroup *cont, struct cftype *cft, 245 int (*read_map)(struct cgroup *cont, struct cftype *cft,
228 struct cgroup_map_cb *cb); 246 struct cgroup_map_cb *cb);
229 /* 247 /*
230 * read_seq_string() is used for outputting a simple sequence 248 * read_seq_string() is used for outputting a simple sequence
231 * using seqfile. 249 * using seqfile.
232 */ 250 */
233 int (*read_seq_string) (struct cgroup *cont, struct cftype *cft, 251 int (*read_seq_string)(struct cgroup *cont, struct cftype *cft,
234 struct seq_file *m); 252 struct seq_file *m);
235 253
236 ssize_t (*write) (struct cgroup *cgrp, struct cftype *cft, 254 ssize_t (*write)(struct cgroup *cgrp, struct cftype *cft,
237 struct file *file, 255 struct file *file,
238 const char __user *buf, size_t nbytes, loff_t *ppos); 256 const char __user *buf, size_t nbytes, loff_t *ppos);
239 257
240 /* 258 /*
241 * write_u64() is a shortcut for the common case of accepting 259 * write_u64() is a shortcut for the common case of accepting
242 * a single integer (as parsed by simple_strtoull) from 260 * a single integer (as parsed by simple_strtoull) from
243 * userspace. Use in place of write(); return 0 or error. 261 * userspace. Use in place of write(); return 0 or error.
244 */ 262 */
245 int (*write_u64) (struct cgroup *cgrp, struct cftype *cft, u64 val); 263 int (*write_u64)(struct cgroup *cgrp, struct cftype *cft, u64 val);
246 /* 264 /*
247 * write_s64() is a signed version of write_u64() 265 * write_s64() is a signed version of write_u64()
248 */ 266 */
249 int (*write_s64) (struct cgroup *cgrp, struct cftype *cft, s64 val); 267 int (*write_s64)(struct cgroup *cgrp, struct cftype *cft, s64 val);
250 268
251 /* 269 /*
270 * write_string() is passed a nul-terminated kernelspace
271 * buffer of maximum length determined by max_write_len.
272 * Returns 0 or -ve error code.
273 */
274 int (*write_string)(struct cgroup *cgrp, struct cftype *cft,
275 const char *buffer);
276 /*
252 * trigger() callback can be used to get some kick from the 277 * trigger() callback can be used to get some kick from the
253 * userspace, when the actual string written is not important 278 * userspace, when the actual string written is not important
254 * at all. The private field can be used to determine the 279 * at all. The private field can be used to determine the
@@ -256,7 +281,7 @@ struct cftype {
256 */ 281 */
257 int (*trigger)(struct cgroup *cgrp, unsigned int event); 282 int (*trigger)(struct cgroup *cgrp, unsigned int event);
258 283
259 int (*release) (struct inode *inode, struct file *file); 284 int (*release)(struct inode *inode, struct file *file);
260}; 285};
261 286
262struct cgroup_scanner { 287struct cgroup_scanner {
@@ -310,7 +335,8 @@ struct cgroup_subsys {
310 */ 335 */
311 void (*mm_owner_changed)(struct cgroup_subsys *ss, 336 void (*mm_owner_changed)(struct cgroup_subsys *ss,
312 struct cgroup *old, 337 struct cgroup *old,
313 struct cgroup *new); 338 struct cgroup *new,
339 struct task_struct *p);
314 int subsys_id; 340 int subsys_id;
315 int active; 341 int active;
316 int disabled; 342 int disabled;
@@ -348,7 +374,8 @@ static inline struct cgroup* task_cgroup(struct task_struct *task,
348 return task_subsys_state(task, subsys_id)->cgroup; 374 return task_subsys_state(task, subsys_id)->cgroup;
349} 375}
350 376
351int cgroup_clone(struct task_struct *tsk, struct cgroup_subsys *ss); 377int cgroup_clone(struct task_struct *tsk, struct cgroup_subsys *ss,
378 char *nodename);
352 379
353/* A cgroup_iter should be treated as an opaque object */ 380/* A cgroup_iter should be treated as an opaque object */
354struct cgroup_iter { 381struct cgroup_iter {
@@ -376,6 +403,9 @@ void cgroup_iter_end(struct cgroup *cgrp, struct cgroup_iter *it);
376int cgroup_scan_tasks(struct cgroup_scanner *scan); 403int cgroup_scan_tasks(struct cgroup_scanner *scan);
377int cgroup_attach_task(struct cgroup *, struct task_struct *); 404int cgroup_attach_task(struct cgroup *, struct task_struct *);
378 405
406void cgroup_mm_owner_callbacks(struct task_struct *old,
407 struct task_struct *new);
408
379#else /* !CONFIG_CGROUPS */ 409#else /* !CONFIG_CGROUPS */
380 410
381static inline int cgroup_init_early(void) { return 0; } 411static inline int cgroup_init_early(void) { return 0; }
@@ -394,15 +424,9 @@ static inline int cgroupstats_build(struct cgroupstats *stats,
394 return -EINVAL; 424 return -EINVAL;
395} 425}
396 426
427static inline void cgroup_mm_owner_callbacks(struct task_struct *old,
428 struct task_struct *new) {}
429
397#endif /* !CONFIG_CGROUPS */ 430#endif /* !CONFIG_CGROUPS */
398 431
399#ifdef CONFIG_MM_OWNER
400extern void
401cgroup_mm_owner_callbacks(struct task_struct *old, struct task_struct *new);
402#else /* !CONFIG_MM_OWNER */
403static inline void
404cgroup_mm_owner_callbacks(struct task_struct *old, struct task_struct *new)
405{
406}
407#endif /* CONFIG_MM_OWNER */
408#endif /* _LINUX_CGROUP_H */ 432#endif /* _LINUX_CGROUP_H */
diff --git a/include/linux/cgroup_subsys.h b/include/linux/cgroup_subsys.h
index e2877454ec82..9c22396e8b50 100644
--- a/include/linux/cgroup_subsys.h
+++ b/include/linux/cgroup_subsys.h
@@ -48,3 +48,9 @@ SUBSYS(devices)
48#endif 48#endif
49 49
50/* */ 50/* */
51
52#ifdef CONFIG_CGROUP_FREEZER
53SUBSYS(freezer)
54#endif
55
56/* */
diff --git a/include/linux/clk.h b/include/linux/clk.h
index 5ca8c6fddb56..778777316ea4 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -35,6 +35,8 @@ struct clk;
35 * clk_get may return different clock producers depending on @dev.) 35 * clk_get may return different clock producers depending on @dev.)
36 * 36 *
37 * Drivers must assume that the clock source is not enabled. 37 * Drivers must assume that the clock source is not enabled.
38 *
39 * clk_get should not be called from within interrupt context.
38 */ 40 */
39struct clk *clk_get(struct device *dev, const char *id); 41struct clk *clk_get(struct device *dev, const char *id);
40 42
@@ -76,6 +78,8 @@ unsigned long clk_get_rate(struct clk *clk);
76 * Note: drivers must ensure that all clk_enable calls made on this 78 * Note: drivers must ensure that all clk_enable calls made on this
77 * clock source are balanced by clk_disable calls prior to calling 79 * clock source are balanced by clk_disable calls prior to calling
78 * this function. 80 * this function.
81 *
82 * clk_put should not be called from within interrupt context.
79 */ 83 */
80void clk_put(struct clk *clk); 84void clk_put(struct clk *clk);
81 85
diff --git a/include/linux/clockchips.h b/include/linux/clockchips.h
index c33b0dc28e4d..ed3a5d473e52 100644
--- a/include/linux/clockchips.h
+++ b/include/linux/clockchips.h
@@ -127,6 +127,8 @@ extern int clockevents_register_notifier(struct notifier_block *nb);
127extern int clockevents_program_event(struct clock_event_device *dev, 127extern int clockevents_program_event(struct clock_event_device *dev,
128 ktime_t expires, ktime_t now); 128 ktime_t expires, ktime_t now);
129 129
130extern void clockevents_handle_noop(struct clock_event_device *dev);
131
130#ifdef CONFIG_GENERIC_CLOCKEVENTS 132#ifdef CONFIG_GENERIC_CLOCKEVENTS
131extern void clockevents_notify(unsigned long reason, void *arg); 133extern void clockevents_notify(unsigned long reason, void *arg);
132#else 134#else
diff --git a/include/linux/clocksource.h b/include/linux/clocksource.h
index 55e434feec99..f88d32f8ff7c 100644
--- a/include/linux/clocksource.h
+++ b/include/linux/clocksource.h
@@ -45,7 +45,8 @@ struct clocksource;
45 * @read: returns a cycle value 45 * @read: returns a cycle value
46 * @mask: bitmask for two's complement 46 * @mask: bitmask for two's complement
47 * subtraction of non 64 bit counters 47 * subtraction of non 64 bit counters
48 * @mult: cycle to nanosecond multiplier 48 * @mult: cycle to nanosecond multiplier (adjusted by NTP)
49 * @mult_orig: cycle to nanosecond multiplier (unadjusted by NTP)
49 * @shift: cycle to nanosecond divisor (power of two) 50 * @shift: cycle to nanosecond divisor (power of two)
50 * @flags: flags describing special properties 51 * @flags: flags describing special properties
51 * @vread: vsyscall based read 52 * @vread: vsyscall based read
@@ -63,6 +64,7 @@ struct clocksource {
63 cycle_t (*read)(void); 64 cycle_t (*read)(void);
64 cycle_t mask; 65 cycle_t mask;
65 u32 mult; 66 u32 mult;
67 u32 mult_orig;
66 u32 shift; 68 u32 shift;
67 unsigned long flags; 69 unsigned long flags;
68 cycle_t (*vread)(void); 70 cycle_t (*vread)(void);
@@ -77,6 +79,7 @@ struct clocksource {
77 /* timekeeping specific data, ignore */ 79 /* timekeeping specific data, ignore */
78 cycle_t cycle_interval; 80 cycle_t cycle_interval;
79 u64 xtime_interval; 81 u64 xtime_interval;
82 u32 raw_interval;
80 /* 83 /*
81 * Second part is written at each timer interrupt 84 * Second part is written at each timer interrupt
82 * Keep it in a different cache line to dirty no 85 * Keep it in a different cache line to dirty no
@@ -85,6 +88,7 @@ struct clocksource {
85 cycle_t cycle_last ____cacheline_aligned_in_smp; 88 cycle_t cycle_last ____cacheline_aligned_in_smp;
86 u64 xtime_nsec; 89 u64 xtime_nsec;
87 s64 error; 90 s64 error;
91 struct timespec raw_time;
88 92
89#ifdef CONFIG_CLOCKSOURCE_WATCHDOG 93#ifdef CONFIG_CLOCKSOURCE_WATCHDOG
90 /* Watchdog related data, used by the framework */ 94 /* Watchdog related data, used by the framework */
@@ -201,17 +205,19 @@ static inline void clocksource_calculate_interval(struct clocksource *c,
201{ 205{
202 u64 tmp; 206 u64 tmp;
203 207
204 /* XXX - All of this could use a whole lot of optimization */ 208 /* Do the ns -> cycle conversion first, using original mult */
205 tmp = length_nsec; 209 tmp = length_nsec;
206 tmp <<= c->shift; 210 tmp <<= c->shift;
207 tmp += c->mult/2; 211 tmp += c->mult_orig/2;
208 do_div(tmp, c->mult); 212 do_div(tmp, c->mult_orig);
209 213
210 c->cycle_interval = (cycle_t)tmp; 214 c->cycle_interval = (cycle_t)tmp;
211 if (c->cycle_interval == 0) 215 if (c->cycle_interval == 0)
212 c->cycle_interval = 1; 216 c->cycle_interval = 1;
213 217
218 /* Go back from cycles -> shifted ns, this time use ntp adjused mult */
214 c->xtime_interval = (u64)c->cycle_interval * c->mult; 219 c->xtime_interval = (u64)c->cycle_interval * c->mult;
220 c->raw_interval = ((u64)c->cycle_interval * c->mult_orig) >> c->shift;
215} 221}
216 222
217 223
diff --git a/include/linux/cnt32_to_63.h b/include/linux/cnt32_to_63.h
new file mode 100644
index 000000000000..8c0f9505b48c
--- /dev/null
+++ b/include/linux/cnt32_to_63.h
@@ -0,0 +1,80 @@
1/*
2 * Extend a 32-bit counter to 63 bits
3 *
4 * Author: Nicolas Pitre
5 * Created: December 3, 2006
6 * Copyright: MontaVista Software, Inc.
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
10 * as published by the Free Software Foundation.
11 */
12
13#ifndef __LINUX_CNT32_TO_63_H__
14#define __LINUX_CNT32_TO_63_H__
15
16#include <linux/compiler.h>
17#include <linux/types.h>
18#include <asm/byteorder.h>
19
20/* this is used only to give gcc a clue about good code generation */
21union cnt32_to_63 {
22 struct {
23#if defined(__LITTLE_ENDIAN)
24 u32 lo, hi;
25#elif defined(__BIG_ENDIAN)
26 u32 hi, lo;
27#endif
28 };
29 u64 val;
30};
31
32
33/**
34 * cnt32_to_63 - Expand a 32-bit counter to a 63-bit counter
35 * @cnt_lo: The low part of the counter
36 *
37 * Many hardware clock counters are only 32 bits wide and therefore have
38 * a relatively short period making wrap-arounds rather frequent. This
39 * is a problem when implementing sched_clock() for example, where a 64-bit
40 * non-wrapping monotonic value is expected to be returned.
41 *
42 * To overcome that limitation, let's extend a 32-bit counter to 63 bits
43 * in a completely lock free fashion. Bits 0 to 31 of the clock are provided
44 * by the hardware while bits 32 to 62 are stored in memory. The top bit in
45 * memory is used to synchronize with the hardware clock half-period. When
46 * the top bit of both counters (hardware and in memory) differ then the
47 * memory is updated with a new value, incrementing it when the hardware
48 * counter wraps around.
49 *
50 * Because a word store in memory is atomic then the incremented value will
51 * always be in synch with the top bit indicating to any potential concurrent
52 * reader if the value in memory is up to date or not with regards to the
53 * needed increment. And any race in updating the value in memory is harmless
54 * as the same value would simply be stored more than once.
55 *
56 * The only restriction for the algorithm to work properly is that this
57 * code must be executed at least once per each half period of the 32-bit
58 * counter to properly update the state bit in memory. This is usually not a
59 * problem in practice, but if it is then a kernel timer could be scheduled
60 * to manage for this code to be executed often enough.
61 *
62 * Note that the top bit (bit 63) in the returned value should be considered
63 * as garbage. It is not cleared here because callers are likely to use a
64 * multiplier on the returned value which can get rid of the top bit
65 * implicitly by making the multiplier even, therefore saving on a runtime
66 * clear-bit instruction. Otherwise caller must remember to clear the top
67 * bit explicitly.
68 */
69#define cnt32_to_63(cnt_lo) \
70({ \
71 static volatile u32 __m_cnt_hi; \
72 union cnt32_to_63 __x; \
73 __x.hi = __m_cnt_hi; \
74 __x.lo = (cnt_lo); \
75 if (unlikely((s32)(__x.hi ^ __x.lo) < 0)) \
76 __m_cnt_hi = __x.hi = (__x.hi ^ 0x80000000) + (__x.hi >> 31); \
77 __x.val; \
78})
79
80#endif
diff --git a/include/linux/coda.h b/include/linux/coda.h
index b5cf0780c51a..96c87693800b 100644
--- a/include/linux/coda.h
+++ b/include/linux/coda.h
@@ -199,28 +199,6 @@ typedef u_int32_t vuid_t;
199typedef u_int32_t vgid_t; 199typedef u_int32_t vgid_t;
200#endif /*_VUID_T_ */ 200#endif /*_VUID_T_ */
201 201
202#ifdef CONFIG_CODA_FS_OLD_API
203struct CodaFid {
204 u_int32_t opaque[3];
205};
206
207static __inline__ ino_t coda_f2i(struct CodaFid *fid)
208{
209 if ( ! fid )
210 return 0;
211 if (fid->opaque[1] == 0xfffffffe || fid->opaque[1] == 0xffffffff)
212 return ((fid->opaque[0] << 20) | (fid->opaque[2] & 0xfffff));
213 else
214 return (fid->opaque[2] + (fid->opaque[1]<<10) + (fid->opaque[0]<<20));
215}
216
217struct coda_cred {
218 vuid_t cr_uid, cr_euid, cr_suid, cr_fsuid; /* Real, efftve, set, fs uid*/
219 vgid_t cr_groupid, cr_egid, cr_sgid, cr_fsgid; /* same for groups */
220};
221
222#else /* not defined(CONFIG_CODA_FS_OLD_API) */
223
224struct CodaFid { 202struct CodaFid {
225 u_int32_t opaque[4]; 203 u_int32_t opaque[4];
226}; 204};
@@ -228,8 +206,6 @@ struct CodaFid {
228#define coda_f2i(fid)\ 206#define coda_f2i(fid)\
229 (fid ? (fid->opaque[3] ^ (fid->opaque[2]<<10) ^ (fid->opaque[1]<<20) ^ fid->opaque[0]) : 0) 207 (fid ? (fid->opaque[3] ^ (fid->opaque[2]<<10) ^ (fid->opaque[1]<<20) ^ fid->opaque[0]) : 0)
230 208
231#endif
232
233#ifndef _VENUS_VATTR_T_ 209#ifndef _VENUS_VATTR_T_
234#define _VENUS_VATTR_T_ 210#define _VENUS_VATTR_T_
235/* 211/*
@@ -313,15 +289,7 @@ struct coda_statfs {
313 289
314#define CIOC_KERNEL_VERSION _IOWR('c', 10, size_t) 290#define CIOC_KERNEL_VERSION _IOWR('c', 10, size_t)
315 291
316#if 0
317#define CODA_KERNEL_VERSION 0 /* don't care about kernel version number */
318#define CODA_KERNEL_VERSION 1 /* The old venus 4.6 compatible interface */
319#endif
320#ifdef CONFIG_CODA_FS_OLD_API
321#define CODA_KERNEL_VERSION 2 /* venus_lookup got an extra parameter */
322#else
323#define CODA_KERNEL_VERSION 3 /* 128-bit file identifiers */ 292#define CODA_KERNEL_VERSION 3 /* 128-bit file identifiers */
324#endif
325 293
326/* 294/*
327 * Venus <-> Coda RPC arguments 295 * Venus <-> Coda RPC arguments
@@ -329,16 +297,9 @@ struct coda_statfs {
329struct coda_in_hdr { 297struct coda_in_hdr {
330 u_int32_t opcode; 298 u_int32_t opcode;
331 u_int32_t unique; /* Keep multiple outstanding msgs distinct */ 299 u_int32_t unique; /* Keep multiple outstanding msgs distinct */
332#ifdef CONFIG_CODA_FS_OLD_API
333 u_int16_t pid; /* Common to all */
334 u_int16_t pgid; /* Common to all */
335 u_int16_t sid; /* Common to all */
336 struct coda_cred cred; /* Common to all */
337#else
338 pid_t pid; 300 pid_t pid;
339 pid_t pgid; 301 pid_t pgid;
340 vuid_t uid; 302 vuid_t uid;
341#endif
342}; 303};
343 304
344/* Really important that opcode and unique are 1st two fields! */ 305/* Really important that opcode and unique are 1st two fields! */
@@ -613,11 +574,7 @@ struct coda_vget_out {
613/* CODA_PURGEUSER is a venus->kernel call */ 574/* CODA_PURGEUSER is a venus->kernel call */
614struct coda_purgeuser_out { 575struct coda_purgeuser_out {
615 struct coda_out_hdr oh; 576 struct coda_out_hdr oh;
616#ifdef CONFIG_CODA_FS_OLD_API
617 struct coda_cred cred;
618#else
619 vuid_t uid; 577 vuid_t uid;
620#endif
621}; 578};
622 579
623/* coda_zapfile: */ 580/* coda_zapfile: */
diff --git a/include/linux/coda_linux.h b/include/linux/coda_linux.h
index 31b75311e2ca..dcc228aa335a 100644
--- a/include/linux/coda_linux.h
+++ b/include/linux/coda_linux.h
@@ -37,7 +37,7 @@ extern const struct file_operations coda_ioctl_operations;
37/* operations shared over more than one file */ 37/* operations shared over more than one file */
38int coda_open(struct inode *i, struct file *f); 38int coda_open(struct inode *i, struct file *f);
39int coda_release(struct inode *i, struct file *f); 39int coda_release(struct inode *i, struct file *f);
40int coda_permission(struct inode *inode, int mask, struct nameidata *nd); 40int coda_permission(struct inode *inode, int mask);
41int coda_revalidate_inode(struct dentry *); 41int coda_revalidate_inode(struct dentry *);
42int coda_getattr(struct vfsmount *, struct dentry *, struct kstat *); 42int coda_getattr(struct vfsmount *, struct dentry *, struct kstat *);
43int coda_setattr(struct dentry *, struct iattr *); 43int coda_setattr(struct dentry *, struct iattr *);
diff --git a/include/linux/compat.h b/include/linux/compat.h
index cf8d11cad5ae..f061a1ea1b74 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -78,7 +78,6 @@ typedef struct {
78 compat_sigset_word sig[_COMPAT_NSIG_WORDS]; 78 compat_sigset_word sig[_COMPAT_NSIG_WORDS];
79} compat_sigset_t; 79} compat_sigset_t;
80 80
81extern int cp_compat_stat(struct kstat *, struct compat_stat __user *);
82extern int get_compat_timespec(struct timespec *, const struct compat_timespec __user *); 81extern int get_compat_timespec(struct timespec *, const struct compat_timespec __user *);
83extern int put_compat_timespec(const struct timespec *, struct compat_timespec __user *); 82extern int put_compat_timespec(const struct timespec *, struct compat_timespec __user *);
84 83
@@ -235,6 +234,11 @@ extern int get_compat_itimerspec(struct itimerspec *dst,
235extern int put_compat_itimerspec(struct compat_itimerspec __user *dst, 234extern int put_compat_itimerspec(struct compat_itimerspec __user *dst,
236 const struct itimerspec *src); 235 const struct itimerspec *src);
237 236
237asmlinkage long compat_sys_gettimeofday(struct compat_timeval __user *tv,
238 struct timezone __user *tz);
239asmlinkage long compat_sys_settimeofday(struct compat_timeval __user *tv,
240 struct timezone __user *tz);
241
238asmlinkage long compat_sys_adjtimex(struct compat_timex __user *utp); 242asmlinkage long compat_sys_adjtimex(struct compat_timex __user *utp);
239 243
240extern int compat_printk(const char *fmt, ...); 244extern int compat_printk(const char *fmt, ...);
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index c8bd2daf95ec..98115d9d04da 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -44,6 +44,8 @@ extern void __chk_io_ptr(const volatile void __iomem *);
44# error Sorry, your compiler is too old/not recognized. 44# error Sorry, your compiler is too old/not recognized.
45#endif 45#endif
46 46
47#define notrace __attribute__((no_instrument_function))
48
47/* Intel compiler defines __GNUC__. So we will overwrite implementations 49/* Intel compiler defines __GNUC__. So we will overwrite implementations
48 * coming from above header files here 50 * coming from above header files here
49 */ 51 */
@@ -190,7 +192,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
190 * ACCESS_ONCE() in different C statements. 192 * ACCESS_ONCE() in different C statements.
191 * 193 *
192 * This macro does absolutely -nothing- to prevent the CPU from reordering, 194 * This macro does absolutely -nothing- to prevent the CPU from reordering,
193 * merging, or refetching absolutely anything at any time. 195 * merging, or refetching absolutely anything at any time. Its main intended
196 * use is to mediate communication between process-level code and irq/NMI
197 * handlers, all running on the same CPU.
194 */ 198 */
195#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x)) 199#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
196 200
diff --git a/include/linux/completion.h b/include/linux/completion.h
index d2961b66d53d..4a6b604ef7e4 100644
--- a/include/linux/completion.h
+++ b/include/linux/completion.h
@@ -10,6 +10,18 @@
10 10
11#include <linux/wait.h> 11#include <linux/wait.h>
12 12
13/**
14 * struct completion - structure used to maintain state for a "completion"
15 *
16 * This is the opaque structure used to maintain the state for a "completion".
17 * Completions currently use a FIFO to queue threads that have to wait for
18 * the "completion" event.
19 *
20 * See also: complete(), wait_for_completion() (and friends _timeout,
21 * _interruptible, _interruptible_timeout, and _killable), init_completion(),
22 * and macros DECLARE_COMPLETION(), DECLARE_COMPLETION_ONSTACK(), and
23 * INIT_COMPLETION().
24 */
13struct completion { 25struct completion {
14 unsigned int done; 26 unsigned int done;
15 wait_queue_head_t wait; 27 wait_queue_head_t wait;
@@ -21,6 +33,14 @@ struct completion {
21#define COMPLETION_INITIALIZER_ONSTACK(work) \ 33#define COMPLETION_INITIALIZER_ONSTACK(work) \
22 ({ init_completion(&work); work; }) 34 ({ init_completion(&work); work; })
23 35
36/**
37 * DECLARE_COMPLETION: - declare and initialize a completion structure
38 * @work: identifier for the completion structure
39 *
40 * This macro declares and initializes a completion structure. Generally used
41 * for static declarations. You should use the _ONSTACK variant for automatic
42 * variables.
43 */
24#define DECLARE_COMPLETION(work) \ 44#define DECLARE_COMPLETION(work) \
25 struct completion work = COMPLETION_INITIALIZER(work) 45 struct completion work = COMPLETION_INITIALIZER(work)
26 46
@@ -29,6 +49,13 @@ struct completion {
29 * completions - so we use the _ONSTACK() variant for those that 49 * completions - so we use the _ONSTACK() variant for those that
30 * are on the kernel stack: 50 * are on the kernel stack:
31 */ 51 */
52/**
53 * DECLARE_COMPLETION_ONSTACK: - declare and initialize a completion structure
54 * @work: identifier for the completion structure
55 *
56 * This macro declares and initializes a completion structure on the kernel
57 * stack.
58 */
32#ifdef CONFIG_LOCKDEP 59#ifdef CONFIG_LOCKDEP
33# define DECLARE_COMPLETION_ONSTACK(work) \ 60# define DECLARE_COMPLETION_ONSTACK(work) \
34 struct completion work = COMPLETION_INITIALIZER_ONSTACK(work) 61 struct completion work = COMPLETION_INITIALIZER_ONSTACK(work)
@@ -36,6 +63,13 @@ struct completion {
36# define DECLARE_COMPLETION_ONSTACK(work) DECLARE_COMPLETION(work) 63# define DECLARE_COMPLETION_ONSTACK(work) DECLARE_COMPLETION(work)
37#endif 64#endif
38 65
66/**
67 * init_completion: - Initialize a dynamically allocated completion
68 * @x: completion structure that is to be initialized
69 *
70 * This inline function will initialize a dynamically created completion
71 * structure.
72 */
39static inline void init_completion(struct completion *x) 73static inline void init_completion(struct completion *x)
40{ 74{
41 x->done = 0; 75 x->done = 0;
@@ -49,10 +83,20 @@ extern unsigned long wait_for_completion_timeout(struct completion *x,
49 unsigned long timeout); 83 unsigned long timeout);
50extern unsigned long wait_for_completion_interruptible_timeout( 84extern unsigned long wait_for_completion_interruptible_timeout(
51 struct completion *x, unsigned long timeout); 85 struct completion *x, unsigned long timeout);
86extern bool try_wait_for_completion(struct completion *x);
87extern bool completion_done(struct completion *x);
52 88
53extern void complete(struct completion *); 89extern void complete(struct completion *);
54extern void complete_all(struct completion *); 90extern void complete_all(struct completion *);
55 91
92/**
93 * INIT_COMPLETION: - reinitialize a completion structure
94 * @x: completion structure to be reinitialized
95 *
96 * This macro should be used to reinitialize a completion structure so it can
97 * be reused. This is especially important after complete_all() is used.
98 */
56#define INIT_COMPLETION(x) ((x).done = 0) 99#define INIT_COMPLETION(x) ((x).done = 0)
57 100
101
58#endif 102#endif
diff --git a/include/linux/configfs.h b/include/linux/configfs.h
index 0488f937634a..7f627775c947 100644
--- a/include/linux/configfs.h
+++ b/include/linux/configfs.h
@@ -40,6 +40,7 @@
40#include <linux/list.h> 40#include <linux/list.h>
41#include <linux/kref.h> 41#include <linux/kref.h>
42#include <linux/mutex.h> 42#include <linux/mutex.h>
43#include <linux/err.h>
43 44
44#include <asm/atomic.h> 45#include <asm/atomic.h>
45 46
@@ -129,8 +130,25 @@ struct configfs_attribute {
129/* 130/*
130 * Users often need to create attribute structures for their configurable 131 * Users often need to create attribute structures for their configurable
131 * attributes, containing a configfs_attribute member and function pointers 132 * attributes, containing a configfs_attribute member and function pointers
132 * for the show() and store() operations on that attribute. They can use 133 * for the show() and store() operations on that attribute. If they don't
133 * this macro (similar to sysfs' __ATTR) to make defining attributes easier. 134 * need anything else on the extended attribute structure, they can use
135 * this macro to define it The argument _item is the name of the
136 * config_item structure.
137 */
138#define CONFIGFS_ATTR_STRUCT(_item) \
139struct _item##_attribute { \
140 struct configfs_attribute attr; \
141 ssize_t (*show)(struct _item *, char *); \
142 ssize_t (*store)(struct _item *, const char *, size_t); \
143}
144
145/*
146 * With the extended attribute structure, users can use this macro
147 * (similar to sysfs' __ATTR) to make defining attributes easier.
148 * An example:
149 * #define MYITEM_ATTR(_name, _mode, _show, _store) \
150 * struct myitem_attribute childless_attr_##_name = \
151 * __CONFIGFS_ATTR(_name, _mode, _show, _store)
134 */ 152 */
135#define __CONFIGFS_ATTR(_name, _mode, _show, _store) \ 153#define __CONFIGFS_ATTR(_name, _mode, _show, _store) \
136{ \ 154{ \
@@ -142,13 +160,60 @@ struct configfs_attribute {
142 .show = _show, \ 160 .show = _show, \
143 .store = _store, \ 161 .store = _store, \
144} 162}
163/* Here is a readonly version, only requiring a show() operation */
164#define __CONFIGFS_ATTR_RO(_name, _show) \
165{ \
166 .attr = { \
167 .ca_name = __stringify(_name), \
168 .ca_mode = 0444, \
169 .ca_owner = THIS_MODULE, \
170 }, \
171 .show = _show, \
172}
173
174/*
175 * With these extended attributes, the simple show_attribute() and
176 * store_attribute() operations need to call the show() and store() of the
177 * attributes. This is a common pattern, so we provide a macro to define
178 * them. The argument _item is the name of the config_item structure.
179 * This macro expects the attributes to be named "struct <name>_attribute"
180 * and the function to_<name>() to exist;
181 */
182#define CONFIGFS_ATTR_OPS(_item) \
183static ssize_t _item##_attr_show(struct config_item *item, \
184 struct configfs_attribute *attr, \
185 char *page) \
186{ \
187 struct _item *_item = to_##_item(item); \
188 struct _item##_attribute *_item##_attr = \
189 container_of(attr, struct _item##_attribute, attr); \
190 ssize_t ret = 0; \
191 \
192 if (_item##_attr->show) \
193 ret = _item##_attr->show(_item, page); \
194 return ret; \
195} \
196static ssize_t _item##_attr_store(struct config_item *item, \
197 struct configfs_attribute *attr, \
198 const char *page, size_t count) \
199{ \
200 struct _item *_item = to_##_item(item); \
201 struct _item##_attribute *_item##_attr = \
202 container_of(attr, struct _item##_attribute, attr); \
203 ssize_t ret = -EINVAL; \
204 \
205 if (_item##_attr->store) \
206 ret = _item##_attr->store(_item, page, count); \
207 return ret; \
208}
145 209
146/* 210/*
147 * If allow_link() exists, the item can symlink(2) out to other 211 * If allow_link() exists, the item can symlink(2) out to other
148 * items. If the item is a group, it may support mkdir(2). 212 * items. If the item is a group, it may support mkdir(2).
149 * Groups supply one of make_group() and make_item(). If the 213 * Groups supply one of make_group() and make_item(). If the
150 * group supports make_group(), one can create group children. If it 214 * group supports make_group(), one can create group children. If it
151 * supports make_item(), one can create config_item children. If it has 215 * supports make_item(), one can create config_item children. make_group()
216 * and make_item() return ERR_PTR() on errors. If it has
152 * default_groups on group->default_groups, it has automatically created 217 * default_groups on group->default_groups, it has automatically created
153 * group children. default_groups may coexist alongsize make_group() or 218 * group children. default_groups may coexist alongsize make_group() or
154 * make_item(), but if the group wishes to have only default_groups 219 * make_item(), but if the group wishes to have only default_groups
@@ -165,8 +230,8 @@ struct configfs_item_operations {
165}; 230};
166 231
167struct configfs_group_operations { 232struct configfs_group_operations {
168 int (*make_item)(struct config_group *group, const char *name, struct config_item **new_item); 233 struct config_item *(*make_item)(struct config_group *group, const char *name);
169 int (*make_group)(struct config_group *group, const char *name, struct config_group **new_group); 234 struct config_group *(*make_group)(struct config_group *group, const char *name);
170 int (*commit_item)(struct config_item *item); 235 int (*commit_item)(struct config_item *item);
171 void (*disconnect_notify)(struct config_group *group, struct config_item *item); 236 void (*disconnect_notify)(struct config_group *group, struct config_item *item);
172 void (*drop_item)(struct config_group *group, struct config_item *item); 237 void (*drop_item)(struct config_group *group, struct config_item *item);
diff --git a/include/linux/connector.h b/include/linux/connector.h
index 96a89d3d6727..5c7f9468f753 100644
--- a/include/linux/connector.h
+++ b/include/linux/connector.h
@@ -38,8 +38,9 @@
38#define CN_W1_VAL 0x1 38#define CN_W1_VAL 0x1
39#define CN_IDX_V86D 0x4 39#define CN_IDX_V86D 0x4
40#define CN_VAL_V86D_UVESAFB 0x1 40#define CN_VAL_V86D_UVESAFB 0x1
41#define CN_IDX_BB 0x5 /* BlackBoard, from the TSP GPL sampling framework */
41 42
42#define CN_NETLINK_USERS 5 43#define CN_NETLINK_USERS 6
43 44
44/* 45/*
45 * Maximum connector's message size. 46 * Maximum connector's message size.
diff --git a/include/linux/console_struct.h b/include/linux/console_struct.h
index b03f80a078be..d71f7c0f931b 100644
--- a/include/linux/console_struct.h
+++ b/include/linux/console_struct.h
@@ -53,7 +53,6 @@ struct vc_data {
53 unsigned short vc_hi_font_mask; /* [#] Attribute set for upper 256 chars of font or 0 if not supported */ 53 unsigned short vc_hi_font_mask; /* [#] Attribute set for upper 256 chars of font or 0 if not supported */
54 struct console_font vc_font; /* Current VC font set */ 54 struct console_font vc_font; /* Current VC font set */
55 unsigned short vc_video_erase_char; /* Background erase character */ 55 unsigned short vc_video_erase_char; /* Background erase character */
56 unsigned short vc_scrl_erase_char; /* Erase character for scroll */
57 /* VT terminal data */ 56 /* VT terminal data */
58 unsigned int vc_state; /* Escape sequence parser state */ 57 unsigned int vc_state; /* Escape sequence parser state */
59 unsigned int vc_npar,vc_par[NPAR]; /* Parameters of current escape sequence */ 58 unsigned int vc_npar,vc_par[NPAR]; /* Parameters of current escape sequence */
diff --git a/include/linux/consolemap.h b/include/linux/consolemap.h
index e2bf7e5db39a..c4811da1338b 100644
--- a/include/linux/consolemap.h
+++ b/include/linux/consolemap.h
@@ -3,6 +3,9 @@
3 * 3 *
4 * Interface between console.c, selection.c and consolemap.c 4 * Interface between console.c, selection.c and consolemap.c
5 */ 5 */
6#ifndef __LINUX_CONSOLEMAP_H__
7#define __LINUX_CONSOLEMAP_H__
8
6#define LAT1_MAP 0 9#define LAT1_MAP 0
7#define GRAF_MAP 1 10#define GRAF_MAP 1
8#define IBMPC_MAP 2 11#define IBMPC_MAP 2
@@ -10,6 +13,7 @@
10 13
11#include <linux/types.h> 14#include <linux/types.h>
12 15
16#ifdef CONFIG_CONSOLE_TRANSLATIONS
13struct vc_data; 17struct vc_data;
14 18
15extern u16 inverse_translate(struct vc_data *conp, int glyph, int use_unicode); 19extern u16 inverse_translate(struct vc_data *conp, int glyph, int use_unicode);
@@ -18,3 +22,13 @@ extern int conv_uni_to_pc(struct vc_data *conp, long ucs);
18extern u32 conv_8bit_to_uni(unsigned char c); 22extern u32 conv_8bit_to_uni(unsigned char c);
19extern int conv_uni_to_8bit(u32 uni); 23extern int conv_uni_to_8bit(u32 uni);
20void console_map_init(void); 24void console_map_init(void);
25#else
26#define inverse_translate(conp, glyph, uni) ((uint16_t)glyph)
27#define set_translate(m, vc) ((unsigned short *)NULL)
28#define conv_uni_to_pc(conp, ucs) ((int) (ucs > 0xff ? -1: ucs))
29#define conv_8bit_to_uni(c) ((uint32_t)(c))
30#define conv_uni_to_8bit(c) ((int) ((c) & 0xff))
31#define console_map_init(c) do { ; } while (0)
32#endif /* CONFIG_CONSOLE_TRANSLATIONS */
33
34#endif /* __LINUX_CONSOLEMAP_H__ */
diff --git a/include/linux/cpu.h b/include/linux/cpu.h
index 7464ba3b4333..c2747ac2ae43 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -69,10 +69,12 @@ static inline void unregister_cpu_notifier(struct notifier_block *nb)
69#endif 69#endif
70 70
71int cpu_up(unsigned int cpu); 71int cpu_up(unsigned int cpu);
72 72void notify_cpu_starting(unsigned int cpu);
73extern void cpu_hotplug_init(void); 73extern void cpu_hotplug_init(void);
74extern void cpu_maps_update_begin(void);
75extern void cpu_maps_update_done(void);
74 76
75#else 77#else /* CONFIG_SMP */
76 78
77static inline int register_cpu_notifier(struct notifier_block *nb) 79static inline int register_cpu_notifier(struct notifier_block *nb)
78{ 80{
@@ -87,10 +89,16 @@ static inline void cpu_hotplug_init(void)
87{ 89{
88} 90}
89 91
92static inline void cpu_maps_update_begin(void)
93{
94}
95
96static inline void cpu_maps_update_done(void)
97{
98}
99
90#endif /* CONFIG_SMP */ 100#endif /* CONFIG_SMP */
91extern struct sysdev_class cpu_sysdev_class; 101extern struct sysdev_class cpu_sysdev_class;
92extern void cpu_maps_update_begin(void);
93extern void cpu_maps_update_done(void);
94 102
95#ifdef CONFIG_HOTPLUG_CPU 103#ifdef CONFIG_HOTPLUG_CPU
96/* Stop CPUs going up and down. */ 104/* Stop CPUs going up and down. */
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index e7e91dbfde0f..1ee608fd7b77 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -4,9 +4,6 @@
4 * Copyright (C) 2001 Russell King 4 * Copyright (C) 2001 Russell King
5 * (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de> 5 * (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de>
6 * 6 *
7 *
8 * $Id: cpufreq.h,v 1.36 2003/01/20 17:31:48 db Exp $
9 *
10 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as 8 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation. 9 * published by the Free Software Foundation.
@@ -109,6 +106,7 @@ struct cpufreq_policy {
109#define CPUFREQ_ADJUST (0) 106#define CPUFREQ_ADJUST (0)
110#define CPUFREQ_INCOMPATIBLE (1) 107#define CPUFREQ_INCOMPATIBLE (1)
111#define CPUFREQ_NOTIFY (2) 108#define CPUFREQ_NOTIFY (2)
109#define CPUFREQ_START (3)
112 110
113#define CPUFREQ_SHARED_TYPE_NONE (0) /* None */ 111#define CPUFREQ_SHARED_TYPE_NONE (0) /* None */
114#define CPUFREQ_SHARED_TYPE_HW (1) /* HW does needed coordination */ 112#define CPUFREQ_SHARED_TYPE_HW (1) /* HW does needed coordination */
@@ -189,7 +187,8 @@ extern int __cpufreq_driver_target(struct cpufreq_policy *policy,
189 unsigned int relation); 187 unsigned int relation);
190 188
191 189
192extern int __cpufreq_driver_getavg(struct cpufreq_policy *policy); 190extern int __cpufreq_driver_getavg(struct cpufreq_policy *policy,
191 unsigned int cpu);
193 192
194int cpufreq_register_governor(struct cpufreq_governor *governor); 193int cpufreq_register_governor(struct cpufreq_governor *governor);
195void cpufreq_unregister_governor(struct cpufreq_governor *governor); 194void cpufreq_unregister_governor(struct cpufreq_governor *governor);
@@ -228,7 +227,9 @@ struct cpufreq_driver {
228 unsigned int (*get) (unsigned int cpu); 227 unsigned int (*get) (unsigned int cpu);
229 228
230 /* optional */ 229 /* optional */
231 unsigned int (*getavg) (unsigned int cpu); 230 unsigned int (*getavg) (struct cpufreq_policy *policy,
231 unsigned int cpu);
232
232 int (*exit) (struct cpufreq_policy *policy); 233 int (*exit) (struct cpufreq_policy *policy);
233 int (*suspend) (struct cpufreq_policy *policy, pm_message_t pmsg); 234 int (*suspend) (struct cpufreq_policy *policy, pm_message_t pmsg);
234 int (*resume) (struct cpufreq_policy *policy); 235 int (*resume) (struct cpufreq_policy *policy);
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index c24875bd9c5b..d3219d73f8e6 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -17,6 +17,20 @@
17 * For details of cpus_onto(), see bitmap_onto in lib/bitmap.c. 17 * For details of cpus_onto(), see bitmap_onto in lib/bitmap.c.
18 * For details of cpus_fold(), see bitmap_fold in lib/bitmap.c. 18 * For details of cpus_fold(), see bitmap_fold in lib/bitmap.c.
19 * 19 *
20 * . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21 * Note: The alternate operations with the suffix "_nr" are used
22 * to limit the range of the loop to nr_cpu_ids instead of
23 * NR_CPUS when NR_CPUS > 64 for performance reasons.
24 * If NR_CPUS is <= 64 then most assembler bitmask
25 * operators execute faster with a constant range, so
26 * the operator will continue to use NR_CPUS.
27 *
28 * Another consideration is that nr_cpu_ids is initialized
29 * to NR_CPUS and isn't lowered until the possible cpus are
30 * discovered (including any disabled cpus). So early uses
31 * will span the entire range of NR_CPUS.
32 * . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
33 *
20 * The available cpumask operations are: 34 * The available cpumask operations are:
21 * 35 *
22 * void cpu_set(cpu, mask) turn on bit 'cpu' in mask 36 * void cpu_set(cpu, mask) turn on bit 'cpu' in mask
@@ -38,18 +52,52 @@
38 * int cpus_empty(mask) Is mask empty (no bits sets)? 52 * int cpus_empty(mask) Is mask empty (no bits sets)?
39 * int cpus_full(mask) Is mask full (all bits sets)? 53 * int cpus_full(mask) Is mask full (all bits sets)?
40 * int cpus_weight(mask) Hamming weigh - number of set bits 54 * int cpus_weight(mask) Hamming weigh - number of set bits
55 * int cpus_weight_nr(mask) Same using nr_cpu_ids instead of NR_CPUS
41 * 56 *
42 * void cpus_shift_right(dst, src, n) Shift right 57 * void cpus_shift_right(dst, src, n) Shift right
43 * void cpus_shift_left(dst, src, n) Shift left 58 * void cpus_shift_left(dst, src, n) Shift left
44 * 59 *
45 * int first_cpu(mask) Number lowest set bit, or NR_CPUS 60 * int first_cpu(mask) Number lowest set bit, or NR_CPUS
46 * int next_cpu(cpu, mask) Next cpu past 'cpu', or NR_CPUS 61 * int next_cpu(cpu, mask) Next cpu past 'cpu', or NR_CPUS
62 * int next_cpu_nr(cpu, mask) Next cpu past 'cpu', or nr_cpu_ids
47 * 63 *
48 * cpumask_t cpumask_of_cpu(cpu) Return cpumask with bit 'cpu' set 64 * cpumask_t cpumask_of_cpu(cpu) Return cpumask with bit 'cpu' set
65 * (can be used as an lvalue)
49 * CPU_MASK_ALL Initializer - all bits set 66 * CPU_MASK_ALL Initializer - all bits set
50 * CPU_MASK_NONE Initializer - no bits set 67 * CPU_MASK_NONE Initializer - no bits set
51 * unsigned long *cpus_addr(mask) Array of unsigned long's in mask 68 * unsigned long *cpus_addr(mask) Array of unsigned long's in mask
52 * 69 *
70 * CPUMASK_ALLOC kmalloc's a structure that is a composite of many cpumask_t
71 * variables, and CPUMASK_PTR provides pointers to each field.
72 *
73 * The structure should be defined something like this:
74 * struct my_cpumasks {
75 * cpumask_t mask1;
76 * cpumask_t mask2;
77 * };
78 *
79 * Usage is then:
80 * CPUMASK_ALLOC(my_cpumasks);
81 * CPUMASK_PTR(mask1, my_cpumasks);
82 * CPUMASK_PTR(mask2, my_cpumasks);
83 *
84 * --- DO NOT reference cpumask_t pointers until this check ---
85 * if (my_cpumasks == NULL)
86 * "kmalloc failed"...
87 *
88 * References are now pointers to the cpumask_t variables (*mask1, ...)
89 *
90 *if NR_CPUS > BITS_PER_LONG
91 * CPUMASK_ALLOC(m) Declares and allocates struct m *m =
92 * kmalloc(sizeof(*m), GFP_KERNEL)
93 * CPUMASK_FREE(m) Macro for kfree(m)
94 *else
95 * CPUMASK_ALLOC(m) Declares struct m _m, *m = &_m
96 * CPUMASK_FREE(m) Nop
97 *endif
98 * CPUMASK_PTR(v, m) Declares cpumask_t *v = &(m->v)
99 * ------------------------------------------------------------------------
100 *
53 * int cpumask_scnprintf(buf, len, mask) Format cpumask for printing 101 * int cpumask_scnprintf(buf, len, mask) Format cpumask for printing
54 * int cpumask_parse_user(ubuf, ulen, mask) Parse ascii string as cpumask 102 * int cpumask_parse_user(ubuf, ulen, mask) Parse ascii string as cpumask
55 * int cpulist_scnprintf(buf, len, mask) Format cpumask as list for printing 103 * int cpulist_scnprintf(buf, len, mask) Format cpumask as list for printing
@@ -59,7 +107,8 @@
59 * void cpus_onto(dst, orig, relmap) *dst = orig relative to relmap 107 * void cpus_onto(dst, orig, relmap) *dst = orig relative to relmap
60 * void cpus_fold(dst, orig, sz) dst bits = orig bits mod sz 108 * void cpus_fold(dst, orig, sz) dst bits = orig bits mod sz
61 * 109 *
62 * for_each_cpu_mask(cpu, mask) for-loop cpu over mask 110 * for_each_cpu_mask(cpu, mask) for-loop cpu over mask using NR_CPUS
111 * for_each_cpu_mask_nr(cpu, mask) for-loop cpu over mask using nr_cpu_ids
63 * 112 *
64 * int num_online_cpus() Number of online CPUs 113 * int num_online_cpus() Number of online CPUs
65 * int num_possible_cpus() Number of all possible CPUs 114 * int num_possible_cpus() Number of all possible CPUs
@@ -216,33 +265,30 @@ static inline void __cpus_shift_left(cpumask_t *dstp,
216 bitmap_shift_left(dstp->bits, srcp->bits, n, nbits); 265 bitmap_shift_left(dstp->bits, srcp->bits, n, nbits);
217} 266}
218 267
219#ifdef CONFIG_SMP 268/*
220int __first_cpu(const cpumask_t *srcp); 269 * Special-case data structure for "single bit set only" constant CPU masks.
221#define first_cpu(src) __first_cpu(&(src)) 270 *
222int __next_cpu(int n, const cpumask_t *srcp); 271 * We pre-generate all the 64 (or 32) possible bit positions, with enough
223#define next_cpu(n, src) __next_cpu((n), &(src)) 272 * padding to the left and the right, and return the constant pointer
224#else 273 * appropriately offset.
225#define first_cpu(src) ({ (void)(src); 0; }) 274 */
226#define next_cpu(n, src) ({ (void)(src); 1; }) 275extern const unsigned long
227#endif 276 cpu_bit_bitmap[BITS_PER_LONG+1][BITS_TO_LONGS(NR_CPUS)];
277
278static inline const cpumask_t *get_cpu_mask(unsigned int cpu)
279{
280 const unsigned long *p = cpu_bit_bitmap[1 + cpu % BITS_PER_LONG];
281 p -= cpu / BITS_PER_LONG;
282 return (const cpumask_t *)p;
283}
228 284
229#ifdef CONFIG_HAVE_CPUMASK_OF_CPU_MAP 285/*
230extern cpumask_t *cpumask_of_cpu_map; 286 * In cases where we take the address of the cpumask immediately,
231#define cpumask_of_cpu(cpu) (cpumask_of_cpu_map[cpu]) 287 * gcc optimizes it out (it's a constant) and there's no huge stack
288 * variable created:
289 */
290#define cpumask_of_cpu(cpu) (*get_cpu_mask(cpu))
232 291
233#else
234#define cpumask_of_cpu(cpu) \
235(*({ \
236 typeof(_unused_cpumask_arg_) m; \
237 if (sizeof(m) == sizeof(unsigned long)) { \
238 m.bits[0] = 1UL<<(cpu); \
239 } else { \
240 cpus_clear(m); \
241 cpu_set((cpu), m); \
242 } \
243 &m; \
244}))
245#endif
246 292
247#define CPU_MASK_LAST_WORD BITMAP_LAST_WORD_MASK(NR_CPUS) 293#define CPU_MASK_LAST_WORD BITMAP_LAST_WORD_MASK(NR_CPUS)
248 294
@@ -281,6 +327,15 @@ extern cpumask_t cpu_mask_all;
281 327
282#define cpus_addr(src) ((src).bits) 328#define cpus_addr(src) ((src).bits)
283 329
330#if NR_CPUS > BITS_PER_LONG
331#define CPUMASK_ALLOC(m) struct m *m = kmalloc(sizeof(*m), GFP_KERNEL)
332#define CPUMASK_FREE(m) kfree(m)
333#else
334#define CPUMASK_ALLOC(m) struct m _m, *m = &_m
335#define CPUMASK_FREE(m)
336#endif
337#define CPUMASK_PTR(v, m) cpumask_t *v = &(m->v)
338
284#define cpumask_scnprintf(buf, len, src) \ 339#define cpumask_scnprintf(buf, len, src) \
285 __cpumask_scnprintf((buf), (len), &(src), NR_CPUS) 340 __cpumask_scnprintf((buf), (len), &(src), NR_CPUS)
286static inline int __cpumask_scnprintf(char *buf, int len, 341static inline int __cpumask_scnprintf(char *buf, int len,
@@ -343,29 +398,59 @@ static inline void __cpus_fold(cpumask_t *dstp, const cpumask_t *origp,
343 bitmap_fold(dstp->bits, origp->bits, sz, nbits); 398 bitmap_fold(dstp->bits, origp->bits, sz, nbits);
344} 399}
345 400
346#if NR_CPUS > 1 401#if NR_CPUS == 1
347#define for_each_cpu_mask(cpu, mask) \ 402
348 for ((cpu) = first_cpu(mask); \ 403#define nr_cpu_ids 1
349 (cpu) < NR_CPUS; \ 404#define first_cpu(src) ({ (void)(src); 0; })
350 (cpu) = next_cpu((cpu), (mask))) 405#define next_cpu(n, src) ({ (void)(src); 1; })
351#else /* NR_CPUS == 1 */ 406#define any_online_cpu(mask) 0
352#define for_each_cpu_mask(cpu, mask) \ 407#define for_each_cpu_mask(cpu, mask) \
353 for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask) 408 for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask)
354#endif /* NR_CPUS */ 409
410#else /* NR_CPUS > 1 */
411
412extern int nr_cpu_ids;
413int __first_cpu(const cpumask_t *srcp);
414int __next_cpu(int n, const cpumask_t *srcp);
415int __any_online_cpu(const cpumask_t *mask);
416
417#define first_cpu(src) __first_cpu(&(src))
418#define next_cpu(n, src) __next_cpu((n), &(src))
419#define any_online_cpu(mask) __any_online_cpu(&(mask))
420#define for_each_cpu_mask(cpu, mask) \
421 for ((cpu) = -1; \
422 (cpu) = next_cpu((cpu), (mask)), \
423 (cpu) < NR_CPUS; )
424#endif
425
426#if NR_CPUS <= 64
355 427
356#define next_cpu_nr(n, src) next_cpu(n, src) 428#define next_cpu_nr(n, src) next_cpu(n, src)
357#define cpus_weight_nr(cpumask) cpus_weight(cpumask) 429#define cpus_weight_nr(cpumask) cpus_weight(cpumask)
358#define for_each_cpu_mask_nr(cpu, mask) for_each_cpu_mask(cpu, mask) 430#define for_each_cpu_mask_nr(cpu, mask) for_each_cpu_mask(cpu, mask)
359 431
432#else /* NR_CPUS > 64 */
433
434int __next_cpu_nr(int n, const cpumask_t *srcp);
435#define next_cpu_nr(n, src) __next_cpu_nr((n), &(src))
436#define cpus_weight_nr(cpumask) __cpus_weight(&(cpumask), nr_cpu_ids)
437#define for_each_cpu_mask_nr(cpu, mask) \
438 for ((cpu) = -1; \
439 (cpu) = next_cpu_nr((cpu), (mask)), \
440 (cpu) < nr_cpu_ids; )
441
442#endif /* NR_CPUS > 64 */
443
360/* 444/*
361 * The following particular system cpumasks and operations manage 445 * The following particular system cpumasks and operations manage
362 * possible, present and online cpus. Each of them is a fixed size 446 * possible, present, active and online cpus. Each of them is a fixed size
363 * bitmap of size NR_CPUS. 447 * bitmap of size NR_CPUS.
364 * 448 *
365 * #ifdef CONFIG_HOTPLUG_CPU 449 * #ifdef CONFIG_HOTPLUG_CPU
366 * cpu_possible_map - has bit 'cpu' set iff cpu is populatable 450 * cpu_possible_map - has bit 'cpu' set iff cpu is populatable
367 * cpu_present_map - has bit 'cpu' set iff cpu is populated 451 * cpu_present_map - has bit 'cpu' set iff cpu is populated
368 * cpu_online_map - has bit 'cpu' set iff cpu available to scheduler 452 * cpu_online_map - has bit 'cpu' set iff cpu available to scheduler
453 * cpu_active_map - has bit 'cpu' set iff cpu available to migration
369 * #else 454 * #else
370 * cpu_possible_map - has bit 'cpu' set iff cpu is populated 455 * cpu_possible_map - has bit 'cpu' set iff cpu is populated
371 * cpu_present_map - copy of cpu_possible_map 456 * cpu_present_map - copy of cpu_possible_map
@@ -416,14 +501,16 @@ static inline void __cpus_fold(cpumask_t *dstp, const cpumask_t *origp,
416extern cpumask_t cpu_possible_map; 501extern cpumask_t cpu_possible_map;
417extern cpumask_t cpu_online_map; 502extern cpumask_t cpu_online_map;
418extern cpumask_t cpu_present_map; 503extern cpumask_t cpu_present_map;
504extern cpumask_t cpu_active_map;
419 505
420#if NR_CPUS > 1 506#if NR_CPUS > 1
421#define num_online_cpus() cpus_weight(cpu_online_map) 507#define num_online_cpus() cpus_weight_nr(cpu_online_map)
422#define num_possible_cpus() cpus_weight(cpu_possible_map) 508#define num_possible_cpus() cpus_weight_nr(cpu_possible_map)
423#define num_present_cpus() cpus_weight(cpu_present_map) 509#define num_present_cpus() cpus_weight_nr(cpu_present_map)
424#define cpu_online(cpu) cpu_isset((cpu), cpu_online_map) 510#define cpu_online(cpu) cpu_isset((cpu), cpu_online_map)
425#define cpu_possible(cpu) cpu_isset((cpu), cpu_possible_map) 511#define cpu_possible(cpu) cpu_isset((cpu), cpu_possible_map)
426#define cpu_present(cpu) cpu_isset((cpu), cpu_present_map) 512#define cpu_present(cpu) cpu_isset((cpu), cpu_present_map)
513#define cpu_active(cpu) cpu_isset((cpu), cpu_active_map)
427#else 514#else
428#define num_online_cpus() 1 515#define num_online_cpus() 1
429#define num_possible_cpus() 1 516#define num_possible_cpus() 1
@@ -431,21 +518,13 @@ extern cpumask_t cpu_present_map;
431#define cpu_online(cpu) ((cpu) == 0) 518#define cpu_online(cpu) ((cpu) == 0)
432#define cpu_possible(cpu) ((cpu) == 0) 519#define cpu_possible(cpu) ((cpu) == 0)
433#define cpu_present(cpu) ((cpu) == 0) 520#define cpu_present(cpu) ((cpu) == 0)
521#define cpu_active(cpu) ((cpu) == 0)
434#endif 522#endif
435 523
436#define cpu_is_offline(cpu) unlikely(!cpu_online(cpu)) 524#define cpu_is_offline(cpu) unlikely(!cpu_online(cpu))
437 525
438#ifdef CONFIG_SMP 526#define for_each_possible_cpu(cpu) for_each_cpu_mask_nr((cpu), cpu_possible_map)
439extern int nr_cpu_ids; 527#define for_each_online_cpu(cpu) for_each_cpu_mask_nr((cpu), cpu_online_map)
440#define any_online_cpu(mask) __any_online_cpu(&(mask)) 528#define for_each_present_cpu(cpu) for_each_cpu_mask_nr((cpu), cpu_present_map)
441int __any_online_cpu(const cpumask_t *mask);
442#else
443#define nr_cpu_ids 1
444#define any_online_cpu(mask) 0
445#endif
446
447#define for_each_possible_cpu(cpu) for_each_cpu_mask((cpu), cpu_possible_map)
448#define for_each_online_cpu(cpu) for_each_cpu_mask((cpu), cpu_online_map)
449#define for_each_present_cpu(cpu) for_each_cpu_mask((cpu), cpu_present_map)
450 529
451#endif /* __LINUX_CPUMASK_H */ 530#endif /* __LINUX_CPUMASK_H */
diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h
index 038578362b47..2691926fb506 100644
--- a/include/linux/cpuset.h
+++ b/include/linux/cpuset.h
@@ -78,6 +78,8 @@ extern void cpuset_track_online_nodes(void);
78 78
79extern int current_cpuset_is_being_rebound(void); 79extern int current_cpuset_is_being_rebound(void);
80 80
81extern void rebuild_sched_domains(void);
82
81#else /* !CONFIG_CPUSETS */ 83#else /* !CONFIG_CPUSETS */
82 84
83static inline int cpuset_init_early(void) { return 0; } 85static inline int cpuset_init_early(void) { return 0; }
@@ -156,6 +158,11 @@ static inline int current_cpuset_is_being_rebound(void)
156 return 0; 158 return 0;
157} 159}
158 160
161static inline void rebuild_sched_domains(void)
162{
163 partition_sched_domains(1, NULL, NULL);
164}
165
159#endif /* !CONFIG_CPUSETS */ 166#endif /* !CONFIG_CPUSETS */
160 167
161#endif /* _LINUX_CPUSET_H */ 168#endif /* _LINUX_CPUSET_H */
diff --git a/include/linux/crash_dump.h b/include/linux/crash_dump.h
index 22c7ac5cd80c..2dac064d8359 100644
--- a/include/linux/crash_dump.h
+++ b/include/linux/crash_dump.h
@@ -8,11 +8,12 @@
8#include <linux/proc_fs.h> 8#include <linux/proc_fs.h>
9 9
10#define ELFCORE_ADDR_MAX (-1ULL) 10#define ELFCORE_ADDR_MAX (-1ULL)
11#define ELFCORE_ADDR_ERR (-2ULL)
12
11extern unsigned long long elfcorehdr_addr; 13extern unsigned long long elfcorehdr_addr;
14
12extern ssize_t copy_oldmem_page(unsigned long, char *, size_t, 15extern ssize_t copy_oldmem_page(unsigned long, char *, size_t,
13 unsigned long, int); 16 unsigned long, int);
14extern const struct file_operations proc_vmcore_operations;
15extern struct proc_dir_entry *proc_vmcore;
16 17
17/* Architecture code defines this if there are other possible ELF 18/* Architecture code defines this if there are other possible ELF
18 * machine types, e.g. on bi-arch capable hardware. */ 19 * machine types, e.g. on bi-arch capable hardware. */
@@ -22,5 +23,46 @@ extern struct proc_dir_entry *proc_vmcore;
22 23
23#define vmcore_elf_check_arch(x) (elf_check_arch(x) || vmcore_elf_check_arch_cross(x)) 24#define vmcore_elf_check_arch(x) (elf_check_arch(x) || vmcore_elf_check_arch_cross(x))
24 25
26/*
27 * is_kdump_kernel() checks whether this kernel is booting after a panic of
28 * previous kernel or not. This is determined by checking if previous kernel
29 * has passed the elf core header address on command line.
30 *
31 * This is not just a test if CONFIG_CRASH_DUMP is enabled or not. It will
32 * return 1 if CONFIG_CRASH_DUMP=y and if kernel is booting after a panic of
33 * previous kernel.
34 */
35
36static inline int is_kdump_kernel(void)
37{
38 return (elfcorehdr_addr != ELFCORE_ADDR_MAX) ? 1 : 0;
39}
40
41/* is_vmcore_usable() checks if the kernel is booting after a panic and
42 * the vmcore region is usable.
43 *
44 * This makes use of the fact that due to alignment -2ULL is not
45 * a valid pointer, much in the vain of IS_ERR(), except
46 * dealing directly with an unsigned long long rather than a pointer.
47 */
48
49static inline int is_vmcore_usable(void)
50{
51 return is_kdump_kernel() && elfcorehdr_addr != ELFCORE_ADDR_ERR ? 1 : 0;
52}
53
54/* vmcore_unusable() marks the vmcore as unusable,
55 * without disturbing the logic of is_kdump_kernel()
56 */
57
58static inline void vmcore_unusable(void)
59{
60 if (is_kdump_kernel())
61 elfcorehdr_addr = ELFCORE_ADDR_ERR;
62}
63#else /* !CONFIG_CRASH_DUMP */
64static inline int is_kdump_kernel(void) { return 0; }
25#endif /* CONFIG_CRASH_DUMP */ 65#endif /* CONFIG_CRASH_DUMP */
66
67extern unsigned long saved_max_pfn;
26#endif /* LINUX_CRASHDUMP_H */ 68#endif /* LINUX_CRASHDUMP_H */
diff --git a/include/linux/cred.h b/include/linux/cred.h
new file mode 100644
index 000000000000..b69222cc1fd2
--- /dev/null
+++ b/include/linux/cred.h
@@ -0,0 +1,50 @@
1/* Credentials management
2 *
3 * Copyright (C) 2008 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
10 */
11
12#ifndef _LINUX_CRED_H
13#define _LINUX_CRED_H
14
15#define get_current_user() (get_uid(current->user))
16
17#define task_uid(task) ((task)->uid)
18#define task_gid(task) ((task)->gid)
19#define task_euid(task) ((task)->euid)
20#define task_egid(task) ((task)->egid)
21
22#define current_uid() (current->uid)
23#define current_gid() (current->gid)
24#define current_euid() (current->euid)
25#define current_egid() (current->egid)
26#define current_suid() (current->suid)
27#define current_sgid() (current->sgid)
28#define current_fsuid() (current->fsuid)
29#define current_fsgid() (current->fsgid)
30#define current_cap() (current->cap_effective)
31
32#define current_uid_gid(_uid, _gid) \
33do { \
34 *(_uid) = current->uid; \
35 *(_gid) = current->gid; \
36} while(0)
37
38#define current_euid_egid(_uid, _gid) \
39do { \
40 *(_uid) = current->euid; \
41 *(_gid) = current->egid; \
42} while(0)
43
44#define current_fsuid_fsgid(_uid, _gid) \
45do { \
46 *(_uid) = current->fsuid; \
47 *(_gid) = current->fsgid; \
48} while(0)
49
50#endif /* _LINUX_CRED_H */
diff --git a/include/linux/crypto.h b/include/linux/crypto.h
index c43dc47fdf75..3d2317e4af2e 100644
--- a/include/linux/crypto.h
+++ b/include/linux/crypto.h
@@ -38,6 +38,7 @@
38#define CRYPTO_ALG_TYPE_DIGEST 0x00000008 38#define CRYPTO_ALG_TYPE_DIGEST 0x00000008
39#define CRYPTO_ALG_TYPE_HASH 0x00000009 39#define CRYPTO_ALG_TYPE_HASH 0x00000009
40#define CRYPTO_ALG_TYPE_AHASH 0x0000000a 40#define CRYPTO_ALG_TYPE_AHASH 0x0000000a
41#define CRYPTO_ALG_TYPE_RNG 0x0000000c
41 42
42#define CRYPTO_ALG_TYPE_HASH_MASK 0x0000000e 43#define CRYPTO_ALG_TYPE_HASH_MASK 0x0000000e
43#define CRYPTO_ALG_TYPE_AHASH_MASK 0x0000000c 44#define CRYPTO_ALG_TYPE_AHASH_MASK 0x0000000c
@@ -61,6 +62,14 @@
61#define CRYPTO_ALG_GENIV 0x00000200 62#define CRYPTO_ALG_GENIV 0x00000200
62 63
63/* 64/*
65 * Set if the algorithm has passed automated run-time testing. Note that
66 * if there is no run-time testing for a given algorithm it is considered
67 * to have passed.
68 */
69
70#define CRYPTO_ALG_TESTED 0x00000400
71
72/*
64 * Transform masks and values (for crt_flags). 73 * Transform masks and values (for crt_flags).
65 */ 74 */
66#define CRYPTO_TFM_REQ_MASK 0x000fff00 75#define CRYPTO_TFM_REQ_MASK 0x000fff00
@@ -105,6 +114,7 @@ struct crypto_aead;
105struct crypto_blkcipher; 114struct crypto_blkcipher;
106struct crypto_hash; 115struct crypto_hash;
107struct crypto_ahash; 116struct crypto_ahash;
117struct crypto_rng;
108struct crypto_tfm; 118struct crypto_tfm;
109struct crypto_type; 119struct crypto_type;
110struct aead_givcrypt_request; 120struct aead_givcrypt_request;
@@ -290,6 +300,15 @@ struct compress_alg {
290 unsigned int slen, u8 *dst, unsigned int *dlen); 300 unsigned int slen, u8 *dst, unsigned int *dlen);
291}; 301};
292 302
303struct rng_alg {
304 int (*rng_make_random)(struct crypto_rng *tfm, u8 *rdata,
305 unsigned int dlen);
306 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
307
308 unsigned int seedsize;
309};
310
311
293#define cra_ablkcipher cra_u.ablkcipher 312#define cra_ablkcipher cra_u.ablkcipher
294#define cra_aead cra_u.aead 313#define cra_aead cra_u.aead
295#define cra_blkcipher cra_u.blkcipher 314#define cra_blkcipher cra_u.blkcipher
@@ -298,6 +317,7 @@ struct compress_alg {
298#define cra_hash cra_u.hash 317#define cra_hash cra_u.hash
299#define cra_ahash cra_u.ahash 318#define cra_ahash cra_u.ahash
300#define cra_compress cra_u.compress 319#define cra_compress cra_u.compress
320#define cra_rng cra_u.rng
301 321
302struct crypto_alg { 322struct crypto_alg {
303 struct list_head cra_list; 323 struct list_head cra_list;
@@ -325,6 +345,7 @@ struct crypto_alg {
325 struct hash_alg hash; 345 struct hash_alg hash;
326 struct ahash_alg ahash; 346 struct ahash_alg ahash;
327 struct compress_alg compress; 347 struct compress_alg compress;
348 struct rng_alg rng;
328 } cra_u; 349 } cra_u;
329 350
330 int (*cra_init)(struct crypto_tfm *tfm); 351 int (*cra_init)(struct crypto_tfm *tfm);
@@ -430,6 +451,12 @@ struct compress_tfm {
430 u8 *dst, unsigned int *dlen); 451 u8 *dst, unsigned int *dlen);
431}; 452};
432 453
454struct rng_tfm {
455 int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
456 unsigned int dlen);
457 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
458};
459
433#define crt_ablkcipher crt_u.ablkcipher 460#define crt_ablkcipher crt_u.ablkcipher
434#define crt_aead crt_u.aead 461#define crt_aead crt_u.aead
435#define crt_blkcipher crt_u.blkcipher 462#define crt_blkcipher crt_u.blkcipher
@@ -437,6 +464,7 @@ struct compress_tfm {
437#define crt_hash crt_u.hash 464#define crt_hash crt_u.hash
438#define crt_ahash crt_u.ahash 465#define crt_ahash crt_u.ahash
439#define crt_compress crt_u.compress 466#define crt_compress crt_u.compress
467#define crt_rng crt_u.rng
440 468
441struct crypto_tfm { 469struct crypto_tfm {
442 470
@@ -450,6 +478,7 @@ struct crypto_tfm {
450 struct hash_tfm hash; 478 struct hash_tfm hash;
451 struct ahash_tfm ahash; 479 struct ahash_tfm ahash;
452 struct compress_tfm compress; 480 struct compress_tfm compress;
481 struct rng_tfm rng;
453 } crt_u; 482 } crt_u;
454 483
455 struct crypto_alg *__crt_alg; 484 struct crypto_alg *__crt_alg;
@@ -481,6 +510,10 @@ struct crypto_hash {
481 struct crypto_tfm base; 510 struct crypto_tfm base;
482}; 511};
483 512
513struct crypto_rng {
514 struct crypto_tfm base;
515};
516
484enum { 517enum {
485 CRYPTOA_UNSPEC, 518 CRYPTOA_UNSPEC,
486 CRYPTOA_ALG, 519 CRYPTOA_ALG,
@@ -515,6 +548,8 @@ struct crypto_tfm *crypto_alloc_tfm(const char *alg_name, u32 tfm_flags);
515struct crypto_tfm *crypto_alloc_base(const char *alg_name, u32 type, u32 mask); 548struct crypto_tfm *crypto_alloc_base(const char *alg_name, u32 type, u32 mask);
516void crypto_free_tfm(struct crypto_tfm *tfm); 549void crypto_free_tfm(struct crypto_tfm *tfm);
517 550
551int alg_test(const char *driver, const char *alg, u32 type, u32 mask);
552
518/* 553/*
519 * Transform helpers which query the underlying algorithm. 554 * Transform helpers which query the underlying algorithm.
520 */ 555 */
diff --git a/include/linux/cyclades.h b/include/linux/cyclades.h
index 504cb2c3fa9a..2d3d1e04ba92 100644
--- a/include/linux/cyclades.h
+++ b/include/linux/cyclades.h
@@ -550,11 +550,11 @@ struct cyclades_icount {
550 550
551struct cyclades_port { 551struct cyclades_port {
552 int magic; 552 int magic;
553 struct tty_port port;
553 struct cyclades_card *card; 554 struct cyclades_card *card;
554 int line; 555 int line;
555 int flags; /* defined in tty.h */ 556 int flags; /* defined in tty.h */
556 int type; /* UART type */ 557 int type; /* UART type */
557 struct tty_struct *tty;
558 int read_status_mask; 558 int read_status_mask;
559 int ignore_status_mask; 559 int ignore_status_mask;
560 int timeout; 560 int timeout;
@@ -567,13 +567,8 @@ struct cyclades_port {
567 int chip_rev; 567 int chip_rev;
568 int custom_divisor; 568 int custom_divisor;
569 u8 x_char; /* to be pushed out ASAP */ 569 u8 x_char; /* to be pushed out ASAP */
570 int close_delay;
571 unsigned short closing_wait;
572 int count; /* # of fd on device */
573 int breakon; 570 int breakon;
574 int breakoff; 571 int breakoff;
575 int blocked_open; /* # of blocked opens */
576 unsigned char *xmit_buf;
577 int xmit_head; 572 int xmit_head;
578 int xmit_tail; 573 int xmit_tail;
579 int xmit_cnt; 574 int xmit_cnt;
@@ -583,16 +578,14 @@ struct cyclades_port {
583 struct cyclades_monitor mon; 578 struct cyclades_monitor mon;
584 struct cyclades_idle_stats idle_stats; 579 struct cyclades_idle_stats idle_stats;
585 struct cyclades_icount icount; 580 struct cyclades_icount icount;
586 wait_queue_head_t open_wait;
587 wait_queue_head_t close_wait;
588 struct completion shutdown_wait; 581 struct completion shutdown_wait;
589 wait_queue_head_t delta_msr_wait; 582 wait_queue_head_t delta_msr_wait;
590 int throttle; 583 int throttle;
591}; 584};
592 585
593#define CLOSING_WAIT_DELAY 30*HZ 586#define CLOSING_WAIT_DELAY 30*HZ
594#define CY_CLOSING_WAIT_NONE 65535 587#define CY_CLOSING_WAIT_NONE ASYNC_CLOSING_WAIT_NONE
595#define CY_CLOSING_WAIT_INF 0 588#define CY_CLOSING_WAIT_INF ASYNC_CLOSING_WAIT_INF
596 589
597 590
598#define CyMAX_CHIPS_PER_CARD 8 591#define CyMAX_CHIPS_PER_CARD 8
diff --git a/include/linux/dca.h b/include/linux/dca.h
index af61cd1f37e9..b00a753eda53 100644
--- a/include/linux/dca.h
+++ b/include/linux/dca.h
@@ -10,6 +10,7 @@ void dca_unregister_notify(struct notifier_block *nb);
10#define DCA_PROVIDER_REMOVE 0x0002 10#define DCA_PROVIDER_REMOVE 0x0002
11 11
12struct dca_provider { 12struct dca_provider {
13 struct list_head node;
13 struct dca_ops *ops; 14 struct dca_ops *ops;
14 struct device *cd; 15 struct device *cd;
15 int id; 16 int id;
@@ -18,7 +19,9 @@ struct dca_provider {
18struct dca_ops { 19struct dca_ops {
19 int (*add_requester) (struct dca_provider *, struct device *); 20 int (*add_requester) (struct dca_provider *, struct device *);
20 int (*remove_requester) (struct dca_provider *, struct device *); 21 int (*remove_requester) (struct dca_provider *, struct device *);
21 u8 (*get_tag) (struct dca_provider *, int cpu); 22 u8 (*get_tag) (struct dca_provider *, struct device *,
23 int cpu);
24 int (*dev_managed) (struct dca_provider *, struct device *);
22}; 25};
23 26
24struct dca_provider *alloc_dca_provider(struct dca_ops *ops, int priv_size); 27struct dca_provider *alloc_dca_provider(struct dca_ops *ops, int priv_size);
@@ -32,9 +35,11 @@ static inline void *dca_priv(struct dca_provider *dca)
32} 35}
33 36
34/* Requester API */ 37/* Requester API */
38#define DCA_GET_TAG_TWO_ARGS
35int dca_add_requester(struct device *dev); 39int dca_add_requester(struct device *dev);
36int dca_remove_requester(struct device *dev); 40int dca_remove_requester(struct device *dev);
37u8 dca_get_tag(int cpu); 41u8 dca_get_tag(int cpu);
42u8 dca3_get_tag(struct device *dev, int cpu);
38 43
39/* internal stuff */ 44/* internal stuff */
40int __init dca_sysfs_init(void); 45int __init dca_sysfs_init(void);
diff --git a/include/linux/dcache.h b/include/linux/dcache.h
index 98202c672fde..a37359d0bad1 100644
--- a/include/linux/dcache.h
+++ b/include/linux/dcache.h
@@ -228,8 +228,9 @@ extern void d_delete(struct dentry *);
228 228
229/* allocate/de-allocate */ 229/* allocate/de-allocate */
230extern struct dentry * d_alloc(struct dentry *, const struct qstr *); 230extern struct dentry * d_alloc(struct dentry *, const struct qstr *);
231extern struct dentry * d_alloc_anon(struct inode *);
232extern struct dentry * d_splice_alias(struct inode *, struct dentry *); 231extern struct dentry * d_splice_alias(struct inode *, struct dentry *);
232extern struct dentry * d_add_ci(struct dentry *, struct inode *, struct qstr *);
233extern struct dentry * d_obtain_alias(struct inode *);
233extern void shrink_dcache_sb(struct super_block *); 234extern void shrink_dcache_sb(struct super_block *);
234extern void shrink_dcache_parent(struct dentry *); 235extern void shrink_dcache_parent(struct dentry *);
235extern void shrink_dcache_for_umount(struct super_block *); 236extern void shrink_dcache_for_umount(struct super_block *);
@@ -286,6 +287,7 @@ static inline struct dentry *d_add_unique(struct dentry *entry, struct inode *in
286 287
287/* used for rename() and baskets */ 288/* used for rename() and baskets */
288extern void d_move(struct dentry *, struct dentry *); 289extern void d_move(struct dentry *, struct dentry *);
290extern struct dentry *d_ancestor(struct dentry *, struct dentry *);
289 291
290/* appendix may either be NULL or be used for transname suffixes */ 292/* appendix may either be NULL or be used for transname suffixes */
291extern struct dentry * d_lookup(struct dentry *, struct qstr *); 293extern struct dentry * d_lookup(struct dentry *, struct qstr *);
diff --git a/include/linux/dccp.h b/include/linux/dccp.h
index aa0737019e37..6080449fbec9 100644
--- a/include/linux/dccp.h
+++ b/include/linux/dccp.h
@@ -364,8 +364,6 @@ static inline unsigned int dccp_hdr_len(const struct sk_buff *skb)
364/* FIXME: for now we're default to 1 but it should really be 0 */ 364/* FIXME: for now we're default to 1 but it should really be 0 */
365#define DCCPF_INITIAL_SEND_NDP_COUNT 1 365#define DCCPF_INITIAL_SEND_NDP_COUNT 1
366 366
367#define DCCP_NDP_LIMIT 0xFFFFFF
368
369/** 367/**
370 * struct dccp_minisock - Minimal DCCP connection representation 368 * struct dccp_minisock - Minimal DCCP connection representation
371 * 369 *
@@ -437,7 +435,7 @@ extern int dccp_parse_options(struct sock *sk, struct dccp_request_sock *dreq,
437 struct sk_buff *skb); 435 struct sk_buff *skb);
438 436
439struct dccp_options_received { 437struct dccp_options_received {
440 u32 dccpor_ndp; /* only 24 bits */ 438 u64 dccpor_ndp:48;
441 u32 dccpor_timestamp; 439 u32 dccpor_timestamp;
442 u32 dccpor_timestamp_echo; 440 u32 dccpor_timestamp_echo;
443 u32 dccpor_elapsed_time; 441 u32 dccpor_elapsed_time;
@@ -533,7 +531,7 @@ struct dccp_sock {
533 __u16 dccps_r_ack_ratio; 531 __u16 dccps_r_ack_ratio;
534 __u16 dccps_pcslen; 532 __u16 dccps_pcslen;
535 __u16 dccps_pcrlen; 533 __u16 dccps_pcrlen;
536 unsigned long dccps_ndp_count; 534 __u64 dccps_ndp_count:48;
537 unsigned long dccps_rate_last; 535 unsigned long dccps_rate_last;
538 struct dccp_minisock dccps_minisock; 536 struct dccp_minisock dccps_minisock;
539 struct dccp_ackvec *dccps_hc_rx_ackvec; 537 struct dccp_ackvec *dccps_hc_rx_ackvec;
diff --git a/include/linux/debugfs.h b/include/linux/debugfs.h
index 7266124361b4..e1a6c046cea3 100644
--- a/include/linux/debugfs.h
+++ b/include/linux/debugfs.h
@@ -26,6 +26,8 @@ struct debugfs_blob_wrapper {
26 unsigned long size; 26 unsigned long size;
27}; 27};
28 28
29extern struct dentry *arch_debugfs_dir;
30
29#if defined(CONFIG_DEBUG_FS) 31#if defined(CONFIG_DEBUG_FS)
30 32
31/* declared over in file.c */ 33/* declared over in file.c */
@@ -42,6 +44,7 @@ struct dentry *debugfs_create_symlink(const char *name, struct dentry *parent,
42 const char *dest); 44 const char *dest);
43 45
44void debugfs_remove(struct dentry *dentry); 46void debugfs_remove(struct dentry *dentry);
47void debugfs_remove_recursive(struct dentry *dentry);
45 48
46struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry, 49struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,
47 struct dentry *new_dir, const char *new_name); 50 struct dentry *new_dir, const char *new_name);
@@ -99,6 +102,9 @@ static inline struct dentry *debugfs_create_symlink(const char *name,
99static inline void debugfs_remove(struct dentry *dentry) 102static inline void debugfs_remove(struct dentry *dentry)
100{ } 103{ }
101 104
105static inline void debugfs_remove_recursive(struct dentry *dentry)
106{ }
107
102static inline struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry, 108static inline struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,
103 struct dentry *new_dir, char *new_name) 109 struct dentry *new_dir, char *new_name)
104{ 110{
diff --git a/include/linux/delayacct.h b/include/linux/delayacct.h
index ab94bc083558..f352f06fa063 100644
--- a/include/linux/delayacct.h
+++ b/include/linux/delayacct.h
@@ -39,6 +39,8 @@ extern void __delayacct_blkio_start(void);
39extern void __delayacct_blkio_end(void); 39extern void __delayacct_blkio_end(void);
40extern int __delayacct_add_tsk(struct taskstats *, struct task_struct *); 40extern int __delayacct_add_tsk(struct taskstats *, struct task_struct *);
41extern __u64 __delayacct_blkio_ticks(struct task_struct *); 41extern __u64 __delayacct_blkio_ticks(struct task_struct *);
42extern void __delayacct_freepages_start(void);
43extern void __delayacct_freepages_end(void);
42 44
43static inline int delayacct_is_task_waiting_on_io(struct task_struct *p) 45static inline int delayacct_is_task_waiting_on_io(struct task_struct *p)
44{ 46{
@@ -107,6 +109,18 @@ static inline __u64 delayacct_blkio_ticks(struct task_struct *tsk)
107 return 0; 109 return 0;
108} 110}
109 111
112static inline void delayacct_freepages_start(void)
113{
114 if (current->delays)
115 __delayacct_freepages_start();
116}
117
118static inline void delayacct_freepages_end(void)
119{
120 if (current->delays)
121 __delayacct_freepages_end();
122}
123
110#else 124#else
111static inline void delayacct_set_flag(int flag) 125static inline void delayacct_set_flag(int flag)
112{} 126{}
@@ -129,6 +143,11 @@ static inline __u64 delayacct_blkio_ticks(struct task_struct *tsk)
129{ return 0; } 143{ return 0; }
130static inline int delayacct_is_task_waiting_on_io(struct task_struct *p) 144static inline int delayacct_is_task_waiting_on_io(struct task_struct *p)
131{ return 0; } 145{ return 0; }
146static inline void delayacct_freepages_start(void)
147{}
148static inline void delayacct_freepages_end(void)
149{}
150
132#endif /* CONFIG_TASK_DELAY_ACCT */ 151#endif /* CONFIG_TASK_DELAY_ACCT */
133 152
134#endif 153#endif
diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h
index 0d8d419d191a..c17fd334e574 100644
--- a/include/linux/device-mapper.h
+++ b/include/linux/device-mapper.h
@@ -9,11 +9,12 @@
9#define _LINUX_DEVICE_MAPPER_H 9#define _LINUX_DEVICE_MAPPER_H
10 10
11#include <linux/bio.h> 11#include <linux/bio.h>
12#include <linux/blkdev.h>
12 13
13struct dm_target; 14struct dm_target;
14struct dm_table; 15struct dm_table;
15struct dm_dev;
16struct mapped_device; 16struct mapped_device;
17struct bio_vec;
17 18
18typedef enum { STATUSTYPE_INFO, STATUSTYPE_TABLE } status_type_t; 19typedef enum { STATUSTYPE_INFO, STATUSTYPE_TABLE } status_type_t;
19 20
@@ -68,10 +69,12 @@ typedef int (*dm_status_fn) (struct dm_target *ti, status_type_t status_type,
68 69
69typedef int (*dm_message_fn) (struct dm_target *ti, unsigned argc, char **argv); 70typedef int (*dm_message_fn) (struct dm_target *ti, unsigned argc, char **argv);
70 71
71typedef int (*dm_ioctl_fn) (struct dm_target *ti, struct inode *inode, 72typedef int (*dm_ioctl_fn) (struct dm_target *ti, unsigned int cmd,
72 struct file *filp, unsigned int cmd,
73 unsigned long arg); 73 unsigned long arg);
74 74
75typedef int (*dm_merge_fn) (struct dm_target *ti, struct bvec_merge_data *bvm,
76 struct bio_vec *biovec, int max_size);
77
75void dm_error(const char *message); 78void dm_error(const char *message);
76 79
77/* 80/*
@@ -79,13 +82,19 @@ void dm_error(const char *message);
79 */ 82 */
80void dm_set_device_limits(struct dm_target *ti, struct block_device *bdev); 83void dm_set_device_limits(struct dm_target *ti, struct block_device *bdev);
81 84
85struct dm_dev {
86 struct block_device *bdev;
87 fmode_t mode;
88 char name[16];
89};
90
82/* 91/*
83 * Constructors should call these functions to ensure destination devices 92 * Constructors should call these functions to ensure destination devices
84 * are opened/closed correctly. 93 * are opened/closed correctly.
85 * FIXME: too many arguments. 94 * FIXME: too many arguments.
86 */ 95 */
87int dm_get_device(struct dm_target *ti, const char *path, sector_t start, 96int dm_get_device(struct dm_target *ti, const char *path, sector_t start,
88 sector_t len, int mode, struct dm_dev **result); 97 sector_t len, fmode_t mode, struct dm_dev **result);
89void dm_put_device(struct dm_target *ti, struct dm_dev *d); 98void dm_put_device(struct dm_target *ti, struct dm_dev *d);
90 99
91/* 100/*
@@ -107,6 +116,7 @@ struct target_type {
107 dm_status_fn status; 116 dm_status_fn status;
108 dm_message_fn message; 117 dm_message_fn message;
109 dm_ioctl_fn ioctl; 118 dm_ioctl_fn ioctl;
119 dm_merge_fn merge;
110}; 120};
111 121
112struct io_restrictions { 122struct io_restrictions {
@@ -196,6 +206,7 @@ int dm_copy_name_and_uuid(struct mapped_device *md, char *name, char *uuid);
196struct gendisk *dm_disk(struct mapped_device *md); 206struct gendisk *dm_disk(struct mapped_device *md);
197int dm_suspended(struct mapped_device *md); 207int dm_suspended(struct mapped_device *md);
198int dm_noflush_suspending(struct dm_target *ti); 208int dm_noflush_suspending(struct dm_target *ti);
209union map_info *dm_get_mapinfo(struct bio *bio);
199 210
200/* 211/*
201 * Geometry functions. 212 * Geometry functions.
@@ -211,7 +222,7 @@ int dm_set_geometry(struct mapped_device *md, struct hd_geometry *geo);
211/* 222/*
212 * First create an empty table. 223 * First create an empty table.
213 */ 224 */
214int dm_table_create(struct dm_table **result, int mode, 225int dm_table_create(struct dm_table **result, fmode_t mode,
215 unsigned num_targets, struct mapped_device *md); 226 unsigned num_targets, struct mapped_device *md);
216 227
217/* 228/*
@@ -226,6 +237,11 @@ int dm_table_add_target(struct dm_table *t, const char *type,
226int dm_table_complete(struct dm_table *t); 237int dm_table_complete(struct dm_table *t);
227 238
228/* 239/*
240 * Unplug all devices in a table.
241 */
242void dm_table_unplug_all(struct dm_table *t);
243
244/*
229 * Table reference counting. 245 * Table reference counting.
230 */ 246 */
231struct dm_table *dm_get_table(struct mapped_device *md); 247struct dm_table *dm_get_table(struct mapped_device *md);
@@ -237,7 +253,7 @@ void dm_table_put(struct dm_table *t);
237 */ 253 */
238sector_t dm_table_get_size(struct dm_table *t); 254sector_t dm_table_get_size(struct dm_table *t);
239unsigned int dm_table_get_num_targets(struct dm_table *t); 255unsigned int dm_table_get_num_targets(struct dm_table *t);
240int dm_table_get_mode(struct dm_table *t); 256fmode_t dm_table_get_mode(struct dm_table *t);
241struct mapped_device *dm_table_get_md(struct dm_table *t); 257struct mapped_device *dm_table_get_md(struct dm_table *t);
242 258
243/* 259/*
@@ -250,6 +266,11 @@ void dm_table_event(struct dm_table *t);
250 */ 266 */
251int dm_swap_table(struct mapped_device *md, struct dm_table *t); 267int dm_swap_table(struct mapped_device *md, struct dm_table *t);
252 268
269/*
270 * A wrapper around vmalloc.
271 */
272void *dm_vcalloc(unsigned long nmemb, unsigned long elem_size);
273
253/*----------------------------------------------------------------- 274/*-----------------------------------------------------------------
254 * Macros. 275 * Macros.
255 *---------------------------------------------------------------*/ 276 *---------------------------------------------------------------*/
@@ -332,6 +353,9 @@ int dm_swap_table(struct mapped_device *md, struct dm_table *t);
332 */ 353 */
333#define dm_round_up(n, sz) (dm_div_up((n), (sz)) * (sz)) 354#define dm_round_up(n, sz) (dm_div_up((n), (sz)) * (sz))
334 355
356#define dm_array_too_big(fixed, obj, num) \
357 ((num) > (UINT_MAX - (fixed)) / (obj))
358
335static inline sector_t to_sector(unsigned long n) 359static inline sector_t to_sector(unsigned long n)
336{ 360{
337 return (n >> SECTOR_SHIFT); 361 return (n >> SECTOR_SHIFT);
diff --git a/include/linux/device.h b/include/linux/device.h
index f71a78d123ae..1a3686d15f98 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -16,6 +16,7 @@
16#include <linux/kobject.h> 16#include <linux/kobject.h>
17#include <linux/klist.h> 17#include <linux/klist.h>
18#include <linux/list.h> 18#include <linux/list.h>
19#include <linux/lockdep.h>
19#include <linux/compiler.h> 20#include <linux/compiler.h>
20#include <linux/types.h> 21#include <linux/types.h>
21#include <linux/module.h> 22#include <linux/module.h>
@@ -24,17 +25,13 @@
24#include <asm/atomic.h> 25#include <asm/atomic.h>
25#include <asm/device.h> 26#include <asm/device.h>
26 27
27#define DEVICE_NAME_SIZE 50 28#define BUS_ID_SIZE 20
28/* DEVICE_NAME_HALF is really less than half to accommodate slop */
29#define DEVICE_NAME_HALF __stringify(20)
30#define DEVICE_ID_SIZE 32
31#define BUS_ID_SIZE KOBJ_NAME_LEN
32
33 29
34struct device; 30struct device;
35struct device_driver; 31struct device_driver;
36struct driver_private; 32struct driver_private;
37struct class; 33struct class;
34struct class_private;
38struct bus_type; 35struct bus_type;
39struct bus_type_private; 36struct bus_type_private;
40 37
@@ -93,6 +90,9 @@ int __must_check bus_for_each_drv(struct bus_type *bus,
93 struct device_driver *start, void *data, 90 struct device_driver *start, void *data,
94 int (*fn)(struct device_driver *, void *)); 91 int (*fn)(struct device_driver *, void *));
95 92
93void bus_sort_breadthfirst(struct bus_type *bus,
94 int (*compare)(const struct device *a,
95 const struct device *b));
96/* 96/*
97 * Bus notifiers: Get notified of addition/removal of devices 97 * Bus notifiers: Get notified of addition/removal of devices
98 * and binding/unbinding of drivers to devices. 98 * and binding/unbinding of drivers to devices.
@@ -186,13 +186,9 @@ struct class {
186 const char *name; 186 const char *name;
187 struct module *owner; 187 struct module *owner;
188 188
189 struct kset subsys;
190 struct list_head devices;
191 struct list_head interfaces;
192 struct kset class_dirs;
193 struct semaphore sem; /* locks children, devices, interfaces */
194 struct class_attribute *class_attrs; 189 struct class_attribute *class_attrs;
195 struct device_attribute *dev_attrs; 190 struct device_attribute *dev_attrs;
191 struct kobject *dev_kobj;
196 192
197 int (*dev_uevent)(struct device *dev, struct kobj_uevent_env *env); 193 int (*dev_uevent)(struct device *dev, struct kobj_uevent_env *env);
198 194
@@ -203,13 +199,40 @@ struct class {
203 int (*resume)(struct device *dev); 199 int (*resume)(struct device *dev);
204 200
205 struct pm_ops *pm; 201 struct pm_ops *pm;
202 struct class_private *p;
203};
204
205struct class_dev_iter {
206 struct klist_iter ki;
207 const struct device_type *type;
206}; 208};
207 209
208extern int __must_check class_register(struct class *class); 210extern struct kobject *sysfs_dev_block_kobj;
211extern struct kobject *sysfs_dev_char_kobj;
212extern int __must_check __class_register(struct class *class,
213 struct lock_class_key *key);
209extern void class_unregister(struct class *class); 214extern void class_unregister(struct class *class);
210extern int class_for_each_device(struct class *class, void *data, 215
216/* This is a #define to keep the compiler from merging different
217 * instances of the __key variable */
218#define class_register(class) \
219({ \
220 static struct lock_class_key __key; \
221 __class_register(class, &__key); \
222})
223
224extern void class_dev_iter_init(struct class_dev_iter *iter,
225 struct class *class,
226 struct device *start,
227 const struct device_type *type);
228extern struct device *class_dev_iter_next(struct class_dev_iter *iter);
229extern void class_dev_iter_exit(struct class_dev_iter *iter);
230
231extern int class_for_each_device(struct class *class, struct device *start,
232 void *data,
211 int (*fn)(struct device *dev, void *data)); 233 int (*fn)(struct device *dev, void *data));
212extern struct device *class_find_device(struct class *class, void *data, 234extern struct device *class_find_device(struct class *class,
235 struct device *start, void *data,
213 int (*match)(struct device *, void *)); 236 int (*match)(struct device *, void *));
214 237
215struct class_attribute { 238struct class_attribute {
@@ -237,9 +260,19 @@ struct class_interface {
237extern int __must_check class_interface_register(struct class_interface *); 260extern int __must_check class_interface_register(struct class_interface *);
238extern void class_interface_unregister(struct class_interface *); 261extern void class_interface_unregister(struct class_interface *);
239 262
240extern struct class *class_create(struct module *owner, const char *name); 263extern struct class * __must_check __class_create(struct module *owner,
264 const char *name,
265 struct lock_class_key *key);
241extern void class_destroy(struct class *cls); 266extern void class_destroy(struct class *cls);
242 267
268/* This is a #define to keep the compiler from merging different
269 * instances of the __key variable */
270#define class_create(owner, name) \
271({ \
272 static struct lock_class_key __key; \
273 __class_create(owner, name, &__key); \
274})
275
243/* 276/*
244 * The type of device, "struct device" is embedded in. A class 277 * The type of device, "struct device" is embedded in. A class
245 * or bus can contain devices of different types 278 * or bus can contain devices of different types
@@ -340,6 +373,7 @@ struct device {
340 373
341 struct kobject kobj; 374 struct kobject kobj;
342 char bus_id[BUS_ID_SIZE]; /* position on parent bus */ 375 char bus_id[BUS_ID_SIZE]; /* position on parent bus */
376 const char *init_name; /* initial name of the device */
343 struct device_type *type; 377 struct device_type *type;
344 unsigned uevent_suppress:1; 378 unsigned uevent_suppress:1;
345 379
@@ -377,7 +411,7 @@ struct device {
377 spinlock_t devres_lock; 411 spinlock_t devres_lock;
378 struct list_head devres_head; 412 struct list_head devres_head;
379 413
380 struct list_head node; 414 struct klist_node knode_class;
381 struct class *class; 415 struct class *class;
382 dev_t devt; /* dev_t, creates the sysfs "dev" */ 416 dev_t devt; /* dev_t, creates the sysfs "dev" */
383 struct attribute_group **groups; /* optional groups */ 417 struct attribute_group **groups; /* optional groups */
@@ -388,7 +422,7 @@ struct device {
388/* Get the wakeup routines, which depend on struct device */ 422/* Get the wakeup routines, which depend on struct device */
389#include <linux/pm_wakeup.h> 423#include <linux/pm_wakeup.h>
390 424
391static inline const char *dev_name(struct device *dev) 425static inline const char *dev_name(const struct device *dev)
392{ 426{
393 /* will be changed into kobject_name(&dev->kobj) in the near future */ 427 /* will be changed into kobject_name(&dev->kobj) in the near future */
394 return dev->bus_id; 428 return dev->bus_id;
@@ -416,7 +450,7 @@ static inline void set_dev_node(struct device *dev, int node)
416} 450}
417#endif 451#endif
418 452
419static inline void *dev_get_drvdata(struct device *dev) 453static inline void *dev_get_drvdata(const struct device *dev)
420{ 454{
421 return dev->driver_data; 455 return dev->driver_data;
422} 456}
@@ -468,13 +502,8 @@ extern struct device *device_create_vargs(struct class *cls,
468 const char *fmt, 502 const char *fmt,
469 va_list vargs); 503 va_list vargs);
470extern struct device *device_create(struct class *cls, struct device *parent, 504extern struct device *device_create(struct class *cls, struct device *parent,
471 dev_t devt, const char *fmt, ...) 505 dev_t devt, void *drvdata,
472 __attribute__((format(printf, 4, 5))); 506 const char *fmt, ...)
473extern struct device *device_create_drvdata(struct class *cls,
474 struct device *parent,
475 dev_t devt,
476 void *drvdata,
477 const char *fmt, ...)
478 __attribute__((format(printf, 5, 6))); 507 __attribute__((format(printf, 5, 6)));
479extern void device_destroy(struct class *cls, dev_t devt); 508extern void device_destroy(struct class *cls, dev_t devt);
480 509
@@ -504,7 +533,7 @@ extern void device_shutdown(void);
504extern void sysdev_shutdown(void); 533extern void sysdev_shutdown(void);
505 534
506/* debugging and troubleshooting/diagnostic helpers. */ 535/* debugging and troubleshooting/diagnostic helpers. */
507extern const char *dev_driver_string(struct device *dev); 536extern const char *dev_driver_string(const struct device *dev);
508#define dev_printk(level, dev, format, arg...) \ 537#define dev_printk(level, dev, format, arg...) \
509 printk(level "%s %s: " format , dev_driver_string(dev) , \ 538 printk(level "%s %s: " format , dev_driver_string(dev) , \
510 dev_name(dev) , ## arg) 539 dev_name(dev) , ## arg)
@@ -524,7 +553,11 @@ extern const char *dev_driver_string(struct device *dev);
524#define dev_info(dev, format, arg...) \ 553#define dev_info(dev, format, arg...) \
525 dev_printk(KERN_INFO , dev , format , ## arg) 554 dev_printk(KERN_INFO , dev , format , ## arg)
526 555
527#ifdef DEBUG 556#if defined(CONFIG_DYNAMIC_PRINTK_DEBUG)
557#define dev_dbg(dev, format, ...) do { \
558 dynamic_dev_dbg(dev, format, ##__VA_ARGS__); \
559 } while (0)
560#elif defined(DEBUG)
528#define dev_dbg(dev, format, arg...) \ 561#define dev_dbg(dev, format, arg...) \
529 dev_printk(KERN_DEBUG , dev , format , ## arg) 562 dev_printk(KERN_DEBUG , dev , format , ## arg)
530#else 563#else
@@ -540,6 +573,14 @@ extern const char *dev_driver_string(struct device *dev);
540 ({ if (0) dev_printk(KERN_DEBUG, dev, format, ##arg); 0; }) 573 ({ if (0) dev_printk(KERN_DEBUG, dev, format, ##arg); 0; })
541#endif 574#endif
542 575
576/*
577 * dev_WARN() acts like dev_printk(), but with the key difference
578 * of using a WARN/WARN_ON to get the message out, including the
579 * file/line information and a backtrace.
580 */
581#define dev_WARN(dev, format, arg...) \
582 WARN(1, "Device: %s\n" format, dev_driver_string(dev), ## arg);
583
543/* Create alias, so I can be autoloaded. */ 584/* Create alias, so I can be autoloaded. */
544#define MODULE_ALIAS_CHARDEV(major,minor) \ 585#define MODULE_ALIAS_CHARDEV(major,minor) \
545 MODULE_ALIAS("char-major-" __stringify(major) "-" __stringify(minor)) 586 MODULE_ALIAS("char-major-" __stringify(major) "-" __stringify(minor))
diff --git a/include/linux/devpts_fs.h b/include/linux/devpts_fs.h
index 154769cad3f3..5ce0e5fd712e 100644
--- a/include/linux/devpts_fs.h
+++ b/include/linux/devpts_fs.h
@@ -17,20 +17,31 @@
17 17
18#ifdef CONFIG_UNIX98_PTYS 18#ifdef CONFIG_UNIX98_PTYS
19 19
20int devpts_new_index(void); 20int devpts_new_index(struct inode *ptmx_inode);
21void devpts_kill_index(int idx); 21void devpts_kill_index(struct inode *ptmx_inode, int idx);
22int devpts_pty_new(struct tty_struct *tty); /* mknod in devpts */ 22/* mknod in devpts */
23struct tty_struct *devpts_get_tty(int number); /* get tty structure */ 23int devpts_pty_new(struct inode *ptmx_inode, struct tty_struct *tty);
24void devpts_pty_kill(int number); /* unlink */ 24/* get tty structure */
25struct tty_struct *devpts_get_tty(struct inode *pts_inode, int number);
26/* unlink */
27void devpts_pty_kill(struct tty_struct *tty);
25 28
26#else 29#else
27 30
28/* Dummy stubs in the no-pty case */ 31/* Dummy stubs in the no-pty case */
29static inline int devpts_new_index(void) { return -EINVAL; } 32static inline int devpts_new_index(struct inode *ptmx_inode) { return -EINVAL; }
30static inline void devpts_kill_index(int idx) { } 33static inline void devpts_kill_index(struct inode *ptmx_inode, int idx) { }
31static inline int devpts_pty_new(struct tty_struct *tty) { return -EINVAL; } 34static inline int devpts_pty_new(struct inode *ptmx_inode,
32static inline struct tty_struct *devpts_get_tty(int number) { return NULL; } 35 struct tty_struct *tty)
33static inline void devpts_pty_kill(int number) { } 36{
37 return -EINVAL;
38}
39static inline struct tty_struct *devpts_get_tty(struct inode *pts_inode,
40 int number)
41{
42 return NULL;
43}
44static inline void devpts_pty_kill(struct tty_struct *tty) { }
34 45
35#endif 46#endif
36 47
diff --git a/include/linux/dirent.h b/include/linux/dirent.h
index 5d6023b87800..f072fb8d10a3 100644
--- a/include/linux/dirent.h
+++ b/include/linux/dirent.h
@@ -1,23 +1,6 @@
1#ifndef _LINUX_DIRENT_H 1#ifndef _LINUX_DIRENT_H
2#define _LINUX_DIRENT_H 2#define _LINUX_DIRENT_H
3 3
4struct dirent {
5 long d_ino;
6 __kernel_off_t d_off;
7 unsigned short d_reclen;
8 char d_name[256]; /* We must not include limits.h! */
9};
10
11struct dirent64 {
12 __u64 d_ino;
13 __s64 d_off;
14 unsigned short d_reclen;
15 unsigned char d_type;
16 char d_name[256];
17};
18
19#ifdef __KERNEL__
20
21struct linux_dirent64 { 4struct linux_dirent64 {
22 u64 d_ino; 5 u64 d_ino;
23 s64 d_off; 6 s64 d_off;
@@ -26,7 +9,4 @@ struct linux_dirent64 {
26 char d_name[0]; 9 char d_name[0];
27}; 10};
28 11
29#endif /* __KERNEL__ */
30
31
32#endif 12#endif
diff --git a/include/linux/dlm.h b/include/linux/dlm.h
index 203a025e30e5..b9cd38603fd8 100644
--- a/include/linux/dlm.h
+++ b/include/linux/dlm.h
@@ -2,7 +2,7 @@
2******************************************************************************* 2*******************************************************************************
3** 3**
4** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. 4** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
5** Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. 5** Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved.
6** 6**
7** This copyrighted material is made available to anyone wishing to use, 7** This copyrighted material is made available to anyone wishing to use,
8** modify, copy, or redistribute it subject to the terms and conditions 8** modify, copy, or redistribute it subject to the terms and conditions
@@ -65,9 +65,12 @@ struct dlm_lksb {
65 char * sb_lvbptr; 65 char * sb_lvbptr;
66}; 66};
67 67
68/* dlm_new_lockspace() flags */
69
68#define DLM_LSFL_NODIR 0x00000001 70#define DLM_LSFL_NODIR 0x00000001
69#define DLM_LSFL_TIMEWARN 0x00000002 71#define DLM_LSFL_TIMEWARN 0x00000002
70#define DLM_LSFL_FS 0x00000004 72#define DLM_LSFL_FS 0x00000004
73#define DLM_LSFL_NEWEXCL 0x00000008
71 74
72#ifdef __KERNEL__ 75#ifdef __KERNEL__
73 76
diff --git a/include/linux/dlm_device.h b/include/linux/dlm_device.h
index c6034508fed9..3060783c4191 100644
--- a/include/linux/dlm_device.h
+++ b/include/linux/dlm_device.h
@@ -26,7 +26,7 @@
26/* Version of the device interface */ 26/* Version of the device interface */
27#define DLM_DEVICE_VERSION_MAJOR 6 27#define DLM_DEVICE_VERSION_MAJOR 6
28#define DLM_DEVICE_VERSION_MINOR 0 28#define DLM_DEVICE_VERSION_MINOR 0
29#define DLM_DEVICE_VERSION_PATCH 0 29#define DLM_DEVICE_VERSION_PATCH 1
30 30
31/* struct passed to the lock write */ 31/* struct passed to the lock write */
32struct dlm_lock_params { 32struct dlm_lock_params {
diff --git a/include/linux/dm-ioctl.h b/include/linux/dm-ioctl.h
index b03c41bbfa14..28c2940eb30d 100644
--- a/include/linux/dm-ioctl.h
+++ b/include/linux/dm-ioctl.h
@@ -256,9 +256,9 @@ enum {
256#define DM_DEV_SET_GEOMETRY _IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, struct dm_ioctl) 256#define DM_DEV_SET_GEOMETRY _IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, struct dm_ioctl)
257 257
258#define DM_VERSION_MAJOR 4 258#define DM_VERSION_MAJOR 4
259#define DM_VERSION_MINOR 13 259#define DM_VERSION_MINOR 14
260#define DM_VERSION_PATCHLEVEL 0 260#define DM_VERSION_PATCHLEVEL 0
261#define DM_VERSION_EXTRA "-ioctl (2007-10-18)" 261#define DM_VERSION_EXTRA "-ioctl (2008-04-23)"
262 262
263/* Status bits */ 263/* Status bits */
264#define DM_READONLY_FLAG (1 << 0) /* In/Out */ 264#define DM_READONLY_FLAG (1 << 0) /* In/Out */
diff --git a/include/linux/dm-region-hash.h b/include/linux/dm-region-hash.h
new file mode 100644
index 000000000000..a9e652a41373
--- /dev/null
+++ b/include/linux/dm-region-hash.h
@@ -0,0 +1,104 @@
1/*
2 * Copyright (C) 2003 Sistina Software Limited.
3 * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved.
4 *
5 * Device-Mapper dirty region hash interface.
6 *
7 * This file is released under the GPL.
8 */
9
10#ifndef DM_REGION_HASH_H
11#define DM_REGION_HASH_H
12
13#include <linux/dm-dirty-log.h>
14
15/*-----------------------------------------------------------------
16 * Region hash
17 *----------------------------------------------------------------*/
18struct dm_region_hash;
19struct dm_region;
20
21/*
22 * States a region can have.
23 */
24enum dm_rh_region_states {
25 DM_RH_CLEAN = 0x01, /* No writes in flight. */
26 DM_RH_DIRTY = 0x02, /* Writes in flight. */
27 DM_RH_NOSYNC = 0x04, /* Out of sync. */
28 DM_RH_RECOVERING = 0x08, /* Under resynchronization. */
29};
30
31/*
32 * Region hash create/destroy.
33 */
34struct bio_list;
35struct dm_region_hash *dm_region_hash_create(
36 void *context, void (*dispatch_bios)(void *context,
37 struct bio_list *bios),
38 void (*wakeup_workers)(void *context),
39 void (*wakeup_all_recovery_waiters)(void *context),
40 sector_t target_begin, unsigned max_recovery,
41 struct dm_dirty_log *log, uint32_t region_size,
42 region_t nr_regions);
43void dm_region_hash_destroy(struct dm_region_hash *rh);
44
45struct dm_dirty_log *dm_rh_dirty_log(struct dm_region_hash *rh);
46
47/*
48 * Conversion functions.
49 */
50region_t dm_rh_bio_to_region(struct dm_region_hash *rh, struct bio *bio);
51sector_t dm_rh_region_to_sector(struct dm_region_hash *rh, region_t region);
52void *dm_rh_region_context(struct dm_region *reg);
53
54/*
55 * Get region size and key (ie. number of the region).
56 */
57sector_t dm_rh_get_region_size(struct dm_region_hash *rh);
58region_t dm_rh_get_region_key(struct dm_region *reg);
59
60/*
61 * Get/set/update region state (and dirty log).
62 *
63 */
64int dm_rh_get_state(struct dm_region_hash *rh, region_t region, int may_block);
65void dm_rh_set_state(struct dm_region_hash *rh, region_t region,
66 enum dm_rh_region_states state, int may_block);
67
68/* Non-zero errors_handled leaves the state of the region NOSYNC */
69void dm_rh_update_states(struct dm_region_hash *rh, int errors_handled);
70
71/* Flush the region hash and dirty log. */
72int dm_rh_flush(struct dm_region_hash *rh);
73
74/* Inc/dec pending count on regions. */
75void dm_rh_inc_pending(struct dm_region_hash *rh, struct bio_list *bios);
76void dm_rh_dec(struct dm_region_hash *rh, region_t region);
77
78/* Delay bios on regions. */
79void dm_rh_delay(struct dm_region_hash *rh, struct bio *bio);
80
81void dm_rh_mark_nosync(struct dm_region_hash *rh,
82 struct bio *bio, unsigned done, int error);
83
84/*
85 * Region recovery control.
86 */
87
88/* Prepare some regions for recovery by starting to quiesce them. */
89void dm_rh_recovery_prepare(struct dm_region_hash *rh);
90
91/* Try fetching a quiesced region for recovery. */
92struct dm_region *dm_rh_recovery_start(struct dm_region_hash *rh);
93
94/* Report recovery end on a region. */
95void dm_rh_recovery_end(struct dm_region *reg, int error);
96
97/* Returns number of regions with recovery work outstanding. */
98int dm_rh_recovery_in_flight(struct dm_region_hash *rh);
99
100/* Start/stop recovery. */
101void dm_rh_start_recovery(struct dm_region_hash *rh);
102void dm_rh_stop_recovery(struct dm_region_hash *rh);
103
104#endif /* DM_REGION_HASH_H */
diff --git a/include/linux/dm9000.h b/include/linux/dm9000.h
index a3750462f9e3..c30879cf93bc 100644
--- a/include/linux/dm9000.h
+++ b/include/linux/dm9000.h
@@ -21,11 +21,13 @@
21#define DM9000_PLATF_32BITONLY (0x0004) 21#define DM9000_PLATF_32BITONLY (0x0004)
22#define DM9000_PLATF_EXT_PHY (0x0008) 22#define DM9000_PLATF_EXT_PHY (0x0008)
23#define DM9000_PLATF_NO_EEPROM (0x0010) 23#define DM9000_PLATF_NO_EEPROM (0x0010)
24#define DM9000_PLATF_SIMPLE_PHY (0x0020) /* Use NSR to find LinkStatus */
24 25
25/* platfrom data for platfrom device structure's platfrom_data field */ 26/* platfrom data for platfrom device structure's platfrom_data field */
26 27
27struct dm9000_plat_data { 28struct dm9000_plat_data {
28 unsigned int flags; 29 unsigned int flags;
30 unsigned char dev_addr[6];
29 31
30 /* allow replacement IO routines */ 32 /* allow replacement IO routines */
31 33
diff --git a/include/linux/dma-attrs.h b/include/linux/dma-attrs.h
index 1677e2bfa00c..71ad34eca6e3 100644
--- a/include/linux/dma-attrs.h
+++ b/include/linux/dma-attrs.h
@@ -12,6 +12,7 @@
12 */ 12 */
13enum dma_attr { 13enum dma_attr {
14 DMA_ATTR_WRITE_BARRIER, 14 DMA_ATTR_WRITE_BARRIER,
15 DMA_ATTR_WEAK_ORDERING,
15 DMA_ATTR_MAX, 16 DMA_ATTR_MAX,
16}; 17};
17 18
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index 952e0f857ac9..ba9114ec5d3a 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -48,6 +48,11 @@ static inline int is_device_dma_capable(struct device *dev)
48 return dev->dma_mask != NULL && *dev->dma_mask != DMA_MASK_NONE; 48 return dev->dma_mask != NULL && *dev->dma_mask != DMA_MASK_NONE;
49} 49}
50 50
51static inline int is_buffer_dma_capable(u64 mask, dma_addr_t addr, size_t size)
52{
53 return addr + size <= mask;
54}
55
51#ifdef CONFIG_HAS_DMA 56#ifdef CONFIG_HAS_DMA
52#include <asm/dma-mapping.h> 57#include <asm/dma-mapping.h>
53#else 58#else
@@ -58,6 +63,13 @@ static inline int is_device_dma_capable(struct device *dev)
58#define dma_sync_single dma_sync_single_for_cpu 63#define dma_sync_single dma_sync_single_for_cpu
59#define dma_sync_sg dma_sync_sg_for_cpu 64#define dma_sync_sg dma_sync_sg_for_cpu
60 65
66static inline u64 dma_get_mask(struct device *dev)
67{
68 if (dev && dev->dma_mask && *dev->dma_mask)
69 return *dev->dma_mask;
70 return DMA_32BIT_MASK;
71}
72
61extern u64 dma_get_required_mask(struct device *dev); 73extern u64 dma_get_required_mask(struct device *dev);
62 74
63static inline unsigned int dma_get_max_seg_size(struct device *dev) 75static inline unsigned int dma_get_max_seg_size(struct device *dev)
diff --git a/include/linux/dma_remapping.h b/include/linux/dma_remapping.h
new file mode 100644
index 000000000000..952df39c989d
--- /dev/null
+++ b/include/linux/dma_remapping.h
@@ -0,0 +1,156 @@
1#ifndef _DMA_REMAPPING_H
2#define _DMA_REMAPPING_H
3
4/*
5 * VT-d hardware uses 4KiB page size regardless of host page size.
6 */
7#define VTD_PAGE_SHIFT (12)
8#define VTD_PAGE_SIZE (1UL << VTD_PAGE_SHIFT)
9#define VTD_PAGE_MASK (((u64)-1) << VTD_PAGE_SHIFT)
10#define VTD_PAGE_ALIGN(addr) (((addr) + VTD_PAGE_SIZE - 1) & VTD_PAGE_MASK)
11
12#define IOVA_PFN(addr) ((addr) >> PAGE_SHIFT)
13#define DMA_32BIT_PFN IOVA_PFN(DMA_32BIT_MASK)
14#define DMA_64BIT_PFN IOVA_PFN(DMA_64BIT_MASK)
15
16
17/*
18 * 0: Present
19 * 1-11: Reserved
20 * 12-63: Context Ptr (12 - (haw-1))
21 * 64-127: Reserved
22 */
23struct root_entry {
24 u64 val;
25 u64 rsvd1;
26};
27#define ROOT_ENTRY_NR (VTD_PAGE_SIZE/sizeof(struct root_entry))
28static inline bool root_present(struct root_entry *root)
29{
30 return (root->val & 1);
31}
32static inline void set_root_present(struct root_entry *root)
33{
34 root->val |= 1;
35}
36static inline void set_root_value(struct root_entry *root, unsigned long value)
37{
38 root->val |= value & VTD_PAGE_MASK;
39}
40
41struct context_entry;
42static inline struct context_entry *
43get_context_addr_from_root(struct root_entry *root)
44{
45 return (struct context_entry *)
46 (root_present(root)?phys_to_virt(
47 root->val & VTD_PAGE_MASK) :
48 NULL);
49}
50
51/*
52 * low 64 bits:
53 * 0: present
54 * 1: fault processing disable
55 * 2-3: translation type
56 * 12-63: address space root
57 * high 64 bits:
58 * 0-2: address width
59 * 3-6: aval
60 * 8-23: domain id
61 */
62struct context_entry {
63 u64 lo;
64 u64 hi;
65};
66#define context_present(c) ((c).lo & 1)
67#define context_fault_disable(c) (((c).lo >> 1) & 1)
68#define context_translation_type(c) (((c).lo >> 2) & 3)
69#define context_address_root(c) ((c).lo & VTD_PAGE_MASK)
70#define context_address_width(c) ((c).hi & 7)
71#define context_domain_id(c) (((c).hi >> 8) & ((1 << 16) - 1))
72
73#define context_set_present(c) do {(c).lo |= 1;} while (0)
74#define context_set_fault_enable(c) \
75 do {(c).lo &= (((u64)-1) << 2) | 1;} while (0)
76#define context_set_translation_type(c, val) \
77 do { \
78 (c).lo &= (((u64)-1) << 4) | 3; \
79 (c).lo |= ((val) & 3) << 2; \
80 } while (0)
81#define CONTEXT_TT_MULTI_LEVEL 0
82#define context_set_address_root(c, val) \
83 do {(c).lo |= (val) & VTD_PAGE_MASK; } while (0)
84#define context_set_address_width(c, val) do {(c).hi |= (val) & 7;} while (0)
85#define context_set_domain_id(c, val) \
86 do {(c).hi |= ((val) & ((1 << 16) - 1)) << 8;} while (0)
87#define context_clear_entry(c) do {(c).lo = 0; (c).hi = 0;} while (0)
88
89/*
90 * 0: readable
91 * 1: writable
92 * 2-6: reserved
93 * 7: super page
94 * 8-11: available
95 * 12-63: Host physcial address
96 */
97struct dma_pte {
98 u64 val;
99};
100#define dma_clear_pte(p) do {(p).val = 0;} while (0)
101
102#define DMA_PTE_READ (1)
103#define DMA_PTE_WRITE (2)
104
105#define dma_set_pte_readable(p) do {(p).val |= DMA_PTE_READ;} while (0)
106#define dma_set_pte_writable(p) do {(p).val |= DMA_PTE_WRITE;} while (0)
107#define dma_set_pte_prot(p, prot) \
108 do {(p).val = ((p).val & ~3) | ((prot) & 3); } while (0)
109#define dma_pte_addr(p) ((p).val & VTD_PAGE_MASK)
110#define dma_set_pte_addr(p, addr) do {\
111 (p).val |= ((addr) & VTD_PAGE_MASK); } while (0)
112#define dma_pte_present(p) (((p).val & 3) != 0)
113
114struct intel_iommu;
115
116struct dmar_domain {
117 int id; /* domain id */
118 struct intel_iommu *iommu; /* back pointer to owning iommu */
119
120 struct list_head devices; /* all devices' list */
121 struct iova_domain iovad; /* iova's that belong to this domain */
122
123 struct dma_pte *pgd; /* virtual address */
124 spinlock_t mapping_lock; /* page table lock */
125 int gaw; /* max guest address width */
126
127 /* adjusted guest address width, 0 is level 2 30-bit */
128 int agaw;
129
130#define DOMAIN_FLAG_MULTIPLE_DEVICES 1
131 int flags;
132};
133
134/* PCI domain-device relationship */
135struct device_domain_info {
136 struct list_head link; /* link to domain siblings */
137 struct list_head global; /* link to global list */
138 u8 bus; /* PCI bus numer */
139 u8 devfn; /* PCI devfn number */
140 struct pci_dev *dev; /* it's NULL for PCIE-to-PCI bridge */
141 struct dmar_domain *domain; /* pointer to domain */
142};
143
144extern int init_dmars(void);
145extern void free_dmar_iommu(struct intel_iommu *iommu);
146
147extern int dmar_disabled;
148
149#ifndef CONFIG_DMAR_GFX_WA
150static inline void iommu_prepare_gfx_mapping(void)
151{
152 return;
153}
154#endif /* !CONFIG_DMAR_GFX_WA */
155
156#endif
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
index d08a5c5eb928..adb0b084eb5a 100644
--- a/include/linux/dmaengine.h
+++ b/include/linux/dmaengine.h
@@ -89,10 +89,23 @@ enum dma_transaction_type {
89 DMA_MEMSET, 89 DMA_MEMSET,
90 DMA_MEMCPY_CRC32C, 90 DMA_MEMCPY_CRC32C,
91 DMA_INTERRUPT, 91 DMA_INTERRUPT,
92 DMA_SLAVE,
92}; 93};
93 94
94/* last transaction type for creation of the capabilities mask */ 95/* last transaction type for creation of the capabilities mask */
95#define DMA_TX_TYPE_END (DMA_INTERRUPT + 1) 96#define DMA_TX_TYPE_END (DMA_SLAVE + 1)
97
98/**
99 * enum dma_slave_width - DMA slave register access width.
100 * @DMA_SLAVE_WIDTH_8BIT: Do 8-bit slave register accesses
101 * @DMA_SLAVE_WIDTH_16BIT: Do 16-bit slave register accesses
102 * @DMA_SLAVE_WIDTH_32BIT: Do 32-bit slave register accesses
103 */
104enum dma_slave_width {
105 DMA_SLAVE_WIDTH_8BIT,
106 DMA_SLAVE_WIDTH_16BIT,
107 DMA_SLAVE_WIDTH_32BIT,
108};
96 109
97/** 110/**
98 * enum dma_ctrl_flags - DMA flags to augment operation preparation, 111 * enum dma_ctrl_flags - DMA flags to augment operation preparation,
@@ -102,10 +115,14 @@ enum dma_transaction_type {
102 * @DMA_CTRL_ACK - the descriptor cannot be reused until the client 115 * @DMA_CTRL_ACK - the descriptor cannot be reused until the client
103 * acknowledges receipt, i.e. has has a chance to establish any 116 * acknowledges receipt, i.e. has has a chance to establish any
104 * dependency chains 117 * dependency chains
118 * @DMA_COMPL_SKIP_SRC_UNMAP - set to disable dma-unmapping the source buffer(s)
119 * @DMA_COMPL_SKIP_DEST_UNMAP - set to disable dma-unmapping the destination(s)
105 */ 120 */
106enum dma_ctrl_flags { 121enum dma_ctrl_flags {
107 DMA_PREP_INTERRUPT = (1 << 0), 122 DMA_PREP_INTERRUPT = (1 << 0),
108 DMA_CTRL_ACK = (1 << 1), 123 DMA_CTRL_ACK = (1 << 1),
124 DMA_COMPL_SKIP_SRC_UNMAP = (1 << 2),
125 DMA_COMPL_SKIP_DEST_UNMAP = (1 << 3),
109}; 126};
110 127
111/** 128/**
@@ -115,6 +132,32 @@ enum dma_ctrl_flags {
115typedef struct { DECLARE_BITMAP(bits, DMA_TX_TYPE_END); } dma_cap_mask_t; 132typedef struct { DECLARE_BITMAP(bits, DMA_TX_TYPE_END); } dma_cap_mask_t;
116 133
117/** 134/**
135 * struct dma_slave - Information about a DMA slave
136 * @dev: device acting as DMA slave
137 * @dma_dev: required DMA master device. If non-NULL, the client can not be
138 * bound to other masters than this.
139 * @tx_reg: physical address of data register used for
140 * memory-to-peripheral transfers
141 * @rx_reg: physical address of data register used for
142 * peripheral-to-memory transfers
143 * @reg_width: peripheral register width
144 *
145 * If dma_dev is non-NULL, the client can not be bound to other DMA
146 * masters than the one corresponding to this device. The DMA master
147 * driver may use this to determine if there is controller-specific
148 * data wrapped around this struct. Drivers of platform code that sets
149 * the dma_dev field must therefore make sure to use an appropriate
150 * controller-specific dma slave structure wrapping this struct.
151 */
152struct dma_slave {
153 struct device *dev;
154 struct device *dma_dev;
155 dma_addr_t tx_reg;
156 dma_addr_t rx_reg;
157 enum dma_slave_width reg_width;
158};
159
160/**
118 * struct dma_chan_percpu - the per-CPU part of struct dma_chan 161 * struct dma_chan_percpu - the per-CPU part of struct dma_chan
119 * @refcount: local_t used for open-coded "bigref" counting 162 * @refcount: local_t used for open-coded "bigref" counting
120 * @memcpy_count: transaction counter 163 * @memcpy_count: transaction counter
@@ -139,6 +182,7 @@ struct dma_chan_percpu {
139 * @rcu: the DMA channel's RCU head 182 * @rcu: the DMA channel's RCU head
140 * @device_node: used to add this to the device chan list 183 * @device_node: used to add this to the device chan list
141 * @local: per-cpu pointer to a struct dma_chan_percpu 184 * @local: per-cpu pointer to a struct dma_chan_percpu
185 * @client-count: how many clients are using this channel
142 */ 186 */
143struct dma_chan { 187struct dma_chan {
144 struct dma_device *device; 188 struct dma_device *device;
@@ -154,6 +198,7 @@ struct dma_chan {
154 198
155 struct list_head device_node; 199 struct list_head device_node;
156 struct dma_chan_percpu *local; 200 struct dma_chan_percpu *local;
201 int client_count;
157}; 202};
158 203
159#define to_dma_chan(p) container_of(p, struct dma_chan, dev) 204#define to_dma_chan(p) container_of(p, struct dma_chan, dev)
@@ -202,11 +247,14 @@ typedef enum dma_state_client (*dma_event_callback) (struct dma_client *client,
202 * @event_callback: func ptr to call when something happens 247 * @event_callback: func ptr to call when something happens
203 * @cap_mask: only return channels that satisfy the requested capabilities 248 * @cap_mask: only return channels that satisfy the requested capabilities
204 * a value of zero corresponds to any capability 249 * a value of zero corresponds to any capability
250 * @slave: data for preparing slave transfer. Must be non-NULL iff the
251 * DMA_SLAVE capability is requested.
205 * @global_node: list_head for global dma_client_list 252 * @global_node: list_head for global dma_client_list
206 */ 253 */
207struct dma_client { 254struct dma_client {
208 dma_event_callback event_callback; 255 dma_event_callback event_callback;
209 dma_cap_mask_t cap_mask; 256 dma_cap_mask_t cap_mask;
257 struct dma_slave *slave;
210 struct list_head global_node; 258 struct list_head global_node;
211}; 259};
212 260
@@ -263,6 +311,8 @@ struct dma_async_tx_descriptor {
263 * @device_prep_dma_zero_sum: prepares a zero_sum operation 311 * @device_prep_dma_zero_sum: prepares a zero_sum operation
264 * @device_prep_dma_memset: prepares a memset operation 312 * @device_prep_dma_memset: prepares a memset operation
265 * @device_prep_dma_interrupt: prepares an end of chain interrupt operation 313 * @device_prep_dma_interrupt: prepares an end of chain interrupt operation
314 * @device_prep_slave_sg: prepares a slave dma operation
315 * @device_terminate_all: terminate all pending operations
266 * @device_issue_pending: push pending transactions to hardware 316 * @device_issue_pending: push pending transactions to hardware
267 */ 317 */
268struct dma_device { 318struct dma_device {
@@ -279,7 +329,8 @@ struct dma_device {
279 int dev_id; 329 int dev_id;
280 struct device *dev; 330 struct device *dev;
281 331
282 int (*device_alloc_chan_resources)(struct dma_chan *chan); 332 int (*device_alloc_chan_resources)(struct dma_chan *chan,
333 struct dma_client *client);
283 void (*device_free_chan_resources)(struct dma_chan *chan); 334 void (*device_free_chan_resources)(struct dma_chan *chan);
284 335
285 struct dma_async_tx_descriptor *(*device_prep_dma_memcpy)( 336 struct dma_async_tx_descriptor *(*device_prep_dma_memcpy)(
@@ -297,6 +348,12 @@ struct dma_device {
297 struct dma_async_tx_descriptor *(*device_prep_dma_interrupt)( 348 struct dma_async_tx_descriptor *(*device_prep_dma_interrupt)(
298 struct dma_chan *chan, unsigned long flags); 349 struct dma_chan *chan, unsigned long flags);
299 350
351 struct dma_async_tx_descriptor *(*device_prep_slave_sg)(
352 struct dma_chan *chan, struct scatterlist *sgl,
353 unsigned int sg_len, enum dma_data_direction direction,
354 unsigned long flags);
355 void (*device_terminate_all)(struct dma_chan *chan);
356
300 enum dma_status (*device_is_tx_complete)(struct dma_chan *chan, 357 enum dma_status (*device_is_tx_complete)(struct dma_chan *chan,
301 dma_cookie_t cookie, dma_cookie_t *last, 358 dma_cookie_t cookie, dma_cookie_t *last,
302 dma_cookie_t *used); 359 dma_cookie_t *used);
@@ -318,16 +375,14 @@ dma_cookie_t dma_async_memcpy_pg_to_pg(struct dma_chan *chan,
318void dma_async_tx_descriptor_init(struct dma_async_tx_descriptor *tx, 375void dma_async_tx_descriptor_init(struct dma_async_tx_descriptor *tx,
319 struct dma_chan *chan); 376 struct dma_chan *chan);
320 377
321static inline void 378static inline void async_tx_ack(struct dma_async_tx_descriptor *tx)
322async_tx_ack(struct dma_async_tx_descriptor *tx)
323{ 379{
324 tx->flags |= DMA_CTRL_ACK; 380 tx->flags |= DMA_CTRL_ACK;
325} 381}
326 382
327static inline int 383static inline bool async_tx_test_ack(struct dma_async_tx_descriptor *tx)
328async_tx_test_ack(struct dma_async_tx_descriptor *tx)
329{ 384{
330 return tx->flags & DMA_CTRL_ACK; 385 return (tx->flags & DMA_CTRL_ACK) == DMA_CTRL_ACK;
331} 386}
332 387
333#define first_dma_cap(mask) __first_dma_cap(&(mask)) 388#define first_dma_cap(mask) __first_dma_cap(&(mask))
diff --git a/include/linux/dmar.h b/include/linux/dmar.h
index 56c73b847551..f1984fc3e06d 100644
--- a/include/linux/dmar.h
+++ b/include/linux/dmar.h
@@ -25,9 +25,98 @@
25#include <linux/types.h> 25#include <linux/types.h>
26#include <linux/msi.h> 26#include <linux/msi.h>
27 27
28#ifdef CONFIG_DMAR 28#if defined(CONFIG_DMAR) || defined(CONFIG_INTR_REMAP)
29struct intel_iommu; 29struct intel_iommu;
30 30
31struct dmar_drhd_unit {
32 struct list_head list; /* list of drhd units */
33 struct acpi_dmar_header *hdr; /* ACPI header */
34 u64 reg_base_addr; /* register base address*/
35 struct pci_dev **devices; /* target device array */
36 int devices_cnt; /* target device count */
37 u8 ignored:1; /* ignore drhd */
38 u8 include_all:1;
39 struct intel_iommu *iommu;
40};
41
42extern struct list_head dmar_drhd_units;
43
44#define for_each_drhd_unit(drhd) \
45 list_for_each_entry(drhd, &dmar_drhd_units, list)
46
47extern int dmar_table_init(void);
48extern int dmar_dev_scope_init(void);
49
50/* Intel IOMMU detection */
51extern void detect_intel_iommu(void);
52
53
54extern int parse_ioapics_under_ir(void);
55extern int alloc_iommu(struct dmar_drhd_unit *);
56#else
57static inline void detect_intel_iommu(void)
58{
59 return;
60}
61
62static inline int dmar_table_init(void)
63{
64 return -ENODEV;
65}
66#endif /* !CONFIG_DMAR && !CONFIG_INTR_REMAP */
67
68#ifdef CONFIG_INTR_REMAP
69extern int intr_remapping_enabled;
70extern int enable_intr_remapping(int);
71
72struct irte {
73 union {
74 struct {
75 __u64 present : 1,
76 fpd : 1,
77 dst_mode : 1,
78 redir_hint : 1,
79 trigger_mode : 1,
80 dlvry_mode : 3,
81 avail : 4,
82 __reserved_1 : 4,
83 vector : 8,
84 __reserved_2 : 8,
85 dest_id : 32;
86 };
87 __u64 low;
88 };
89
90 union {
91 struct {
92 __u64 sid : 16,
93 sq : 2,
94 svt : 2,
95 __reserved_3 : 44;
96 };
97 __u64 high;
98 };
99};
100extern int get_irte(int irq, struct irte *entry);
101extern int modify_irte(int irq, struct irte *irte_modified);
102extern int alloc_irte(struct intel_iommu *iommu, int irq, u16 count);
103extern int set_irte_irq(int irq, struct intel_iommu *iommu, u16 index,
104 u16 sub_handle);
105extern int map_irq_to_irte_handle(int irq, u16 *sub_handle);
106extern int clear_irte_irq(int irq, struct intel_iommu *iommu, u16 index);
107extern int flush_irte(int irq);
108extern int free_irte(int irq);
109
110extern int irq_remapped(int irq);
111extern struct intel_iommu *map_dev_to_ir(struct pci_dev *dev);
112extern struct intel_iommu *map_ioapic_to_ir(int apic);
113#else
114#define irq_remapped(irq) (0)
115#define enable_intr_remapping(mode) (-1)
116#define intr_remapping_enabled (0)
117#endif
118
119#ifdef CONFIG_DMAR
31extern const char *dmar_get_fault_reason(u8 fault_reason); 120extern const char *dmar_get_fault_reason(u8 fault_reason);
32 121
33/* Can't use the common MSI interrupt functions 122/* Can't use the common MSI interrupt functions
@@ -40,47 +129,30 @@ extern void dmar_msi_write(int irq, struct msi_msg *msg);
40extern int dmar_set_interrupt(struct intel_iommu *iommu); 129extern int dmar_set_interrupt(struct intel_iommu *iommu);
41extern int arch_setup_dmar_msi(unsigned int irq); 130extern int arch_setup_dmar_msi(unsigned int irq);
42 131
43/* Intel IOMMU detection and initialization functions */ 132extern int iommu_detected, no_iommu;
44extern void detect_intel_iommu(void);
45extern int intel_iommu_init(void);
46
47extern int dmar_table_init(void);
48extern int early_dmar_detect(void);
49
50extern struct list_head dmar_drhd_units;
51extern struct list_head dmar_rmrr_units; 133extern struct list_head dmar_rmrr_units;
52
53struct dmar_drhd_unit {
54 struct list_head list; /* list of drhd units */
55 u64 reg_base_addr; /* register base address*/
56 struct pci_dev **devices; /* target device array */
57 int devices_cnt; /* target device count */
58 u8 ignored:1; /* ignore drhd */
59 u8 include_all:1;
60 struct intel_iommu *iommu;
61};
62
63struct dmar_rmrr_unit { 134struct dmar_rmrr_unit {
64 struct list_head list; /* list of rmrr units */ 135 struct list_head list; /* list of rmrr units */
136 struct acpi_dmar_header *hdr; /* ACPI header */
65 u64 base_address; /* reserved base address*/ 137 u64 base_address; /* reserved base address*/
66 u64 end_address; /* reserved end address */ 138 u64 end_address; /* reserved end address */
67 struct pci_dev **devices; /* target devices */ 139 struct pci_dev **devices; /* target devices */
68 int devices_cnt; /* target device count */ 140 int devices_cnt; /* target device count */
69}; 141};
70 142
71#define for_each_drhd_unit(drhd) \
72 list_for_each_entry(drhd, &dmar_drhd_units, list)
73#define for_each_rmrr_units(rmrr) \ 143#define for_each_rmrr_units(rmrr) \
74 list_for_each_entry(rmrr, &dmar_rmrr_units, list) 144 list_for_each_entry(rmrr, &dmar_rmrr_units, list)
145/* Intel DMAR initialization functions */
146extern int intel_iommu_init(void);
147extern int dmar_disabled;
75#else 148#else
76static inline void detect_intel_iommu(void)
77{
78 return;
79}
80static inline int intel_iommu_init(void) 149static inline int intel_iommu_init(void)
81{ 150{
151#ifdef CONFIG_INTR_REMAP
152 return dmar_dev_scope_init();
153#else
82 return -ENODEV; 154 return -ENODEV;
155#endif
83} 156}
84
85#endif /* !CONFIG_DMAR */ 157#endif /* !CONFIG_DMAR */
86#endif /* __DMAR_H__ */ 158#endif /* __DMAR_H__ */
diff --git a/include/linux/dmi.h b/include/linux/dmi.h
index 2a063b64133f..e5084eb5943a 100644
--- a/include/linux/dmi.h
+++ b/include/linux/dmi.h
@@ -2,29 +2,9 @@
2#define __DMI_H__ 2#define __DMI_H__
3 3
4#include <linux/list.h> 4#include <linux/list.h>
5#include <linux/mod_devicetable.h>
5 6
6enum dmi_field { 7/* enum dmi_field is in mod_devicetable.h */
7 DMI_NONE,
8 DMI_BIOS_VENDOR,
9 DMI_BIOS_VERSION,
10 DMI_BIOS_DATE,
11 DMI_SYS_VENDOR,
12 DMI_PRODUCT_NAME,
13 DMI_PRODUCT_VERSION,
14 DMI_PRODUCT_SERIAL,
15 DMI_PRODUCT_UUID,
16 DMI_BOARD_VENDOR,
17 DMI_BOARD_NAME,
18 DMI_BOARD_VERSION,
19 DMI_BOARD_SERIAL,
20 DMI_BOARD_ASSET_TAG,
21 DMI_CHASSIS_VENDOR,
22 DMI_CHASSIS_TYPE,
23 DMI_CHASSIS_VERSION,
24 DMI_CHASSIS_SERIAL,
25 DMI_CHASSIS_ASSET_TAG,
26 DMI_STRING_MAX,
27};
28 8
29enum dmi_device_type { 9enum dmi_device_type {
30 DMI_DEV_TYPE_ANY = 0, 10 DMI_DEV_TYPE_ANY = 0,
@@ -48,23 +28,6 @@ struct dmi_header {
48 u16 handle; 28 u16 handle;
49}; 29};
50 30
51/*
52 * DMI callbacks for problem boards
53 */
54struct dmi_strmatch {
55 u8 slot;
56 char *substr;
57};
58
59struct dmi_system_id {
60 int (*callback)(const struct dmi_system_id *);
61 const char *ident;
62 struct dmi_strmatch matches[4];
63 void *driver_data;
64};
65
66#define DMI_MATCH(a, b) { a, b }
67
68struct dmi_device { 31struct dmi_device {
69 struct list_head list; 32 struct list_head list;
70 int type; 33 int type;
diff --git a/include/linux/ds1286.h b/include/linux/ds1286.h
index d8989860e4ce..45ea0aa0aeb9 100644
--- a/include/linux/ds1286.h
+++ b/include/linux/ds1286.h
@@ -8,8 +8,6 @@
8#ifndef __LINUX_DS1286_H 8#ifndef __LINUX_DS1286_H
9#define __LINUX_DS1286_H 9#define __LINUX_DS1286_H
10 10
11#include <asm/ds1286.h>
12
13/********************************************************************** 11/**********************************************************************
14 * register summary 12 * register summary
15 **********************************************************************/ 13 **********************************************************************/
diff --git a/include/linux/dvb/frontend.h b/include/linux/dvb/frontend.h
index c8cbd90ba375..79a8ed8e6a7d 100644
--- a/include/linux/dvb/frontend.h
+++ b/include/linux/dvb/frontend.h
@@ -62,6 +62,7 @@ typedef enum fe_caps {
62 FE_CAN_HIERARCHY_AUTO = 0x100000, 62 FE_CAN_HIERARCHY_AUTO = 0x100000,
63 FE_CAN_8VSB = 0x200000, 63 FE_CAN_8VSB = 0x200000,
64 FE_CAN_16VSB = 0x400000, 64 FE_CAN_16VSB = 0x400000,
65 FE_HAS_EXTENDED_CAPS = 0x800000, // We need more bitspace for newer APIs, indicate this.
65 FE_NEEDS_BENDING = 0x20000000, // not supported anymore, don't use (frontend requires frequency bending) 66 FE_NEEDS_BENDING = 0x20000000, // not supported anymore, don't use (frontend requires frequency bending)
66 FE_CAN_RECOVER = 0x40000000, // frontend can recover from a cable unplug automatically 67 FE_CAN_RECOVER = 0x40000000, // frontend can recover from a cable unplug automatically
67 FE_CAN_MUTE_TS = 0x80000000 // frontend can stop spurious TS data output 68 FE_CAN_MUTE_TS = 0x80000000 // frontend can stop spurious TS data output
@@ -147,7 +148,9 @@ typedef enum fe_code_rate {
147 FEC_6_7, 148 FEC_6_7,
148 FEC_7_8, 149 FEC_7_8,
149 FEC_8_9, 150 FEC_8_9,
150 FEC_AUTO 151 FEC_AUTO,
152 FEC_3_5,
153 FEC_9_10,
151} fe_code_rate_t; 154} fe_code_rate_t;
152 155
153 156
@@ -160,7 +163,11 @@ typedef enum fe_modulation {
160 QAM_256, 163 QAM_256,
161 QAM_AUTO, 164 QAM_AUTO,
162 VSB_8, 165 VSB_8,
163 VSB_16 166 VSB_16,
167 PSK_8,
168 APSK_16,
169 APSK_32,
170 DQPSK,
164} fe_modulation_t; 171} fe_modulation_t;
165 172
166typedef enum fe_transmit_mode { 173typedef enum fe_transmit_mode {
@@ -239,6 +246,107 @@ struct dvb_frontend_event {
239 struct dvb_frontend_parameters parameters; 246 struct dvb_frontend_parameters parameters;
240}; 247};
241 248
249/* S2API Commands */
250#define DTV_UNDEFINED 0
251#define DTV_TUNE 1
252#define DTV_CLEAR 2
253#define DTV_FREQUENCY 3
254#define DTV_MODULATION 4
255#define DTV_BANDWIDTH_HZ 5
256#define DTV_INVERSION 6
257#define DTV_DISEQC_MASTER 7
258#define DTV_SYMBOL_RATE 8
259#define DTV_INNER_FEC 9
260#define DTV_VOLTAGE 10
261#define DTV_TONE 11
262#define DTV_PILOT 12
263#define DTV_ROLLOFF 13
264#define DTV_DISEQC_SLAVE_REPLY 14
265
266/* Basic enumeration set for querying unlimited capabilities */
267#define DTV_FE_CAPABILITY_COUNT 15
268#define DTV_FE_CAPABILITY 16
269#define DTV_DELIVERY_SYSTEM 17
270
271#define DTV_API_VERSION 35
272#define DTV_API_VERSION 35
273#define DTV_CODE_RATE_HP 36
274#define DTV_CODE_RATE_LP 37
275#define DTV_GUARD_INTERVAL 38
276#define DTV_TRANSMISSION_MODE 39
277#define DTV_HIERARCHY 40
278
279#define DTV_MAX_COMMAND DTV_HIERARCHY
280
281typedef enum fe_pilot {
282 PILOT_ON,
283 PILOT_OFF,
284 PILOT_AUTO,
285} fe_pilot_t;
286
287typedef enum fe_rolloff {
288 ROLLOFF_35, /* Implied value in DVB-S, default for DVB-S2 */
289 ROLLOFF_20,
290 ROLLOFF_25,
291 ROLLOFF_AUTO,
292} fe_rolloff_t;
293
294typedef enum fe_delivery_system {
295 SYS_UNDEFINED,
296 SYS_DVBC_ANNEX_AC,
297 SYS_DVBC_ANNEX_B,
298 SYS_DVBT,
299 SYS_DSS,
300 SYS_DVBS,
301 SYS_DVBS2,
302 SYS_DVBH,
303 SYS_ISDBT,
304 SYS_ISDBS,
305 SYS_ISDBC,
306 SYS_ATSC,
307 SYS_ATSCMH,
308 SYS_DMBTH,
309 SYS_CMMB,
310 SYS_DAB,
311} fe_delivery_system_t;
312
313struct dtv_cmds_h {
314 char *name; /* A display name for debugging purposes */
315
316 __u32 cmd; /* A unique ID */
317
318 /* Flags */
319 __u32 set:1; /* Either a set or get property */
320 __u32 buffer:1; /* Does this property use the buffer? */
321 __u32 reserved:30; /* Align */
322};
323
324struct dtv_property {
325 __u32 cmd;
326 __u32 reserved[3];
327 union {
328 __u32 data;
329 struct {
330 __u8 data[32];
331 __u32 len;
332 __u32 reserved1[3];
333 void *reserved2;
334 } buffer;
335 } u;
336 int result;
337} __attribute__ ((packed));
338
339/* num of properties cannot exceed DTV_IOCTL_MAX_MSGS per ioctl */
340#define DTV_IOCTL_MAX_MSGS 64
341
342struct dtv_properties {
343 __u32 num;
344 struct dtv_property *props;
345};
346
347#define FE_SET_PROPERTY _IOW('o', 82, struct dtv_properties)
348#define FE_GET_PROPERTY _IOR('o', 83, struct dtv_properties)
349
242 350
243/** 351/**
244 * When set, this flag will disable any zigzagging or other "normal" tuning 352 * When set, this flag will disable any zigzagging or other "normal" tuning
diff --git a/include/linux/dvb/version.h b/include/linux/dvb/version.h
index 126e0c26cb09..25b823b81734 100644
--- a/include/linux/dvb/version.h
+++ b/include/linux/dvb/version.h
@@ -23,7 +23,7 @@
23#ifndef _DVBVERSION_H_ 23#ifndef _DVBVERSION_H_
24#define _DVBVERSION_H_ 24#define _DVBVERSION_H_
25 25
26#define DVB_API_VERSION 3 26#define DVB_API_VERSION 5
27#define DVB_API_VERSION_MINOR 2 27#define DVB_API_VERSION_MINOR 0
28 28
29#endif /*_DVBVERSION_H_*/ 29#endif /*_DVBVERSION_H_*/
diff --git a/include/linux/dw_dmac.h b/include/linux/dw_dmac.h
new file mode 100644
index 000000000000..04d217b442bf
--- /dev/null
+++ b/include/linux/dw_dmac.h
@@ -0,0 +1,62 @@
1/*
2 * Driver for the Synopsys DesignWare DMA Controller (aka DMACA on
3 * AVR32 systems.)
4 *
5 * Copyright (C) 2007 Atmel Corporation
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#ifndef DW_DMAC_H
12#define DW_DMAC_H
13
14#include <linux/dmaengine.h>
15
16/**
17 * struct dw_dma_platform_data - Controller configuration parameters
18 * @nr_channels: Number of channels supported by hardware (max 8)
19 */
20struct dw_dma_platform_data {
21 unsigned int nr_channels;
22};
23
24/**
25 * struct dw_dma_slave - Controller-specific information about a slave
26 * @slave: Generic information about the slave
27 * @ctl_lo: Platform-specific initializer for the CTL_LO register
28 * @cfg_hi: Platform-specific initializer for the CFG_HI register
29 * @cfg_lo: Platform-specific initializer for the CFG_LO register
30 */
31struct dw_dma_slave {
32 struct dma_slave slave;
33 u32 cfg_hi;
34 u32 cfg_lo;
35};
36
37/* Platform-configurable bits in CFG_HI */
38#define DWC_CFGH_FCMODE (1 << 0)
39#define DWC_CFGH_FIFO_MODE (1 << 1)
40#define DWC_CFGH_PROTCTL(x) ((x) << 2)
41#define DWC_CFGH_SRC_PER(x) ((x) << 7)
42#define DWC_CFGH_DST_PER(x) ((x) << 11)
43
44/* Platform-configurable bits in CFG_LO */
45#define DWC_CFGL_PRIO(x) ((x) << 5) /* priority */
46#define DWC_CFGL_LOCK_CH_XFER (0 << 12) /* scope of LOCK_CH */
47#define DWC_CFGL_LOCK_CH_BLOCK (1 << 12)
48#define DWC_CFGL_LOCK_CH_XACT (2 << 12)
49#define DWC_CFGL_LOCK_BUS_XFER (0 << 14) /* scope of LOCK_BUS */
50#define DWC_CFGL_LOCK_BUS_BLOCK (1 << 14)
51#define DWC_CFGL_LOCK_BUS_XACT (2 << 14)
52#define DWC_CFGL_LOCK_CH (1 << 15) /* channel lockout */
53#define DWC_CFGL_LOCK_BUS (1 << 16) /* busmaster lockout */
54#define DWC_CFGL_HS_DST_POL (1 << 18) /* dst handshake active low */
55#define DWC_CFGL_HS_SRC_POL (1 << 19) /* src handshake active low */
56
57static inline struct dw_dma_slave *to_dw_dma_slave(struct dma_slave *slave)
58{
59 return container_of(slave, struct dw_dma_slave, slave);
60}
61
62#endif /* DW_DMAC_H */
diff --git a/include/linux/dynamic_printk.h b/include/linux/dynamic_printk.h
new file mode 100644
index 000000000000..2d528d009074
--- /dev/null
+++ b/include/linux/dynamic_printk.h
@@ -0,0 +1,93 @@
1#ifndef _DYNAMIC_PRINTK_H
2#define _DYNAMIC_PRINTK_H
3
4#define DYNAMIC_DEBUG_HASH_BITS 6
5#define DEBUG_HASH_TABLE_SIZE (1 << DYNAMIC_DEBUG_HASH_BITS)
6
7#define TYPE_BOOLEAN 1
8
9#define DYNAMIC_ENABLED_ALL 0
10#define DYNAMIC_ENABLED_NONE 1
11#define DYNAMIC_ENABLED_SOME 2
12
13extern int dynamic_enabled;
14
15/* dynamic_printk_enabled, and dynamic_printk_enabled2 are bitmasks in which
16 * bit n is set to 1 if any modname hashes into the bucket n, 0 otherwise. They
17 * use independent hash functions, to reduce the chance of false positives.
18 */
19extern long long dynamic_printk_enabled;
20extern long long dynamic_printk_enabled2;
21
22struct mod_debug {
23 char *modname;
24 char *logical_modname;
25 char *flag_names;
26 int type;
27 int hash;
28 int hash2;
29} __attribute__((aligned(8)));
30
31int register_dynamic_debug_module(char *mod_name, int type, char *share_name,
32 char *flags, int hash, int hash2);
33
34#if defined(CONFIG_DYNAMIC_PRINTK_DEBUG)
35extern int unregister_dynamic_debug_module(char *mod_name);
36extern int __dynamic_dbg_enabled_helper(char *modname, int type,
37 int value, int hash);
38
39#define __dynamic_dbg_enabled(module, type, value, level, hash) ({ \
40 int __ret = 0; \
41 if (unlikely((dynamic_printk_enabled & (1LL << DEBUG_HASH)) && \
42 (dynamic_printk_enabled2 & (1LL << DEBUG_HASH2)))) \
43 __ret = __dynamic_dbg_enabled_helper(module, type, \
44 value, hash);\
45 __ret; })
46
47#define dynamic_pr_debug(fmt, ...) do { \
48 static char mod_name[] \
49 __attribute__((section("__verbose_strings"))) \
50 = KBUILD_MODNAME; \
51 static struct mod_debug descriptor \
52 __used \
53 __attribute__((section("__verbose"), aligned(8))) = \
54 { mod_name, mod_name, NULL, TYPE_BOOLEAN, DEBUG_HASH, DEBUG_HASH2 };\
55 if (__dynamic_dbg_enabled(KBUILD_MODNAME, TYPE_BOOLEAN, \
56 0, 0, DEBUG_HASH)) \
57 printk(KERN_DEBUG KBUILD_MODNAME ":" fmt, \
58 ##__VA_ARGS__); \
59 } while (0)
60
61#define dynamic_dev_dbg(dev, format, ...) do { \
62 static char mod_name[] \
63 __attribute__((section("__verbose_strings"))) \
64 = KBUILD_MODNAME; \
65 static struct mod_debug descriptor \
66 __used \
67 __attribute__((section("__verbose"), aligned(8))) = \
68 { mod_name, mod_name, NULL, TYPE_BOOLEAN, DEBUG_HASH, DEBUG_HASH2 };\
69 if (__dynamic_dbg_enabled(KBUILD_MODNAME, TYPE_BOOLEAN, \
70 0, 0, DEBUG_HASH)) \
71 dev_printk(KERN_DEBUG, dev, \
72 KBUILD_MODNAME ": " format, \
73 ##__VA_ARGS__); \
74 } while (0)
75
76#else
77
78static inline int unregister_dynamic_debug_module(const char *mod_name)
79{
80 return 0;
81}
82static inline int __dynamic_dbg_enabled_helper(char *modname, int type,
83 int value, int hash)
84{
85 return 0;
86}
87
88#define __dynamic_dbg_enabled(module, type, value, level, hash) ({ 0; })
89#define dynamic_pr_debug(fmt, ...) do { } while (0)
90#define dynamic_dev_dbg(dev, format, ...) do { } while (0)
91#endif
92
93#endif
diff --git a/include/linux/efi.h b/include/linux/efi.h
index 807373d467f7..bb66feb164bd 100644
--- a/include/linux/efi.h
+++ b/include/linux/efi.h
@@ -208,6 +208,9 @@ typedef efi_status_t efi_set_virtual_address_map_t (unsigned long memory_map_siz
208#define EFI_GLOBAL_VARIABLE_GUID \ 208#define EFI_GLOBAL_VARIABLE_GUID \
209 EFI_GUID( 0x8be4df61, 0x93ca, 0x11d2, 0xaa, 0x0d, 0x00, 0xe0, 0x98, 0x03, 0x2b, 0x8c ) 209 EFI_GUID( 0x8be4df61, 0x93ca, 0x11d2, 0xaa, 0x0d, 0x00, 0xe0, 0x98, 0x03, 0x2b, 0x8c )
210 210
211#define UV_SYSTEM_TABLE_GUID \
212 EFI_GUID( 0x3b13a7d4, 0x633e, 0x11dd, 0x93, 0xec, 0xda, 0x25, 0x56, 0xd8, 0x95, 0x93 )
213
211typedef struct { 214typedef struct {
212 efi_guid_t guid; 215 efi_guid_t guid;
213 unsigned long table; 216 unsigned long table;
@@ -255,6 +258,7 @@ extern struct efi {
255 unsigned long boot_info; /* boot info table */ 258 unsigned long boot_info; /* boot info table */
256 unsigned long hcdp; /* HCDP table */ 259 unsigned long hcdp; /* HCDP table */
257 unsigned long uga; /* UGA table */ 260 unsigned long uga; /* UGA table */
261 unsigned long uv_systab; /* UV system table */
258 efi_get_time_t *get_time; 262 efi_get_time_t *get_time;
259 efi_set_time_t *set_time; 263 efi_set_time_t *set_time;
260 efi_get_wakeup_time_t *get_wakeup_time; 264 efi_get_wakeup_time_t *get_wakeup_time;
diff --git a/include/linux/eisa.h b/include/linux/eisa.h
index fe806b6f030d..e61c0be2a459 100644
--- a/include/linux/eisa.h
+++ b/include/linux/eisa.h
@@ -40,7 +40,7 @@ struct eisa_device {
40 u64 dma_mask; 40 u64 dma_mask;
41 struct device dev; /* generic device */ 41 struct device dev; /* generic device */
42#ifdef CONFIG_EISA_NAMES 42#ifdef CONFIG_EISA_NAMES
43 char pretty_name[DEVICE_NAME_SIZE]; 43 char pretty_name[50];
44#endif 44#endif
45}; 45};
46 46
diff --git a/include/linux/elevator.h b/include/linux/elevator.h
index 639624b55fbe..92f6f634e3e6 100644
--- a/include/linux/elevator.h
+++ b/include/linux/elevator.h
@@ -112,6 +112,7 @@ extern struct request *elv_latter_request(struct request_queue *, struct request
112extern int elv_register_queue(struct request_queue *q); 112extern int elv_register_queue(struct request_queue *q);
113extern void elv_unregister_queue(struct request_queue *q); 113extern void elv_unregister_queue(struct request_queue *q);
114extern int elv_may_queue(struct request_queue *, int); 114extern int elv_may_queue(struct request_queue *, int);
115extern void elv_abort_queue(struct request_queue *);
115extern void elv_completed_request(struct request_queue *, struct request *); 116extern void elv_completed_request(struct request_queue *, struct request *);
116extern int elv_set_request(struct request_queue *, struct request *, gfp_t); 117extern int elv_set_request(struct request_queue *, struct request *, gfp_t);
117extern void elv_put_request(struct request_queue *, struct request *); 118extern void elv_put_request(struct request_queue *, struct request *);
@@ -173,15 +174,15 @@ enum {
173#define rb_entry_rq(node) rb_entry((node), struct request, rb_node) 174#define rb_entry_rq(node) rb_entry((node), struct request, rb_node)
174 175
175/* 176/*
176 * Hack to reuse the donelist list_head as the fifo time holder while 177 * Hack to reuse the csd.list list_head as the fifo time holder while
177 * the request is in the io scheduler. Saves an unsigned long in rq. 178 * the request is in the io scheduler. Saves an unsigned long in rq.
178 */ 179 */
179#define rq_fifo_time(rq) ((unsigned long) (rq)->donelist.next) 180#define rq_fifo_time(rq) ((unsigned long) (rq)->csd.list.next)
180#define rq_set_fifo_time(rq,exp) ((rq)->donelist.next = (void *) (exp)) 181#define rq_set_fifo_time(rq,exp) ((rq)->csd.list.next = (void *) (exp))
181#define rq_entry_fifo(ptr) list_entry((ptr), struct request, queuelist) 182#define rq_entry_fifo(ptr) list_entry((ptr), struct request, queuelist)
182#define rq_fifo_clear(rq) do { \ 183#define rq_fifo_clear(rq) do { \
183 list_del_init(&(rq)->queuelist); \ 184 list_del_init(&(rq)->queuelist); \
184 INIT_LIST_HEAD(&(rq)->donelist); \ 185 INIT_LIST_HEAD(&(rq)->csd.list); \
185 } while (0) 186 } while (0)
186 187
187/* 188/*
diff --git a/include/linux/elf.h b/include/linux/elf.h
index edc3dac3f02f..0b61ca41a044 100644
--- a/include/linux/elf.h
+++ b/include/linux/elf.h
@@ -360,6 +360,7 @@ typedef struct elf64_shdr {
360#define NT_PPC_SPE 0x101 /* PowerPC SPE/EVR registers */ 360#define NT_PPC_SPE 0x101 /* PowerPC SPE/EVR registers */
361#define NT_PPC_VSX 0x102 /* PowerPC VSX registers */ 361#define NT_PPC_VSX 0x102 /* PowerPC VSX registers */
362#define NT_386_TLS 0x200 /* i386 TLS slots (struct user_desc) */ 362#define NT_386_TLS 0x200 /* i386 TLS slots (struct user_desc) */
363#define NT_386_IOPERM 0x201 /* x86 io permission bitmap (1=deny) */
363 364
364 365
365/* Note header in a PT_NOTE section */ 366/* Note header in a PT_NOTE section */
diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
index c8d216357865..b4b038b89ee6 100644
--- a/include/linux/ethtool.h
+++ b/include/linux/ethtool.h
@@ -27,9 +27,24 @@ struct ethtool_cmd {
27 __u8 autoneg; /* Enable or disable autonegotiation */ 27 __u8 autoneg; /* Enable or disable autonegotiation */
28 __u32 maxtxpkt; /* Tx pkts before generating tx int */ 28 __u32 maxtxpkt; /* Tx pkts before generating tx int */
29 __u32 maxrxpkt; /* Rx pkts before generating rx int */ 29 __u32 maxrxpkt; /* Rx pkts before generating rx int */
30 __u32 reserved[4]; 30 __u16 speed_hi;
31 __u16 reserved2;
32 __u32 reserved[3];
31}; 33};
32 34
35static inline void ethtool_cmd_speed_set(struct ethtool_cmd *ep,
36 __u32 speed)
37{
38
39 ep->speed = (__u16)speed;
40 ep->speed_hi = (__u16)(speed >> 16);
41}
42
43static inline __u32 ethtool_cmd_speed(struct ethtool_cmd *ep)
44{
45 return (ep->speed_hi << 16) | ep->speed;
46}
47
33#define ETHTOOL_BUSINFO_LEN 32 48#define ETHTOOL_BUSINFO_LEN 32
34/* these strings are set to whatever the driver author decides... */ 49/* these strings are set to whatever the driver author decides... */
35struct ethtool_drvinfo { 50struct ethtool_drvinfo {
@@ -272,6 +287,12 @@ enum ethtool_flags {
272 ETH_FLAG_LRO = (1 << 15), /* LRO is enabled */ 287 ETH_FLAG_LRO = (1 << 15), /* LRO is enabled */
273}; 288};
274 289
290struct ethtool_rxnfc {
291 __u32 cmd;
292 __u32 flow_type;
293 __u64 data;
294};
295
275#ifdef __KERNEL__ 296#ifdef __KERNEL__
276 297
277struct net_device; 298struct net_device;
@@ -396,6 +417,8 @@ struct ethtool_ops {
396 /* the following hooks are obsolete */ 417 /* the following hooks are obsolete */
397 int (*self_test_count)(struct net_device *);/* use get_sset_count */ 418 int (*self_test_count)(struct net_device *);/* use get_sset_count */
398 int (*get_stats_count)(struct net_device *);/* use get_sset_count */ 419 int (*get_stats_count)(struct net_device *);/* use get_sset_count */
420 int (*get_rxhash)(struct net_device *, struct ethtool_rxnfc *);
421 int (*set_rxhash)(struct net_device *, struct ethtool_rxnfc *);
399}; 422};
400#endif /* __KERNEL__ */ 423#endif /* __KERNEL__ */
401 424
@@ -442,6 +465,9 @@ struct ethtool_ops {
442#define ETHTOOL_GPFLAGS 0x00000027 /* Get driver-private flags bitmap */ 465#define ETHTOOL_GPFLAGS 0x00000027 /* Get driver-private flags bitmap */
443#define ETHTOOL_SPFLAGS 0x00000028 /* Set driver-private flags bitmap */ 466#define ETHTOOL_SPFLAGS 0x00000028 /* Set driver-private flags bitmap */
444 467
468#define ETHTOOL_GRXFH 0x00000029 /* Get RX flow hash configuration */
469#define ETHTOOL_SRXFH 0x0000002a /* Set RX flow hash configuration */
470
445/* compatibility with older code */ 471/* compatibility with older code */
446#define SPARC_ETH_GSET ETHTOOL_GSET 472#define SPARC_ETH_GSET ETHTOOL_GSET
447#define SPARC_ETH_SSET ETHTOOL_SSET 473#define SPARC_ETH_SSET ETHTOOL_SSET
@@ -528,4 +554,26 @@ struct ethtool_ops {
528#define WAKE_MAGIC (1 << 5) 554#define WAKE_MAGIC (1 << 5)
529#define WAKE_MAGICSECURE (1 << 6) /* only meaningful if WAKE_MAGIC */ 555#define WAKE_MAGICSECURE (1 << 6) /* only meaningful if WAKE_MAGIC */
530 556
557/* L3-L4 network traffic flow types */
558#define TCP_V4_FLOW 0x01
559#define UDP_V4_FLOW 0x02
560#define SCTP_V4_FLOW 0x03
561#define AH_ESP_V4_FLOW 0x04
562#define TCP_V6_FLOW 0x05
563#define UDP_V6_FLOW 0x06
564#define SCTP_V6_FLOW 0x07
565#define AH_ESP_V6_FLOW 0x08
566
567/* L3-L4 network traffic flow hash options */
568#define RXH_DEV_PORT (1 << 0)
569#define RXH_L2DA (1 << 1)
570#define RXH_VLAN (1 << 2)
571#define RXH_L3_PROTO (1 << 3)
572#define RXH_IP_SRC (1 << 4)
573#define RXH_IP_DST (1 << 5)
574#define RXH_L4_B_0_1 (1 << 6) /* src port in case of TCP/UDP/SCTP */
575#define RXH_L4_B_2_3 (1 << 7) /* dst port in case of TCP/UDP/SCTP */
576#define RXH_DISCARD (1 << 31)
577
578
531#endif /* _LINUX_ETHTOOL_H */ 579#endif /* _LINUX_ETHTOOL_H */
diff --git a/include/linux/eventfd.h b/include/linux/eventfd.h
index a701399b7fed..a667637b54e3 100644
--- a/include/linux/eventfd.h
+++ b/include/linux/eventfd.h
@@ -10,6 +10,13 @@
10 10
11#ifdef CONFIG_EVENTFD 11#ifdef CONFIG_EVENTFD
12 12
13/* For O_CLOEXEC and O_NONBLOCK */
14#include <linux/fcntl.h>
15
16/* Flags for eventfd2. */
17#define EFD_CLOEXEC O_CLOEXEC
18#define EFD_NONBLOCK O_NONBLOCK
19
13struct file *eventfd_fget(int fd); 20struct file *eventfd_fget(int fd);
14int eventfd_signal(struct file *file, int n); 21int eventfd_signal(struct file *file, int n);
15 22
diff --git a/include/linux/eventpoll.h b/include/linux/eventpoll.h
index cf79853967ff..f1e1d3c47125 100644
--- a/include/linux/eventpoll.h
+++ b/include/linux/eventpoll.h
@@ -14,8 +14,12 @@
14#ifndef _LINUX_EVENTPOLL_H 14#ifndef _LINUX_EVENTPOLL_H
15#define _LINUX_EVENTPOLL_H 15#define _LINUX_EVENTPOLL_H
16 16
17/* For O_CLOEXEC */
18#include <linux/fcntl.h>
17#include <linux/types.h> 19#include <linux/types.h>
18 20
21/* Flags for epoll_create1. */
22#define EPOLL_CLOEXEC O_CLOEXEC
19 23
20/* Valid opcodes to issue to sys_epoll_ctl() */ 24/* Valid opcodes to issue to sys_epoll_ctl() */
21#define EPOLL_CTL_ADD 1 25#define EPOLL_CTL_ADD 1
diff --git a/include/linux/exportfs.h b/include/linux/exportfs.h
index f5abd1306638..27e772cefb6a 100644
--- a/include/linux/exportfs.h
+++ b/include/linux/exportfs.h
@@ -35,6 +35,27 @@ enum fid_type {
35 FILEID_INO32_GEN_PARENT = 2, 35 FILEID_INO32_GEN_PARENT = 2,
36 36
37 /* 37 /*
38 * 64 bit object ID, 64 bit root object ID,
39 * 32 bit generation number.
40 */
41 FILEID_BTRFS_WITHOUT_PARENT = 0x4d,
42
43 /*
44 * 64 bit object ID, 64 bit root object ID,
45 * 32 bit generation number,
46 * 64 bit parent object ID, 32 bit parent generation.
47 */
48 FILEID_BTRFS_WITH_PARENT = 0x4e,
49
50 /*
51 * 64 bit object ID, 64 bit root object ID,
52 * 32 bit generation number,
53 * 64 bit parent object ID, 32 bit parent generation,
54 * 64 bit parent root object ID.
55 */
56 FILEID_BTRFS_WITH_PARENT_ROOT = 0x4f,
57
58 /*
38 * 32 bit block number, 16 bit partition reference, 59 * 32 bit block number, 16 bit partition reference,
39 * 16 bit unused, 32 bit generation number. 60 * 16 bit unused, 32 bit generation number.
40 */ 61 */
diff --git a/include/linux/ext2_fs.h b/include/linux/ext2_fs.h
index 84cec2aa9f1e..78c775a83f7c 100644
--- a/include/linux/ext2_fs.h
+++ b/include/linux/ext2_fs.h
@@ -47,7 +47,7 @@
47#ifdef EXT2FS_DEBUG 47#ifdef EXT2FS_DEBUG
48# define ext2_debug(f, a...) { \ 48# define ext2_debug(f, a...) { \
49 printk ("EXT2-fs DEBUG (%s, %d): %s:", \ 49 printk ("EXT2-fs DEBUG (%s, %d): %s:", \
50 __FILE__, __LINE__, __FUNCTION__); \ 50 __FILE__, __LINE__, __func__); \
51 printk (f, ## a); \ 51 printk (f, ## a); \
52 } 52 }
53#else 53#else
@@ -284,8 +284,8 @@ struct ext2_inode {
284 284
285#ifdef __hurd__ 285#ifdef __hurd__
286#define i_translator osd1.hurd1.h_i_translator 286#define i_translator osd1.hurd1.h_i_translator
287#define i_frag osd2.hurd2.h_i_frag; 287#define i_frag osd2.hurd2.h_i_frag
288#define i_fsize osd2.hurd2.h_i_fsize; 288#define i_fsize osd2.hurd2.h_i_fsize
289#define i_uid_high osd2.hurd2.h_i_uid_high 289#define i_uid_high osd2.hurd2.h_i_uid_high
290#define i_gid_high osd2.hurd2.h_i_gid_high 290#define i_gid_high osd2.hurd2.h_i_gid_high
291#define i_author osd2.hurd2.h_i_author 291#define i_author osd2.hurd2.h_i_author
diff --git a/include/linux/ext3_fs.h b/include/linux/ext3_fs.h
index 36c540396377..d14f02918483 100644
--- a/include/linux/ext3_fs.h
+++ b/include/linux/ext3_fs.h
@@ -43,7 +43,7 @@
43#define ext3_debug(f, a...) \ 43#define ext3_debug(f, a...) \
44 do { \ 44 do { \
45 printk (KERN_DEBUG "EXT3-fs DEBUG (%s, %d): %s:", \ 45 printk (KERN_DEBUG "EXT3-fs DEBUG (%s, %d): %s:", \
46 __FILE__, __LINE__, __FUNCTION__); \ 46 __FILE__, __LINE__, __func__); \
47 printk (KERN_DEBUG f, ## a); \ 47 printk (KERN_DEBUG f, ## a); \
48 } while (0) 48 } while (0)
49#else 49#else
@@ -380,6 +380,8 @@ struct ext3_inode {
380#define EXT3_MOUNT_QUOTA 0x80000 /* Some quota option set */ 380#define EXT3_MOUNT_QUOTA 0x80000 /* Some quota option set */
381#define EXT3_MOUNT_USRQUOTA 0x100000 /* "old" user quota */ 381#define EXT3_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
382#define EXT3_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */ 382#define EXT3_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
383#define EXT3_MOUNT_DATA_ERR_ABORT 0x400000 /* Abort on file data write
384 * error in ordered mode */
383 385
384/* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */ 386/* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
385#ifndef _LINUX_EXT2_FS_H 387#ifndef _LINUX_EXT2_FS_H
@@ -832,10 +834,13 @@ extern void ext3_discard_reservation (struct inode *);
832extern void ext3_dirty_inode(struct inode *); 834extern void ext3_dirty_inode(struct inode *);
833extern int ext3_change_inode_journal_flag(struct inode *, int); 835extern int ext3_change_inode_journal_flag(struct inode *, int);
834extern int ext3_get_inode_loc(struct inode *, struct ext3_iloc *); 836extern int ext3_get_inode_loc(struct inode *, struct ext3_iloc *);
837extern int ext3_can_truncate(struct inode *inode);
835extern void ext3_truncate (struct inode *); 838extern void ext3_truncate (struct inode *);
836extern void ext3_set_inode_flags(struct inode *); 839extern void ext3_set_inode_flags(struct inode *);
837extern void ext3_get_inode_flags(struct ext3_inode_info *); 840extern void ext3_get_inode_flags(struct ext3_inode_info *);
838extern void ext3_set_aops(struct inode *inode); 841extern void ext3_set_aops(struct inode *inode);
842extern int ext3_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
843 u64 start, u64 len);
839 844
840/* ioctl.c */ 845/* ioctl.c */
841extern int ext3_ioctl (struct inode *, struct file *, unsigned int, 846extern int ext3_ioctl (struct inode *, struct file *, unsigned int,
@@ -868,7 +873,7 @@ extern void ext3_update_dynamic_rev (struct super_block *sb);
868#define ext3_std_error(sb, errno) \ 873#define ext3_std_error(sb, errno) \
869do { \ 874do { \
870 if ((errno)) \ 875 if ((errno)) \
871 __ext3_std_error((sb), __FUNCTION__, (errno)); \ 876 __ext3_std_error((sb), __func__, (errno)); \
872} while (0) 877} while (0)
873 878
874/* 879/*
diff --git a/include/linux/ext3_jbd.h b/include/linux/ext3_jbd.h
index 8c43b13a02fe..cf82d519be40 100644
--- a/include/linux/ext3_jbd.h
+++ b/include/linux/ext3_jbd.h
@@ -137,17 +137,17 @@ int __ext3_journal_dirty_metadata(const char *where,
137 handle_t *handle, struct buffer_head *bh); 137 handle_t *handle, struct buffer_head *bh);
138 138
139#define ext3_journal_get_undo_access(handle, bh) \ 139#define ext3_journal_get_undo_access(handle, bh) \
140 __ext3_journal_get_undo_access(__FUNCTION__, (handle), (bh)) 140 __ext3_journal_get_undo_access(__func__, (handle), (bh))
141#define ext3_journal_get_write_access(handle, bh) \ 141#define ext3_journal_get_write_access(handle, bh) \
142 __ext3_journal_get_write_access(__FUNCTION__, (handle), (bh)) 142 __ext3_journal_get_write_access(__func__, (handle), (bh))
143#define ext3_journal_revoke(handle, blocknr, bh) \ 143#define ext3_journal_revoke(handle, blocknr, bh) \
144 __ext3_journal_revoke(__FUNCTION__, (handle), (blocknr), (bh)) 144 __ext3_journal_revoke(__func__, (handle), (blocknr), (bh))
145#define ext3_journal_get_create_access(handle, bh) \ 145#define ext3_journal_get_create_access(handle, bh) \
146 __ext3_journal_get_create_access(__FUNCTION__, (handle), (bh)) 146 __ext3_journal_get_create_access(__func__, (handle), (bh))
147#define ext3_journal_dirty_metadata(handle, bh) \ 147#define ext3_journal_dirty_metadata(handle, bh) \
148 __ext3_journal_dirty_metadata(__FUNCTION__, (handle), (bh)) 148 __ext3_journal_dirty_metadata(__func__, (handle), (bh))
149#define ext3_journal_forget(handle, bh) \ 149#define ext3_journal_forget(handle, bh) \
150 __ext3_journal_forget(__FUNCTION__, (handle), (bh)) 150 __ext3_journal_forget(__func__, (handle), (bh))
151 151
152int ext3_journal_dirty_data(handle_t *handle, struct buffer_head *bh); 152int ext3_journal_dirty_data(handle_t *handle, struct buffer_head *bh);
153 153
@@ -160,7 +160,7 @@ static inline handle_t *ext3_journal_start(struct inode *inode, int nblocks)
160} 160}
161 161
162#define ext3_journal_stop(handle) \ 162#define ext3_journal_stop(handle) \
163 __ext3_journal_stop(__FUNCTION__, (handle)) 163 __ext3_journal_stop(__func__, (handle))
164 164
165static inline handle_t *ext3_journal_current_handle(void) 165static inline handle_t *ext3_journal_current_handle(void)
166{ 166{
diff --git a/include/linux/fb.h b/include/linux/fb.h
index 72295b099228..75a81eaf3430 100644
--- a/include/linux/fb.h
+++ b/include/linux/fb.h
@@ -8,7 +8,6 @@ struct dentry;
8 8
9/* Definitions of frame buffers */ 9/* Definitions of frame buffers */
10 10
11#define FB_MAJOR 29
12#define FB_MAX 32 /* sufficient for now */ 11#define FB_MAX 32 /* sufficient for now */
13 12
14/* ioctls 13/* ioctls
@@ -120,6 +119,10 @@ struct dentry;
120#define FB_ACCEL_XGI_VOLARI_V 47 /* XGI Volari V3XT, V5, V8 */ 119#define FB_ACCEL_XGI_VOLARI_V 47 /* XGI Volari V3XT, V5, V8 */
121#define FB_ACCEL_XGI_VOLARI_Z 48 /* XGI Volari Z7 */ 120#define FB_ACCEL_XGI_VOLARI_Z 48 /* XGI Volari Z7 */
122#define FB_ACCEL_OMAP1610 49 /* TI OMAP16xx */ 121#define FB_ACCEL_OMAP1610 49 /* TI OMAP16xx */
122#define FB_ACCEL_TRIDENT_TGUI 50 /* Trident TGUI */
123#define FB_ACCEL_TRIDENT_3DIMAGE 51 /* Trident 3DImage */
124#define FB_ACCEL_TRIDENT_BLADE3D 52 /* Trident Blade3D */
125#define FB_ACCEL_TRIDENT_BLADEXP 53 /* Trident BladeXP */
123#define FB_ACCEL_NEOMAGIC_NM2070 90 /* NeoMagic NM2070 */ 126#define FB_ACCEL_NEOMAGIC_NM2070 90 /* NeoMagic NM2070 */
124#define FB_ACCEL_NEOMAGIC_NM2090 91 /* NeoMagic NM2090 */ 127#define FB_ACCEL_NEOMAGIC_NM2090 91 /* NeoMagic NM2090 */
125#define FB_ACCEL_NEOMAGIC_NM2093 92 /* NeoMagic NM2093 */ 128#define FB_ACCEL_NEOMAGIC_NM2093 92 /* NeoMagic NM2093 */
@@ -805,6 +808,7 @@ struct fb_tile_ops {
805struct fb_info { 808struct fb_info {
806 int node; 809 int node;
807 int flags; 810 int flags;
811 struct mutex lock; /* Lock for open/release/ioctl funcs */
808 struct fb_var_screeninfo var; /* Current var */ 812 struct fb_var_screeninfo var; /* Current var */
809 struct fb_fix_screeninfo fix; /* Current fix */ 813 struct fb_fix_screeninfo fix; /* Current fix */
810 struct fb_monspecs monspecs; /* Current Monitor specs */ 814 struct fb_monspecs monspecs; /* Current Monitor specs */
@@ -973,6 +977,9 @@ static inline void __fb_pad_aligned_buffer(u8 *dst, u32 d_pitch,
973 977
974/* drivers/video/fb_defio.c */ 978/* drivers/video/fb_defio.c */
975extern void fb_deferred_io_init(struct fb_info *info); 979extern void fb_deferred_io_init(struct fb_info *info);
980extern void fb_deferred_io_open(struct fb_info *info,
981 struct inode *inode,
982 struct file *file);
976extern void fb_deferred_io_cleanup(struct fb_info *info); 983extern void fb_deferred_io_cleanup(struct fb_info *info);
977extern int fb_deferred_io_fsync(struct file *file, struct dentry *dentry, 984extern int fb_deferred_io_fsync(struct file *file, struct dentry *dentry,
978 int datasync); 985 int datasync);
diff --git a/include/linux/fd.h b/include/linux/fd.h
index b6bd41d2b460..f5d194af07a8 100644
--- a/include/linux/fd.h
+++ b/include/linux/fd.h
@@ -15,10 +15,16 @@ struct floppy_struct {
15 sect, /* sectors per track */ 15 sect, /* sectors per track */
16 head, /* nr of heads */ 16 head, /* nr of heads */
17 track, /* nr of tracks */ 17 track, /* nr of tracks */
18 stretch; /* !=0 means double track steps */ 18 stretch; /* bit 0 !=0 means double track steps */
19 /* bit 1 != 0 means swap sides */
20 /* bits 2..9 give the first sector */
21 /* number (the LSB is flipped) */
19#define FD_STRETCH 1 22#define FD_STRETCH 1
20#define FD_SWAPSIDES 2 23#define FD_SWAPSIDES 2
21#define FD_ZEROBASED 4 24#define FD_ZEROBASED 4
25#define FD_SECTBASEMASK 0x3FC
26#define FD_MKSECTBASE(s) (((s) ^ 1) << 2)
27#define FD_SECTBASE(floppy) ((((floppy)->stretch & FD_SECTBASEMASK) >> 2) ^ 1)
22 28
23 unsigned char gap, /* gap1 size */ 29 unsigned char gap, /* gap1 size */
24 30
diff --git a/include/linux/fd1772.h b/include/linux/fd1772.h
deleted file mode 100644
index 871d6e4c677e..000000000000
--- a/include/linux/fd1772.h
+++ /dev/null
@@ -1,80 +0,0 @@
1#ifndef _LINUX_FD1772REG_H
2#define _LINUX_FD1772REG_H
3
4/*
5** WD1772 stuff - originally from the M68K Linux
6 * Modified for Archimedes by Dave Gilbert (gilbertd@cs.man.ac.uk)
7 */
8
9/* register codes */
10
11#define FDC1772SELREG_STP (0x80) /* command/status register */
12#define FDC1772SELREG_TRA (0x82) /* track register */
13#define FDC1772SELREG_SEC (0x84) /* sector register */
14#define FDC1772SELREG_DTA (0x86) /* data register */
15
16/* register names for FDC1772_READ/WRITE macros */
17
18#define FDC1772REG_CMD 0
19#define FDC1772REG_STATUS 0
20#define FDC1772REG_TRACK 2
21#define FDC1772REG_SECTOR 4
22#define FDC1772REG_DATA 6
23
24/* command opcodes */
25
26#define FDC1772CMD_RESTORE (0x00) /* - */
27#define FDC1772CMD_SEEK (0x10) /* | */
28#define FDC1772CMD_STEP (0x20) /* | TYP 1 Commands */
29#define FDC1772CMD_STIN (0x40) /* | */
30#define FDC1772CMD_STOT (0x60) /* - */
31#define FDC1772CMD_RDSEC (0x80) /* - TYP 2 Commands */
32#define FDC1772CMD_WRSEC (0xa0) /* - " */
33#define FDC1772CMD_RDADR (0xc0) /* - */
34#define FDC1772CMD_RDTRA (0xe0) /* | TYP 3 Commands */
35#define FDC1772CMD_WRTRA (0xf0) /* - */
36#define FDC1772CMD_FORCI (0xd0) /* - TYP 4 Command */
37
38/* command modifier bits */
39
40#define FDC1772CMDADD_SR6 (0x00) /* step rate settings */
41#define FDC1772CMDADD_SR12 (0x01)
42#define FDC1772CMDADD_SR2 (0x02)
43#define FDC1772CMDADD_SR3 (0x03)
44#define FDC1772CMDADD_V (0x04) /* verify */
45#define FDC1772CMDADD_H (0x08) /* wait for spin-up */
46#define FDC1772CMDADD_U (0x10) /* update track register */
47#define FDC1772CMDADD_M (0x10) /* multiple sector access */
48#define FDC1772CMDADD_E (0x04) /* head settling flag */
49#define FDC1772CMDADD_P (0x02) /* precompensation */
50#define FDC1772CMDADD_A0 (0x01) /* DAM flag */
51
52/* status register bits */
53
54#define FDC1772STAT_MOTORON (0x80) /* motor on */
55#define FDC1772STAT_WPROT (0x40) /* write protected (FDC1772CMD_WR*) */
56#define FDC1772STAT_SPINUP (0x20) /* motor speed stable (Type I) */
57#define FDC1772STAT_DELDAM (0x20) /* sector has deleted DAM (Type II+III) */
58#define FDC1772STAT_RECNF (0x10) /* record not found */
59#define FDC1772STAT_CRC (0x08) /* CRC error */
60#define FDC1772STAT_TR00 (0x04) /* Track 00 flag (Type I) */
61#define FDC1772STAT_LOST (0x04) /* Lost Data (Type II+III) */
62#define FDC1772STAT_IDX (0x02) /* Index status (Type I) */
63#define FDC1772STAT_DRQ (0x02) /* DRQ status (Type II+III) */
64#define FDC1772STAT_BUSY (0x01) /* FDC1772 is busy */
65
66
67/* PSG Port A Bit Nr 0 .. Side Sel .. 0 -> Side 1 1 -> Side 2 */
68#define DSKSIDE (0x01)
69
70#define DSKDRVNONE (0x06)
71#define DSKDRV0 (0x02)
72#define DSKDRV1 (0x04)
73
74/* step rates */
75#define FDC1772STEP_6 0x00
76#define FDC1772STEP_12 0x01
77#define FDC1772STEP_2 0x02
78#define FDC1772STEP_3 0x03
79
80#endif
diff --git a/include/linux/fiemap.h b/include/linux/fiemap.h
new file mode 100644
index 000000000000..671decbd2aeb
--- /dev/null
+++ b/include/linux/fiemap.h
@@ -0,0 +1,64 @@
1/*
2 * FS_IOC_FIEMAP ioctl infrastructure.
3 *
4 * Some portions copyright (C) 2007 Cluster File Systems, Inc
5 *
6 * Authors: Mark Fasheh <mfasheh@suse.com>
7 * Kalpak Shah <kalpak.shah@sun.com>
8 * Andreas Dilger <adilger@sun.com>
9 */
10
11#ifndef _LINUX_FIEMAP_H
12#define _LINUX_FIEMAP_H
13
14struct fiemap_extent {
15 __u64 fe_logical; /* logical offset in bytes for the start of
16 * the extent from the beginning of the file */
17 __u64 fe_physical; /* physical offset in bytes for the start
18 * of the extent from the beginning of the disk */
19 __u64 fe_length; /* length in bytes for this extent */
20 __u64 fe_reserved64[2];
21 __u32 fe_flags; /* FIEMAP_EXTENT_* flags for this extent */
22 __u32 fe_reserved[3];
23};
24
25struct fiemap {
26 __u64 fm_start; /* logical offset (inclusive) at
27 * which to start mapping (in) */
28 __u64 fm_length; /* logical length of mapping which
29 * userspace wants (in) */
30 __u32 fm_flags; /* FIEMAP_FLAG_* flags for request (in/out) */
31 __u32 fm_mapped_extents;/* number of extents that were mapped (out) */
32 __u32 fm_extent_count; /* size of fm_extents array (in) */
33 __u32 fm_reserved;
34 struct fiemap_extent fm_extents[0]; /* array of mapped extents (out) */
35};
36
37#define FIEMAP_MAX_OFFSET (~0ULL)
38
39#define FIEMAP_FLAG_SYNC 0x00000001 /* sync file data before map */
40#define FIEMAP_FLAG_XATTR 0x00000002 /* map extended attribute tree */
41
42#define FIEMAP_FLAGS_COMPAT (FIEMAP_FLAG_SYNC | FIEMAP_FLAG_XATTR)
43
44#define FIEMAP_EXTENT_LAST 0x00000001 /* Last extent in file. */
45#define FIEMAP_EXTENT_UNKNOWN 0x00000002 /* Data location unknown. */
46#define FIEMAP_EXTENT_DELALLOC 0x00000004 /* Location still pending.
47 * Sets EXTENT_UNKNOWN. */
48#define FIEMAP_EXTENT_ENCODED 0x00000008 /* Data can not be read
49 * while fs is unmounted */
50#define FIEMAP_EXTENT_DATA_ENCRYPTED 0x00000080 /* Data is encrypted by fs.
51 * Sets EXTENT_NO_BYPASS. */
52#define FIEMAP_EXTENT_NOT_ALIGNED 0x00000100 /* Extent offsets may not be
53 * block aligned. */
54#define FIEMAP_EXTENT_DATA_INLINE 0x00000200 /* Data mixed with metadata.
55 * Sets EXTENT_NOT_ALIGNED.*/
56#define FIEMAP_EXTENT_DATA_TAIL 0x00000400 /* Multiple files in block.
57 * Sets EXTENT_NOT_ALIGNED.*/
58#define FIEMAP_EXTENT_UNWRITTEN 0x00000800 /* Space allocated, but
59 * no data (i.e. zero). */
60#define FIEMAP_EXTENT_MERGED 0x00001000 /* File does not natively
61 * support extents. Result
62 * merged for efficiency. */
63
64#endif /* _LINUX_FIEMAP_H */
diff --git a/include/linux/file.h b/include/linux/file.h
index 27c64bdc68c9..335a0a5c316e 100644
--- a/include/linux/file.h
+++ b/include/linux/file.h
@@ -19,10 +19,10 @@ struct file_operations;
19struct vfsmount; 19struct vfsmount;
20struct dentry; 20struct dentry;
21extern int init_file(struct file *, struct vfsmount *mnt, 21extern int init_file(struct file *, struct vfsmount *mnt,
22 struct dentry *dentry, mode_t mode, 22 struct dentry *dentry, fmode_t mode,
23 const struct file_operations *fop); 23 const struct file_operations *fop);
24extern struct file *alloc_file(struct vfsmount *, struct dentry *dentry, 24extern struct file *alloc_file(struct vfsmount *, struct dentry *dentry,
25 mode_t mode, const struct file_operations *fop); 25 fmode_t mode, const struct file_operations *fop);
26 26
27static inline void fput_light(struct file *file, int fput_needed) 27static inline void fput_light(struct file *file, int fput_needed)
28{ 28{
@@ -34,8 +34,9 @@ extern struct file *fget(unsigned int fd);
34extern struct file *fget_light(unsigned int fd, int *fput_needed); 34extern struct file *fget_light(unsigned int fd, int *fput_needed);
35extern void set_close_on_exec(unsigned int fd, int flag); 35extern void set_close_on_exec(unsigned int fd, int flag);
36extern void put_filp(struct file *); 36extern void put_filp(struct file *);
37extern int alloc_fd(unsigned start, unsigned flags);
37extern int get_unused_fd(void); 38extern int get_unused_fd(void);
38extern int get_unused_fd_flags(int flags); 39#define get_unused_fd_flags(flags) alloc_fd(0, (flags))
39extern void put_unused_fd(unsigned int fd); 40extern void put_unused_fd(unsigned int fd);
40 41
41extern void fd_install(unsigned int fd, struct file *file); 42extern void fd_install(unsigned int fd, struct file *file);
diff --git a/include/linux/firewire-cdev.h b/include/linux/firewire-cdev.h
index 0f0e271f97fa..4d078e99c017 100644
--- a/include/linux/firewire-cdev.h
+++ b/include/linux/firewire-cdev.h
@@ -154,8 +154,13 @@ struct fw_cdev_event_iso_interrupt {
154 * @request: Valid if @common.type == %FW_CDEV_EVENT_REQUEST 154 * @request: Valid if @common.type == %FW_CDEV_EVENT_REQUEST
155 * @iso_interrupt: Valid if @common.type == %FW_CDEV_EVENT_ISO_INTERRUPT 155 * @iso_interrupt: Valid if @common.type == %FW_CDEV_EVENT_ISO_INTERRUPT
156 * 156 *
157 * Convenience union for userspace use. Events could be read(2) into a char 157 * Convenience union for userspace use. Events could be read(2) into an
158 * buffer and then cast to this union for further processing. 158 * appropriately aligned char buffer and then cast to this union for further
159 * processing. Note that for a request, response or iso_interrupt event,
160 * the data[] or header[] may make the size of the full event larger than
161 * sizeof(union fw_cdev_event). Also note that if you attempt to read(2)
162 * an event into a buffer that is not large enough for it, the data that does
163 * not fit will be discarded so that the next read(2) will return a new event.
159 */ 164 */
160union fw_cdev_event { 165union fw_cdev_event {
161 struct fw_cdev_event_common common; 166 struct fw_cdev_event_common common;
diff --git a/include/linux/firmware-map.h b/include/linux/firmware-map.h
index acbdbcc16051..6e199c8dfacc 100644
--- a/include/linux/firmware-map.h
+++ b/include/linux/firmware-map.h
@@ -24,34 +24,8 @@
24 */ 24 */
25#ifdef CONFIG_FIRMWARE_MEMMAP 25#ifdef CONFIG_FIRMWARE_MEMMAP
26 26
27/**
28 * Adds a firmware mapping entry. This function uses kmalloc() for memory
29 * allocation. Use firmware_map_add_early() if you want to use the bootmem
30 * allocator.
31 *
32 * That function must be called before late_initcall.
33 *
34 * @start: Start of the memory range.
35 * @end: End of the memory range (inclusive).
36 * @type: Type of the memory range.
37 *
38 * Returns 0 on success, or -ENOMEM if no memory could be allocated.
39 */
40int firmware_map_add(resource_size_t start, resource_size_t end, 27int firmware_map_add(resource_size_t start, resource_size_t end,
41 const char *type); 28 const char *type);
42
43/**
44 * Adds a firmware mapping entry. This function uses the bootmem allocator
45 * for memory allocation. Use firmware_map_add() if you want to use kmalloc().
46 *
47 * That function must be called before late_initcall.
48 *
49 * @start: Start of the memory range.
50 * @end: End of the memory range (inclusive).
51 * @type: Type of the memory range.
52 *
53 * Returns 0 on success, or -ENOMEM if no memory could be allocated.
54 */
55int firmware_map_add_early(resource_size_t start, resource_size_t end, 29int firmware_map_add_early(resource_size_t start, resource_size_t end,
56 const char *type); 30 const char *type);
57 31
diff --git a/include/linux/freezer.h b/include/linux/freezer.h
index deddeedf3257..8f225339eee9 100644
--- a/include/linux/freezer.h
+++ b/include/linux/freezer.h
@@ -6,7 +6,7 @@
6#include <linux/sched.h> 6#include <linux/sched.h>
7#include <linux/wait.h> 7#include <linux/wait.h>
8 8
9#ifdef CONFIG_PM_SLEEP 9#ifdef CONFIG_FREEZER
10/* 10/*
11 * Check if a process has been frozen 11 * Check if a process has been frozen
12 */ 12 */
@@ -39,28 +39,18 @@ static inline void clear_freeze_flag(struct task_struct *p)
39 clear_tsk_thread_flag(p, TIF_FREEZE); 39 clear_tsk_thread_flag(p, TIF_FREEZE);
40} 40}
41 41
42static inline bool should_send_signal(struct task_struct *p)
43{
44 return !(p->flags & PF_FREEZER_NOSIG);
45}
46
42/* 47/*
43 * Wake up a frozen process 48 * Wake up a frozen process
44 *
45 * task_lock() is taken to prevent the race with refrigerator() which may
46 * occur if the freezing of tasks fails. Namely, without the lock, if the
47 * freezing of tasks failed, thaw_tasks() might have run before a task in
48 * refrigerator() could call frozen_process(), in which case the task would be
49 * frozen and no one would thaw it.
50 */ 49 */
51static inline int thaw_process(struct task_struct *p) 50extern int __thaw_process(struct task_struct *p);
52{ 51
53 task_lock(p); 52/* Takes and releases task alloc lock using task_lock() */
54 if (frozen(p)) { 53extern int thaw_process(struct task_struct *p);
55 p->flags &= ~PF_FROZEN;
56 task_unlock(p);
57 wake_up_process(p);
58 return 1;
59 }
60 clear_freeze_flag(p);
61 task_unlock(p);
62 return 0;
63}
64 54
65extern void refrigerator(void); 55extern void refrigerator(void);
66extern int freeze_processes(void); 56extern int freeze_processes(void);
@@ -75,6 +65,15 @@ static inline int try_to_freeze(void)
75 return 0; 65 return 0;
76} 66}
77 67
68extern bool freeze_task(struct task_struct *p, bool sig_only);
69extern void cancel_freezing(struct task_struct *p);
70
71#ifdef CONFIG_CGROUP_FREEZER
72extern int cgroup_frozen(struct task_struct *task);
73#else /* !CONFIG_CGROUP_FREEZER */
74static inline int cgroup_frozen(struct task_struct *task) { return 0; }
75#endif /* !CONFIG_CGROUP_FREEZER */
76
78/* 77/*
79 * The PF_FREEZER_SKIP flag should be set by a vfork parent right before it 78 * The PF_FREEZER_SKIP flag should be set by a vfork parent right before it
80 * calls wait_for_completion(&vfork) and reset right after it returns from this 79 * calls wait_for_completion(&vfork) and reset right after it returns from this
@@ -166,7 +165,7 @@ static inline void set_freezable_with_signal(void)
166 } while (try_to_freeze()); \ 165 } while (try_to_freeze()); \
167 __retval; \ 166 __retval; \
168}) 167})
169#else /* !CONFIG_PM_SLEEP */ 168#else /* !CONFIG_FREEZER */
170static inline int frozen(struct task_struct *p) { return 0; } 169static inline int frozen(struct task_struct *p) { return 0; }
171static inline int freezing(struct task_struct *p) { return 0; } 170static inline int freezing(struct task_struct *p) { return 0; }
172static inline void set_freeze_flag(struct task_struct *p) {} 171static inline void set_freeze_flag(struct task_struct *p) {}
@@ -191,6 +190,6 @@ static inline void set_freezable_with_signal(void) {}
191#define wait_event_freezable_timeout(wq, condition, timeout) \ 190#define wait_event_freezable_timeout(wq, condition, timeout) \
192 wait_event_interruptible_timeout(wq, condition, timeout) 191 wait_event_interruptible_timeout(wq, condition, timeout)
193 192
194#endif /* !CONFIG_PM_SLEEP */ 193#endif /* !CONFIG_FREEZER */
195 194
196#endif /* FREEZER_H_INCLUDED */ 195#endif /* FREEZER_H_INCLUDED */
diff --git a/include/linux/fs.h b/include/linux/fs.h
index c6455dadb21b..5b248d61430c 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -60,19 +60,26 @@ extern int dir_notify_enable;
60#define MAY_WRITE 2 60#define MAY_WRITE 2
61#define MAY_READ 4 61#define MAY_READ 4
62#define MAY_APPEND 8 62#define MAY_APPEND 8
63#define MAY_ACCESS 16
64#define MAY_OPEN 32
63 65
64#define FMODE_READ 1 66#define FMODE_READ ((__force fmode_t)1)
65#define FMODE_WRITE 2 67#define FMODE_WRITE ((__force fmode_t)2)
66 68
67/* Internal kernel extensions */ 69/* Internal kernel extensions */
68#define FMODE_LSEEK 4 70#define FMODE_LSEEK ((__force fmode_t)4)
69#define FMODE_PREAD 8 71#define FMODE_PREAD ((__force fmode_t)8)
70#define FMODE_PWRITE FMODE_PREAD /* These go hand in hand */ 72#define FMODE_PWRITE FMODE_PREAD /* These go hand in hand */
71 73
72/* File is being opened for execution. Primary users of this flag are 74/* File is being opened for execution. Primary users of this flag are
73 distributed filesystems that can use it to achieve correct ETXTBUSY 75 distributed filesystems that can use it to achieve correct ETXTBUSY
74 behavior for cross-node execution/opening_for_writing of files */ 76 behavior for cross-node execution/opening_for_writing of files */
75#define FMODE_EXEC 16 77#define FMODE_EXEC ((__force fmode_t)16)
78
79#define FMODE_NDELAY ((__force fmode_t)32)
80#define FMODE_EXCL ((__force fmode_t)64)
81#define FMODE_WRITE_IOCTL ((__force fmode_t)128)
82#define FMODE_NDELAY_NOW ((__force fmode_t)256)
76 83
77#define RW_MASK 1 84#define RW_MASK 1
78#define RWA_MASK 2 85#define RWA_MASK 2
@@ -84,7 +91,9 @@ extern int dir_notify_enable;
84#define READ_META (READ | (1 << BIO_RW_META)) 91#define READ_META (READ | (1 << BIO_RW_META))
85#define WRITE_SYNC (WRITE | (1 << BIO_RW_SYNC)) 92#define WRITE_SYNC (WRITE | (1 << BIO_RW_SYNC))
86#define SWRITE_SYNC (SWRITE | (1 << BIO_RW_SYNC)) 93#define SWRITE_SYNC (SWRITE | (1 << BIO_RW_SYNC))
87#define WRITE_BARRIER ((1 << BIO_RW) | (1 << BIO_RW_BARRIER)) 94#define WRITE_BARRIER (WRITE | (1 << BIO_RW_BARRIER))
95#define DISCARD_NOBARRIER (1 << BIO_RW_DISCARD)
96#define DISCARD_BARRIER ((1 << BIO_RW_DISCARD) | (1 << BIO_RW_BARRIER))
88 97
89#define SEL_IN 1 98#define SEL_IN 1
90#define SEL_OUT 2 99#define SEL_OUT 2
@@ -132,7 +141,7 @@ extern int dir_notify_enable;
132/* 141/*
133 * Superblock flags that can be altered by MS_REMOUNT 142 * Superblock flags that can be altered by MS_REMOUNT
134 */ 143 */
135#define MS_RMT_MASK (MS_RDONLY|MS_SYNCHRONOUS|MS_MANDLOCK) 144#define MS_RMT_MASK (MS_RDONLY|MS_SYNCHRONOUS|MS_MANDLOCK|MS_I_VERSION)
136 145
137/* 146/*
138 * Old magic mount flag and mask 147 * Old magic mount flag and mask
@@ -220,6 +229,7 @@ extern int dir_notify_enable;
220#define BLKTRACESTART _IO(0x12,116) 229#define BLKTRACESTART _IO(0x12,116)
221#define BLKTRACESTOP _IO(0x12,117) 230#define BLKTRACESTOP _IO(0x12,117)
222#define BLKTRACETEARDOWN _IO(0x12,118) 231#define BLKTRACETEARDOWN _IO(0x12,118)
232#define BLKDISCARD _IO(0x12,119)
223 233
224#define BMAP_IOCTL 1 /* obsolete - kept for compatibility */ 234#define BMAP_IOCTL 1 /* obsolete - kept for compatibility */
225#define FIBMAP _IO(0x00,1) /* bmap access */ 235#define FIBMAP _IO(0x00,1) /* bmap access */
@@ -229,6 +239,7 @@ extern int dir_notify_enable;
229#define FS_IOC_SETFLAGS _IOW('f', 2, long) 239#define FS_IOC_SETFLAGS _IOW('f', 2, long)
230#define FS_IOC_GETVERSION _IOR('v', 1, long) 240#define FS_IOC_GETVERSION _IOR('v', 1, long)
231#define FS_IOC_SETVERSION _IOW('v', 2, long) 241#define FS_IOC_SETVERSION _IOW('v', 2, long)
242#define FS_IOC_FIEMAP _IOWR('f', 11, struct fiemap)
232#define FS_IOC32_GETFLAGS _IOR('f', 1, int) 243#define FS_IOC32_GETFLAGS _IOR('f', 1, int)
233#define FS_IOC32_SETFLAGS _IOW('f', 2, int) 244#define FS_IOC32_SETFLAGS _IOW('f', 2, int)
234#define FS_IOC32_GETVERSION _IOR('v', 1, int) 245#define FS_IOC32_GETVERSION _IOR('v', 1, int)
@@ -277,7 +288,7 @@ extern int dir_notify_enable;
277#include <linux/types.h> 288#include <linux/types.h>
278#include <linux/kdev_t.h> 289#include <linux/kdev_t.h>
279#include <linux/dcache.h> 290#include <linux/dcache.h>
280#include <linux/namei.h> 291#include <linux/path.h>
281#include <linux/stat.h> 292#include <linux/stat.h>
282#include <linux/cache.h> 293#include <linux/cache.h>
283#include <linux/kobject.h> 294#include <linux/kobject.h>
@@ -289,6 +300,7 @@ extern int dir_notify_enable;
289#include <linux/mutex.h> 300#include <linux/mutex.h>
290#include <linux/capability.h> 301#include <linux/capability.h>
291#include <linux/semaphore.h> 302#include <linux/semaphore.h>
303#include <linux/fiemap.h>
292 304
293#include <asm/atomic.h> 305#include <asm/atomic.h>
294#include <asm/byteorder.h> 306#include <asm/byteorder.h>
@@ -318,22 +330,23 @@ typedef void (dio_iodone_t)(struct kiocb *iocb, loff_t offset,
318 * Attribute flags. These should be or-ed together to figure out what 330 * Attribute flags. These should be or-ed together to figure out what
319 * has been changed! 331 * has been changed!
320 */ 332 */
321#define ATTR_MODE 1 333#define ATTR_MODE (1 << 0)
322#define ATTR_UID 2 334#define ATTR_UID (1 << 1)
323#define ATTR_GID 4 335#define ATTR_GID (1 << 2)
324#define ATTR_SIZE 8 336#define ATTR_SIZE (1 << 3)
325#define ATTR_ATIME 16 337#define ATTR_ATIME (1 << 4)
326#define ATTR_MTIME 32 338#define ATTR_MTIME (1 << 5)
327#define ATTR_CTIME 64 339#define ATTR_CTIME (1 << 6)
328#define ATTR_ATIME_SET 128 340#define ATTR_ATIME_SET (1 << 7)
329#define ATTR_MTIME_SET 256 341#define ATTR_MTIME_SET (1 << 8)
330#define ATTR_FORCE 512 /* Not a change, but a change it */ 342#define ATTR_FORCE (1 << 9) /* Not a change, but a change it */
331#define ATTR_ATTR_FLAG 1024 343#define ATTR_ATTR_FLAG (1 << 10)
332#define ATTR_KILL_SUID 2048 344#define ATTR_KILL_SUID (1 << 11)
333#define ATTR_KILL_SGID 4096 345#define ATTR_KILL_SGID (1 << 12)
334#define ATTR_FILE 8192 346#define ATTR_FILE (1 << 13)
335#define ATTR_KILL_PRIV 16384 347#define ATTR_KILL_PRIV (1 << 14)
336#define ATTR_OPEN 32768 /* Truncating from open(O_TRUNC) */ 348#define ATTR_OPEN (1 << 15) /* Truncating from open(O_TRUNC) */
349#define ATTR_TIMES_SET (1 << 16)
337 350
338/* 351/*
339 * This is the Inode Attributes structure, used for notify_change(). It 352 * This is the Inode Attributes structure, used for notify_change(). It
@@ -440,6 +453,27 @@ static inline size_t iov_iter_count(struct iov_iter *i)
440 return i->count; 453 return i->count;
441} 454}
442 455
456/*
457 * "descriptor" for what we're up to with a read.
458 * This allows us to use the same read code yet
459 * have multiple different users of the data that
460 * we read from a file.
461 *
462 * The simplest case just copies the data to user
463 * mode.
464 */
465typedef struct {
466 size_t written;
467 size_t count;
468 union {
469 char __user *buf;
470 void *data;
471 } arg;
472 int error;
473} read_descriptor_t;
474
475typedef int (*read_actor_t)(read_descriptor_t *, struct page *,
476 unsigned long, unsigned long);
443 477
444struct address_space_operations { 478struct address_space_operations {
445 int (*writepage)(struct page *page, struct writeback_control *wbc); 479 int (*writepage)(struct page *page, struct writeback_control *wbc);
@@ -481,6 +515,8 @@ struct address_space_operations {
481 int (*migratepage) (struct address_space *, 515 int (*migratepage) (struct address_space *,
482 struct page *, struct page *); 516 struct page *, struct page *);
483 int (*launder_page) (struct page *); 517 int (*launder_page) (struct page *);
518 int (*is_partially_uptodate) (struct page *, read_descriptor_t *,
519 unsigned long);
484}; 520};
485 521
486/* 522/*
@@ -499,7 +535,7 @@ struct backing_dev_info;
499struct address_space { 535struct address_space {
500 struct inode *host; /* owner: inode, block_device */ 536 struct inode *host; /* owner: inode, block_device */
501 struct radix_tree_root page_tree; /* radix tree of all pages */ 537 struct radix_tree_root page_tree; /* radix tree of all pages */
502 rwlock_t tree_lock; /* and rwlock protecting it */ 538 spinlock_t tree_lock; /* and lock protecting it */
503 unsigned int i_mmap_writable;/* count VM_SHARED mappings */ 539 unsigned int i_mmap_writable;/* count VM_SHARED mappings */
504 struct prio_tree_root i_mmap; /* tree of private and shared mappings */ 540 struct prio_tree_root i_mmap; /* tree of private and shared mappings */
505 struct list_head i_mmap_nonlinear;/*list VM_NONLINEAR mappings */ 541 struct list_head i_mmap_nonlinear;/*list VM_NONLINEAR mappings */
@@ -792,9 +828,9 @@ struct file {
792#define f_dentry f_path.dentry 828#define f_dentry f_path.dentry
793#define f_vfsmnt f_path.mnt 829#define f_vfsmnt f_path.mnt
794 const struct file_operations *f_op; 830 const struct file_operations *f_op;
795 atomic_t f_count; 831 atomic_long_t f_count;
796 unsigned int f_flags; 832 unsigned int f_flags;
797 mode_t f_mode; 833 fmode_t f_mode;
798 loff_t f_pos; 834 loff_t f_pos;
799 struct fown_struct f_owner; 835 struct fown_struct f_owner;
800 unsigned int f_uid, f_gid; 836 unsigned int f_uid, f_gid;
@@ -821,8 +857,8 @@ extern spinlock_t files_lock;
821#define file_list_lock() spin_lock(&files_lock); 857#define file_list_lock() spin_lock(&files_lock);
822#define file_list_unlock() spin_unlock(&files_lock); 858#define file_list_unlock() spin_unlock(&files_lock);
823 859
824#define get_file(x) atomic_inc(&(x)->f_count) 860#define get_file(x) atomic_long_inc(&(x)->f_count)
825#define file_count(x) atomic_read(&(x)->f_count) 861#define file_count(x) atomic_long_read(&(x)->f_count)
826 862
827#ifdef CONFIG_DEBUG_WRITECOUNT 863#ifdef CONFIG_DEBUG_WRITECOUNT
828static inline void file_take_write(struct file *f) 864static inline void file_take_write(struct file *f)
@@ -886,6 +922,12 @@ static inline int file_check_writeable(struct file *filp)
886#define FL_SLEEP 128 /* A blocking lock */ 922#define FL_SLEEP 128 /* A blocking lock */
887 923
888/* 924/*
925 * Special return value from posix_lock_file() and vfs_lock_file() for
926 * asynchronous locking.
927 */
928#define FILE_LOCK_DEFERRED 1
929
930/*
889 * The POSIX file lock owner is determined by 931 * The POSIX file lock owner is determined by
890 * the "struct files_struct" in the thread group 932 * the "struct files_struct" in the thread group
891 * (or NULL for no owner - BSD locks). 933 * (or NULL for no owner - BSD locks).
@@ -910,6 +952,14 @@ struct lock_manager_operations {
910 int (*fl_change)(struct file_lock **, int); 952 int (*fl_change)(struct file_lock **, int);
911}; 953};
912 954
955struct lock_manager {
956 struct list_head list;
957};
958
959void locks_start_grace(struct lock_manager *);
960void locks_end_grace(struct lock_manager *);
961int locks_in_grace(void);
962
913/* that will die - we need it for nfs_lock_info */ 963/* that will die - we need it for nfs_lock_info */
914#include <linux/nfs_fs_i.h> 964#include <linux/nfs_fs_i.h>
915 965
@@ -918,12 +968,12 @@ struct file_lock {
918 struct list_head fl_link; /* doubly linked list of all locks */ 968 struct list_head fl_link; /* doubly linked list of all locks */
919 struct list_head fl_block; /* circular list of blocked processes */ 969 struct list_head fl_block; /* circular list of blocked processes */
920 fl_owner_t fl_owner; 970 fl_owner_t fl_owner;
971 unsigned char fl_flags;
972 unsigned char fl_type;
921 unsigned int fl_pid; 973 unsigned int fl_pid;
922 struct pid *fl_nspid; 974 struct pid *fl_nspid;
923 wait_queue_head_t fl_wait; 975 wait_queue_head_t fl_wait;
924 struct file *fl_file; 976 struct file *fl_file;
925 unsigned char fl_flags;
926 unsigned char fl_type;
927 loff_t fl_start; 977 loff_t fl_start;
928 loff_t fl_end; 978 loff_t fl_end;
929 979
@@ -951,6 +1001,13 @@ struct file_lock {
951 1001
952#include <linux/fcntl.h> 1002#include <linux/fcntl.h>
953 1003
1004extern void send_sigio(struct fown_struct *fown, int fd, int band);
1005
1006/* fs/sync.c */
1007extern int do_sync_mapping_range(struct address_space *mapping, loff_t offset,
1008 loff_t endbyte, unsigned int flags);
1009
1010#ifdef CONFIG_FILE_LOCKING
954extern int fcntl_getlk(struct file *, struct flock __user *); 1011extern int fcntl_getlk(struct file *, struct flock __user *);
955extern int fcntl_setlk(unsigned int, struct file *, unsigned int, 1012extern int fcntl_setlk(unsigned int, struct file *, unsigned int,
956 struct flock __user *); 1013 struct flock __user *);
@@ -961,14 +1018,9 @@ extern int fcntl_setlk64(unsigned int, struct file *, unsigned int,
961 struct flock64 __user *); 1018 struct flock64 __user *);
962#endif 1019#endif
963 1020
964extern void send_sigio(struct fown_struct *fown, int fd, int band);
965extern int fcntl_setlease(unsigned int fd, struct file *filp, long arg); 1021extern int fcntl_setlease(unsigned int fd, struct file *filp, long arg);
966extern int fcntl_getlease(struct file *filp); 1022extern int fcntl_getlease(struct file *filp);
967 1023
968/* fs/sync.c */
969extern int do_sync_mapping_range(struct address_space *mapping, loff_t offset,
970 loff_t endbyte, unsigned int flags);
971
972/* fs/locks.c */ 1024/* fs/locks.c */
973extern void locks_init_lock(struct file_lock *); 1025extern void locks_init_lock(struct file_lock *);
974extern void locks_copy_lock(struct file_lock *, struct file_lock *); 1026extern void locks_copy_lock(struct file_lock *, struct file_lock *);
@@ -990,7 +1042,37 @@ extern int vfs_setlease(struct file *, long, struct file_lock **);
990extern int lease_modify(struct file_lock **, int); 1042extern int lease_modify(struct file_lock **, int);
991extern int lock_may_read(struct inode *, loff_t start, unsigned long count); 1043extern int lock_may_read(struct inode *, loff_t start, unsigned long count);
992extern int lock_may_write(struct inode *, loff_t start, unsigned long count); 1044extern int lock_may_write(struct inode *, loff_t start, unsigned long count);
993extern struct seq_operations locks_seq_operations; 1045#else /* !CONFIG_FILE_LOCKING */
1046#define fcntl_getlk(a, b) ({ -EINVAL; })
1047#define fcntl_setlk(a, b, c, d) ({ -EACCES; })
1048#if BITS_PER_LONG == 32
1049#define fcntl_getlk64(a, b) ({ -EINVAL; })
1050#define fcntl_setlk64(a, b, c, d) ({ -EACCES; })
1051#endif
1052#define fcntl_setlease(a, b, c) ({ 0; })
1053#define fcntl_getlease(a) ({ 0; })
1054#define locks_init_lock(a) ({ })
1055#define __locks_copy_lock(a, b) ({ })
1056#define locks_copy_lock(a, b) ({ })
1057#define locks_remove_posix(a, b) ({ })
1058#define locks_remove_flock(a) ({ })
1059#define posix_test_lock(a, b) ({ 0; })
1060#define posix_lock_file(a, b, c) ({ -ENOLCK; })
1061#define posix_lock_file_wait(a, b) ({ -ENOLCK; })
1062#define posix_unblock_lock(a, b) (-ENOENT)
1063#define vfs_test_lock(a, b) ({ 0; })
1064#define vfs_lock_file(a, b, c, d) (-ENOLCK)
1065#define vfs_cancel_lock(a, b) ({ 0; })
1066#define flock_lock_file_wait(a, b) ({ -ENOLCK; })
1067#define __break_lease(a, b) ({ 0; })
1068#define lease_get_mtime(a, b) ({ })
1069#define generic_setlease(a, b, c) ({ -EINVAL; })
1070#define vfs_setlease(a, b, c) ({ -EINVAL; })
1071#define lease_modify(a, b) ({ -EINVAL; })
1072#define lock_may_read(a, b, c) ({ 1; })
1073#define lock_may_write(a, b, c) ({ 1; })
1074#endif /* !CONFIG_FILE_LOCKING */
1075
994 1076
995struct fasync_struct { 1077struct fasync_struct {
996 int magic; 1078 int magic;
@@ -1025,6 +1107,7 @@ extern int send_sigurg(struct fown_struct *fown);
1025extern struct list_head super_blocks; 1107extern struct list_head super_blocks;
1026extern spinlock_t sb_lock; 1108extern spinlock_t sb_lock;
1027 1109
1110#define sb_entry(list) list_entry((list), struct super_block, s_list)
1028#define S_BIAS (1<<30) 1111#define S_BIAS (1<<30)
1029struct super_block { 1112struct super_block {
1030 struct list_head s_list; /* Keep this first */ 1113 struct list_head s_list; /* Keep this first */
@@ -1058,6 +1141,9 @@ struct super_block {
1058 struct list_head s_more_io; /* parked for more writeback */ 1141 struct list_head s_more_io; /* parked for more writeback */
1059 struct hlist_head s_anon; /* anonymous dentries for (nfs) exporting */ 1142 struct hlist_head s_anon; /* anonymous dentries for (nfs) exporting */
1060 struct list_head s_files; 1143 struct list_head s_files;
1144 /* s_dentry_lru and s_nr_dentry_unused are protected by dcache_lock */
1145 struct list_head s_dentry_lru; /* unused dentry lru */
1146 int s_nr_dentry_unused; /* # of dentry on lru */
1061 1147
1062 struct block_device *s_bdev; 1148 struct block_device *s_bdev;
1063 struct mtd_info *s_mtd; 1149 struct mtd_info *s_mtd;
@@ -1070,6 +1156,7 @@ struct super_block {
1070 char s_id[32]; /* Informational name */ 1156 char s_id[32]; /* Informational name */
1071 1157
1072 void *s_fs_info; /* Filesystem private info */ 1158 void *s_fs_info; /* Filesystem private info */
1159 fmode_t s_mode;
1073 1160
1074 /* 1161 /*
1075 * The next field is for VFS *only*. No filesystems have any business 1162 * The next field is for VFS *only*. No filesystems have any business
@@ -1126,7 +1213,7 @@ extern int vfs_permission(struct nameidata *, int);
1126extern int vfs_create(struct inode *, struct dentry *, int, struct nameidata *); 1213extern int vfs_create(struct inode *, struct dentry *, int, struct nameidata *);
1127extern int vfs_mkdir(struct inode *, struct dentry *, int); 1214extern int vfs_mkdir(struct inode *, struct dentry *, int);
1128extern int vfs_mknod(struct inode *, struct dentry *, int, dev_t); 1215extern int vfs_mknod(struct inode *, struct dentry *, int, dev_t);
1129extern int vfs_symlink(struct inode *, struct dentry *, const char *, int); 1216extern int vfs_symlink(struct inode *, struct dentry *, const char *);
1130extern int vfs_link(struct dentry *, struct inode *, struct dentry *); 1217extern int vfs_link(struct dentry *, struct inode *, struct dentry *);
1131extern int vfs_rmdir(struct inode *, struct dentry *); 1218extern int vfs_rmdir(struct inode *, struct dentry *);
1132extern int vfs_unlink(struct inode *, struct dentry *); 1219extern int vfs_unlink(struct inode *, struct dentry *);
@@ -1143,6 +1230,20 @@ extern void dentry_unhash(struct dentry *dentry);
1143extern int file_permission(struct file *, int); 1230extern int file_permission(struct file *, int);
1144 1231
1145/* 1232/*
1233 * VFS FS_IOC_FIEMAP helper definitions.
1234 */
1235struct fiemap_extent_info {
1236 unsigned int fi_flags; /* Flags as passed from user */
1237 unsigned int fi_extents_mapped; /* Number of mapped extents */
1238 unsigned int fi_extents_max; /* Size of fiemap_extent array */
1239 struct fiemap_extent *fi_extents_start; /* Start of fiemap_extent
1240 * array */
1241};
1242int fiemap_fill_next_extent(struct fiemap_extent_info *info, u64 logical,
1243 u64 phys, u64 len, u32 flags);
1244int fiemap_check_flags(struct fiemap_extent_info *fieinfo, u32 fs_flags);
1245
1246/*
1146 * File types 1247 * File types
1147 * 1248 *
1148 * NOTE! These match bits 12..15 of stat.st_mode 1249 * NOTE! These match bits 12..15 of stat.st_mode
@@ -1170,41 +1271,7 @@ int generic_osync_inode(struct inode *, struct address_space *, int);
1170 * to have different dirent layouts depending on the binary type. 1271 * to have different dirent layouts depending on the binary type.
1171 */ 1272 */
1172typedef int (*filldir_t)(void *, const char *, int, loff_t, u64, unsigned); 1273typedef int (*filldir_t)(void *, const char *, int, loff_t, u64, unsigned);
1173 1274struct block_device_operations;
1174struct block_device_operations {
1175 int (*open) (struct inode *, struct file *);
1176 int (*release) (struct inode *, struct file *);
1177 int (*ioctl) (struct inode *, struct file *, unsigned, unsigned long);
1178 long (*unlocked_ioctl) (struct file *, unsigned, unsigned long);
1179 long (*compat_ioctl) (struct file *, unsigned, unsigned long);
1180 int (*direct_access) (struct block_device *, sector_t,
1181 void **, unsigned long *);
1182 int (*media_changed) (struct gendisk *);
1183 int (*revalidate_disk) (struct gendisk *);
1184 int (*getgeo)(struct block_device *, struct hd_geometry *);
1185 struct module *owner;
1186};
1187
1188/*
1189 * "descriptor" for what we're up to with a read.
1190 * This allows us to use the same read code yet
1191 * have multiple different users of the data that
1192 * we read from a file.
1193 *
1194 * The simplest case just copies the data to user
1195 * mode.
1196 */
1197typedef struct {
1198 size_t written;
1199 size_t count;
1200 union {
1201 char __user * buf;
1202 void *data;
1203 } arg;
1204 int error;
1205} read_descriptor_t;
1206
1207typedef int (*read_actor_t)(read_descriptor_t *, struct page *, unsigned long, unsigned long);
1208 1275
1209/* These macros are for out of kernel modules to test that 1276/* These macros are for out of kernel modules to test that
1210 * the kernel supports the unlocked_ioctl and compat_ioctl 1277 * the kernel supports the unlocked_ioctl and compat_ioctl
@@ -1262,7 +1329,7 @@ struct inode_operations {
1262 void * (*follow_link) (struct dentry *, struct nameidata *); 1329 void * (*follow_link) (struct dentry *, struct nameidata *);
1263 void (*put_link) (struct dentry *, struct nameidata *, void *); 1330 void (*put_link) (struct dentry *, struct nameidata *, void *);
1264 void (*truncate) (struct inode *); 1331 void (*truncate) (struct inode *);
1265 int (*permission) (struct inode *, int, struct nameidata *); 1332 int (*permission) (struct inode *, int);
1266 int (*setattr) (struct dentry *, struct iattr *); 1333 int (*setattr) (struct dentry *, struct iattr *);
1267 int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *); 1334 int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *);
1268 int (*setxattr) (struct dentry *, const char *,const void *,size_t,int); 1335 int (*setxattr) (struct dentry *, const char *,const void *,size_t,int);
@@ -1272,6 +1339,8 @@ struct inode_operations {
1272 void (*truncate_range)(struct inode *, loff_t, loff_t); 1339 void (*truncate_range)(struct inode *, loff_t, loff_t);
1273 long (*fallocate)(struct inode *inode, int mode, loff_t offset, 1340 long (*fallocate)(struct inode *inode, int mode, loff_t offset,
1274 loff_t len); 1341 loff_t len);
1342 int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start,
1343 u64 len);
1275}; 1344};
1276 1345
1277struct seq_file; 1346struct seq_file;
@@ -1516,7 +1585,6 @@ extern int get_sb_pseudo(struct file_system_type *, char *,
1516 struct vfsmount *mnt); 1585 struct vfsmount *mnt);
1517extern int simple_set_mnt(struct vfsmount *mnt, struct super_block *sb); 1586extern int simple_set_mnt(struct vfsmount *mnt, struct super_block *sb);
1518int __put_super_and_need_restart(struct super_block *sb); 1587int __put_super_and_need_restart(struct super_block *sb);
1519void unnamed_dev_init(void);
1520 1588
1521/* Alas, no aliases. Too much hassle with bringing module.h everywhere */ 1589/* Alas, no aliases. Too much hassle with bringing module.h everywhere */
1522#define fops_get(fops) \ 1590#define fops_get(fops) \
@@ -1539,9 +1607,12 @@ extern int vfs_statfs(struct dentry *, struct kstatfs *);
1539/* /sys/fs */ 1607/* /sys/fs */
1540extern struct kobject *fs_kobj; 1608extern struct kobject *fs_kobj;
1541 1609
1610extern int rw_verify_area(int, struct file *, loff_t *, size_t);
1611
1542#define FLOCK_VERIFY_READ 1 1612#define FLOCK_VERIFY_READ 1
1543#define FLOCK_VERIFY_WRITE 2 1613#define FLOCK_VERIFY_WRITE 2
1544 1614
1615#ifdef CONFIG_FILE_LOCKING
1545extern int locks_mandatory_locked(struct inode *); 1616extern int locks_mandatory_locked(struct inode *);
1546extern int locks_mandatory_area(int, struct inode *, struct file *, loff_t, size_t); 1617extern int locks_mandatory_area(int, struct inode *, struct file *, loff_t, size_t);
1547 1618
@@ -1572,8 +1643,6 @@ static inline int locks_verify_locked(struct inode *inode)
1572 return 0; 1643 return 0;
1573} 1644}
1574 1645
1575extern int rw_verify_area(int, struct file *, loff_t *, size_t);
1576
1577static inline int locks_verify_truncate(struct inode *inode, 1646static inline int locks_verify_truncate(struct inode *inode,
1578 struct file *filp, 1647 struct file *filp,
1579 loff_t size) 1648 loff_t size)
@@ -1594,6 +1663,15 @@ static inline int break_lease(struct inode *inode, unsigned int mode)
1594 return __break_lease(inode, mode); 1663 return __break_lease(inode, mode);
1595 return 0; 1664 return 0;
1596} 1665}
1666#else /* !CONFIG_FILE_LOCKING */
1667#define locks_mandatory_locked(a) ({ 0; })
1668#define locks_mandatory_area(a, b, c, d, e) ({ 0; })
1669#define __mandatory_lock(a) ({ 0; })
1670#define mandatory_lock(a) ({ 0; })
1671#define locks_verify_locked(a) ({ 0; })
1672#define locks_verify_truncate(a, b, c) ({ 0; })
1673#define break_lease(a, b) ({ 0; })
1674#endif /* CONFIG_FILE_LOCKING */
1597 1675
1598/* fs/open.c */ 1676/* fs/open.c */
1599 1677
@@ -1627,7 +1705,7 @@ extern struct block_device *bdget(dev_t);
1627extern void bd_set_size(struct block_device *, loff_t size); 1705extern void bd_set_size(struct block_device *, loff_t size);
1628extern void bd_forget(struct inode *inode); 1706extern void bd_forget(struct inode *inode);
1629extern void bdput(struct block_device *); 1707extern void bdput(struct block_device *);
1630extern struct block_device *open_by_devnum(dev_t, unsigned); 1708extern struct block_device *open_by_devnum(dev_t, fmode_t);
1631#else 1709#else
1632static inline void bd_forget(struct inode *inode) {} 1710static inline void bd_forget(struct inode *inode) {}
1633#endif 1711#endif
@@ -1637,13 +1715,10 @@ extern const struct file_operations bad_sock_fops;
1637extern const struct file_operations def_fifo_fops; 1715extern const struct file_operations def_fifo_fops;
1638#ifdef CONFIG_BLOCK 1716#ifdef CONFIG_BLOCK
1639extern int ioctl_by_bdev(struct block_device *, unsigned, unsigned long); 1717extern int ioctl_by_bdev(struct block_device *, unsigned, unsigned long);
1640extern int blkdev_ioctl(struct inode *, struct file *, unsigned, unsigned long); 1718extern int blkdev_ioctl(struct block_device *, fmode_t, unsigned, unsigned long);
1641extern int blkdev_driver_ioctl(struct inode *inode, struct file *file,
1642 struct gendisk *disk, unsigned cmd,
1643 unsigned long arg);
1644extern long compat_blkdev_ioctl(struct file *, unsigned, unsigned long); 1719extern long compat_blkdev_ioctl(struct file *, unsigned, unsigned long);
1645extern int blkdev_get(struct block_device *, mode_t, unsigned); 1720extern int blkdev_get(struct block_device *, fmode_t);
1646extern int blkdev_put(struct block_device *); 1721extern int blkdev_put(struct block_device *, fmode_t);
1647extern int bd_claim(struct block_device *, void *); 1722extern int bd_claim(struct block_device *, void *);
1648extern void bd_release(struct block_device *); 1723extern void bd_release(struct block_device *);
1649#ifdef CONFIG_SYSFS 1724#ifdef CONFIG_SYSFS
@@ -1667,15 +1742,17 @@ extern void chrdev_show(struct seq_file *,off_t);
1667 1742
1668/* fs/block_dev.c */ 1743/* fs/block_dev.c */
1669#define BDEVNAME_SIZE 32 /* Largest string for a blockdev identifier */ 1744#define BDEVNAME_SIZE 32 /* Largest string for a blockdev identifier */
1745#define BDEVT_SIZE 10 /* Largest string for MAJ:MIN for blkdev */
1670 1746
1671#ifdef CONFIG_BLOCK 1747#ifdef CONFIG_BLOCK
1672#define BLKDEV_MAJOR_HASH_SIZE 255 1748#define BLKDEV_MAJOR_HASH_SIZE 255
1673extern const char *__bdevname(dev_t, char *buffer); 1749extern const char *__bdevname(dev_t, char *buffer);
1674extern const char *bdevname(struct block_device *bdev, char *buffer); 1750extern const char *bdevname(struct block_device *bdev, char *buffer);
1675extern struct block_device *lookup_bdev(const char *); 1751extern struct block_device *lookup_bdev(const char *);
1676extern struct block_device *open_bdev_excl(const char *, int, void *); 1752extern struct block_device *open_bdev_exclusive(const char *, fmode_t, void *);
1677extern void close_bdev_excl(struct block_device *); 1753extern void close_bdev_exclusive(struct block_device *, fmode_t);
1678extern void blkdev_show(struct seq_file *,off_t); 1754extern void blkdev_show(struct seq_file *,off_t);
1755
1679#else 1756#else
1680#define BLKDEV_MAJOR_HASH_SIZE 0 1757#define BLKDEV_MAJOR_HASH_SIZE 0
1681#endif 1758#endif
@@ -1686,9 +1763,9 @@ extern void init_special_inode(struct inode *, umode_t, dev_t);
1686extern void make_bad_inode(struct inode *); 1763extern void make_bad_inode(struct inode *);
1687extern int is_bad_inode(struct inode *); 1764extern int is_bad_inode(struct inode *);
1688 1765
1689extern const struct file_operations read_fifo_fops; 1766extern const struct file_operations read_pipefifo_fops;
1690extern const struct file_operations write_fifo_fops; 1767extern const struct file_operations write_pipefifo_fops;
1691extern const struct file_operations rdwr_fifo_fops; 1768extern const struct file_operations rdwr_pipefifo_fops;
1692 1769
1693extern int fs_may_remount_ro(struct super_block *); 1770extern int fs_may_remount_ro(struct super_block *);
1694 1771
@@ -1703,6 +1780,9 @@ extern int fs_may_remount_ro(struct super_block *);
1703 */ 1780 */
1704#define bio_data_dir(bio) ((bio)->bi_rw & 1) 1781#define bio_data_dir(bio) ((bio)->bi_rw & 1)
1705 1782
1783extern void check_disk_size_change(struct gendisk *disk,
1784 struct block_device *bdev);
1785extern int revalidate_disk(struct gendisk *);
1706extern int check_disk_change(struct block_device *); 1786extern int check_disk_change(struct block_device *);
1707extern int __invalidate_device(struct block_device *); 1787extern int __invalidate_device(struct block_device *);
1708extern int invalidate_partition(struct gendisk *, int); 1788extern int invalidate_partition(struct gendisk *, int);
@@ -1757,10 +1837,15 @@ extern int do_remount_sb(struct super_block *sb, int flags,
1757extern sector_t bmap(struct inode *, sector_t); 1837extern sector_t bmap(struct inode *, sector_t);
1758#endif 1838#endif
1759extern int notify_change(struct dentry *, struct iattr *); 1839extern int notify_change(struct dentry *, struct iattr *);
1760extern int permission(struct inode *, int, struct nameidata *); 1840extern int inode_permission(struct inode *, int);
1761extern int generic_permission(struct inode *, int, 1841extern int generic_permission(struct inode *, int,
1762 int (*check_acl)(struct inode *, int)); 1842 int (*check_acl)(struct inode *, int));
1763 1843
1844static inline bool execute_ok(struct inode *inode)
1845{
1846 return (inode->i_mode & S_IXUGO) || S_ISDIR(inode->i_mode);
1847}
1848
1764extern int get_write_access(struct inode *); 1849extern int get_write_access(struct inode *);
1765extern int deny_write_access(struct file *); 1850extern int deny_write_access(struct file *);
1766static inline void put_write_access(struct inode * inode) 1851static inline void put_write_access(struct inode * inode)
@@ -1773,8 +1858,9 @@ static inline void allow_write_access(struct file *file)
1773 atomic_inc(&file->f_path.dentry->d_inode->i_writecount); 1858 atomic_inc(&file->f_path.dentry->d_inode->i_writecount);
1774} 1859}
1775extern int do_pipe(int *); 1860extern int do_pipe(int *);
1776extern struct file *create_read_pipe(struct file *f); 1861extern int do_pipe_flags(int *, int);
1777extern struct file *create_write_pipe(void); 1862extern struct file *create_read_pipe(struct file *f, int flags);
1863extern struct file *create_write_pipe(int flags);
1778extern void free_write_pipe(struct file *); 1864extern void free_write_pipe(struct file *);
1779 1865
1780extern struct file *do_filp_open(int dfd, const char *pathname, 1866extern struct file *do_filp_open(int dfd, const char *pathname,
@@ -1820,7 +1906,7 @@ extern void clear_inode(struct inode *);
1820extern void destroy_inode(struct inode *); 1906extern void destroy_inode(struct inode *);
1821extern struct inode *new_inode(struct super_block *); 1907extern struct inode *new_inode(struct super_block *);
1822extern int should_remove_suid(struct dentry *); 1908extern int should_remove_suid(struct dentry *);
1823extern int remove_suid(struct dentry *); 1909extern int file_remove_suid(struct file *);
1824 1910
1825extern void __insert_inode_hash(struct inode *, unsigned long hashval); 1911extern void __insert_inode_hash(struct inode *, unsigned long hashval);
1826extern void remove_inode_hash(struct inode *); 1912extern void remove_inode_hash(struct inode *);
@@ -1964,6 +2050,9 @@ extern int vfs_fstat(unsigned int, struct kstat *);
1964 2050
1965extern int do_vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd, 2051extern int do_vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd,
1966 unsigned long arg); 2052 unsigned long arg);
2053extern int generic_block_fiemap(struct inode *inode,
2054 struct fiemap_extent_info *fieinfo, u64 start,
2055 u64 len, get_block_t *get_block);
1967 2056
1968extern void get_filesystem(struct file_system_type *fs); 2057extern void get_filesystem(struct file_system_type *fs);
1969extern void put_filesystem(struct file_system_type *fs); 2058extern void put_filesystem(struct file_system_type *fs);
@@ -2006,8 +2095,6 @@ extern void simple_release_fs(struct vfsmount **mount, int *count);
2006 2095
2007extern ssize_t simple_read_from_buffer(void __user *to, size_t count, 2096extern ssize_t simple_read_from_buffer(void __user *to, size_t count,
2008 loff_t *ppos, const void *from, size_t available); 2097 loff_t *ppos, const void *from, size_t available);
2009extern ssize_t memory_read_from_buffer(void *to, size_t count, loff_t *ppos,
2010 const void *from, size_t available);
2011 2098
2012#ifdef CONFIG_MIGRATION 2099#ifdef CONFIG_MIGRATION
2013extern int buffer_migrate_page(struct address_space *, 2100extern int buffer_migrate_page(struct address_space *,
diff --git a/include/linux/fs_enet_pd.h b/include/linux/fs_enet_pd.h
index 9bc045b8c478..8300cab30f9a 100644
--- a/include/linux/fs_enet_pd.h
+++ b/include/linux/fs_enet_pd.h
@@ -103,10 +103,6 @@ struct fs_mii_bb_platform_info {
103 struct fs_mii_bit mdio_dir; 103 struct fs_mii_bit mdio_dir;
104 struct fs_mii_bit mdio_dat; 104 struct fs_mii_bit mdio_dat;
105 struct fs_mii_bit mdc_dat; 105 struct fs_mii_bit mdc_dat;
106 int mdio_port; /* port & bit for MDIO */
107 int mdio_bit;
108 int mdc_port; /* port & bit for MDC */
109 int mdc_bit;
110 int delay; /* delay in us */ 106 int delay; /* delay in us */
111 int irq[32]; /* irqs per phy's */ 107 int irq[32]; /* irqs per phy's */
112}; 108};
@@ -135,11 +131,7 @@ struct fs_platform_info {
135 u32 device_flags; 131 u32 device_flags;
136 132
137 int phy_addr; /* the phy address (-1 no phy) */ 133 int phy_addr; /* the phy address (-1 no phy) */
138#ifdef CONFIG_PPC_CPM_NEW_BINDING
139 char bus_id[16]; 134 char bus_id[16];
140#else
141 const char* bus_id;
142#endif
143 int phy_irq; /* the phy irq (if it exists) */ 135 int phy_irq; /* the phy irq (if it exists) */
144 136
145 const struct fs_mii_bus_info *bus_info; 137 const struct fs_mii_bus_info *bus_info;
diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
index 282f54219129..9e5a06e78d02 100644
--- a/include/linux/fs_struct.h
+++ b/include/linux/fs_struct.h
@@ -7,7 +7,7 @@ struct fs_struct {
7 atomic_t count; 7 atomic_t count;
8 rwlock_t lock; 8 rwlock_t lock;
9 int umask; 9 int umask;
10 struct path root, pwd, altroot; 10 struct path root, pwd;
11}; 11};
12 12
13#define INIT_FS { \ 13#define INIT_FS { \
@@ -19,7 +19,6 @@ struct fs_struct {
19extern struct kmem_cache *fs_cachep; 19extern struct kmem_cache *fs_cachep;
20 20
21extern void exit_fs(struct task_struct *); 21extern void exit_fs(struct task_struct *);
22extern void set_fs_altroot(void);
23extern void set_fs_root(struct fs_struct *, struct path *); 22extern void set_fs_root(struct fs_struct *, struct path *);
24extern void set_fs_pwd(struct fs_struct *, struct path *); 23extern void set_fs_pwd(struct fs_struct *, struct path *);
25extern struct fs_struct *copy_fs_struct(struct fs_struct *); 24extern struct fs_struct *copy_fs_struct(struct fs_struct *);
diff --git a/include/linux/fs_uart_pd.h b/include/linux/fs_uart_pd.h
index 809bb9ffc788..36b61ff39277 100644
--- a/include/linux/fs_uart_pd.h
+++ b/include/linux/fs_uart_pd.h
@@ -12,7 +12,6 @@
12#ifndef FS_UART_PD_H 12#ifndef FS_UART_PD_H
13#define FS_UART_PD_H 13#define FS_UART_PD_H
14 14
15#include <linux/version.h>
16#include <asm/types.h> 15#include <asm/types.h>
17 16
18enum fs_uart_id { 17enum fs_uart_id {
diff --git a/include/linux/fsl_devices.h b/include/linux/fsl_devices.h
index c415a496de3a..4e625e0094c8 100644
--- a/include/linux/fsl_devices.h
+++ b/include/linux/fsl_devices.h
@@ -69,6 +69,7 @@ struct gianfar_mdio_data {
69#define FSL_GIANFAR_DEV_HAS_VLAN 0x00000020 69#define FSL_GIANFAR_DEV_HAS_VLAN 0x00000020
70#define FSL_GIANFAR_DEV_HAS_EXTENDED_HASH 0x00000040 70#define FSL_GIANFAR_DEV_HAS_EXTENDED_HASH 0x00000040
71#define FSL_GIANFAR_DEV_HAS_PADDING 0x00000080 71#define FSL_GIANFAR_DEV_HAS_PADDING 0x00000080
72#define FSL_GIANFAR_DEV_HAS_MAGIC_PACKET 0x00000100
72 73
73/* Flags in gianfar_platform_data */ 74/* Flags in gianfar_platform_data */
74#define FSL_GIANFAR_BRD_HAS_PHY_INTR 0x00000001 /* set or use a timer */ 75#define FSL_GIANFAR_BRD_HAS_PHY_INTR 0x00000001 /* set or use a timer */
@@ -125,4 +126,10 @@ struct mpc8xx_pcmcia_ops {
125 int(*voltage_set)(int slot, int vcc, int vpp); 126 int(*voltage_set)(int slot, int vcc, int vpp);
126}; 127};
127 128
129/* Returns non-zero if the current suspend operation would
130 * lead to a deep sleep (i.e. power removed from the core,
131 * instead of just the clock).
132 */
133int fsl_deep_sleep(void);
134
128#endif /* _FSL_DEVICE_H_ */ 135#endif /* _FSL_DEVICE_H_ */
diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
index a89513188ce7..00fbd5b245c9 100644
--- a/include/linux/fsnotify.h
+++ b/include/linux/fsnotify.h
@@ -188,7 +188,7 @@ static inline void fsnotify_close(struct file *file)
188 struct dentry *dentry = file->f_path.dentry; 188 struct dentry *dentry = file->f_path.dentry;
189 struct inode *inode = dentry->d_inode; 189 struct inode *inode = dentry->d_inode;
190 const char *name = dentry->d_name.name; 190 const char *name = dentry->d_name.name;
191 mode_t mode = file->f_mode; 191 fmode_t mode = file->f_mode;
192 u32 mask = (mode & FMODE_WRITE) ? IN_CLOSE_WRITE : IN_CLOSE_NOWRITE; 192 u32 mask = (mode & FMODE_WRITE) ? IN_CLOSE_WRITE : IN_CLOSE_NOWRITE;
193 193
194 if (S_ISDIR(inode->i_mode)) 194 if (S_ISDIR(inode->i_mode))
diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
index f368d041e02d..a3d46151be19 100644
--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -1,10 +1,14 @@
1#ifndef _LINUX_FTRACE_H 1#ifndef _LINUX_FTRACE_H
2#define _LINUX_FTRACE_H 2#define _LINUX_FTRACE_H
3 3
4#ifdef CONFIG_FTRACE
5
6#include <linux/linkage.h> 4#include <linux/linkage.h>
7#include <linux/fs.h> 5#include <linux/fs.h>
6#include <linux/ktime.h>
7#include <linux/init.h>
8#include <linux/types.h>
9#include <linux/kallsyms.h>
10
11#ifdef CONFIG_FTRACE
8 12
9extern int ftrace_enabled; 13extern int ftrace_enabled;
10extern int 14extern int
@@ -36,6 +40,7 @@ extern void ftrace_stub(unsigned long a0, unsigned long a1);
36# define register_ftrace_function(ops) do { } while (0) 40# define register_ftrace_function(ops) do { } while (0)
37# define unregister_ftrace_function(ops) do { } while (0) 41# define unregister_ftrace_function(ops) do { } while (0)
38# define clear_ftrace_function(ops) do { } while (0) 42# define clear_ftrace_function(ops) do { } while (0)
43static inline void ftrace_kill_atomic(void) { }
39#endif /* CONFIG_FTRACE */ 44#endif /* CONFIG_FTRACE */
40 45
41#ifdef CONFIG_DYNAMIC_FTRACE 46#ifdef CONFIG_DYNAMIC_FTRACE
@@ -76,8 +81,10 @@ extern void mcount_call(void);
76 81
77extern int skip_trace(unsigned long ip); 82extern int skip_trace(unsigned long ip);
78 83
79void ftrace_disable_daemon(void); 84extern void ftrace_release(void *start, unsigned long size);
80void ftrace_enable_daemon(void); 85
86extern void ftrace_disable_daemon(void);
87extern void ftrace_enable_daemon(void);
81 88
82#else 89#else
83# define skip_trace(ip) ({ 0; }) 90# define skip_trace(ip) ({ 0; })
@@ -85,6 +92,7 @@ void ftrace_enable_daemon(void);
85# define ftrace_set_filter(buf, len, reset) do { } while (0) 92# define ftrace_set_filter(buf, len, reset) do { } while (0)
86# define ftrace_disable_daemon() do { } while (0) 93# define ftrace_disable_daemon() do { } while (0)
87# define ftrace_enable_daemon() do { } while (0) 94# define ftrace_enable_daemon() do { } while (0)
95static inline void ftrace_release(void *start, unsigned long size) { }
88#endif /* CONFIG_DYNAMIC_FTRACE */ 96#endif /* CONFIG_DYNAMIC_FTRACE */
89 97
90/* totally disable ftrace - can not re-enable after this */ 98/* totally disable ftrace - can not re-enable after this */
@@ -98,6 +106,29 @@ static inline void tracer_disable(void)
98#endif 106#endif
99} 107}
100 108
109/*
110 * Ftrace disable/restore without lock. Some synchronization mechanism
111 * must be used to prevent ftrace_enabled to be changed between
112 * disable/restore.
113 */
114static inline int __ftrace_enabled_save(void)
115{
116#ifdef CONFIG_FTRACE
117 int saved_ftrace_enabled = ftrace_enabled;
118 ftrace_enabled = 0;
119 return saved_ftrace_enabled;
120#else
121 return 0;
122#endif
123}
124
125static inline void __ftrace_enabled_restore(int enabled)
126{
127#ifdef CONFIG_FTRACE
128 ftrace_enabled = enabled;
129#endif
130}
131
101#ifdef CONFIG_FRAME_POINTER 132#ifdef CONFIG_FRAME_POINTER
102/* TODO: need to fix this for ARM */ 133/* TODO: need to fix this for ARM */
103# define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0)) 134# define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
@@ -136,9 +167,71 @@ static inline void tracer_disable(void)
136#ifdef CONFIG_TRACING 167#ifdef CONFIG_TRACING
137extern void 168extern void
138ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3); 169ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3);
170
171/**
172 * ftrace_printk - printf formatting in the ftrace buffer
173 * @fmt: the printf format for printing
174 *
175 * Note: __ftrace_printk is an internal function for ftrace_printk and
176 * the @ip is passed in via the ftrace_printk macro.
177 *
178 * This function allows a kernel developer to debug fast path sections
179 * that printk is not appropriate for. By scattering in various
180 * printk like tracing in the code, a developer can quickly see
181 * where problems are occurring.
182 *
183 * This is intended as a debugging tool for the developer only.
184 * Please refrain from leaving ftrace_printks scattered around in
185 * your code.
186 */
187# define ftrace_printk(fmt...) __ftrace_printk(_THIS_IP_, fmt)
188extern int
189__ftrace_printk(unsigned long ip, const char *fmt, ...)
190 __attribute__ ((format (printf, 2, 3)));
191extern void ftrace_dump(void);
139#else 192#else
140static inline void 193static inline void
141ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3) { } 194ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3) { }
195static inline int
196ftrace_printk(const char *fmt, ...) __attribute__ ((format (printf, 1, 0)));
197
198static inline int
199ftrace_printk(const char *fmt, ...)
200{
201 return 0;
202}
203static inline void ftrace_dump(void) { }
204#endif
205
206#ifdef CONFIG_FTRACE_MCOUNT_RECORD
207extern void ftrace_init(void);
208extern void ftrace_init_module(unsigned long *start, unsigned long *end);
209#else
210static inline void ftrace_init(void) { }
211static inline void
212ftrace_init_module(unsigned long *start, unsigned long *end) { }
142#endif 213#endif
143 214
215
216struct boot_trace {
217 pid_t caller;
218 char func[KSYM_NAME_LEN];
219 int result;
220 unsigned long long duration; /* usecs */
221 ktime_t calltime;
222 ktime_t rettime;
223};
224
225#ifdef CONFIG_BOOT_TRACER
226extern void trace_boot(struct boot_trace *it, initcall_t fn);
227extern void start_boot_trace(void);
228extern void stop_boot_trace(void);
229#else
230static inline void trace_boot(struct boot_trace *it, initcall_t fn) { }
231static inline void start_boot_trace(void) { }
232static inline void stop_boot_trace(void) { }
233#endif
234
235
236
144#endif /* _LINUX_FTRACE_H */ 237#endif /* _LINUX_FTRACE_H */
diff --git a/include/linux/fuse.h b/include/linux/fuse.h
index d48282197696..350fe9767bbc 100644
--- a/include/linux/fuse.h
+++ b/include/linux/fuse.h
@@ -17,8 +17,14 @@
17 * - add lock_owner field to fuse_setattr_in, fuse_read_in and fuse_write_in 17 * - add lock_owner field to fuse_setattr_in, fuse_read_in and fuse_write_in
18 * - add blksize field to fuse_attr 18 * - add blksize field to fuse_attr
19 * - add file flags field to fuse_read_in and fuse_write_in 19 * - add file flags field to fuse_read_in and fuse_write_in
20 *
21 * 7.10
22 * - add nonseekable open flag
20 */ 23 */
21 24
25#ifndef _LINUX_FUSE_H
26#define _LINUX_FUSE_H
27
22#include <asm/types.h> 28#include <asm/types.h>
23#include <linux/major.h> 29#include <linux/major.h>
24 30
@@ -26,7 +32,7 @@
26#define FUSE_KERNEL_VERSION 7 32#define FUSE_KERNEL_VERSION 7
27 33
28/** Minor version number of this interface */ 34/** Minor version number of this interface */
29#define FUSE_KERNEL_MINOR_VERSION 9 35#define FUSE_KERNEL_MINOR_VERSION 10
30 36
31/** The node ID of the root inode */ 37/** The node ID of the root inode */
32#define FUSE_ROOT_ID 1 38#define FUSE_ROOT_ID 1
@@ -98,17 +104,22 @@ struct fuse_file_lock {
98 * 104 *
99 * FOPEN_DIRECT_IO: bypass page cache for this open file 105 * FOPEN_DIRECT_IO: bypass page cache for this open file
100 * FOPEN_KEEP_CACHE: don't invalidate the data cache on open 106 * FOPEN_KEEP_CACHE: don't invalidate the data cache on open
107 * FOPEN_NONSEEKABLE: the file is not seekable
101 */ 108 */
102#define FOPEN_DIRECT_IO (1 << 0) 109#define FOPEN_DIRECT_IO (1 << 0)
103#define FOPEN_KEEP_CACHE (1 << 1) 110#define FOPEN_KEEP_CACHE (1 << 1)
111#define FOPEN_NONSEEKABLE (1 << 2)
104 112
105/** 113/**
106 * INIT request/reply flags 114 * INIT request/reply flags
115 *
116 * FUSE_EXPORT_SUPPORT: filesystem handles lookups of "." and ".."
107 */ 117 */
108#define FUSE_ASYNC_READ (1 << 0) 118#define FUSE_ASYNC_READ (1 << 0)
109#define FUSE_POSIX_LOCKS (1 << 1) 119#define FUSE_POSIX_LOCKS (1 << 1)
110#define FUSE_FILE_OPS (1 << 2) 120#define FUSE_FILE_OPS (1 << 2)
111#define FUSE_ATOMIC_O_TRUNC (1 << 3) 121#define FUSE_ATOMIC_O_TRUNC (1 << 3)
122#define FUSE_EXPORT_SUPPORT (1 << 4)
112#define FUSE_BIG_WRITES (1 << 5) 123#define FUSE_BIG_WRITES (1 << 5)
113 124
114/** 125/**
@@ -406,3 +417,5 @@ struct fuse_dirent {
406#define FUSE_DIRENT_ALIGN(x) (((x) + sizeof(__u64) - 1) & ~(sizeof(__u64) - 1)) 417#define FUSE_DIRENT_ALIGN(x) (((x) + sizeof(__u64) - 1) & ~(sizeof(__u64) - 1))
407#define FUSE_DIRENT_SIZE(d) \ 418#define FUSE_DIRENT_SIZE(d) \
408 FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen) 419 FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen)
420
421#endif /* _LINUX_FUSE_H */
diff --git a/include/linux/gameport.h b/include/linux/gameport.h
index afad95272841..0cd825f7363a 100644
--- a/include/linux/gameport.h
+++ b/include/linux/gameport.h
@@ -68,7 +68,6 @@ struct gameport_driver {
68 68
69int gameport_open(struct gameport *gameport, struct gameport_driver *drv, int mode); 69int gameport_open(struct gameport *gameport, struct gameport_driver *drv, int mode);
70void gameport_close(struct gameport *gameport); 70void gameport_close(struct gameport *gameport);
71void gameport_rescan(struct gameport *gameport);
72 71
73#if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE)) 72#if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE))
74 73
@@ -147,10 +146,11 @@ static inline void gameport_unpin_driver(struct gameport *gameport)
147 mutex_unlock(&gameport->drv_mutex); 146 mutex_unlock(&gameport->drv_mutex);
148} 147}
149 148
150void __gameport_register_driver(struct gameport_driver *drv, struct module *owner); 149int __gameport_register_driver(struct gameport_driver *drv,
151static inline void gameport_register_driver(struct gameport_driver *drv) 150 struct module *owner, const char *mod_name);
151static inline int __must_check gameport_register_driver(struct gameport_driver *drv)
152{ 152{
153 __gameport_register_driver(drv, THIS_MODULE); 153 return __gameport_register_driver(drv, THIS_MODULE, KBUILD_MODNAME);
154} 154}
155 155
156void gameport_unregister_driver(struct gameport_driver *drv); 156void gameport_unregister_driver(struct gameport_driver *drv);
diff --git a/include/linux/generic_serial.h b/include/linux/generic_serial.h
index 110833666e37..4cc913939817 100644
--- a/include/linux/generic_serial.h
+++ b/include/linux/generic_serial.h
@@ -14,6 +14,7 @@
14 14
15#ifdef __KERNEL__ 15#ifdef __KERNEL__
16#include <linux/mutex.h> 16#include <linux/mutex.h>
17#include <linux/tty.h>
17 18
18struct real_driver { 19struct real_driver {
19 void (*disable_tx_interrupts) (void *); 20 void (*disable_tx_interrupts) (void *);
@@ -33,17 +34,12 @@ struct real_driver {
33 34
34struct gs_port { 35struct gs_port {
35 int magic; 36 int magic;
37 struct tty_port port;
36 unsigned char *xmit_buf; 38 unsigned char *xmit_buf;
37 int xmit_head; 39 int xmit_head;
38 int xmit_tail; 40 int xmit_tail;
39 int xmit_cnt; 41 int xmit_cnt;
40 struct mutex port_write_mutex; 42 struct mutex port_write_mutex;
41 int flags;
42 wait_queue_head_t open_wait;
43 wait_queue_head_t close_wait;
44 int count;
45 int blocked_open;
46 struct tty_struct *tty;
47 unsigned long event; 43 unsigned long event;
48 unsigned short closing_wait; 44 unsigned short closing_wait;
49 int close_delay; 45 int close_delay;
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index e8787417f65a..e439e6aed832 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -11,20 +11,20 @@
11 11
12#include <linux/types.h> 12#include <linux/types.h>
13#include <linux/kdev_t.h> 13#include <linux/kdev_t.h>
14#include <linux/rcupdate.h>
14 15
15#ifdef CONFIG_BLOCK 16#ifdef CONFIG_BLOCK
16 17
17#define kobj_to_dev(k) container_of(k, struct device, kobj) 18#define kobj_to_dev(k) container_of((k), struct device, kobj)
18#define dev_to_disk(device) container_of(device, struct gendisk, dev) 19#define dev_to_disk(device) container_of((device), struct gendisk, part0.__dev)
19#define dev_to_part(device) container_of(device, struct hd_struct, dev) 20#define dev_to_part(device) container_of((device), struct hd_struct, __dev)
21#define disk_to_dev(disk) (&(disk)->part0.__dev)
22#define part_to_dev(part) (&((part)->__dev))
20 23
21extern struct device_type part_type; 24extern struct device_type part_type;
22extern struct kobject *block_depr; 25extern struct kobject *block_depr;
23extern struct class block_class; 26extern struct class block_class;
24 27
25extern const struct seq_operations partitions_op;
26extern const struct seq_operations diskstats_op;
27
28enum { 28enum {
29/* These three have identical behaviour; use the second one if DOS FDISK gets 29/* These three have identical behaviour; use the second one if DOS FDISK gets
30 confused about extended/logical partitions starting past cylinder 1023. */ 30 confused about extended/logical partitions starting past cylinder 1023. */
@@ -55,6 +55,9 @@ enum {
55 UNIXWARE_PARTITION = 0x63, /* Same as GNU_HURD and SCO Unix */ 55 UNIXWARE_PARTITION = 0x63, /* Same as GNU_HURD and SCO Unix */
56}; 56};
57 57
58#define DISK_MAX_PARTS 256
59#define DISK_NAME_LEN 32
60
58#include <linux/major.h> 61#include <linux/major.h>
59#include <linux/device.h> 62#include <linux/device.h>
60#include <linux/smp.h> 63#include <linux/smp.h>
@@ -87,7 +90,7 @@ struct disk_stats {
87struct hd_struct { 90struct hd_struct {
88 sector_t start_sect; 91 sector_t start_sect;
89 sector_t nr_sects; 92 sector_t nr_sects;
90 struct device dev; 93 struct device __dev;
91 struct kobject *holder_dir; 94 struct kobject *holder_dir;
92 int policy, partno; 95 int policy, partno;
93#ifdef CONFIG_FAIL_MAKE_REQUEST 96#ifdef CONFIG_FAIL_MAKE_REQUEST
@@ -100,6 +103,7 @@ struct hd_struct {
100#else 103#else
101 struct disk_stats dkstats; 104 struct disk_stats dkstats;
102#endif 105#endif
106 struct rcu_head rcu_head;
103}; 107};
104 108
105#define GENHD_FL_REMOVABLE 1 109#define GENHD_FL_REMOVABLE 1
@@ -108,7 +112,7 @@ struct hd_struct {
108#define GENHD_FL_CD 8 112#define GENHD_FL_CD 8
109#define GENHD_FL_UP 16 113#define GENHD_FL_UP 16
110#define GENHD_FL_SUPPRESS_PARTITION_INFO 32 114#define GENHD_FL_SUPPRESS_PARTITION_INFO 32
111#define GENHD_FL_FAIL 64 115#define GENHD_FL_EXT_DEVT 64 /* allow extended devt */
112 116
113#define BLK_SCSI_MAX_CMDS (256) 117#define BLK_SCSI_MAX_CMDS (256)
114#define BLK_SCSI_CMD_PER_LONG (BLK_SCSI_MAX_CMDS / (sizeof(long) * 8)) 118#define BLK_SCSI_CMD_PER_LONG (BLK_SCSI_MAX_CMDS / (sizeof(long) * 8))
@@ -119,99 +123,137 @@ struct blk_scsi_cmd_filter {
119 struct kobject kobj; 123 struct kobject kobj;
120}; 124};
121 125
126struct disk_part_tbl {
127 struct rcu_head rcu_head;
128 int len;
129 struct hd_struct *part[];
130};
131
122struct gendisk { 132struct gendisk {
133 /* major, first_minor and minors are input parameters only,
134 * don't use directly. Use disk_devt() and disk_max_parts().
135 */
123 int major; /* major number of driver */ 136 int major; /* major number of driver */
124 int first_minor; 137 int first_minor;
125 int minors; /* maximum number of minors, =1 for 138 int minors; /* maximum number of minors, =1 for
126 * disks that can't be partitioned. */ 139 * disks that can't be partitioned. */
127 char disk_name[32]; /* name of major driver */ 140
128 struct hd_struct **part; /* [indexed by minor] */ 141 char disk_name[DISK_NAME_LEN]; /* name of major driver */
142
143 /* Array of pointers to partitions indexed by partno.
144 * Protected with matching bdev lock but stat and other
145 * non-critical accesses use RCU. Always access through
146 * helpers.
147 */
148 struct disk_part_tbl *part_tbl;
149 struct hd_struct part0;
150
129 struct block_device_operations *fops; 151 struct block_device_operations *fops;
130 struct request_queue *queue; 152 struct request_queue *queue;
131 struct blk_scsi_cmd_filter cmd_filter;
132 void *private_data; 153 void *private_data;
133 sector_t capacity;
134 154
135 int flags; 155 int flags;
136 struct device *driverfs_dev; // FIXME: remove 156 struct device *driverfs_dev; // FIXME: remove
137 struct device dev;
138 struct kobject *holder_dir;
139 struct kobject *slave_dir; 157 struct kobject *slave_dir;
140 158
141 struct timer_rand_state *random; 159 struct timer_rand_state *random;
142 int policy;
143 160
144 atomic_t sync_io; /* RAID */ 161 atomic_t sync_io; /* RAID */
145 unsigned long stamp;
146 int in_flight;
147#ifdef CONFIG_SMP
148 struct disk_stats *dkstats;
149#else
150 struct disk_stats dkstats;
151#endif
152 struct work_struct async_notify; 162 struct work_struct async_notify;
153#ifdef CONFIG_BLK_DEV_INTEGRITY 163#ifdef CONFIG_BLK_DEV_INTEGRITY
154 struct blk_integrity *integrity; 164 struct blk_integrity *integrity;
155#endif 165#endif
166 int node_id;
156}; 167};
157 168
158/* 169static inline struct gendisk *part_to_disk(struct hd_struct *part)
159 * Macros to operate on percpu disk statistics:
160 *
161 * The __ variants should only be called in critical sections. The full
162 * variants disable/enable preemption.
163 */
164static inline struct hd_struct *get_part(struct gendisk *gendiskp,
165 sector_t sector)
166{ 170{
167 struct hd_struct *part; 171 if (likely(part)) {
168 int i; 172 if (part->partno)
169 for (i = 0; i < gendiskp->minors - 1; i++) { 173 return dev_to_disk(part_to_dev(part)->parent);
170 part = gendiskp->part[i]; 174 else
171 if (part && part->start_sect <= sector 175 return dev_to_disk(part_to_dev(part));
172 && sector < part->start_sect + part->nr_sects)
173 return part;
174 } 176 }
175 return NULL; 177 return NULL;
176} 178}
177 179
178#ifdef CONFIG_SMP 180static inline int disk_max_parts(struct gendisk *disk)
179#define __disk_stat_add(gendiskp, field, addnd) \ 181{
180 (per_cpu_ptr(gendiskp->dkstats, smp_processor_id())->field += addnd) 182 if (disk->flags & GENHD_FL_EXT_DEVT)
183 return DISK_MAX_PARTS;
184 return disk->minors;
185}
181 186
182#define disk_stat_read(gendiskp, field) \ 187static inline bool disk_partitionable(struct gendisk *disk)
183({ \ 188{
184 typeof(gendiskp->dkstats->field) res = 0; \ 189 return disk_max_parts(disk) > 1;
185 int i; \ 190}
186 for_each_possible_cpu(i) \
187 res += per_cpu_ptr(gendiskp->dkstats, i)->field; \
188 res; \
189})
190 191
191static inline void disk_stat_set_all(struct gendisk *gendiskp, int value) { 192static inline dev_t disk_devt(struct gendisk *disk)
192 int i; 193{
194 return disk_to_dev(disk)->devt;
195}
193 196
194 for_each_possible_cpu(i) 197static inline dev_t part_devt(struct hd_struct *part)
195 memset(per_cpu_ptr(gendiskp->dkstats, i), value, 198{
196 sizeof(struct disk_stats)); 199 return part_to_dev(part)->devt;
197} 200}
198 201
199#define __part_stat_add(part, field, addnd) \ 202extern struct hd_struct *disk_get_part(struct gendisk *disk, int partno);
200 (per_cpu_ptr(part->dkstats, smp_processor_id())->field += addnd)
201 203
202#define __all_stat_add(gendiskp, part, field, addnd, sector) \ 204static inline void disk_put_part(struct hd_struct *part)
203({ \ 205{
204 if (part) \ 206 if (likely(part))
205 __part_stat_add(part, field, addnd); \ 207 put_device(part_to_dev(part));
206 __disk_stat_add(gendiskp, field, addnd); \ 208}
207}) 209
210/*
211 * Smarter partition iterator without context limits.
212 */
213#define DISK_PITER_REVERSE (1 << 0) /* iterate in the reverse direction */
214#define DISK_PITER_INCL_EMPTY (1 << 1) /* include 0-sized parts */
215#define DISK_PITER_INCL_PART0 (1 << 2) /* include partition 0 */
216
217struct disk_part_iter {
218 struct gendisk *disk;
219 struct hd_struct *part;
220 int idx;
221 unsigned int flags;
222};
223
224extern void disk_part_iter_init(struct disk_part_iter *piter,
225 struct gendisk *disk, unsigned int flags);
226extern struct hd_struct *disk_part_iter_next(struct disk_part_iter *piter);
227extern void disk_part_iter_exit(struct disk_part_iter *piter);
228
229extern struct hd_struct *disk_map_sector_rcu(struct gendisk *disk,
230 sector_t sector);
231
232/*
233 * Macros to operate on percpu disk statistics:
234 *
235 * {disk|part|all}_stat_{add|sub|inc|dec}() modify the stat counters
236 * and should be called between disk_stat_lock() and
237 * disk_stat_unlock().
238 *
239 * part_stat_read() can be called at any time.
240 *
241 * part_stat_{add|set_all}() and {init|free}_part_stats are for
242 * internal use only.
243 */
244#ifdef CONFIG_SMP
245#define part_stat_lock() ({ rcu_read_lock(); get_cpu(); })
246#define part_stat_unlock() do { put_cpu(); rcu_read_unlock(); } while (0)
247
248#define __part_stat_add(cpu, part, field, addnd) \
249 (per_cpu_ptr((part)->dkstats, (cpu))->field += (addnd))
208 250
209#define part_stat_read(part, field) \ 251#define part_stat_read(part, field) \
210({ \ 252({ \
211 typeof(part->dkstats->field) res = 0; \ 253 typeof((part)->dkstats->field) res = 0; \
212 int i; \ 254 int i; \
213 for_each_possible_cpu(i) \ 255 for_each_possible_cpu(i) \
214 res += per_cpu_ptr(part->dkstats, i)->field; \ 256 res += per_cpu_ptr((part)->dkstats, i)->field; \
215 res; \ 257 res; \
216}) 258})
217 259
@@ -223,171 +265,107 @@ static inline void part_stat_set_all(struct hd_struct *part, int value)
223 memset(per_cpu_ptr(part->dkstats, i), value, 265 memset(per_cpu_ptr(part->dkstats, i), value,
224 sizeof(struct disk_stats)); 266 sizeof(struct disk_stats));
225} 267}
226
227#else /* !CONFIG_SMP */
228#define __disk_stat_add(gendiskp, field, addnd) \
229 (gendiskp->dkstats.field += addnd)
230#define disk_stat_read(gendiskp, field) (gendiskp->dkstats.field)
231 268
232static inline void disk_stat_set_all(struct gendisk *gendiskp, int value) 269static inline int init_part_stats(struct hd_struct *part)
233{ 270{
234 memset(&gendiskp->dkstats, value, sizeof (struct disk_stats)); 271 part->dkstats = alloc_percpu(struct disk_stats);
272 if (!part->dkstats)
273 return 0;
274 return 1;
235} 275}
236 276
237#define __part_stat_add(part, field, addnd) \ 277static inline void free_part_stats(struct hd_struct *part)
238 (part->dkstats.field += addnd)
239
240#define __all_stat_add(gendiskp, part, field, addnd, sector) \
241({ \
242 if (part) \
243 part->dkstats.field += addnd; \
244 __disk_stat_add(gendiskp, field, addnd); \
245})
246
247#define part_stat_read(part, field) (part->dkstats.field)
248
249static inline void part_stat_set_all(struct hd_struct *part, int value)
250{ 278{
251 memset(&part->dkstats, value, sizeof(struct disk_stats)); 279 free_percpu(part->dkstats);
252} 280}
253 281
254#endif /* CONFIG_SMP */ 282#else /* !CONFIG_SMP */
283#define part_stat_lock() ({ rcu_read_lock(); 0; })
284#define part_stat_unlock() rcu_read_unlock()
255 285
256#define disk_stat_add(gendiskp, field, addnd) \ 286#define __part_stat_add(cpu, part, field, addnd) \
257 do { \ 287 ((part)->dkstats.field += addnd)
258 preempt_disable(); \ 288
259 __disk_stat_add(gendiskp, field, addnd); \ 289#define part_stat_read(part, field) ((part)->dkstats.field)
260 preempt_enable(); \
261 } while (0)
262
263#define __disk_stat_dec(gendiskp, field) __disk_stat_add(gendiskp, field, -1)
264#define disk_stat_dec(gendiskp, field) disk_stat_add(gendiskp, field, -1)
265
266#define __disk_stat_inc(gendiskp, field) __disk_stat_add(gendiskp, field, 1)
267#define disk_stat_inc(gendiskp, field) disk_stat_add(gendiskp, field, 1)
268
269#define __disk_stat_sub(gendiskp, field, subnd) \
270 __disk_stat_add(gendiskp, field, -subnd)
271#define disk_stat_sub(gendiskp, field, subnd) \
272 disk_stat_add(gendiskp, field, -subnd)
273
274#define part_stat_add(gendiskp, field, addnd) \
275 do { \
276 preempt_disable(); \
277 __part_stat_add(gendiskp, field, addnd);\
278 preempt_enable(); \
279 } while (0)
280
281#define __part_stat_dec(gendiskp, field) __part_stat_add(gendiskp, field, -1)
282#define part_stat_dec(gendiskp, field) part_stat_add(gendiskp, field, -1)
283
284#define __part_stat_inc(gendiskp, field) __part_stat_add(gendiskp, field, 1)
285#define part_stat_inc(gendiskp, field) part_stat_add(gendiskp, field, 1)
286
287#define __part_stat_sub(gendiskp, field, subnd) \
288 __part_stat_add(gendiskp, field, -subnd)
289#define part_stat_sub(gendiskp, field, subnd) \
290 part_stat_add(gendiskp, field, -subnd)
291
292#define all_stat_add(gendiskp, part, field, addnd, sector) \
293 do { \
294 preempt_disable(); \
295 __all_stat_add(gendiskp, part, field, addnd, sector); \
296 preempt_enable(); \
297 } while (0)
298
299#define __all_stat_dec(gendiskp, field, sector) \
300 __all_stat_add(gendiskp, field, -1, sector)
301#define all_stat_dec(gendiskp, field, sector) \
302 all_stat_add(gendiskp, field, -1, sector)
303
304#define __all_stat_inc(gendiskp, part, field, sector) \
305 __all_stat_add(gendiskp, part, field, 1, sector)
306#define all_stat_inc(gendiskp, part, field, sector) \
307 all_stat_add(gendiskp, part, field, 1, sector)
308
309#define __all_stat_sub(gendiskp, part, field, subnd, sector) \
310 __all_stat_add(gendiskp, part, field, -subnd, sector)
311#define all_stat_sub(gendiskp, part, field, subnd, sector) \
312 all_stat_add(gendiskp, part, field, -subnd, sector)
313
314/* Inlines to alloc and free disk stats in struct gendisk */
315#ifdef CONFIG_SMP
316static inline int init_disk_stats(struct gendisk *disk)
317{
318 disk->dkstats = alloc_percpu(struct disk_stats);
319 if (!disk->dkstats)
320 return 0;
321 return 1;
322}
323 290
324static inline void free_disk_stats(struct gendisk *disk) 291static inline void part_stat_set_all(struct hd_struct *part, int value)
325{ 292{
326 free_percpu(disk->dkstats); 293 memset(&part->dkstats, value, sizeof(struct disk_stats));
327} 294}
328 295
329static inline int init_part_stats(struct hd_struct *part) 296static inline int init_part_stats(struct hd_struct *part)
330{ 297{
331 part->dkstats = alloc_percpu(struct disk_stats);
332 if (!part->dkstats)
333 return 0;
334 return 1; 298 return 1;
335} 299}
336 300
337static inline void free_part_stats(struct hd_struct *part) 301static inline void free_part_stats(struct hd_struct *part)
338{ 302{
339 free_percpu(part->dkstats);
340}
341
342#else /* CONFIG_SMP */
343static inline int init_disk_stats(struct gendisk *disk)
344{
345 return 1;
346} 303}
347 304
348static inline void free_disk_stats(struct gendisk *disk) 305#endif /* CONFIG_SMP */
349{
350}
351 306
352static inline int init_part_stats(struct hd_struct *part) 307#define part_stat_add(cpu, part, field, addnd) do { \
308 __part_stat_add((cpu), (part), field, addnd); \
309 if ((part)->partno) \
310 __part_stat_add((cpu), &part_to_disk((part))->part0, \
311 field, addnd); \
312} while (0)
313
314#define part_stat_dec(cpu, gendiskp, field) \
315 part_stat_add(cpu, gendiskp, field, -1)
316#define part_stat_inc(cpu, gendiskp, field) \
317 part_stat_add(cpu, gendiskp, field, 1)
318#define part_stat_sub(cpu, gendiskp, field, subnd) \
319 part_stat_add(cpu, gendiskp, field, -subnd)
320
321static inline void part_inc_in_flight(struct hd_struct *part)
353{ 322{
354 return 1; 323 part->in_flight++;
324 if (part->partno)
325 part_to_disk(part)->part0.in_flight++;
355} 326}
356 327
357static inline void free_part_stats(struct hd_struct *part) 328static inline void part_dec_in_flight(struct hd_struct *part)
358{ 329{
330 part->in_flight--;
331 if (part->partno)
332 part_to_disk(part)->part0.in_flight--;
359} 333}
360#endif /* CONFIG_SMP */
361 334
362/* drivers/block/ll_rw_blk.c */ 335/* drivers/block/ll_rw_blk.c */
363extern void disk_round_stats(struct gendisk *disk); 336extern void part_round_stats(int cpu, struct hd_struct *part);
364extern void part_round_stats(struct hd_struct *part);
365 337
366/* drivers/block/genhd.c */ 338/* drivers/block/genhd.c */
367extern int get_blkdev_list(char *, int); 339extern int get_blkdev_list(char *, int);
368extern void add_disk(struct gendisk *disk); 340extern void add_disk(struct gendisk *disk);
369extern void del_gendisk(struct gendisk *gp); 341extern void del_gendisk(struct gendisk *gp);
370extern void unlink_gendisk(struct gendisk *gp); 342extern void unlink_gendisk(struct gendisk *gp);
371extern struct gendisk *get_gendisk(dev_t dev, int *part); 343extern struct gendisk *get_gendisk(dev_t dev, int *partno);
344extern struct block_device *bdget_disk(struct gendisk *disk, int partno);
372 345
373extern void set_device_ro(struct block_device *bdev, int flag); 346extern void set_device_ro(struct block_device *bdev, int flag);
374extern void set_disk_ro(struct gendisk *disk, int flag); 347extern void set_disk_ro(struct gendisk *disk, int flag);
375 348
349static inline int get_disk_ro(struct gendisk *disk)
350{
351 return disk->part0.policy;
352}
353
376/* drivers/char/random.c */ 354/* drivers/char/random.c */
377extern void add_disk_randomness(struct gendisk *disk); 355extern void add_disk_randomness(struct gendisk *disk);
378extern void rand_initialize_disk(struct gendisk *disk); 356extern void rand_initialize_disk(struct gendisk *disk);
379 357
380static inline sector_t get_start_sect(struct block_device *bdev) 358static inline sector_t get_start_sect(struct block_device *bdev)
381{ 359{
382 return bdev->bd_contains == bdev ? 0 : bdev->bd_part->start_sect; 360 return bdev->bd_part->start_sect;
383} 361}
384static inline sector_t get_capacity(struct gendisk *disk) 362static inline sector_t get_capacity(struct gendisk *disk)
385{ 363{
386 return disk->capacity; 364 return disk->part0.nr_sects;
387} 365}
388static inline void set_capacity(struct gendisk *disk, sector_t size) 366static inline void set_capacity(struct gendisk *disk, sector_t size)
389{ 367{
390 disk->capacity = size; 368 disk->part0.nr_sects = size;
391} 369}
392 370
393#ifdef CONFIG_SOLARIS_X86_PARTITION 371#ifdef CONFIG_SOLARIS_X86_PARTITION
@@ -537,11 +515,14 @@ struct unixware_disklabel {
537#define ADDPART_FLAG_RAID 1 515#define ADDPART_FLAG_RAID 1
538#define ADDPART_FLAG_WHOLEDISK 2 516#define ADDPART_FLAG_WHOLEDISK 2
539 517
540extern dev_t blk_lookup_devt(const char *name, int part); 518extern int blk_alloc_devt(struct hd_struct *part, dev_t *devt);
541extern char *disk_name (struct gendisk *hd, int part, char *buf); 519extern void blk_free_devt(dev_t devt);
520extern dev_t blk_lookup_devt(const char *name, int partno);
521extern char *disk_name (struct gendisk *hd, int partno, char *buf);
542 522
523extern int disk_expand_part_tbl(struct gendisk *disk, int target);
543extern int rescan_partitions(struct gendisk *disk, struct block_device *bdev); 524extern int rescan_partitions(struct gendisk *disk, struct block_device *bdev);
544extern void add_partition(struct gendisk *, int, sector_t, sector_t, int); 525extern int __must_check add_partition(struct gendisk *, int, sector_t, sector_t, int);
545extern void delete_partition(struct gendisk *, int); 526extern void delete_partition(struct gendisk *, int);
546extern void printk_all_partitions(void); 527extern void printk_all_partitions(void);
547 528
@@ -556,16 +537,23 @@ extern void blk_register_region(dev_t devt, unsigned long range,
556 void *data); 537 void *data);
557extern void blk_unregister_region(dev_t devt, unsigned long range); 538extern void blk_unregister_region(dev_t devt, unsigned long range);
558 539
559static inline struct block_device *bdget_disk(struct gendisk *disk, int index) 540extern ssize_t part_size_show(struct device *dev,
560{ 541 struct device_attribute *attr, char *buf);
561 return bdget(MKDEV(disk->major, disk->first_minor) + index); 542extern ssize_t part_stat_show(struct device *dev,
562} 543 struct device_attribute *attr, char *buf);
544#ifdef CONFIG_FAIL_MAKE_REQUEST
545extern ssize_t part_fail_show(struct device *dev,
546 struct device_attribute *attr, char *buf);
547extern ssize_t part_fail_store(struct device *dev,
548 struct device_attribute *attr,
549 const char *buf, size_t count);
550#endif /* CONFIG_FAIL_MAKE_REQUEST */
563 551
564#else /* CONFIG_BLOCK */ 552#else /* CONFIG_BLOCK */
565 553
566static inline void printk_all_partitions(void) { } 554static inline void printk_all_partitions(void) { }
567 555
568static inline dev_t blk_lookup_devt(const char *name, int part) 556static inline dev_t blk_lookup_devt(const char *name, int partno)
569{ 557{
570 dev_t devt = MKDEV(0, 0); 558 dev_t devt = MKDEV(0, 0);
571 return devt; 559 return devt;
diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index b414be387180..e8003afeffba 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -173,11 +173,24 @@ static inline void arch_free_page(struct page *page, int order) { }
173static inline void arch_alloc_page(struct page *page, int order) { } 173static inline void arch_alloc_page(struct page *page, int order) { }
174#endif 174#endif
175 175
176extern struct page *__alloc_pages(gfp_t, unsigned int, struct zonelist *); 176struct page *
177__alloc_pages_internal(gfp_t gfp_mask, unsigned int order,
178 struct zonelist *zonelist, nodemask_t *nodemask);
179
180static inline struct page *
181__alloc_pages(gfp_t gfp_mask, unsigned int order,
182 struct zonelist *zonelist)
183{
184 return __alloc_pages_internal(gfp_mask, order, zonelist, NULL);
185}
186
187static inline struct page *
188__alloc_pages_nodemask(gfp_t gfp_mask, unsigned int order,
189 struct zonelist *zonelist, nodemask_t *nodemask)
190{
191 return __alloc_pages_internal(gfp_mask, order, zonelist, nodemask);
192}
177 193
178extern struct page *
179__alloc_pages_nodemask(gfp_t, unsigned int,
180 struct zonelist *, nodemask_t *nodemask);
181 194
182static inline struct page *alloc_pages_node(int nid, gfp_t gfp_mask, 195static inline struct page *alloc_pages_node(int nid, gfp_t gfp_mask,
183 unsigned int order) 196 unsigned int order)
@@ -215,6 +228,9 @@ extern struct page *alloc_page_vma(gfp_t gfp_mask,
215extern unsigned long __get_free_pages(gfp_t gfp_mask, unsigned int order); 228extern unsigned long __get_free_pages(gfp_t gfp_mask, unsigned int order);
216extern unsigned long get_zeroed_page(gfp_t gfp_mask); 229extern unsigned long get_zeroed_page(gfp_t gfp_mask);
217 230
231void *alloc_pages_exact(size_t size, gfp_t gfp_mask);
232void free_pages_exact(void *virt, size_t size);
233
218#define __get_free_page(gfp_mask) \ 234#define __get_free_page(gfp_mask) \
219 __get_free_pages((gfp_mask),0) 235 __get_free_pages((gfp_mask),0)
220 236
diff --git a/include/linux/gfs2_ondisk.h b/include/linux/gfs2_ondisk.h
index c3c19f926e6f..14d0df0b5749 100644
--- a/include/linux/gfs2_ondisk.h
+++ b/include/linux/gfs2_ondisk.h
@@ -118,7 +118,11 @@ struct gfs2_sb {
118 118
119 char sb_lockproto[GFS2_LOCKNAME_LEN]; 119 char sb_lockproto[GFS2_LOCKNAME_LEN];
120 char sb_locktable[GFS2_LOCKNAME_LEN]; 120 char sb_locktable[GFS2_LOCKNAME_LEN];
121 /* In gfs1, quota and license dinodes followed */ 121
122 struct gfs2_inum __pad3; /* Was quota inode in gfs1 */
123 struct gfs2_inum __pad4; /* Was licence inode in gfs1 */
124#define GFS2_HAS_UUID 1
125 __u8 sb_uuid[16]; /* The UUID, maybe 0 for backwards compat */
122}; 126};
123 127
124/* 128/*
diff --git a/include/linux/gpio.h b/include/linux/gpio.h
index 98be6c5762b9..e10c49a5b96e 100644
--- a/include/linux/gpio.h
+++ b/include/linux/gpio.h
@@ -8,6 +8,7 @@
8 8
9#else 9#else
10 10
11#include <linux/kernel.h>
11#include <linux/types.h> 12#include <linux/types.h>
12#include <linux/errno.h> 13#include <linux/errno.h>
13 14
@@ -32,6 +33,8 @@ static inline int gpio_request(unsigned gpio, const char *label)
32 33
33static inline void gpio_free(unsigned gpio) 34static inline void gpio_free(unsigned gpio)
34{ 35{
36 might_sleep();
37
35 /* GPIO can never have been requested */ 38 /* GPIO can never have been requested */
36 WARN_ON(1); 39 WARN_ON(1);
37} 40}
@@ -79,6 +82,19 @@ static inline void gpio_set_value_cansleep(unsigned gpio, int value)
79 WARN_ON(1); 82 WARN_ON(1);
80} 83}
81 84
85static inline int gpio_export(unsigned gpio, bool direction_may_change)
86{
87 /* GPIO can never have been requested or set as {in,out}put */
88 WARN_ON(1);
89 return -EINVAL;
90}
91
92static inline void gpio_unexport(unsigned gpio)
93{
94 /* GPIO can never have been exported */
95 WARN_ON(1);
96}
97
82static inline int gpio_to_irq(unsigned gpio) 98static inline int gpio_to_irq(unsigned gpio)
83{ 99{
84 /* GPIO can never have been requested or set as input */ 100 /* GPIO can never have been requested or set as input */
diff --git a/include/linux/gpio_keys.h b/include/linux/gpio_keys.h
index c6d3a9de5634..ec6ecd74781d 100644
--- a/include/linux/gpio_keys.h
+++ b/include/linux/gpio_keys.h
@@ -9,6 +9,7 @@ struct gpio_keys_button {
9 char *desc; 9 char *desc;
10 int type; /* input event type (EV_KEY, EV_SW) */ 10 int type; /* input event type (EV_KEY, EV_SW) */
11 int wakeup; /* configure the button as a wake-up source */ 11 int wakeup; /* configure the button as a wake-up source */
12 int debounce_interval; /* debounce ticks interval in msecs */
12}; 13};
13 14
14struct gpio_keys_platform_data { 15struct gpio_keys_platform_data {
diff --git a/include/linux/harrier_defs.h b/include/linux/harrier_defs.h
deleted file mode 100644
index efef11db790f..000000000000
--- a/include/linux/harrier_defs.h
+++ /dev/null
@@ -1,212 +0,0 @@
1/*
2 * include/linux/harrier_defs.h
3 *
4 * Definitions for Motorola MCG Harrier North Bridge & Memory controller
5 *
6 * Author: Dale Farnsworth
7 * dale.farnsworth@mvista.com
8 *
9 * Extracted from asm-ppc/harrier.h by:
10 * Randy Vinson
11 * rvinson@mvista.com
12 *
13 * Copyright 2001-2002 MontaVista Software Inc.
14 *
15 * This program is free software; you can redistribute it and/or modify it
16 * under the terms of the GNU General Public License as published by the
17 * Free Software Foundation; either version 2 of the License, or (at your
18 * option) any later version.
19 */
20
21#ifndef __ASMPPC_HARRIER_DEFS_H
22#define __ASMPPC_HARRIER_DEFS_H
23
24#define HARRIER_DEFAULT_XCSR_BASE 0xfeff0000
25
26#define HARRIER_VEND_DEV_ID 0x1057480b
27
28#define HARRIER_VENI_OFF 0x00
29
30#define HARRIER_REVI_OFF 0x05
31#define HARRIER_UCTL_OFF 0xd0
32#define HARRIER_XTAL64_MASK 0x02
33
34#define HARRIER_MISC_CSR_OFF 0x1c
35#define HARRIER_RSTOUT 0x01000000
36#define HARRIER_SYSCON 0x08000000
37#define HARRIER_EREADY 0x10000000
38#define HARRIER_ERDYS 0x20000000
39
40/* Function exception registers */
41#define HARRIER_FEEN_OFF 0x40 /* enable */
42#define HARRIER_FEST_OFF 0x44 /* status */
43#define HARRIER_FEMA_OFF 0x48 /* mask */
44#define HARRIER_FECL_OFF 0x4c /* clear */
45
46#define HARRIER_FE_DMA 0x80
47#define HARRIER_FE_MIDB 0x40
48#define HARRIER_FE_MIM0 0x20
49#define HARRIER_FE_MIM1 0x10
50#define HARRIER_FE_MIP 0x08
51#define HARRIER_FE_UA0 0x04
52#define HARRIER_FE_UA1 0x02
53#define HARRIER_FE_ABT 0x01
54
55#define HARRIER_SERIAL_0_OFF 0xc0
56
57#define HARRIER_MBAR_OFF 0xe0
58#define HARRIER_MBAR_MSK 0xfffc0000
59#define HARRIER_MPIC_CSR_OFF 0xe4
60#define HARRIER_MPIC_OPI_ENABLE 0x40
61#define HARRIER_MPIC_IFEVP_OFF 0x10200
62#define HARRIER_MPIC_IFEVP_VECT_MSK 0xff
63#define HARRIER_MPIC_IFEDE_OFF 0x10210
64
65/*
66 * Define the Memory Controller register offsets.
67 */
68#define HARRIER_SDBA_OFF 0x110
69#define HARRIER_SDBB_OFF 0x114
70#define HARRIER_SDBC_OFF 0x118
71#define HARRIER_SDBD_OFF 0x11c
72#define HARRIER_SDBE_OFF 0x120
73#define HARRIER_SDBF_OFF 0x124
74#define HARRIER_SDBG_OFF 0x128
75#define HARRIER_SDBH_OFF 0x12c
76
77#define HARRIER_SDB_ENABLE 0x00000100
78#define HARRIER_SDB_SIZE_MASK 0xf
79#define HARRIER_SDB_SIZE_SHIFT 16
80#define HARRIER_SDB_BASE_MASK 0xff
81#define HARRIER_SDB_BASE_SHIFT 24
82
83/*
84 * Define outbound register offsets.
85 */
86#define HARRIER_OTAD0_OFF 0x220
87#define HARRIER_OTOF0_OFF 0x224
88#define HARRIER_OTAD1_OFF 0x228
89#define HARRIER_OTOF1_OFF 0x22c
90#define HARRIER_OTAD2_OFF 0x230
91#define HARRIER_OTOF2_OFF 0x234
92#define HARRIER_OTAD3_OFF 0x238
93#define HARRIER_OTOF3_OFF 0x23c
94
95#define HARRIER_OTADX_START_MSK 0xffff0000UL
96#define HARRIER_OTADX_END_MSK 0x0000ffffUL
97
98#define HARRIER_OTOFX_OFF_MSK 0xffff0000UL
99#define HARRIER_OTOFX_ENA 0x80UL
100#define HARRIER_OTOFX_WPE 0x10UL
101#define HARRIER_OTOFX_SGE 0x08UL
102#define HARRIER_OTOFX_RAE 0x04UL
103#define HARRIER_OTOFX_MEM 0x02UL
104#define HARRIER_OTOFX_IOM 0x01UL
105
106/*
107 * Define generic message passing register offsets
108 */
109/* Mirrored registers (visible from both PowerPC and PCI space) */
110#define HARRIER_XCSR_MP_BASE_OFF 0x290 /* base offset in XCSR space */
111#define HARRIER_PMEP_MP_BASE_OFF 0x100 /* base offset in PMEM space */
112#define HARRIER_MGOM0_OFF 0x00 /* outbound msg 0 */
113#define HARRIER_MGOM1_OFF 0x04 /* outbound msg 1 */
114#define HARRIER_MGOD_OFF 0x08 /* outbound doorbells */
115
116#define HARRIER_MGIM0_OFF 0x10 /* inbound msg 0 */
117#define HARRIER_MGIM1_OFF 0x14 /* inbound msg 1 */
118#define HARRIER_MGID_OFF 0x18 /* inbound doorbells */
119
120/* PowerPC-only registers */
121#define HARRIER_MGIDM_OFF 0x20 /* inbound doorbell mask */
122
123/* PCI-only registers */
124#define HARRIER_PMEP_MGST_OFF 0x20 /* (outbound) interrupt status */
125#define HARRIER_PMEP_MGMS_OFF 0x24 /* (outbound) interrupt mask */
126#define HARRIER_MG_OMI0 (1<<4)
127#define HARRIER_MG_OMI1 (1<<5)
128
129#define HARRIER_PMEP_MGODM_OFF 0x28 /* outbound doorbell mask */
130
131/*
132 * Define PCI configuration space register offsets
133 */
134#define HARRIER_XCSR_TO_PCFS_OFF 0x300
135
136/*
137 * Define message passing attribute register offset
138 */
139#define HARRIER_MPAT_OFF 0x44
140
141/*
142 * Define inbound attribute register offsets.
143 */
144#define HARRIER_ITSZ0_OFF 0x48
145#define HARRIER_ITAT0_OFF 0x4c
146
147#define HARRIER_ITSZ1_OFF 0x50
148#define HARRIER_ITAT1_OFF 0x54
149
150#define HARRIER_ITSZ2_OFF 0x58
151#define HARRIER_ITAT2_OFF 0x5c
152
153#define HARRIER_ITSZ3_OFF 0x60
154#define HARRIER_ITAT3_OFF 0x64
155
156/* inbound translation size constants */
157#define HARRIER_ITSZ_MSK 0xff
158#define HARRIER_ITSZ_4KB 0x00
159#define HARRIER_ITSZ_8KB 0x01
160#define HARRIER_ITSZ_16KB 0x02
161#define HARRIER_ITSZ_32KB 0x03
162#define HARRIER_ITSZ_64KB 0x04
163#define HARRIER_ITSZ_128KB 0x05
164#define HARRIER_ITSZ_256KB 0x06
165#define HARRIER_ITSZ_512KB 0x07
166#define HARRIER_ITSZ_1MB 0x08
167#define HARRIER_ITSZ_2MB 0x09
168#define HARRIER_ITSZ_4MB 0x0A
169#define HARRIER_ITSZ_8MB 0x0B
170#define HARRIER_ITSZ_16MB 0x0C
171#define HARRIER_ITSZ_32MB 0x0D
172#define HARRIER_ITSZ_64MB 0x0E
173#define HARRIER_ITSZ_128MB 0x0F
174#define HARRIER_ITSZ_256MB 0x10
175#define HARRIER_ITSZ_512MB 0x11
176#define HARRIER_ITSZ_1GB 0x12
177#define HARRIER_ITSZ_2GB 0x13
178
179/* inbound translation offset */
180#define HARRIER_ITOF_SHIFT 0x10
181#define HARRIER_ITOF_MSK 0xffff
182
183/* inbound translation atttributes */
184#define HARRIER_ITAT_PRE (1<<3)
185#define HARRIER_ITAT_RAE (1<<4)
186#define HARRIER_ITAT_WPE (1<<5)
187#define HARRIER_ITAT_MEM (1<<6)
188#define HARRIER_ITAT_ENA (1<<7)
189#define HARRIER_ITAT_GBL (1<<16)
190
191#define HARRIER_LBA_OFF 0x80
192#define HARRIER_LBA_MSK (1<<31)
193
194#define HARRIER_XCSR_SIZE 1024
195
196/* macros to calculate message passing register offsets */
197#define HARRIER_MP_XCSR(x) ((u32)HARRIER_XCSR_MP_BASE_OFF + (u32)x)
198
199#define HARRIER_MP_PMEP(x) ((u32)HARRIER_PMEP_MP_BASE_OFF + (u32)x)
200
201/*
202 * Define PCI configuration space register offsets
203 */
204#define HARRIER_MPBAR_OFF PCI_BASE_ADDRESS_0
205#define HARRIER_ITBAR0_OFF PCI_BASE_ADDRESS_1
206#define HARRIER_ITBAR1_OFF PCI_BASE_ADDRESS_2
207#define HARRIER_ITBAR2_OFF PCI_BASE_ADDRESS_3
208#define HARRIER_ITBAR3_OFF PCI_BASE_ADDRESS_4
209
210#define HARRIER_XCSR_CONFIG(x) ((u32)HARRIER_XCSR_TO_PCFS_OFF + (u32)x)
211
212#endif /* __ASMPPC_HARRIER_DEFS_H */
diff --git a/include/linux/hayesesp.h b/include/linux/hayesesp.h
index 2177ee5b2fe2..940aeb51d53f 100644
--- a/include/linux/hayesesp.h
+++ b/include/linux/hayesesp.h
@@ -76,11 +76,10 @@ struct hayes_esp_config {
76 76
77struct esp_struct { 77struct esp_struct {
78 int magic; 78 int magic;
79 struct tty_port port;
79 spinlock_t lock; 80 spinlock_t lock;
80 int port; 81 int io_port;
81 int irq; 82 int irq;
82 int flags; /* defined in tty.h */
83 struct tty_struct *tty;
84 int read_status_mask; 83 int read_status_mask;
85 int ignore_status_mask; 84 int ignore_status_mask;
86 int timeout; 85 int timeout;
@@ -93,14 +92,10 @@ struct esp_struct {
93 int MCR; /* Modem control register */ 92 int MCR; /* Modem control register */
94 unsigned long last_active; 93 unsigned long last_active;
95 int line; 94 int line;
96 int count; /* # of fd on device */
97 int blocked_open; /* # of blocked opens */
98 unsigned char *xmit_buf; 95 unsigned char *xmit_buf;
99 int xmit_head; 96 int xmit_head;
100 int xmit_tail; 97 int xmit_tail;
101 int xmit_cnt; 98 int xmit_cnt;
102 wait_queue_head_t open_wait;
103 wait_queue_head_t close_wait;
104 wait_queue_head_t delta_msr_wait; 99 wait_queue_head_t delta_msr_wait;
105 wait_queue_head_t break_wait; 100 wait_queue_head_t break_wait;
106 struct async_icount icount; /* kernel counters for the 4 input interrupts */ 101 struct async_icount icount; /* kernel counters for the 4 input interrupts */
diff --git a/include/linux/hdlc.h b/include/linux/hdlc.h
index 6115545a5b9c..c59769693bee 100644
--- a/include/linux/hdlc.h
+++ b/include/linux/hdlc.h
@@ -45,7 +45,6 @@ struct hdlc_proto {
45 45
46/* Pointed to by dev->priv */ 46/* Pointed to by dev->priv */
47typedef struct hdlc_device { 47typedef struct hdlc_device {
48 struct net_device_stats stats;
49 /* used by HDLC layer to take control over HDLC device from hw driver*/ 48 /* used by HDLC layer to take control over HDLC device from hw driver*/
50 int (*attach)(struct net_device *dev, 49 int (*attach)(struct net_device *dev,
51 unsigned short encoding, unsigned short parity); 50 unsigned short encoding, unsigned short parity);
@@ -109,12 +108,6 @@ int attach_hdlc_protocol(struct net_device *dev, struct hdlc_proto *proto,
109/* May be used by hardware driver to gain control over HDLC device */ 108/* May be used by hardware driver to gain control over HDLC device */
110void detach_hdlc_protocol(struct net_device *dev); 109void detach_hdlc_protocol(struct net_device *dev);
111 110
112static __inline__ struct net_device_stats *hdlc_stats(struct net_device *dev)
113{
114 return &dev_to_hdlc(dev)->stats;
115}
116
117
118static __inline__ __be16 hdlc_type_trans(struct sk_buff *skb, 111static __inline__ __be16 hdlc_type_trans(struct sk_buff *skb,
119 struct net_device *dev) 112 struct net_device *dev)
120{ 113{
diff --git a/include/linux/hid.h b/include/linux/hid.h
index fe56b86f2c67..f13bca2dd53b 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -67,6 +67,7 @@
67#include <linux/types.h> 67#include <linux/types.h>
68#include <linux/slab.h> 68#include <linux/slab.h>
69#include <linux/list.h> 69#include <linux/list.h>
70#include <linux/mod_devicetable.h> /* hid_device_id */
70#include <linux/timer.h> 71#include <linux/timer.h>
71#include <linux/workqueue.h> 72#include <linux/workqueue.h>
72#include <linux/input.h> 73#include <linux/input.h>
@@ -246,6 +247,19 @@ struct hid_item {
246#define HID_FEATURE_REPORT 2 247#define HID_FEATURE_REPORT 2
247 248
248/* 249/*
250 * HID connect requests
251 */
252
253#define HID_CONNECT_HIDINPUT 0x01
254#define HID_CONNECT_HIDINPUT_FORCE 0x02
255#define HID_CONNECT_HIDRAW 0x04
256#define HID_CONNECT_HIDDEV 0x08
257#define HID_CONNECT_HIDDEV_FORCE 0x10
258#define HID_CONNECT_FF 0x20
259#define HID_CONNECT_DEFAULT (HID_CONNECT_HIDINPUT|HID_CONNECT_HIDRAW| \
260 HID_CONNECT_HIDDEV|HID_CONNECT_FF)
261
262/*
249 * HID device quirks. 263 * HID device quirks.
250 */ 264 */
251 265
@@ -256,48 +270,11 @@ struct hid_item {
256 270
257#define HID_QUIRK_INVERT 0x00000001 271#define HID_QUIRK_INVERT 0x00000001
258#define HID_QUIRK_NOTOUCH 0x00000002 272#define HID_QUIRK_NOTOUCH 0x00000002
259#define HID_QUIRK_IGNORE 0x00000004
260#define HID_QUIRK_NOGET 0x00000008 273#define HID_QUIRK_NOGET 0x00000008
261#define HID_QUIRK_HIDDEV 0x00000010
262#define HID_QUIRK_BADPAD 0x00000020 274#define HID_QUIRK_BADPAD 0x00000020
263#define HID_QUIRK_MULTI_INPUT 0x00000040 275#define HID_QUIRK_MULTI_INPUT 0x00000040
264#define HID_QUIRK_2WHEEL_MOUSE_HACK_7 0x00000080
265#define HID_QUIRK_2WHEEL_MOUSE_HACK_5 0x00000100
266#define HID_QUIRK_2WHEEL_MOUSE_HACK_ON 0x00000200
267#define HID_QUIRK_MIGHTYMOUSE 0x00000400
268#define HID_QUIRK_APPLE_HAS_FN 0x00000800
269#define HID_QUIRK_APPLE_FN_ON 0x00001000
270#define HID_QUIRK_INVERT_HWHEEL 0x00002000
271#define HID_QUIRK_APPLE_ISO_KEYBOARD 0x00004000
272#define HID_QUIRK_BAD_RELATIVE_KEYS 0x00008000
273#define HID_QUIRK_SKIP_OUTPUT_REPORTS 0x00010000 276#define HID_QUIRK_SKIP_OUTPUT_REPORTS 0x00010000
274#define HID_QUIRK_IGNORE_MOUSE 0x00020000
275#define HID_QUIRK_SONY_PS3_CONTROLLER 0x00040000
276#define HID_QUIRK_DUPLICATE_USAGES 0x00080000
277#define HID_QUIRK_RESET_LEDS 0x00100000
278#define HID_QUIRK_HIDINPUT 0x00200000
279#define HID_QUIRK_LOGITECH_IGNORE_DOUBLED_WHEEL 0x00400000
280#define HID_QUIRK_LOGITECH_EXPANDED_KEYMAP 0x00800000
281#define HID_QUIRK_IGNORE_HIDINPUT 0x01000000
282#define HID_QUIRK_2WHEEL_MOUSE_HACK_B8 0x02000000
283#define HID_QUIRK_HWHEEL_WHEEL_INVERT 0x04000000
284#define HID_QUIRK_MICROSOFT_KEYS 0x08000000
285#define HID_QUIRK_FULLSPEED_INTERVAL 0x10000000 277#define HID_QUIRK_FULLSPEED_INTERVAL 0x10000000
286#define HID_QUIRK_APPLE_NUMLOCK_EMULATION 0x20000000
287
288/*
289 * Separate quirks for runtime report descriptor fixup
290 */
291
292#define HID_QUIRK_RDESC_CYMOTION 0x00000001
293#define HID_QUIRK_RDESC_LOGITECH 0x00000002
294#define HID_QUIRK_RDESC_SWAPPED_MIN_MAX 0x00000004
295#define HID_QUIRK_RDESC_PETALYNX 0x00000008
296#define HID_QUIRK_RDESC_MACBOOK_JIS 0x00000010
297#define HID_QUIRK_RDESC_BUTTON_CONSUMER 0x00000020
298#define HID_QUIRK_RDESC_SAMSUNG_REMOTE 0x00000040
299#define HID_QUIRK_RDESC_MICROSOFT_RECV_1028 0x00000080
300#define HID_QUIRK_RDESC_SUNPLUS_WDESKTOP 0x00000100
301 278
302/* 279/*
303 * This is the global environment of the parser. This information is 280 * This is the global environment of the parser. This information is
@@ -411,12 +388,21 @@ struct hid_report_enum {
411struct hid_control_fifo { 388struct hid_control_fifo {
412 unsigned char dir; 389 unsigned char dir;
413 struct hid_report *report; 390 struct hid_report *report;
391 char *raw_report;
392};
393
394struct hid_output_fifo {
395 struct hid_report *report;
396 char *raw_report;
414}; 397};
415 398
416#define HID_CLAIMED_INPUT 1 399#define HID_CLAIMED_INPUT 1
417#define HID_CLAIMED_HIDDEV 2 400#define HID_CLAIMED_HIDDEV 2
418#define HID_CLAIMED_HIDRAW 4 401#define HID_CLAIMED_HIDRAW 4
419 402
403#define HID_STAT_ADDED 1
404#define HID_STAT_PARSED 2
405
420#define HID_CTRL_RUNNING 1 406#define HID_CTRL_RUNNING 1
421#define HID_OUT_RUNNING 2 407#define HID_OUT_RUNNING 2
422#define HID_IN_RUNNING 3 408#define HID_IN_RUNNING 3
@@ -431,22 +417,28 @@ struct hid_input {
431 struct input_dev *input; 417 struct input_dev *input;
432}; 418};
433 419
420struct hid_driver;
421struct hid_ll_driver;
422
434struct hid_device { /* device report descriptor */ 423struct hid_device { /* device report descriptor */
435 __u8 *rdesc; 424 __u8 *rdesc;
436 unsigned rsize; 425 unsigned rsize;
437 struct hid_collection *collection; /* List of HID collections */ 426 struct hid_collection *collection; /* List of HID collections */
438 unsigned collection_size; /* Number of allocated hid_collections */ 427 unsigned collection_size; /* Number of allocated hid_collections */
439 unsigned maxcollection; /* Number of parsed collections */ 428 unsigned maxcollection; /* Number of parsed collections */
440 unsigned maxapplication; /* Number of applications */ 429 unsigned maxapplication; /* Number of applications */
441 unsigned short bus; /* BUS ID */ 430 __u16 bus; /* BUS ID */
442 unsigned short vendor; /* Vendor ID */ 431 __u32 vendor; /* Vendor ID */
443 unsigned short product; /* Product ID */ 432 __u32 product; /* Product ID */
444 unsigned version; /* HID version */ 433 __u32 version; /* HID version */
445 unsigned country; /* HID country */ 434 unsigned country; /* HID country */
446 struct hid_report_enum report_enum[HID_REPORT_TYPES]; 435 struct hid_report_enum report_enum[HID_REPORT_TYPES];
447 436
448 struct device *dev; /* device */ 437 struct device dev; /* device */
438 struct hid_driver *driver;
439 struct hid_ll_driver *ll_driver;
449 440
441 unsigned int status; /* see STAT flags above */
450 unsigned claimed; /* Claimed by hidinput, hiddev? */ 442 unsigned claimed; /* Claimed by hidinput, hiddev? */
451 unsigned quirks; /* Various quirks the device can pull on us */ 443 unsigned quirks; /* Various quirks the device can pull on us */
452 444
@@ -462,26 +454,29 @@ struct hid_device { /* device report descriptor */
462 454
463 void *driver_data; 455 void *driver_data;
464 456
465 __s32 delayed_value; /* For A4 Tech mice hwheel quirk */ 457 /* temporary hid_ff handling (until moved to the drivers) */
466 458 int (*ff_init)(struct hid_device *);
467 /* device-specific function pointers */
468 int (*hidinput_input_event) (struct input_dev *, unsigned int, unsigned int, int);
469 int (*hid_open) (struct hid_device *);
470 void (*hid_close) (struct hid_device *);
471 459
472 /* hiddev event handler */ 460 /* hiddev event handler */
461 int (*hiddev_connect)(struct hid_device *, unsigned int);
473 void (*hiddev_hid_event) (struct hid_device *, struct hid_field *field, 462 void (*hiddev_hid_event) (struct hid_device *, struct hid_field *field,
474 struct hid_usage *, __s32); 463 struct hid_usage *, __s32);
475 void (*hiddev_report_event) (struct hid_device *, struct hid_report *); 464 void (*hiddev_report_event) (struct hid_device *, struct hid_report *);
476 465
477 /* handler for raw output data, used by hidraw */ 466 /* handler for raw output data, used by hidraw */
478 int (*hid_output_raw_report) (struct hid_device *, __u8 *, size_t); 467 int (*hid_output_raw_report) (struct hid_device *, __u8 *, size_t);
479#ifdef CONFIG_USB_HIDINPUT_POWERBOOK
480 unsigned long apple_pressed_fn[BITS_TO_LONGS(KEY_CNT)];
481 unsigned long pb_pressed_numlock[BITS_TO_LONGS(KEY_CNT)];
482#endif
483}; 468};
484 469
470static inline void *hid_get_drvdata(struct hid_device *hdev)
471{
472 return dev_get_drvdata(&hdev->dev);
473}
474
475static inline void hid_set_drvdata(struct hid_device *hdev, void *data)
476{
477 dev_set_drvdata(&hdev->dev, data);
478}
479
485#define HID_GLOBAL_STACK_SIZE 4 480#define HID_GLOBAL_STACK_SIZE 4
486#define HID_COLLECTION_STACK_SIZE 4 481#define HID_COLLECTION_STACK_SIZE 4
487 482
@@ -510,9 +505,110 @@ struct hid_descriptor {
510 struct hid_class_descriptor desc[1]; 505 struct hid_class_descriptor desc[1];
511} __attribute__ ((packed)); 506} __attribute__ ((packed));
512 507
508#define HID_DEVICE(b, ven, prod) \
509 .bus = (b), \
510 .vendor = (ven), .product = (prod)
511
512#define HID_USB_DEVICE(ven, prod) HID_DEVICE(BUS_USB, ven, prod)
513#define HID_BLUETOOTH_DEVICE(ven, prod) HID_DEVICE(BUS_BLUETOOTH, ven, prod)
514
515#define HID_REPORT_ID(rep) \
516 .report_type = (rep)
517#define HID_USAGE_ID(uhid, utype, ucode) \
518 .usage_hid = (uhid), .usage_type = (utype), .usage_code = (ucode)
519/* we don't want to catch types and codes equal to 0 */
520#define HID_TERMINATOR (HID_ANY_ID - 1)
521
522struct hid_report_id {
523 __u32 report_type;
524};
525struct hid_usage_id {
526 __u32 usage_hid;
527 __u32 usage_type;
528 __u32 usage_code;
529};
530
531/**
532 * struct hid_driver
533 * @name: driver name (e.g. "Footech_bar-wheel")
534 * @id_table: which devices is this driver for (must be non-NULL for probe
535 * to be called)
536 * @probe: new device inserted
537 * @remove: device removed (NULL if not a hot-plug capable driver)
538 * @report_table: on which reports to call raw_event (NULL means all)
539 * @raw_event: if report in report_table, this hook is called (NULL means nop)
540 * @usage_table: on which events to call event (NULL means all)
541 * @event: if usage in usage_table, this hook is called (NULL means nop)
542 * @report_fixup: called before report descriptor parsing (NULL means nop)
543 * @input_mapping: invoked on input registering before mapping an usage
544 * @input_mapped: invoked on input registering after mapping an usage
545 *
546 * raw_event and event should return 0 on no action performed, 1 when no
547 * further processing should be done and negative on error
548 *
549 * input_mapping shall return a negative value to completely ignore this usage
550 * (e.g. doubled or invalid usage), zero to continue with parsing of this
551 * usage by generic code (no special handling needed) or positive to skip
552 * generic parsing (needed special handling which was done in the hook already)
553 * input_mapped shall return negative to inform the layer that this usage
554 * should not be considered for further processing or zero to notify that
555 * no processing was performed and should be done in a generic manner
556 * Both these functions may be NULL which means the same behavior as returning
557 * zero from them.
558 */
559struct hid_driver {
560 char *name;
561 const struct hid_device_id *id_table;
562
563 int (*probe)(struct hid_device *dev, const struct hid_device_id *id);
564 void (*remove)(struct hid_device *dev);
565
566 const struct hid_report_id *report_table;
567 int (*raw_event)(struct hid_device *hdev, struct hid_report *report,
568 u8 *data, int size);
569 const struct hid_usage_id *usage_table;
570 int (*event)(struct hid_device *hdev, struct hid_field *field,
571 struct hid_usage *usage, __s32 value);
572
573 void (*report_fixup)(struct hid_device *hdev, __u8 *buf,
574 unsigned int size);
575
576 int (*input_mapping)(struct hid_device *hdev,
577 struct hid_input *hidinput, struct hid_field *field,
578 struct hid_usage *usage, unsigned long **bit, int *max);
579 int (*input_mapped)(struct hid_device *hdev,
580 struct hid_input *hidinput, struct hid_field *field,
581 struct hid_usage *usage, unsigned long **bit, int *max);
582/* private: */
583 struct device_driver driver;
584};
585
586/**
587 * hid_ll_driver - low level driver callbacks
588 * @start: called on probe to start the device
589 * @stop: called on remove
590 * @open: called by input layer on open
591 * @close: called by input layer on close
592 * @hidinput_input_event: event input event (e.g. ff or leds)
593 * @parse: this method is called only once to parse the device data,
594 * shouldn't allocate anything to not leak memory
595 */
596struct hid_ll_driver {
597 int (*start)(struct hid_device *hdev);
598 void (*stop)(struct hid_device *hdev);
599
600 int (*open)(struct hid_device *hdev);
601 void (*close)(struct hid_device *hdev);
602
603 int (*hidinput_input_event) (struct input_dev *idev, unsigned int type,
604 unsigned int code, int value);
605
606 int (*parse)(struct hid_device *hdev);
607};
608
513/* Applications from HID Usage Tables 4/8/99 Version 1.1 */ 609/* Applications from HID Usage Tables 4/8/99 Version 1.1 */
514/* We ignore a few input applications that are not widely used */ 610/* We ignore a few input applications that are not widely used */
515#define IS_INPUT_APPLICATION(a) (((a >= 0x00010000) && (a <= 0x00010008)) || (a == 0x00010080) || (a == 0x000c0001)) 611#define IS_INPUT_APPLICATION(a) (((a >= 0x00010000) && (a <= 0x00010008)) || (a == 0x00010080) || (a == 0x000c0001) || (a == 0x000d0002))
516 612
517/* HID core API */ 613/* HID core API */
518 614
@@ -520,43 +616,157 @@ struct hid_descriptor {
520extern int hid_debug; 616extern int hid_debug;
521#endif 617#endif
522 618
619extern int hid_add_device(struct hid_device *);
620extern void hid_destroy_device(struct hid_device *);
621
622extern int __must_check __hid_register_driver(struct hid_driver *,
623 struct module *, const char *mod_name);
624static inline int __must_check hid_register_driver(struct hid_driver *driver)
625{
626 return __hid_register_driver(driver, THIS_MODULE, KBUILD_MODNAME);
627}
628extern void hid_unregister_driver(struct hid_driver *);
629
523extern void hidinput_hid_event(struct hid_device *, struct hid_field *, struct hid_usage *, __s32); 630extern void hidinput_hid_event(struct hid_device *, struct hid_field *, struct hid_usage *, __s32);
524extern void hidinput_report_event(struct hid_device *hid, struct hid_report *report); 631extern void hidinput_report_event(struct hid_device *hid, struct hid_report *report);
525extern int hidinput_connect(struct hid_device *); 632extern int hidinput_connect(struct hid_device *hid, unsigned int force);
526extern void hidinput_disconnect(struct hid_device *); 633extern void hidinput_disconnect(struct hid_device *);
527 634
528int hid_set_field(struct hid_field *, unsigned, __s32); 635int hid_set_field(struct hid_field *, unsigned, __s32);
529int hid_input_report(struct hid_device *, int type, u8 *, int, int); 636int hid_input_report(struct hid_device *, int type, u8 *, int, int);
530int hidinput_find_field(struct hid_device *hid, unsigned int type, unsigned int code, struct hid_field **field); 637int hidinput_find_field(struct hid_device *hid, unsigned int type, unsigned int code, struct hid_field **field);
531int hidinput_mapping_quirks(struct hid_usage *, struct input_dev *, unsigned long **, int *);
532int hidinput_event_quirks(struct hid_device *, struct hid_field *, struct hid_usage *, __s32);
533int hidinput_apple_event(struct hid_device *, struct input_dev *, struct hid_usage *, __s32);
534void hid_output_report(struct hid_report *report, __u8 *data); 638void hid_output_report(struct hid_report *report, __u8 *data);
535void hid_free_device(struct hid_device *device); 639struct hid_device *hid_allocate_device(void);
536struct hid_device *hid_parse_report(__u8 *start, unsigned size); 640int hid_parse_report(struct hid_device *hid, __u8 *start, unsigned size);
641int hid_connect(struct hid_device *hid, unsigned int connect_mask);
642
643/**
644 * hid_map_usage - map usage input bits
645 *
646 * @hidinput: hidinput which we are interested in
647 * @usage: usage to fill in
648 * @bit: pointer to input->{}bit (out parameter)
649 * @max: maximal valid usage->code to consider later (out parameter)
650 * @type: input event type (EV_KEY, EV_REL, ...)
651 * @c: code which corresponds to this usage and type
652 */
653static inline void hid_map_usage(struct hid_input *hidinput,
654 struct hid_usage *usage, unsigned long **bit, int *max,
655 __u8 type, __u16 c)
656{
657 struct input_dev *input = hidinput->input;
658
659 usage->type = type;
660 usage->code = c;
661
662 switch (type) {
663 case EV_ABS:
664 *bit = input->absbit;
665 *max = ABS_MAX;
666 break;
667 case EV_REL:
668 *bit = input->relbit;
669 *max = REL_MAX;
670 break;
671 case EV_KEY:
672 *bit = input->keybit;
673 *max = KEY_MAX;
674 break;
675 case EV_LED:
676 *bit = input->ledbit;
677 *max = LED_MAX;
678 break;
679 }
680}
681
682/**
683 * hid_map_usage_clear - map usage input bits and clear the input bit
684 *
685 * The same as hid_map_usage, except the @c bit is also cleared in supported
686 * bits (@bit).
687 */
688static inline void hid_map_usage_clear(struct hid_input *hidinput,
689 struct hid_usage *usage, unsigned long **bit, int *max,
690 __u8 type, __u16 c)
691{
692 hid_map_usage(hidinput, usage, bit, max, type, c);
693 clear_bit(c, *bit);
694}
695
696/**
697 * hid_parse - parse HW reports
698 *
699 * @hdev: hid device
700 *
701 * Call this from probe after you set up the device (if needed). Your
702 * report_fixup will be called (if non-NULL) after reading raw report from
703 * device before passing it to hid layer for real parsing.
704 */
705static inline int __must_check hid_parse(struct hid_device *hdev)
706{
707 int ret;
708
709 if (hdev->status & HID_STAT_PARSED)
710 return 0;
711
712 ret = hdev->ll_driver->parse(hdev);
713 if (!ret)
714 hdev->status |= HID_STAT_PARSED;
715
716 return ret;
717}
718
719/**
720 * hid_hw_start - start underlaying HW
721 *
722 * @hdev: hid device
723 * @connect_mask: which outputs to connect, see HID_CONNECT_*
724 *
725 * Call this in probe function *after* hid_parse. This will setup HW buffers
726 * and start the device (if not deffered to device open). hid_hw_stop must be
727 * called if this was successfull.
728 */
729static inline int __must_check hid_hw_start(struct hid_device *hdev,
730 unsigned int connect_mask)
731{
732 int ret = hdev->ll_driver->start(hdev);
733 if (ret || !connect_mask)
734 return ret;
735 ret = hid_connect(hdev, connect_mask);
736 if (ret)
737 hdev->ll_driver->stop(hdev);
738 return ret;
739}
740
741/**
742 * hid_hw_stop - stop underlaying HW
743 *
744 * @hdev: hid device
745 *
746 * This is usually called from remove function or from probe when something
747 * failed and hid_hw_start was called already.
748 */
749static inline void hid_hw_stop(struct hid_device *hdev)
750{
751 hdev->ll_driver->stop(hdev);
752}
753
754void hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size,
755 int interrupt);
756
757extern int hid_generic_init(void);
758extern void hid_generic_exit(void);
537 759
538/* HID quirks API */ 760/* HID quirks API */
539u32 usbhid_lookup_quirk(const u16 idVendor, const u16 idProduct); 761u32 usbhid_lookup_quirk(const u16 idVendor, const u16 idProduct);
540int usbhid_quirks_init(char **quirks_param); 762int usbhid_quirks_init(char **quirks_param);
541void usbhid_quirks_exit(void); 763void usbhid_quirks_exit(void);
542void usbhid_fixup_report_descriptor(const u16, const u16, char *, unsigned, char **); 764void usbhid_set_leds(struct hid_device *hid);
543
544#ifdef CONFIG_HID_FF
545int hid_ff_init(struct hid_device *hid);
546 765
547int hid_lgff_init(struct hid_device *hid);
548int hid_lg2ff_init(struct hid_device *hid);
549int hid_plff_init(struct hid_device *hid);
550int hid_tmff_init(struct hid_device *hid);
551int hid_zpff_init(struct hid_device *hid);
552#ifdef CONFIG_HID_PID 766#ifdef CONFIG_HID_PID
553int hid_pidff_init(struct hid_device *hid); 767int hid_pidff_init(struct hid_device *hid);
554#else 768#else
555static inline int hid_pidff_init(struct hid_device *hid) { return -ENODEV; } 769#define hid_pidff_init NULL
556#endif
557
558#else
559static inline int hid_ff_init(struct hid_device *hid) { return -1; }
560#endif 770#endif
561 771
562#ifdef CONFIG_HID_DEBUG 772#ifdef CONFIG_HID_DEBUG
@@ -572,10 +782,23 @@ dbg_hid(const char *fmt, ...)
572 return 0; 782 return 0;
573} 783}
574#define dbg_hid_line dbg_hid 784#define dbg_hid_line dbg_hid
575#endif 785#endif /* HID_DEBUG */
576 786
577#define err_hid(format, arg...) printk(KERN_ERR "%s: " format "\n" , \ 787#define err_hid(format, arg...) printk(KERN_ERR "%s: " format "\n" , \
578 __FILE__ , ## arg) 788 __FILE__ , ## arg)
579#endif 789#endif /* HID_FF */
790
791#ifdef CONFIG_HID_COMPAT
792#define HID_COMPAT_LOAD_DRIVER(name) \
793void hid_compat_##name(void) { } \
794EXPORT_SYMBOL(hid_compat_##name)
795#else
796#define HID_COMPAT_LOAD_DRIVER(name)
797#endif /* HID_COMPAT */
798#define HID_COMPAT_CALL_DRIVER(name) do { \
799 extern void hid_compat_##name(void); \
800 hid_compat_##name(); \
801} while (0)
802
580#endif 803#endif
581 804
diff --git a/include/linux/hiddev.h b/include/linux/hiddev.h
index a416b904ba90..c760ae0eb6a1 100644
--- a/include/linux/hiddev.h
+++ b/include/linux/hiddev.h
@@ -182,26 +182,28 @@ struct hiddev_usage_ref_multi {
182/* To traverse the input report descriptor info for a HID device, perform the 182/* To traverse the input report descriptor info for a HID device, perform the
183 * following: 183 * following:
184 * 184 *
185 * rinfo.report_type = HID_REPORT_TYPE_INPUT; 185 * rinfo.report_type = HID_REPORT_TYPE_INPUT;
186 * rinfo.report_id = HID_REPORT_ID_FIRST; 186 * rinfo.report_id = HID_REPORT_ID_FIRST;
187 * ret = ioctl(fd, HIDIOCGREPORTINFO, &rinfo); 187 * ret = ioctl(fd, HIDIOCGREPORTINFO, &rinfo);
188 * 188 *
189 * while (ret >= 0) { 189 * while (ret >= 0) {
190 * for (i = 0; i < rinfo.num_fields; i++) { 190 * for (i = 0; i < rinfo.num_fields; i++) {
191 * finfo.report_type = rinfo.report_type; 191 * finfo.report_type = rinfo.report_type;
192 * finfo.report_id = rinfo.report_id; 192 * finfo.report_id = rinfo.report_id;
193 * finfo.field_index = i; 193 * finfo.field_index = i;
194 * ioctl(fd, HIDIOCGFIELDINFO, &finfo); 194 * ioctl(fd, HIDIOCGFIELDINFO, &finfo);
195 * for (j = 0; j < finfo.maxusage; j++) { 195 * for (j = 0; j < finfo.maxusage; j++) {
196 * uref.field_index = i; 196 * uref.report_type = rinfo.report_type;
197 * uref.usage_index = j; 197 * uref.report_id = rinfo.report_id;
198 * ioctl(fd, HIDIOCGUCODE, &uref); 198 * uref.field_index = i;
199 * ioctl(fd, HIDIOCGUSAGE, &uref); 199 * uref.usage_index = j;
200 * } 200 * ioctl(fd, HIDIOCGUCODE, &uref);
201 * } 201 * ioctl(fd, HIDIOCGUSAGE, &uref);
202 * rinfo.report_id |= HID_REPORT_ID_NEXT; 202 * }
203 * ret = ioctl(fd, HIDIOCGREPORTINFO, &rinfo); 203 * }
204 * } 204 * rinfo.report_id |= HID_REPORT_ID_NEXT;
205 * ret = ioctl(fd, HIDIOCGREPORTINFO, &rinfo);
206 * }
205 */ 207 */
206 208
207 209
@@ -217,7 +219,7 @@ struct hid_field;
217struct hid_report; 219struct hid_report;
218 220
219#ifdef CONFIG_USB_HIDDEV 221#ifdef CONFIG_USB_HIDDEV
220int hiddev_connect(struct hid_device *); 222int hiddev_connect(struct hid_device *hid, unsigned int force);
221void hiddev_disconnect(struct hid_device *); 223void hiddev_disconnect(struct hid_device *);
222void hiddev_hid_event(struct hid_device *hid, struct hid_field *field, 224void hiddev_hid_event(struct hid_device *hid, struct hid_field *field,
223 struct hid_usage *usage, __s32 value); 225 struct hid_usage *usage, __s32 value);
@@ -225,7 +227,9 @@ void hiddev_report_event(struct hid_device *hid, struct hid_report *report);
225int __init hiddev_init(void); 227int __init hiddev_init(void);
226void hiddev_exit(void); 228void hiddev_exit(void);
227#else 229#else
228static inline int hiddev_connect(struct hid_device *hid) { return -1; } 230static inline int hiddev_connect(struct hid_device *hid,
231 unsigned int force)
232{ return -1; }
229static inline void hiddev_disconnect(struct hid_device *hid) { } 233static inline void hiddev_disconnect(struct hid_device *hid) { }
230static inline void hiddev_hid_event(struct hid_device *hid, struct hid_field *field, 234static inline void hiddev_hid_event(struct hid_device *hid, struct hid_field *field,
231 struct hid_usage *usage, __s32 value) { } 235 struct hid_usage *usage, __s32 value) { }
diff --git a/include/linux/hpet.h b/include/linux/hpet.h
index 2dc29ce6c8e4..79f63a27bcef 100644
--- a/include/linux/hpet.h
+++ b/include/linux/hpet.h
@@ -37,6 +37,7 @@ struct hpet {
37#define hpet_compare _u1._hpet_compare 37#define hpet_compare _u1._hpet_compare
38 38
39#define HPET_MAX_TIMERS (32) 39#define HPET_MAX_TIMERS (32)
40#define HPET_MAX_IRQ (32)
40 41
41/* 42/*
42 * HPET general capabilities register 43 * HPET general capabilities register
@@ -64,7 +65,7 @@ struct hpet {
64 */ 65 */
65 66
66#define Tn_INT_ROUTE_CAP_MASK (0xffffffff00000000ULL) 67#define Tn_INT_ROUTE_CAP_MASK (0xffffffff00000000ULL)
67#define Tn_INI_ROUTE_CAP_SHIFT (32UL) 68#define Tn_INT_ROUTE_CAP_SHIFT (32UL)
68#define Tn_FSB_INT_DELCAP_MASK (0x8000UL) 69#define Tn_FSB_INT_DELCAP_MASK (0x8000UL)
69#define Tn_FSB_INT_DELCAP_SHIFT (15) 70#define Tn_FSB_INT_DELCAP_SHIFT (15)
70#define Tn_FSB_EN_CNF_MASK (0x4000UL) 71#define Tn_FSB_EN_CNF_MASK (0x4000UL)
@@ -91,23 +92,14 @@ struct hpet {
91 * exported interfaces 92 * exported interfaces
92 */ 93 */
93 94
94struct hpet_task {
95 void (*ht_func) (void *);
96 void *ht_data;
97 void *ht_opaque;
98};
99
100struct hpet_data { 95struct hpet_data {
101 unsigned long hd_phys_address; 96 unsigned long hd_phys_address;
102 void __iomem *hd_address; 97 void __iomem *hd_address;
103 unsigned short hd_nirqs; 98 unsigned short hd_nirqs;
104 unsigned short hd_flags;
105 unsigned int hd_state; /* timer allocated */ 99 unsigned int hd_state; /* timer allocated */
106 unsigned int hd_irq[HPET_MAX_TIMERS]; 100 unsigned int hd_irq[HPET_MAX_TIMERS];
107}; 101};
108 102
109#define HPET_DATA_PLATFORM 0x0001 /* platform call to hpet_alloc */
110
111static inline void hpet_reserve_timer(struct hpet_data *hd, int timer) 103static inline void hpet_reserve_timer(struct hpet_data *hd, int timer)
112{ 104{
113 hd->hd_state |= (1 << timer); 105 hd->hd_state |= (1 << timer);
@@ -125,7 +117,7 @@ struct hpet_info {
125 unsigned short hi_timer; 117 unsigned short hi_timer;
126}; 118};
127 119
128#define HPET_INFO_PERIODIC 0x0001 /* timer is periodic */ 120#define HPET_INFO_PERIODIC 0x0010 /* periodic-capable comparator */
129 121
130#define HPET_IE_ON _IO('h', 0x01) /* interrupt on */ 122#define HPET_IE_ON _IO('h', 0x01) /* interrupt on */
131#define HPET_IE_OFF _IO('h', 0x02) /* interrupt off */ 123#define HPET_IE_OFF _IO('h', 0x02) /* interrupt off */
diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
index 6d93dce61cbb..2b3645b1acf4 100644
--- a/include/linux/hrtimer.h
+++ b/include/linux/hrtimer.h
@@ -20,6 +20,8 @@
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/list.h> 21#include <linux/list.h>
22#include <linux/wait.h> 22#include <linux/wait.h>
23#include <linux/percpu.h>
24
23 25
24struct hrtimer_clock_base; 26struct hrtimer_clock_base;
25struct hrtimer_cpu_base; 27struct hrtimer_cpu_base;
@@ -47,14 +49,22 @@ enum hrtimer_restart {
47 * HRTIMER_CB_IRQSAFE: Callback may run in hardirq context 49 * HRTIMER_CB_IRQSAFE: Callback may run in hardirq context
48 * HRTIMER_CB_IRQSAFE_NO_RESTART: Callback may run in hardirq context and 50 * HRTIMER_CB_IRQSAFE_NO_RESTART: Callback may run in hardirq context and
49 * does not restart the timer 51 * does not restart the timer
50 * HRTIMER_CB_IRQSAFE_NO_SOFTIRQ: Callback must run in hardirq context 52 * HRTIMER_CB_IRQSAFE_PERCPU: Callback must run in hardirq context
51 * Special mode for tick emultation 53 * Special mode for tick emulation and
54 * scheduler timer. Such timers are per
55 * cpu and not allowed to be migrated on
56 * cpu unplug.
57 * HRTIMER_CB_IRQSAFE_UNLOCKED: Callback should run in hardirq context
58 * with timer->base lock unlocked
59 * used for timers which call wakeup to
60 * avoid lock order problems with rq->lock
52 */ 61 */
53enum hrtimer_cb_mode { 62enum hrtimer_cb_mode {
54 HRTIMER_CB_SOFTIRQ, 63 HRTIMER_CB_SOFTIRQ,
55 HRTIMER_CB_IRQSAFE, 64 HRTIMER_CB_IRQSAFE,
56 HRTIMER_CB_IRQSAFE_NO_RESTART, 65 HRTIMER_CB_IRQSAFE_NO_RESTART,
57 HRTIMER_CB_IRQSAFE_NO_SOFTIRQ, 66 HRTIMER_CB_IRQSAFE_PERCPU,
67 HRTIMER_CB_IRQSAFE_UNLOCKED,
58}; 68};
59 69
60/* 70/*
@@ -67,9 +77,10 @@ enum hrtimer_cb_mode {
67 * 0x02 callback function running 77 * 0x02 callback function running
68 * 0x04 callback pending (high resolution mode) 78 * 0x04 callback pending (high resolution mode)
69 * 79 *
70 * Special case: 80 * Special cases:
71 * 0x03 callback function running and enqueued 81 * 0x03 callback function running and enqueued
72 * (was requeued on another CPU) 82 * (was requeued on another CPU)
83 * 0x09 timer was migrated on CPU hotunplug
73 * The "callback function running and enqueued" status is only possible on 84 * The "callback function running and enqueued" status is only possible on
74 * SMP. It happens for example when a posix timer expired and the callback 85 * SMP. It happens for example when a posix timer expired and the callback
75 * queued a signal. Between dropping the lock which protects the posix timer 86 * queued a signal. Between dropping the lock which protects the posix timer
@@ -87,13 +98,19 @@ enum hrtimer_cb_mode {
87#define HRTIMER_STATE_ENQUEUED 0x01 98#define HRTIMER_STATE_ENQUEUED 0x01
88#define HRTIMER_STATE_CALLBACK 0x02 99#define HRTIMER_STATE_CALLBACK 0x02
89#define HRTIMER_STATE_PENDING 0x04 100#define HRTIMER_STATE_PENDING 0x04
101#define HRTIMER_STATE_MIGRATE 0x08
90 102
91/** 103/**
92 * struct hrtimer - the basic hrtimer structure 104 * struct hrtimer - the basic hrtimer structure
93 * @node: red black tree node for time ordered insertion 105 * @node: red black tree node for time ordered insertion
94 * @expires: the absolute expiry time in the hrtimers internal 106 * @_expires: the absolute expiry time in the hrtimers internal
95 * representation. The time is related to the clock on 107 * representation. The time is related to the clock on
96 * which the timer is based. 108 * which the timer is based. Is setup by adding
109 * slack to the _softexpires value. For non range timers
110 * identical to _softexpires.
111 * @_softexpires: the absolute earliest expiry time of the hrtimer.
112 * The time which was given as expiry time when the timer
113 * was armed.
97 * @function: timer expiry callback function 114 * @function: timer expiry callback function
98 * @base: pointer to the timer base (per cpu and per clock) 115 * @base: pointer to the timer base (per cpu and per clock)
99 * @state: state information (See bit values above) 116 * @state: state information (See bit values above)
@@ -111,16 +128,17 @@ enum hrtimer_cb_mode {
111 */ 128 */
112struct hrtimer { 129struct hrtimer {
113 struct rb_node node; 130 struct rb_node node;
114 ktime_t expires; 131 ktime_t _expires;
132 ktime_t _softexpires;
115 enum hrtimer_restart (*function)(struct hrtimer *); 133 enum hrtimer_restart (*function)(struct hrtimer *);
116 struct hrtimer_clock_base *base; 134 struct hrtimer_clock_base *base;
117 unsigned long state; 135 unsigned long state;
118 enum hrtimer_cb_mode cb_mode;
119 struct list_head cb_entry; 136 struct list_head cb_entry;
137 enum hrtimer_cb_mode cb_mode;
120#ifdef CONFIG_TIMER_STATS 138#ifdef CONFIG_TIMER_STATS
139 int start_pid;
121 void *start_site; 140 void *start_site;
122 char start_comm[16]; 141 char start_comm[16];
123 int start_pid;
124#endif 142#endif
125}; 143};
126 144
@@ -145,10 +163,8 @@ struct hrtimer_sleeper {
145 * @first: pointer to the timer node which expires first 163 * @first: pointer to the timer node which expires first
146 * @resolution: the resolution of the clock, in nanoseconds 164 * @resolution: the resolution of the clock, in nanoseconds
147 * @get_time: function to retrieve the current time of the clock 165 * @get_time: function to retrieve the current time of the clock
148 * @get_softirq_time: function to retrieve the current time from the softirq
149 * @softirq_time: the time when running the hrtimer queue in the softirq 166 * @softirq_time: the time when running the hrtimer queue in the softirq
150 * @offset: offset of this clock to the monotonic base 167 * @offset: offset of this clock to the monotonic base
151 * @reprogram: function to reprogram the timer event
152 */ 168 */
153struct hrtimer_clock_base { 169struct hrtimer_clock_base {
154 struct hrtimer_cpu_base *cpu_base; 170 struct hrtimer_cpu_base *cpu_base;
@@ -157,13 +173,9 @@ struct hrtimer_clock_base {
157 struct rb_node *first; 173 struct rb_node *first;
158 ktime_t resolution; 174 ktime_t resolution;
159 ktime_t (*get_time)(void); 175 ktime_t (*get_time)(void);
160 ktime_t (*get_softirq_time)(void);
161 ktime_t softirq_time; 176 ktime_t softirq_time;
162#ifdef CONFIG_HIGH_RES_TIMERS 177#ifdef CONFIG_HIGH_RES_TIMERS
163 ktime_t offset; 178 ktime_t offset;
164 int (*reprogram)(struct hrtimer *t,
165 struct hrtimer_clock_base *b,
166 ktime_t n);
167#endif 179#endif
168}; 180};
169 181
@@ -197,6 +209,71 @@ struct hrtimer_cpu_base {
197#endif 209#endif
198}; 210};
199 211
212static inline void hrtimer_set_expires(struct hrtimer *timer, ktime_t time)
213{
214 timer->_expires = time;
215 timer->_softexpires = time;
216}
217
218static inline void hrtimer_set_expires_range(struct hrtimer *timer, ktime_t time, ktime_t delta)
219{
220 timer->_softexpires = time;
221 timer->_expires = ktime_add_safe(time, delta);
222}
223
224static inline void hrtimer_set_expires_range_ns(struct hrtimer *timer, ktime_t time, unsigned long delta)
225{
226 timer->_softexpires = time;
227 timer->_expires = ktime_add_safe(time, ns_to_ktime(delta));
228}
229
230static inline void hrtimer_set_expires_tv64(struct hrtimer *timer, s64 tv64)
231{
232 timer->_expires.tv64 = tv64;
233 timer->_softexpires.tv64 = tv64;
234}
235
236static inline void hrtimer_add_expires(struct hrtimer *timer, ktime_t time)
237{
238 timer->_expires = ktime_add_safe(timer->_expires, time);
239 timer->_softexpires = ktime_add_safe(timer->_softexpires, time);
240}
241
242static inline void hrtimer_add_expires_ns(struct hrtimer *timer, unsigned long ns)
243{
244 timer->_expires = ktime_add_ns(timer->_expires, ns);
245 timer->_softexpires = ktime_add_ns(timer->_softexpires, ns);
246}
247
248static inline ktime_t hrtimer_get_expires(const struct hrtimer *timer)
249{
250 return timer->_expires;
251}
252
253static inline ktime_t hrtimer_get_softexpires(const struct hrtimer *timer)
254{
255 return timer->_softexpires;
256}
257
258static inline s64 hrtimer_get_expires_tv64(const struct hrtimer *timer)
259{
260 return timer->_expires.tv64;
261}
262static inline s64 hrtimer_get_softexpires_tv64(const struct hrtimer *timer)
263{
264 return timer->_softexpires.tv64;
265}
266
267static inline s64 hrtimer_get_expires_ns(const struct hrtimer *timer)
268{
269 return ktime_to_ns(timer->_expires);
270}
271
272static inline ktime_t hrtimer_expires_remaining(const struct hrtimer *timer)
273{
274 return ktime_sub(timer->_expires, timer->base->get_time());
275}
276
200#ifdef CONFIG_HIGH_RES_TIMERS 277#ifdef CONFIG_HIGH_RES_TIMERS
201struct clock_event_device; 278struct clock_event_device;
202 279
@@ -217,6 +294,8 @@ static inline int hrtimer_is_hres_active(struct hrtimer *timer)
217 return timer->base->cpu_base->hres_active; 294 return timer->base->cpu_base->hres_active;
218} 295}
219 296
297extern void hrtimer_peek_ahead_timers(void);
298
220/* 299/*
221 * The resolution of the clocks. The resolution value is returned in 300 * The resolution of the clocks. The resolution value is returned in
222 * the clock_getres() system call to give application programmers an 301 * the clock_getres() system call to give application programmers an
@@ -239,6 +318,7 @@ static inline int hrtimer_is_hres_active(struct hrtimer *timer)
239 * is expired in the next softirq when the clock was advanced. 318 * is expired in the next softirq when the clock was advanced.
240 */ 319 */
241static inline void clock_was_set(void) { } 320static inline void clock_was_set(void) { }
321static inline void hrtimer_peek_ahead_timers(void) { }
242 322
243static inline void hres_timers_resume(void) { } 323static inline void hres_timers_resume(void) { }
244 324
@@ -260,6 +340,10 @@ static inline int hrtimer_is_hres_active(struct hrtimer *timer)
260extern ktime_t ktime_get(void); 340extern ktime_t ktime_get(void);
261extern ktime_t ktime_get_real(void); 341extern ktime_t ktime_get_real(void);
262 342
343
344DECLARE_PER_CPU(struct tick_device, tick_cpu_device);
345
346
263/* Exported timer functions: */ 347/* Exported timer functions: */
264 348
265/* Initialize timers: */ 349/* Initialize timers: */
@@ -284,12 +368,25 @@ static inline void destroy_hrtimer_on_stack(struct hrtimer *timer) { }
284/* Basic timer operations: */ 368/* Basic timer operations: */
285extern int hrtimer_start(struct hrtimer *timer, ktime_t tim, 369extern int hrtimer_start(struct hrtimer *timer, ktime_t tim,
286 const enum hrtimer_mode mode); 370 const enum hrtimer_mode mode);
371extern int hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim,
372 unsigned long range_ns, const enum hrtimer_mode mode);
287extern int hrtimer_cancel(struct hrtimer *timer); 373extern int hrtimer_cancel(struct hrtimer *timer);
288extern int hrtimer_try_to_cancel(struct hrtimer *timer); 374extern int hrtimer_try_to_cancel(struct hrtimer *timer);
289 375
376static inline int hrtimer_start_expires(struct hrtimer *timer,
377 enum hrtimer_mode mode)
378{
379 unsigned long delta;
380 ktime_t soft, hard;
381 soft = hrtimer_get_softexpires(timer);
382 hard = hrtimer_get_expires(timer);
383 delta = ktime_to_ns(ktime_sub(hard, soft));
384 return hrtimer_start_range_ns(timer, soft, delta, mode);
385}
386
290static inline int hrtimer_restart(struct hrtimer *timer) 387static inline int hrtimer_restart(struct hrtimer *timer)
291{ 388{
292 return hrtimer_start(timer, timer->expires, HRTIMER_MODE_ABS); 389 return hrtimer_start_expires(timer, HRTIMER_MODE_ABS);
293} 390}
294 391
295/* Query timers: */ 392/* Query timers: */
@@ -346,6 +443,10 @@ extern long hrtimer_nanosleep_restart(struct restart_block *restart_block);
346extern void hrtimer_init_sleeper(struct hrtimer_sleeper *sl, 443extern void hrtimer_init_sleeper(struct hrtimer_sleeper *sl,
347 struct task_struct *tsk); 444 struct task_struct *tsk);
348 445
446extern int schedule_hrtimeout_range(ktime_t *expires, unsigned long delta,
447 const enum hrtimer_mode mode);
448extern int schedule_hrtimeout(ktime_t *expires, const enum hrtimer_mode mode);
449
349/* Soft interrupt function to run the hrtimer queues: */ 450/* Soft interrupt function to run the hrtimer queues: */
350extern void hrtimer_run_queues(void); 451extern void hrtimer_run_queues(void);
351extern void hrtimer_run_pending(void); 452extern void hrtimer_run_pending(void);
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index a79e80b689d8..e1c8afc002c0 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -8,7 +8,6 @@
8#include <linux/mempolicy.h> 8#include <linux/mempolicy.h>
9#include <linux/shm.h> 9#include <linux/shm.h>
10#include <asm/tlbflush.h> 10#include <asm/tlbflush.h>
11#include <asm/hugetlb.h>
12 11
13struct ctl_table; 12struct ctl_table;
14 13
@@ -17,38 +16,45 @@ static inline int is_vm_hugetlb_page(struct vm_area_struct *vma)
17 return vma->vm_flags & VM_HUGETLB; 16 return vma->vm_flags & VM_HUGETLB;
18} 17}
19 18
19void reset_vma_resv_huge_pages(struct vm_area_struct *vma);
20int hugetlb_sysctl_handler(struct ctl_table *, int, struct file *, void __user *, size_t *, loff_t *); 20int hugetlb_sysctl_handler(struct ctl_table *, int, struct file *, void __user *, size_t *, loff_t *);
21int hugetlb_overcommit_handler(struct ctl_table *, int, struct file *, void __user *, size_t *, loff_t *); 21int hugetlb_overcommit_handler(struct ctl_table *, int, struct file *, void __user *, size_t *, loff_t *);
22int hugetlb_treat_movable_handler(struct ctl_table *, int, struct file *, void __user *, size_t *, loff_t *); 22int hugetlb_treat_movable_handler(struct ctl_table *, int, struct file *, void __user *, size_t *, loff_t *);
23int copy_hugetlb_page_range(struct mm_struct *, struct mm_struct *, struct vm_area_struct *); 23int copy_hugetlb_page_range(struct mm_struct *, struct mm_struct *, struct vm_area_struct *);
24int follow_hugetlb_page(struct mm_struct *, struct vm_area_struct *, struct page **, struct vm_area_struct **, unsigned long *, int *, int, int); 24int follow_hugetlb_page(struct mm_struct *, struct vm_area_struct *, struct page **, struct vm_area_struct **, unsigned long *, int *, int, int);
25void unmap_hugepage_range(struct vm_area_struct *, unsigned long, unsigned long); 25void unmap_hugepage_range(struct vm_area_struct *,
26void __unmap_hugepage_range(struct vm_area_struct *, unsigned long, unsigned long); 26 unsigned long, unsigned long, struct page *);
27void __unmap_hugepage_range(struct vm_area_struct *,
28 unsigned long, unsigned long, struct page *);
27int hugetlb_prefault(struct address_space *, struct vm_area_struct *); 29int hugetlb_prefault(struct address_space *, struct vm_area_struct *);
28int hugetlb_report_meminfo(char *); 30void hugetlb_report_meminfo(struct seq_file *);
29int hugetlb_report_node_meminfo(int, char *); 31int hugetlb_report_node_meminfo(int, char *);
30unsigned long hugetlb_total_pages(void); 32unsigned long hugetlb_total_pages(void);
31int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma, 33int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
32 unsigned long address, int write_access); 34 unsigned long address, int write_access);
33int hugetlb_reserve_pages(struct inode *inode, long from, long to); 35int hugetlb_reserve_pages(struct inode *inode, long from, long to,
36 struct vm_area_struct *vma);
34void hugetlb_unreserve_pages(struct inode *inode, long offset, long freed); 37void hugetlb_unreserve_pages(struct inode *inode, long offset, long freed);
35 38
36extern unsigned long max_huge_pages;
37extern unsigned long sysctl_overcommit_huge_pages;
38extern unsigned long hugepages_treat_as_movable; 39extern unsigned long hugepages_treat_as_movable;
39extern const unsigned long hugetlb_zero, hugetlb_infinity; 40extern const unsigned long hugetlb_zero, hugetlb_infinity;
40extern int sysctl_hugetlb_shm_group; 41extern int sysctl_hugetlb_shm_group;
42extern struct list_head huge_boot_pages;
41 43
42/* arch callbacks */ 44/* arch callbacks */
43 45
44pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr); 46pte_t *huge_pte_alloc(struct mm_struct *mm,
47 unsigned long addr, unsigned long sz);
45pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr); 48pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr);
46int huge_pmd_unshare(struct mm_struct *mm, unsigned long *addr, pte_t *ptep); 49int huge_pmd_unshare(struct mm_struct *mm, unsigned long *addr, pte_t *ptep);
47struct page *follow_huge_addr(struct mm_struct *mm, unsigned long address, 50struct page *follow_huge_addr(struct mm_struct *mm, unsigned long address,
48 int write); 51 int write);
49struct page *follow_huge_pmd(struct mm_struct *mm, unsigned long address, 52struct page *follow_huge_pmd(struct mm_struct *mm, unsigned long address,
50 pmd_t *pmd, int write); 53 pmd_t *pmd, int write);
54struct page *follow_huge_pud(struct mm_struct *mm, unsigned long address,
55 pud_t *pud, int write);
51int pmd_huge(pmd_t pmd); 56int pmd_huge(pmd_t pmd);
57int pud_huge(pud_t pmd);
52void hugetlb_change_protection(struct vm_area_struct *vma, 58void hugetlb_change_protection(struct vm_area_struct *vma,
53 unsigned long address, unsigned long end, pgprot_t newprot); 59 unsigned long address, unsigned long end, pgprot_t newprot);
54 60
@@ -58,6 +64,11 @@ static inline int is_vm_hugetlb_page(struct vm_area_struct *vma)
58{ 64{
59 return 0; 65 return 0;
60} 66}
67
68static inline void reset_vma_resv_huge_pages(struct vm_area_struct *vma)
69{
70}
71
61static inline unsigned long hugetlb_total_pages(void) 72static inline unsigned long hugetlb_total_pages(void)
62{ 73{
63 return 0; 74 return 0;
@@ -67,12 +78,16 @@ static inline unsigned long hugetlb_total_pages(void)
67#define follow_huge_addr(mm, addr, write) ERR_PTR(-EINVAL) 78#define follow_huge_addr(mm, addr, write) ERR_PTR(-EINVAL)
68#define copy_hugetlb_page_range(src, dst, vma) ({ BUG(); 0; }) 79#define copy_hugetlb_page_range(src, dst, vma) ({ BUG(); 0; })
69#define hugetlb_prefault(mapping, vma) ({ BUG(); 0; }) 80#define hugetlb_prefault(mapping, vma) ({ BUG(); 0; })
70#define unmap_hugepage_range(vma, start, end) BUG() 81#define unmap_hugepage_range(vma, start, end, page) BUG()
71#define hugetlb_report_meminfo(buf) 0 82static inline void hugetlb_report_meminfo(struct seq_file *m)
83{
84}
72#define hugetlb_report_node_meminfo(n, buf) 0 85#define hugetlb_report_node_meminfo(n, buf) 0
73#define follow_huge_pmd(mm, addr, pmd, write) NULL 86#define follow_huge_pmd(mm, addr, pmd, write) NULL
74#define prepare_hugepage_range(addr,len) (-EINVAL) 87#define follow_huge_pud(mm, addr, pud, write) NULL
88#define prepare_hugepage_range(file, addr, len) (-EINVAL)
75#define pmd_huge(x) 0 89#define pmd_huge(x) 0
90#define pud_huge(x) 0
76#define is_hugepage_only_range(mm, addr, len) 0 91#define is_hugepage_only_range(mm, addr, len) 0
77#define hugetlb_free_pgd_range(tlb, addr, end, floor, ceiling) ({BUG(); 0; }) 92#define hugetlb_free_pgd_range(tlb, addr, end, floor, ceiling) ({BUG(); 0; })
78#define hugetlb_fault(mm, vma, addr, write) ({ BUG(); 0; }) 93#define hugetlb_fault(mm, vma, addr, write) ({ BUG(); 0; })
@@ -93,6 +108,7 @@ struct hugetlbfs_config {
93 umode_t mode; 108 umode_t mode;
94 long nr_blocks; 109 long nr_blocks;
95 long nr_inodes; 110 long nr_inodes;
111 struct hstate *hstate;
96}; 112};
97 113
98struct hugetlbfs_sb_info { 114struct hugetlbfs_sb_info {
@@ -101,6 +117,7 @@ struct hugetlbfs_sb_info {
101 long max_inodes; /* inodes allowed */ 117 long max_inodes; /* inodes allowed */
102 long free_inodes; /* inodes free */ 118 long free_inodes; /* inodes free */
103 spinlock_t stat_lock; 119 spinlock_t stat_lock;
120 struct hstate *hstate;
104}; 121};
105 122
106 123
@@ -125,8 +142,6 @@ struct file *hugetlb_file_setup(const char *name, size_t);
125int hugetlb_get_quota(struct address_space *mapping, long delta); 142int hugetlb_get_quota(struct address_space *mapping, long delta);
126void hugetlb_put_quota(struct address_space *mapping, long delta); 143void hugetlb_put_quota(struct address_space *mapping, long delta);
127 144
128#define BLOCKS_PER_HUGEPAGE (HPAGE_SIZE / 512)
129
130static inline int is_file_hugepages(struct file *file) 145static inline int is_file_hugepages(struct file *file)
131{ 146{
132 if (file->f_op == &hugetlbfs_file_operations) 147 if (file->f_op == &hugetlbfs_file_operations)
@@ -155,4 +170,115 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
155 unsigned long flags); 170 unsigned long flags);
156#endif /* HAVE_ARCH_HUGETLB_UNMAPPED_AREA */ 171#endif /* HAVE_ARCH_HUGETLB_UNMAPPED_AREA */
157 172
173#ifdef CONFIG_HUGETLB_PAGE
174
175#define HSTATE_NAME_LEN 32
176/* Defines one hugetlb page size */
177struct hstate {
178 int hugetlb_next_nid;
179 unsigned int order;
180 unsigned long mask;
181 unsigned long max_huge_pages;
182 unsigned long nr_huge_pages;
183 unsigned long free_huge_pages;
184 unsigned long resv_huge_pages;
185 unsigned long surplus_huge_pages;
186 unsigned long nr_overcommit_huge_pages;
187 struct list_head hugepage_freelists[MAX_NUMNODES];
188 unsigned int nr_huge_pages_node[MAX_NUMNODES];
189 unsigned int free_huge_pages_node[MAX_NUMNODES];
190 unsigned int surplus_huge_pages_node[MAX_NUMNODES];
191 char name[HSTATE_NAME_LEN];
192};
193
194struct huge_bootmem_page {
195 struct list_head list;
196 struct hstate *hstate;
197};
198
199/* arch callback */
200int __init alloc_bootmem_huge_page(struct hstate *h);
201
202void __init hugetlb_add_hstate(unsigned order);
203struct hstate *size_to_hstate(unsigned long size);
204
205#ifndef HUGE_MAX_HSTATE
206#define HUGE_MAX_HSTATE 1
207#endif
208
209extern struct hstate hstates[HUGE_MAX_HSTATE];
210extern unsigned int default_hstate_idx;
211
212#define default_hstate (hstates[default_hstate_idx])
213
214static inline struct hstate *hstate_inode(struct inode *i)
215{
216 struct hugetlbfs_sb_info *hsb;
217 hsb = HUGETLBFS_SB(i->i_sb);
218 return hsb->hstate;
219}
220
221static inline struct hstate *hstate_file(struct file *f)
222{
223 return hstate_inode(f->f_dentry->d_inode);
224}
225
226static inline struct hstate *hstate_vma(struct vm_area_struct *vma)
227{
228 return hstate_file(vma->vm_file);
229}
230
231static inline unsigned long huge_page_size(struct hstate *h)
232{
233 return (unsigned long)PAGE_SIZE << h->order;
234}
235
236static inline unsigned long huge_page_mask(struct hstate *h)
237{
238 return h->mask;
239}
240
241static inline unsigned int huge_page_order(struct hstate *h)
242{
243 return h->order;
244}
245
246static inline unsigned huge_page_shift(struct hstate *h)
247{
248 return h->order + PAGE_SHIFT;
249}
250
251static inline unsigned int pages_per_huge_page(struct hstate *h)
252{
253 return 1 << h->order;
254}
255
256static inline unsigned int blocks_per_huge_page(struct hstate *h)
257{
258 return huge_page_size(h) / 512;
259}
260
261#include <asm/hugetlb.h>
262
263static inline struct hstate *page_hstate(struct page *page)
264{
265 return size_to_hstate(PAGE_SIZE << compound_order(page));
266}
267
268#else
269struct hstate {};
270#define alloc_bootmem_huge_page(h) NULL
271#define hstate_file(f) NULL
272#define hstate_vma(v) NULL
273#define hstate_inode(i) NULL
274#define huge_page_size(h) PAGE_SIZE
275#define huge_page_mask(h) PAGE_MASK
276#define huge_page_order(h) 0
277#define huge_page_shift(h) PAGE_SHIFT
278static inline unsigned int pages_per_huge_page(struct hstate *h)
279{
280 return 1;
281}
282#endif
283
158#endif /* _LINUX_HUGETLB_H */ 284#endif /* _LINUX_HUGETLB_H */
diff --git a/include/linux/i2c-algo-pcf.h b/include/linux/i2c-algo-pcf.h
index 0177d280f733..0f91a957a690 100644
--- a/include/linux/i2c-algo-pcf.h
+++ b/include/linux/i2c-algo-pcf.h
@@ -31,7 +31,10 @@ struct i2c_algo_pcf_data {
31 int (*getpcf) (void *data, int ctl); 31 int (*getpcf) (void *data, int ctl);
32 int (*getown) (void *data); 32 int (*getown) (void *data);
33 int (*getclock) (void *data); 33 int (*getclock) (void *data);
34 void (*waitforpin) (void); 34 void (*waitforpin) (void *data);
35
36 void (*xfer_begin) (void *data);
37 void (*xfer_end) (void *data);
35 38
36 /* Multi-master lost arbitration back-off delay (msecs) 39 /* Multi-master lost arbitration back-off delay (msecs)
37 * This should be set by the bus adapter or knowledgable client 40 * This should be set by the bus adapter or knowledgable client
diff --git a/include/linux/i2c-id.h b/include/linux/i2c-id.h
index ef13b7c66df3..01d67ba9e985 100644
--- a/include/linux/i2c-id.h
+++ b/include/linux/i2c-id.h
@@ -33,26 +33,18 @@
33 33
34#define I2C_DRIVERID_MSP3400 1 34#define I2C_DRIVERID_MSP3400 1
35#define I2C_DRIVERID_TUNER 2 35#define I2C_DRIVERID_TUNER 2
36#define I2C_DRIVERID_TDA8425 4 /* stereo sound processor */
37#define I2C_DRIVERID_TEA6420 5 /* audio matrix switch */ 36#define I2C_DRIVERID_TEA6420 5 /* audio matrix switch */
38#define I2C_DRIVERID_TEA6415C 6 /* video matrix switch */ 37#define I2C_DRIVERID_TEA6415C 6 /* video matrix switch */
39#define I2C_DRIVERID_TDA9840 7 /* stereo sound processor */ 38#define I2C_DRIVERID_TDA9840 7 /* stereo sound processor */
40#define I2C_DRIVERID_SAA7111A 8 /* video input processor */ 39#define I2C_DRIVERID_SAA7111A 8 /* video input processor */
41#define I2C_DRIVERID_SAA7185B 13 /* video encoder */ 40#define I2C_DRIVERID_SAA7185B 13 /* video encoder */
42#define I2C_DRIVERID_TEA6300 18 /* audio mixer */
43#define I2C_DRIVERID_TDA9850 20 /* audio mixer */
44#define I2C_DRIVERID_TDA9855 21 /* audio mixer */
45#define I2C_DRIVERID_SAA7110 22 /* video decoder */ 41#define I2C_DRIVERID_SAA7110 22 /* video decoder */
46#define I2C_DRIVERID_MGATVO 23 /* Matrox TVOut */
47#define I2C_DRIVERID_SAA5249 24 /* SAA5249 and compatibles */ 42#define I2C_DRIVERID_SAA5249 24 /* SAA5249 and compatibles */
48#define I2C_DRIVERID_PCF8583 25 /* real time clock */ 43#define I2C_DRIVERID_PCF8583 25 /* real time clock */
49#define I2C_DRIVERID_SAB3036 26 /* SAB3036 tuner */
50#define I2C_DRIVERID_TDA7432 27 /* Stereo sound processor */ 44#define I2C_DRIVERID_TDA7432 27 /* Stereo sound processor */
51#define I2C_DRIVERID_TVMIXER 28 /* Mixer driver for tv cards */ 45#define I2C_DRIVERID_TVMIXER 28 /* Mixer driver for tv cards */
52#define I2C_DRIVERID_TVAUDIO 29 /* Generic TV sound driver */ 46#define I2C_DRIVERID_TVAUDIO 29 /* Generic TV sound driver */
53#define I2C_DRIVERID_TDA9873 31 /* TV sound decoder chip */
54#define I2C_DRIVERID_TDA9875 32 /* TV sound decoder chip */ 47#define I2C_DRIVERID_TDA9875 32 /* TV sound decoder chip */
55#define I2C_DRIVERID_PIC16C54_PV9 33 /* Audio mux/ir receiver */
56#define I2C_DRIVERID_BT819 40 /* video decoder */ 48#define I2C_DRIVERID_BT819 40 /* video decoder */
57#define I2C_DRIVERID_BT856 41 /* video encoder */ 49#define I2C_DRIVERID_BT856 41 /* video encoder */
58#define I2C_DRIVERID_VPX3220 42 /* video decoder+vbi/vtxt */ 50#define I2C_DRIVERID_VPX3220 42 /* video decoder+vbi/vtxt */
@@ -63,13 +55,12 @@
63#define I2C_DRIVERID_INDYCAM 58 /* SGI IndyCam */ 55#define I2C_DRIVERID_INDYCAM 58 /* SGI IndyCam */
64#define I2C_DRIVERID_OVCAMCHIP 61 /* OmniVision CMOS image sens. */ 56#define I2C_DRIVERID_OVCAMCHIP 61 /* OmniVision CMOS image sens. */
65#define I2C_DRIVERID_MAX6900 63 /* MAX6900 real-time clock */ 57#define I2C_DRIVERID_MAX6900 63 /* MAX6900 real-time clock */
66#define I2C_DRIVERID_TDA9874 66 /* TV sound decoder */
67#define I2C_DRIVERID_SAA6752HS 67 /* MPEG2 encoder */ 58#define I2C_DRIVERID_SAA6752HS 67 /* MPEG2 encoder */
68#define I2C_DRIVERID_TVEEPROM 68 /* TV EEPROM */ 59#define I2C_DRIVERID_TVEEPROM 68 /* TV EEPROM */
69#define I2C_DRIVERID_WM8775 69 /* wm8775 audio processor */ 60#define I2C_DRIVERID_WM8775 69 /* wm8775 audio processor */
70#define I2C_DRIVERID_CS53L32A 70 /* cs53l32a audio processor */ 61#define I2C_DRIVERID_CS53L32A 70 /* cs53l32a audio processor */
71#define I2C_DRIVERID_CX25840 71 /* cx2584x video encoder */ 62#define I2C_DRIVERID_CX25840 71 /* cx2584x video encoder */
72#define I2C_DRIVERID_SAA7127 72 /* saa7124 video encoder */ 63#define I2C_DRIVERID_SAA7127 72 /* saa7127 video encoder */
73#define I2C_DRIVERID_SAA711X 73 /* saa711x video encoders */ 64#define I2C_DRIVERID_SAA711X 73 /* saa711x video encoders */
74#define I2C_DRIVERID_AKITAIOEXP 74 /* IO Expander on Sharp SL-C1000 */ 65#define I2C_DRIVERID_AKITAIOEXP 74 /* IO Expander on Sharp SL-C1000 */
75#define I2C_DRIVERID_INFRARED 75 /* I2C InfraRed on Video boards */ 66#define I2C_DRIVERID_INFRARED 75 /* I2C InfraRed on Video boards */
@@ -102,7 +93,6 @@
102#define I2C_HW_B_BT848 0x010005 /* BT848 video boards */ 93#define I2C_HW_B_BT848 0x010005 /* BT848 video boards */
103#define I2C_HW_B_VIA 0x010007 /* Via vt82c586b */ 94#define I2C_HW_B_VIA 0x010007 /* Via vt82c586b */
104#define I2C_HW_B_HYDRA 0x010008 /* Apple Hydra Mac I/O */ 95#define I2C_HW_B_HYDRA 0x010008 /* Apple Hydra Mac I/O */
105#define I2C_HW_B_G400 0x010009 /* Matrox G400 */
106#define I2C_HW_B_I810 0x01000a /* Intel I810 */ 96#define I2C_HW_B_I810 0x01000a /* Intel I810 */
107#define I2C_HW_B_VOO 0x01000b /* 3dfx Voodoo 3 / Banshee */ 97#define I2C_HW_B_VOO 0x01000b /* 3dfx Voodoo 3 / Banshee */
108#define I2C_HW_B_SCX200 0x01000e /* Nat'l Semi SCx200 I2C */ 98#define I2C_HW_B_SCX200 0x01000e /* Nat'l Semi SCx200 I2C */
@@ -158,7 +148,6 @@
158#define I2C_HW_SMBUS_W9968CF 0x04000d 148#define I2C_HW_SMBUS_W9968CF 0x04000d
159#define I2C_HW_SMBUS_OV511 0x04000e /* OV511(+) USB 1.1 webcam ICs */ 149#define I2C_HW_SMBUS_OV511 0x04000e /* OV511(+) USB 1.1 webcam ICs */
160#define I2C_HW_SMBUS_OV518 0x04000f /* OV518(+) USB 1.1 webcam ICs */ 150#define I2C_HW_SMBUS_OV518 0x04000f /* OV518(+) USB 1.1 webcam ICs */
161#define I2C_HW_SMBUS_OVFX2 0x040011 /* Cypress/OmniVision FX2 webcam */
162#define I2C_HW_SMBUS_CAFE 0x040012 /* Marvell 88ALP01 "CAFE" cam */ 151#define I2C_HW_SMBUS_CAFE 0x040012 /* Marvell 88ALP01 "CAFE" cam */
163#define I2C_HW_SMBUS_ALI1563 0x040013 152#define I2C_HW_SMBUS_ALI1563 0x040013
164 153
diff --git a/include/linux/i2c-pnx.h b/include/linux/i2c-pnx.h
index e6e9c814da61..f13255e06406 100644
--- a/include/linux/i2c-pnx.h
+++ b/include/linux/i2c-pnx.h
@@ -12,7 +12,9 @@
12#ifndef __I2C_PNX_H__ 12#ifndef __I2C_PNX_H__
13#define __I2C_PNX_H__ 13#define __I2C_PNX_H__
14 14
15#include <asm/arch/i2c.h> 15#include <linux/pm.h>
16
17struct platform_device;
16 18
17struct i2c_pnx_mif { 19struct i2c_pnx_mif {
18 int ret; /* Return value */ 20 int ret; /* Return value */
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 08be0d21864c..33a5992d4936 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -53,51 +53,62 @@ struct i2c_board_info;
53 * transmit one message at a time, a more complex version can be used to 53 * transmit one message at a time, a more complex version can be used to
54 * transmit an arbitrary number of messages without interruption. 54 * transmit an arbitrary number of messages without interruption.
55 */ 55 */
56extern int i2c_master_send(struct i2c_client *,const char* ,int); 56extern int i2c_master_send(struct i2c_client *client, const char *buf,
57extern int i2c_master_recv(struct i2c_client *,char* ,int); 57 int count);
58extern int i2c_master_recv(struct i2c_client *client, char *buf, int count);
58 59
59/* Transfer num messages. 60/* Transfer num messages.
60 */ 61 */
61extern int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num); 62extern int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
62 63 int num);
63 64
64/* This is the very generalized SMBus access routine. You probably do not 65/* This is the very generalized SMBus access routine. You probably do not
65 want to use this, though; one of the functions below may be much easier, 66 want to use this, though; one of the functions below may be much easier,
66 and probably just as fast. 67 and probably just as fast.
67 Note that we use i2c_adapter here, because you do not need a specific 68 Note that we use i2c_adapter here, because you do not need a specific
68 smbus adapter to call this function. */ 69 smbus adapter to call this function. */
69extern s32 i2c_smbus_xfer (struct i2c_adapter * adapter, u16 addr, 70extern s32 i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr,
70 unsigned short flags, 71 unsigned short flags, char read_write, u8 command,
71 char read_write, u8 command, int size, 72 int size, union i2c_smbus_data *data);
72 union i2c_smbus_data * data);
73 73
74/* Now follow the 'nice' access routines. These also document the calling 74/* Now follow the 'nice' access routines. These also document the calling
75 conventions of i2c_smbus_xfer. */ 75 conventions of i2c_smbus_xfer. */
76 76
77extern s32 i2c_smbus_read_byte(struct i2c_client * client); 77extern s32 i2c_smbus_read_byte(struct i2c_client *client);
78extern s32 i2c_smbus_write_byte(struct i2c_client * client, u8 value); 78extern s32 i2c_smbus_write_byte(struct i2c_client *client, u8 value);
79extern s32 i2c_smbus_read_byte_data(struct i2c_client * client, u8 command); 79extern s32 i2c_smbus_read_byte_data(struct i2c_client *client, u8 command);
80extern s32 i2c_smbus_write_byte_data(struct i2c_client * client, 80extern s32 i2c_smbus_write_byte_data(struct i2c_client *client,
81 u8 command, u8 value); 81 u8 command, u8 value);
82extern s32 i2c_smbus_read_word_data(struct i2c_client * client, u8 command); 82extern s32 i2c_smbus_read_word_data(struct i2c_client *client, u8 command);
83extern s32 i2c_smbus_write_word_data(struct i2c_client * client, 83extern s32 i2c_smbus_write_word_data(struct i2c_client *client,
84 u8 command, u16 value); 84 u8 command, u16 value);
85/* Returns the number of read bytes */ 85/* Returns the number of read bytes */
86extern s32 i2c_smbus_read_block_data(struct i2c_client *client, 86extern s32 i2c_smbus_read_block_data(struct i2c_client *client,
87 u8 command, u8 *values); 87 u8 command, u8 *values);
88extern s32 i2c_smbus_write_block_data(struct i2c_client * client, 88extern s32 i2c_smbus_write_block_data(struct i2c_client *client,
89 u8 command, u8 length, 89 u8 command, u8 length, const u8 *values);
90 const u8 *values);
91/* Returns the number of read bytes */ 90/* Returns the number of read bytes */
92extern s32 i2c_smbus_read_i2c_block_data(struct i2c_client * client, 91extern s32 i2c_smbus_read_i2c_block_data(struct i2c_client *client,
93 u8 command, u8 length, u8 *values); 92 u8 command, u8 length, u8 *values);
94extern s32 i2c_smbus_write_i2c_block_data(struct i2c_client * client, 93extern s32 i2c_smbus_write_i2c_block_data(struct i2c_client *client,
95 u8 command, u8 length, 94 u8 command, u8 length,
96 const u8 *values); 95 const u8 *values);
97 96
98/** 97/**
99 * struct i2c_driver - represent an I2C device driver 98 * struct i2c_driver - represent an I2C device driver
99 * @id: Unique driver ID (optional)
100 * @class: What kind of i2c device we instantiate (for detect) 100 * @class: What kind of i2c device we instantiate (for detect)
101 * @attach_adapter: Callback for bus addition (for legacy drivers)
102 * @detach_adapter: Callback for bus removal (for legacy drivers)
103 * @detach_client: Callback for device removal (for legacy drivers)
104 * @probe: Callback for device binding (new-style drivers)
105 * @remove: Callback for device unbinding (new-style drivers)
106 * @shutdown: Callback for device shutdown
107 * @suspend: Callback for device suspend
108 * @resume: Callback for device resume
109 * @command: Callback for bus-wide signaling (optional)
110 * @driver: Device driver model driver
111 * @id_table: List of I2C devices supported by this driver
101 * @detect: Callback for device detection 112 * @detect: Callback for device detection
102 * @address_data: The I2C addresses to probe, ignore or force (for detect) 113 * @address_data: The I2C addresses to probe, ignore or force (for detect)
103 * @clients: List of detected clients we created (for i2c-core use only) 114 * @clients: List of detected clients we created (for i2c-core use only)
@@ -157,7 +168,7 @@ struct i2c_driver {
157 /* a ioctl like command that can be used to perform specific functions 168 /* a ioctl like command that can be used to perform specific functions
158 * with the device. 169 * with the device.
159 */ 170 */
160 int (*command)(struct i2c_client *client,unsigned int cmd, void *arg); 171 int (*command)(struct i2c_client *client, unsigned int cmd, void *arg);
161 172
162 struct device_driver driver; 173 struct device_driver driver;
163 const struct i2c_device_id *id_table; 174 const struct i2c_device_id *id_table;
@@ -212,14 +223,14 @@ static inline struct i2c_client *kobj_to_i2c_client(struct kobject *kobj)
212 return to_i2c_client(dev); 223 return to_i2c_client(dev);
213} 224}
214 225
215static inline void *i2c_get_clientdata (struct i2c_client *dev) 226static inline void *i2c_get_clientdata(const struct i2c_client *dev)
216{ 227{
217 return dev_get_drvdata (&dev->dev); 228 return dev_get_drvdata(&dev->dev);
218} 229}
219 230
220static inline void i2c_set_clientdata (struct i2c_client *dev, void *data) 231static inline void i2c_set_clientdata(struct i2c_client *dev, void *data)
221{ 232{
222 dev_set_drvdata (&dev->dev, data); 233 dev_set_drvdata(&dev->dev, data);
223} 234}
224 235
225/** 236/**
@@ -228,6 +239,7 @@ static inline void i2c_set_clientdata (struct i2c_client *dev, void *data)
228 * @flags: to initialize i2c_client.flags 239 * @flags: to initialize i2c_client.flags
229 * @addr: stored in i2c_client.addr 240 * @addr: stored in i2c_client.addr
230 * @platform_data: stored in i2c_client.dev.platform_data 241 * @platform_data: stored in i2c_client.dev.platform_data
242 * @archdata: copied into i2c_client.dev.archdata
231 * @irq: stored in i2c_client.irq 243 * @irq: stored in i2c_client.irq
232 * 244 *
233 * I2C doesn't actually support hardware probing, although controllers and 245 * I2C doesn't actually support hardware probing, although controllers and
@@ -247,6 +259,7 @@ struct i2c_board_info {
247 unsigned short flags; 259 unsigned short flags;
248 unsigned short addr; 260 unsigned short addr;
249 void *platform_data; 261 void *platform_data;
262 struct dev_archdata *archdata;
250 int irq; 263 int irq;
251}; 264};
252 265
@@ -260,7 +273,7 @@ struct i2c_board_info {
260 * fields (such as associated irq, or device-specific platform_data) 273 * fields (such as associated irq, or device-specific platform_data)
261 * are provided using conventional syntax. 274 * are provided using conventional syntax.
262 */ 275 */
263#define I2C_BOARD_INFO(dev_type,dev_addr) \ 276#define I2C_BOARD_INFO(dev_type, dev_addr) \
264 .type = (dev_type), .addr = (dev_addr) 277 .type = (dev_type), .addr = (dev_addr)
265 278
266 279
@@ -294,10 +307,12 @@ extern void i2c_unregister_device(struct i2c_client *);
294 */ 307 */
295#ifdef CONFIG_I2C_BOARDINFO 308#ifdef CONFIG_I2C_BOARDINFO
296extern int 309extern int
297i2c_register_board_info(int busnum, struct i2c_board_info const *info, unsigned n); 310i2c_register_board_info(int busnum, struct i2c_board_info const *info,
311 unsigned n);
298#else 312#else
299static inline int 313static inline int
300i2c_register_board_info(int busnum, struct i2c_board_info const *info, unsigned n) 314i2c_register_board_info(int busnum, struct i2c_board_info const *info,
315 unsigned n)
301{ 316{
302 return 0; 317 return 0;
303} 318}
@@ -316,11 +331,11 @@ struct i2c_algorithm {
316 using common I2C messages */ 331 using common I2C messages */
317 /* master_xfer should return the number of messages successfully 332 /* master_xfer should return the number of messages successfully
318 processed, or a negative value on error */ 333 processed, or a negative value on error */
319 int (*master_xfer)(struct i2c_adapter *adap,struct i2c_msg *msgs, 334 int (*master_xfer)(struct i2c_adapter *adap, struct i2c_msg *msgs,
320 int num); 335 int num);
321 int (*smbus_xfer) (struct i2c_adapter *adap, u16 addr, 336 int (*smbus_xfer) (struct i2c_adapter *adap, u16 addr,
322 unsigned short flags, char read_write, 337 unsigned short flags, char read_write,
323 u8 command, int size, union i2c_smbus_data * data); 338 u8 command, int size, union i2c_smbus_data *data);
324 339
325 /* To determine what the adapter supports */ 340 /* To determine what the adapter supports */
326 u32 (*functionality) (struct i2c_adapter *); 341 u32 (*functionality) (struct i2c_adapter *);
@@ -333,7 +348,7 @@ struct i2c_algorithm {
333struct i2c_adapter { 348struct i2c_adapter {
334 struct module *owner; 349 struct module *owner;
335 unsigned int id; 350 unsigned int id;
336 unsigned int class; 351 unsigned int class; /* classes to allow probing for */
337 const struct i2c_algorithm *algo; /* the algorithm to access the bus */ 352 const struct i2c_algorithm *algo; /* the algorithm to access the bus */
338 void *algo_data; 353 void *algo_data;
339 354
@@ -357,14 +372,14 @@ struct i2c_adapter {
357}; 372};
358#define to_i2c_adapter(d) container_of(d, struct i2c_adapter, dev) 373#define to_i2c_adapter(d) container_of(d, struct i2c_adapter, dev)
359 374
360static inline void *i2c_get_adapdata (struct i2c_adapter *dev) 375static inline void *i2c_get_adapdata(const struct i2c_adapter *dev)
361{ 376{
362 return dev_get_drvdata (&dev->dev); 377 return dev_get_drvdata(&dev->dev);
363} 378}
364 379
365static inline void i2c_set_adapdata (struct i2c_adapter *dev, void *data) 380static inline void i2c_set_adapdata(struct i2c_adapter *dev, void *data)
366{ 381{
367 dev_set_drvdata (&dev->dev, data); 382 dev_set_drvdata(&dev->dev, data);
368} 383}
369 384
370/*flags for the client struct: */ 385/*flags for the client struct: */
@@ -437,7 +452,7 @@ extern int i2c_probe(struct i2c_adapter *adapter,
437 const struct i2c_client_address_data *address_data, 452 const struct i2c_client_address_data *address_data,
438 int (*found_proc) (struct i2c_adapter *, int, int)); 453 int (*found_proc) (struct i2c_adapter *, int, int));
439 454
440extern struct i2c_adapter* i2c_get_adapter(int id); 455extern struct i2c_adapter *i2c_get_adapter(int id);
441extern void i2c_put_adapter(struct i2c_adapter *adap); 456extern void i2c_put_adapter(struct i2c_adapter *adap);
442 457
443 458
@@ -453,7 +468,7 @@ static inline int i2c_check_functionality(struct i2c_adapter *adap, u32 func)
453 return (func & i2c_get_functionality(adap)) == func; 468 return (func & i2c_get_functionality(adap)) == func;
454} 469}
455 470
456/* Return id number for a specific adapter */ 471/* Return the adapter number for a specific adapter */
457static inline int i2c_adapter_id(struct i2c_adapter *adap) 472static inline int i2c_adapter_id(struct i2c_adapter *adap)
458{ 473{
459 return adap->nr; 474 return adap->nr;
@@ -514,7 +529,7 @@ struct i2c_msg {
514 529
515#define I2C_FUNC_I2C 0x00000001 530#define I2C_FUNC_I2C 0x00000001
516#define I2C_FUNC_10BIT_ADDR 0x00000002 531#define I2C_FUNC_10BIT_ADDR 0x00000002
517#define I2C_FUNC_PROTOCOL_MANGLING 0x00000004 /* I2C_M_{REV_DIR_ADDR,NOSTART,..} */ 532#define I2C_FUNC_PROTOCOL_MANGLING 0x00000004 /* I2C_M_NOSTART etc. */
518#define I2C_FUNC_SMBUS_PEC 0x00000008 533#define I2C_FUNC_SMBUS_PEC 0x00000008
519#define I2C_FUNC_SMBUS_BLOCK_PROC_CALL 0x00008000 /* SMBus 2.0 */ 534#define I2C_FUNC_SMBUS_BLOCK_PROC_CALL 0x00008000 /* SMBus 2.0 */
520#define I2C_FUNC_SMBUS_QUICK 0x00010000 535#define I2C_FUNC_SMBUS_QUICK 0x00010000
@@ -529,30 +544,26 @@ struct i2c_msg {
529#define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000 544#define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000
530#define I2C_FUNC_SMBUS_READ_I2C_BLOCK 0x04000000 /* I2C-like block xfer */ 545#define I2C_FUNC_SMBUS_READ_I2C_BLOCK 0x04000000 /* I2C-like block xfer */
531#define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK 0x08000000 /* w/ 1-byte reg. addr. */ 546#define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK 0x08000000 /* w/ 1-byte reg. addr. */
532#define I2C_FUNC_SMBUS_READ_I2C_BLOCK_2 0x10000000 /* I2C-like block xfer */ 547
533#define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK_2 0x20000000 /* w/ 2-byte reg. addr. */ 548#define I2C_FUNC_SMBUS_BYTE (I2C_FUNC_SMBUS_READ_BYTE | \
534 549 I2C_FUNC_SMBUS_WRITE_BYTE)
535#define I2C_FUNC_SMBUS_BYTE (I2C_FUNC_SMBUS_READ_BYTE | \ 550#define I2C_FUNC_SMBUS_BYTE_DATA (I2C_FUNC_SMBUS_READ_BYTE_DATA | \
536 I2C_FUNC_SMBUS_WRITE_BYTE) 551 I2C_FUNC_SMBUS_WRITE_BYTE_DATA)
537#define I2C_FUNC_SMBUS_BYTE_DATA (I2C_FUNC_SMBUS_READ_BYTE_DATA | \ 552#define I2C_FUNC_SMBUS_WORD_DATA (I2C_FUNC_SMBUS_READ_WORD_DATA | \
538 I2C_FUNC_SMBUS_WRITE_BYTE_DATA) 553 I2C_FUNC_SMBUS_WRITE_WORD_DATA)
539#define I2C_FUNC_SMBUS_WORD_DATA (I2C_FUNC_SMBUS_READ_WORD_DATA | \ 554#define I2C_FUNC_SMBUS_BLOCK_DATA (I2C_FUNC_SMBUS_READ_BLOCK_DATA | \
540 I2C_FUNC_SMBUS_WRITE_WORD_DATA) 555 I2C_FUNC_SMBUS_WRITE_BLOCK_DATA)
541#define I2C_FUNC_SMBUS_BLOCK_DATA (I2C_FUNC_SMBUS_READ_BLOCK_DATA | \ 556#define I2C_FUNC_SMBUS_I2C_BLOCK (I2C_FUNC_SMBUS_READ_I2C_BLOCK | \
542 I2C_FUNC_SMBUS_WRITE_BLOCK_DATA) 557 I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)
543#define I2C_FUNC_SMBUS_I2C_BLOCK (I2C_FUNC_SMBUS_READ_I2C_BLOCK | \ 558
544 I2C_FUNC_SMBUS_WRITE_I2C_BLOCK) 559#define I2C_FUNC_SMBUS_EMUL (I2C_FUNC_SMBUS_QUICK | \
545#define I2C_FUNC_SMBUS_I2C_BLOCK_2 (I2C_FUNC_SMBUS_READ_I2C_BLOCK_2 | \ 560 I2C_FUNC_SMBUS_BYTE | \
546 I2C_FUNC_SMBUS_WRITE_I2C_BLOCK_2) 561 I2C_FUNC_SMBUS_BYTE_DATA | \
547 562 I2C_FUNC_SMBUS_WORD_DATA | \
548#define I2C_FUNC_SMBUS_EMUL (I2C_FUNC_SMBUS_QUICK | \ 563 I2C_FUNC_SMBUS_PROC_CALL | \
549 I2C_FUNC_SMBUS_BYTE | \ 564 I2C_FUNC_SMBUS_WRITE_BLOCK_DATA | \
550 I2C_FUNC_SMBUS_BYTE_DATA | \ 565 I2C_FUNC_SMBUS_I2C_BLOCK | \
551 I2C_FUNC_SMBUS_WORD_DATA | \ 566 I2C_FUNC_SMBUS_PEC)
552 I2C_FUNC_SMBUS_PROC_CALL | \
553 I2C_FUNC_SMBUS_WRITE_BLOCK_DATA | \
554 I2C_FUNC_SMBUS_I2C_BLOCK | \
555 I2C_FUNC_SMBUS_PEC)
556 567
557/* 568/*
558 * Data for SMBus Messages 569 * Data for SMBus Messages
@@ -562,7 +573,7 @@ union i2c_smbus_data {
562 __u8 byte; 573 __u8 byte;
563 __u16 word; 574 __u16 word;
564 __u8 block[I2C_SMBUS_BLOCK_MAX + 2]; /* block[0] is used for length */ 575 __u8 block[I2C_SMBUS_BLOCK_MAX + 2]; /* block[0] is used for length */
565 /* and one more for user-space compatibility */ 576 /* and one more for user-space compatibility */
566}; 577};
567 578
568/* i2c_smbus_xfer read or write markers */ 579/* i2c_smbus_xfer read or write markers */
@@ -590,21 +601,21 @@ union i2c_smbus_data {
590 601
591/* Default fill of many variables */ 602/* Default fill of many variables */
592#define I2C_CLIENT_DEFAULTS {I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 603#define I2C_CLIENT_DEFAULTS {I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
593 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 604 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
594 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 605 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
595 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 606 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
596 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 607 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
597 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 608 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
598 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 609 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
599 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 610 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
600 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 611 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
601 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 612 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
602 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 613 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
603 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 614 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
604 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 615 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
605 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 616 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
606 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 617 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
607 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END} 618 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END}
608 619
609/* I2C_CLIENT_MODULE_PARM creates a module parameter, and puts it in the 620/* I2C_CLIENT_MODULE_PARM creates a module parameter, and puts it in the
610 module header */ 621 module header */
@@ -613,7 +624,7 @@ union i2c_smbus_data {
613 static unsigned short var[I2C_CLIENT_MAX_OPTS] = I2C_CLIENT_DEFAULTS; \ 624 static unsigned short var[I2C_CLIENT_MAX_OPTS] = I2C_CLIENT_DEFAULTS; \
614 static unsigned int var##_num; \ 625 static unsigned int var##_num; \
615 module_param_array(var, short, &var##_num, 0); \ 626 module_param_array(var, short, &var##_num, 0); \
616 MODULE_PARM_DESC(var,desc) 627 MODULE_PARM_DESC(var, desc)
617 628
618#define I2C_CLIENT_MODULE_PARM_FORCE(name) \ 629#define I2C_CLIENT_MODULE_PARM_FORCE(name) \
619I2C_CLIENT_MODULE_PARM(force_##name, \ 630I2C_CLIENT_MODULE_PARM(force_##name, \
diff --git a/include/linux/i2c/max732x.h b/include/linux/i2c/max732x.h
new file mode 100644
index 000000000000..e10336631c62
--- /dev/null
+++ b/include/linux/i2c/max732x.h
@@ -0,0 +1,19 @@
1#ifndef __LINUX_I2C_MAX732X_H
2#define __LINUX_I2C_MAX732X_H
3
4/* platform data for the MAX732x 8/16-bit I/O expander driver */
5
6struct max732x_platform_data {
7 /* number of the first GPIO */
8 unsigned gpio_base;
9
10 void *context; /* param to setup/teardown */
11
12 int (*setup)(struct i2c_client *client,
13 unsigned gpio, unsigned ngpio,
14 void *context);
15 int (*teardown)(struct i2c_client *client,
16 unsigned gpio, unsigned ngpio,
17 void *context);
18};
19#endif /* __LINUX_I2C_MAX732X_H */
diff --git a/include/linux/i2c/twl4030.h b/include/linux/i2c/twl4030.h
new file mode 100644
index 000000000000..fb604dcd38f1
--- /dev/null
+++ b/include/linux/i2c/twl4030.h
@@ -0,0 +1,343 @@
1/*
2 * twl4030.h - header for TWL4030 PM and audio CODEC device
3 *
4 * Copyright (C) 2005-2006 Texas Instruments, Inc.
5 *
6 * Based on tlv320aic23.c:
7 * Copyright (c) by Kai Svahn <kai.svahn@nokia.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 *
23 */
24
25#ifndef __TWL4030_H_
26#define __TWL4030_H_
27
28/*
29 * Using the twl4030 core we address registers using a pair
30 * { module id, relative register offset }
31 * which that core then maps to the relevant
32 * { i2c slave, absolute register address }
33 *
34 * The module IDs are meaningful only to the twl4030 core code,
35 * which uses them as array indices to look up the first register
36 * address each module uses within a given i2c slave.
37 */
38
39/* Slave 0 (i2c address 0x48) */
40#define TWL4030_MODULE_USB 0x00
41
42/* Slave 1 (i2c address 0x49) */
43#define TWL4030_MODULE_AUDIO_VOICE 0x01
44#define TWL4030_MODULE_GPIO 0x02
45#define TWL4030_MODULE_INTBR 0x03
46#define TWL4030_MODULE_PIH 0x04
47#define TWL4030_MODULE_TEST 0x05
48
49/* Slave 2 (i2c address 0x4a) */
50#define TWL4030_MODULE_KEYPAD 0x06
51#define TWL4030_MODULE_MADC 0x07
52#define TWL4030_MODULE_INTERRUPTS 0x08
53#define TWL4030_MODULE_LED 0x09
54#define TWL4030_MODULE_MAIN_CHARGE 0x0A
55#define TWL4030_MODULE_PRECHARGE 0x0B
56#define TWL4030_MODULE_PWM0 0x0C
57#define TWL4030_MODULE_PWM1 0x0D
58#define TWL4030_MODULE_PWMA 0x0E
59#define TWL4030_MODULE_PWMB 0x0F
60
61/* Slave 3 (i2c address 0x4b) */
62#define TWL4030_MODULE_BACKUP 0x10
63#define TWL4030_MODULE_INT 0x11
64#define TWL4030_MODULE_PM_MASTER 0x12
65#define TWL4030_MODULE_PM_RECEIVER 0x13
66#define TWL4030_MODULE_RTC 0x14
67#define TWL4030_MODULE_SECURED_REG 0x15
68
69/*
70 * Read and write single 8-bit registers
71 */
72int twl4030_i2c_write_u8(u8 mod_no, u8 val, u8 reg);
73int twl4030_i2c_read_u8(u8 mod_no, u8 *val, u8 reg);
74
75/*
76 * Read and write several 8-bit registers at once.
77 *
78 * IMPORTANT: For twl4030_i2c_write(), allocate num_bytes + 1
79 * for the value, and populate your data starting at offset 1.
80 */
81int twl4030_i2c_write(u8 mod_no, u8 *value, u8 reg, u8 num_bytes);
82int twl4030_i2c_read(u8 mod_no, u8 *value, u8 reg, u8 num_bytes);
83
84/*----------------------------------------------------------------------*/
85
86/*
87 * NOTE: at up to 1024 registers, this is a big chip.
88 *
89 * Avoid putting register declarations in this file, instead of into
90 * a driver-private file, unless some of the registers in a block
91 * need to be shared with other drivers. One example is blocks that
92 * have Secondary IRQ Handler (SIH) registers.
93 */
94
95#define TWL4030_SIH_CTRL_EXCLEN_MASK BIT(0)
96#define TWL4030_SIH_CTRL_PENDDIS_MASK BIT(1)
97#define TWL4030_SIH_CTRL_COR_MASK BIT(2)
98
99/*----------------------------------------------------------------------*/
100
101/*
102 * GPIO Block Register offsets (use TWL4030_MODULE_GPIO)
103 */
104
105#define REG_GPIODATAIN1 0x0
106#define REG_GPIODATAIN2 0x1
107#define REG_GPIODATAIN3 0x2
108#define REG_GPIODATADIR1 0x3
109#define REG_GPIODATADIR2 0x4
110#define REG_GPIODATADIR3 0x5
111#define REG_GPIODATAOUT1 0x6
112#define REG_GPIODATAOUT2 0x7
113#define REG_GPIODATAOUT3 0x8
114#define REG_CLEARGPIODATAOUT1 0x9
115#define REG_CLEARGPIODATAOUT2 0xA
116#define REG_CLEARGPIODATAOUT3 0xB
117#define REG_SETGPIODATAOUT1 0xC
118#define REG_SETGPIODATAOUT2 0xD
119#define REG_SETGPIODATAOUT3 0xE
120#define REG_GPIO_DEBEN1 0xF
121#define REG_GPIO_DEBEN2 0x10
122#define REG_GPIO_DEBEN3 0x11
123#define REG_GPIO_CTRL 0x12
124#define REG_GPIOPUPDCTR1 0x13
125#define REG_GPIOPUPDCTR2 0x14
126#define REG_GPIOPUPDCTR3 0x15
127#define REG_GPIOPUPDCTR4 0x16
128#define REG_GPIOPUPDCTR5 0x17
129#define REG_GPIO_ISR1A 0x19
130#define REG_GPIO_ISR2A 0x1A
131#define REG_GPIO_ISR3A 0x1B
132#define REG_GPIO_IMR1A 0x1C
133#define REG_GPIO_IMR2A 0x1D
134#define REG_GPIO_IMR3A 0x1E
135#define REG_GPIO_ISR1B 0x1F
136#define REG_GPIO_ISR2B 0x20
137#define REG_GPIO_ISR3B 0x21
138#define REG_GPIO_IMR1B 0x22
139#define REG_GPIO_IMR2B 0x23
140#define REG_GPIO_IMR3B 0x24
141#define REG_GPIO_EDR1 0x28
142#define REG_GPIO_EDR2 0x29
143#define REG_GPIO_EDR3 0x2A
144#define REG_GPIO_EDR4 0x2B
145#define REG_GPIO_EDR5 0x2C
146#define REG_GPIO_SIH_CTRL 0x2D
147
148/* Up to 18 signals are available as GPIOs, when their
149 * pins are not assigned to another use (such as ULPI/USB).
150 */
151#define TWL4030_GPIO_MAX 18
152
153/*----------------------------------------------------------------------*/
154
155/*
156 * Keypad register offsets (use TWL4030_MODULE_KEYPAD)
157 * ... SIH/interrupt only
158 */
159
160#define TWL4030_KEYPAD_KEYP_ISR1 0x11
161#define TWL4030_KEYPAD_KEYP_IMR1 0x12
162#define TWL4030_KEYPAD_KEYP_ISR2 0x13
163#define TWL4030_KEYPAD_KEYP_IMR2 0x14
164#define TWL4030_KEYPAD_KEYP_SIR 0x15 /* test register */
165#define TWL4030_KEYPAD_KEYP_EDR 0x16
166#define TWL4030_KEYPAD_KEYP_SIH_CTRL 0x17
167
168/*----------------------------------------------------------------------*/
169
170/*
171 * Multichannel ADC register offsets (use TWL4030_MODULE_MADC)
172 * ... SIH/interrupt only
173 */
174
175#define TWL4030_MADC_ISR1 0x61
176#define TWL4030_MADC_IMR1 0x62
177#define TWL4030_MADC_ISR2 0x63
178#define TWL4030_MADC_IMR2 0x64
179#define TWL4030_MADC_SIR 0x65 /* test register */
180#define TWL4030_MADC_EDR 0x66
181#define TWL4030_MADC_SIH_CTRL 0x67
182
183/*----------------------------------------------------------------------*/
184
185/*
186 * Battery charger register offsets (use TWL4030_MODULE_INTERRUPTS)
187 */
188
189#define TWL4030_INTERRUPTS_BCIISR1A 0x0
190#define TWL4030_INTERRUPTS_BCIISR2A 0x1
191#define TWL4030_INTERRUPTS_BCIIMR1A 0x2
192#define TWL4030_INTERRUPTS_BCIIMR2A 0x3
193#define TWL4030_INTERRUPTS_BCIISR1B 0x4
194#define TWL4030_INTERRUPTS_BCIISR2B 0x5
195#define TWL4030_INTERRUPTS_BCIIMR1B 0x6
196#define TWL4030_INTERRUPTS_BCIIMR2B 0x7
197#define TWL4030_INTERRUPTS_BCISIR1 0x8 /* test register */
198#define TWL4030_INTERRUPTS_BCISIR2 0x9 /* test register */
199#define TWL4030_INTERRUPTS_BCIEDR1 0xa
200#define TWL4030_INTERRUPTS_BCIEDR2 0xb
201#define TWL4030_INTERRUPTS_BCIEDR3 0xc
202#define TWL4030_INTERRUPTS_BCISIHCTRL 0xd
203
204/*----------------------------------------------------------------------*/
205
206/*
207 * Power Interrupt block register offsets (use TWL4030_MODULE_INT)
208 */
209
210#define TWL4030_INT_PWR_ISR1 0x0
211#define TWL4030_INT_PWR_IMR1 0x1
212#define TWL4030_INT_PWR_ISR2 0x2
213#define TWL4030_INT_PWR_IMR2 0x3
214#define TWL4030_INT_PWR_SIR 0x4 /* test register */
215#define TWL4030_INT_PWR_EDR1 0x5
216#define TWL4030_INT_PWR_EDR2 0x6
217#define TWL4030_INT_PWR_SIH_CTRL 0x7
218
219/*----------------------------------------------------------------------*/
220
221struct twl4030_bci_platform_data {
222 int *battery_tmp_tbl;
223 unsigned int tblsize;
224};
225
226/* TWL4030_GPIO_MAX (18) GPIOs, with interrupts */
227struct twl4030_gpio_platform_data {
228 int gpio_base;
229 unsigned irq_base, irq_end;
230
231 /* package the two LED signals as output-only GPIOs? */
232 bool use_leds;
233
234 /* gpio-n should control VMMC(n+1) if BIT(n) in mmc_cd is set */
235 u8 mmc_cd;
236
237 /* For gpio-N, bit (1 << N) in "pullups" is set if that pullup
238 * should be enabled. Else, if that bit is set in "pulldowns",
239 * that pulldown is enabled. Don't waste power by letting any
240 * digital inputs float...
241 */
242 u32 pullups;
243 u32 pulldowns;
244
245 int (*setup)(struct device *dev,
246 unsigned gpio, unsigned ngpio);
247 int (*teardown)(struct device *dev,
248 unsigned gpio, unsigned ngpio);
249};
250
251struct twl4030_madc_platform_data {
252 int irq_line;
253};
254
255struct twl4030_keypad_data {
256 int rows;
257 int cols;
258 int *keymap;
259 int irq;
260 unsigned int keymapsize;
261 unsigned int rep:1;
262};
263
264enum twl4030_usb_mode {
265 T2_USB_MODE_ULPI = 1,
266 T2_USB_MODE_CEA2011_3PIN = 2,
267};
268
269struct twl4030_usb_data {
270 enum twl4030_usb_mode usb_mode;
271};
272
273struct twl4030_platform_data {
274 unsigned irq_base, irq_end;
275 struct twl4030_bci_platform_data *bci;
276 struct twl4030_gpio_platform_data *gpio;
277 struct twl4030_madc_platform_data *madc;
278 struct twl4030_keypad_data *keypad;
279 struct twl4030_usb_data *usb;
280
281 /* REVISIT more to come ... _nothing_ should be hard-wired */
282};
283
284/*----------------------------------------------------------------------*/
285
286int twl4030_sih_setup(int module);
287
288/*
289 * FIXME completely stop using TWL4030_IRQ_BASE ... instead, pass the
290 * IRQ data to subsidiary devices using platform device resources.
291 */
292
293/* IRQ information-need base */
294#include <mach/irqs.h>
295/* TWL4030 interrupts */
296
297/* #define TWL4030_MODIRQ_GPIO (TWL4030_IRQ_BASE + 0) */
298#define TWL4030_MODIRQ_KEYPAD (TWL4030_IRQ_BASE + 1)
299#define TWL4030_MODIRQ_BCI (TWL4030_IRQ_BASE + 2)
300#define TWL4030_MODIRQ_MADC (TWL4030_IRQ_BASE + 3)
301/* #define TWL4030_MODIRQ_USB (TWL4030_IRQ_BASE + 4) */
302/* #define TWL4030_MODIRQ_PWR (TWL4030_IRQ_BASE + 5) */
303
304#define TWL4030_PWRIRQ_PWRBTN (TWL4030_PWR_IRQ_BASE + 0)
305/* #define TWL4030_PWRIRQ_CHG_PRES (TWL4030_PWR_IRQ_BASE + 1) */
306/* #define TWL4030_PWRIRQ_USB_PRES (TWL4030_PWR_IRQ_BASE + 2) */
307/* #define TWL4030_PWRIRQ_RTC (TWL4030_PWR_IRQ_BASE + 3) */
308/* #define TWL4030_PWRIRQ_HOT_DIE (TWL4030_PWR_IRQ_BASE + 4) */
309/* #define TWL4030_PWRIRQ_PWROK_TIMEOUT (TWL4030_PWR_IRQ_BASE + 5) */
310/* #define TWL4030_PWRIRQ_MBCHG (TWL4030_PWR_IRQ_BASE + 6) */
311/* #define TWL4030_PWRIRQ_SC_DETECT (TWL4030_PWR_IRQ_BASE + 7) */
312
313/* Rest are unsued currently*/
314
315/* Offsets to Power Registers */
316#define TWL4030_VDAC_DEV_GRP 0x3B
317#define TWL4030_VDAC_DEDICATED 0x3E
318#define TWL4030_VAUX1_DEV_GRP 0x17
319#define TWL4030_VAUX1_DEDICATED 0x1A
320#define TWL4030_VAUX2_DEV_GRP 0x1B
321#define TWL4030_VAUX2_DEDICATED 0x1E
322#define TWL4030_VAUX3_DEV_GRP 0x1F
323#define TWL4030_VAUX3_DEDICATED 0x22
324
325/* TWL4030 GPIO interrupt definitions */
326
327#define TWL4030_GPIO_IRQ_NO(n) (TWL4030_GPIO_IRQ_BASE + (n))
328
329/*
330 * Exported TWL4030 GPIO APIs
331 *
332 * WARNING -- use standard GPIO and IRQ calls instead; these will vanish.
333 */
334int twl4030_set_gpio_debounce(int gpio, int enable);
335
336#if defined(CONFIG_TWL4030_BCI_BATTERY) || \
337 defined(CONFIG_TWL4030_BCI_BATTERY_MODULE)
338 extern int twl4030charger_usb_en(int enable);
339#else
340 static inline int twl4030charger_usb_en(int enable) { return 0; }
341#endif
342
343#endif /* End of __TWL4030_H */
diff --git a/include/linux/i2o.h b/include/linux/i2o.h
index 7d51cbca49ab..4c4e57d1f19d 100644
--- a/include/linux/i2o.h
+++ b/include/linux/i2o.h
@@ -570,7 +570,6 @@ struct i2o_controller {
570#endif 570#endif
571 spinlock_t lock; /* lock for controller 571 spinlock_t lock; /* lock for controller
572 configuration */ 572 configuration */
573
574 void *driver_data[I2O_MAX_DRIVERS]; /* storage for drivers */ 573 void *driver_data[I2O_MAX_DRIVERS]; /* storage for drivers */
575}; 574};
576 575
@@ -691,289 +690,22 @@ static inline u32 i2o_dma_high(dma_addr_t dma_addr)
691}; 690};
692#endif 691#endif
693 692
694/** 693extern u16 i2o_sg_tablesize(struct i2o_controller *c, u16 body_size);
695 * i2o_sg_tablesize - Calculate the maximum number of elements in a SGL 694extern dma_addr_t i2o_dma_map_single(struct i2o_controller *c, void *ptr,
696 * @c: I2O controller for which the calculation should be done
697 * @body_size: maximum body size used for message in 32-bit words.
698 *
699 * Return the maximum number of SG elements in a SG list.
700 */
701static inline u16 i2o_sg_tablesize(struct i2o_controller *c, u16 body_size)
702{
703 i2o_status_block *sb = c->status_block.virt;
704 u16 sg_count =
705 (sb->inbound_frame_size - sizeof(struct i2o_message) / 4) -
706 body_size;
707
708 if (c->pae_support) {
709 /*
710 * for 64-bit a SG attribute element must be added and each
711 * SG element needs 12 bytes instead of 8.
712 */
713 sg_count -= 2;
714 sg_count /= 3;
715 } else
716 sg_count /= 2;
717
718 if (c->short_req && (sg_count > 8))
719 sg_count = 8;
720
721 return sg_count;
722};
723
724/**
725 * i2o_dma_map_single - Map pointer to controller and fill in I2O message.
726 * @c: I2O controller
727 * @ptr: pointer to the data which should be mapped
728 * @size: size of data in bytes
729 * @direction: DMA_TO_DEVICE / DMA_FROM_DEVICE
730 * @sg_ptr: pointer to the SG list inside the I2O message
731 *
732 * This function does all necessary DMA handling and also writes the I2O
733 * SGL elements into the I2O message. For details on DMA handling see also
734 * dma_map_single(). The pointer sg_ptr will only be set to the end of the
735 * SG list if the allocation was successful.
736 *
737 * Returns DMA address which must be checked for failures using
738 * dma_mapping_error().
739 */
740static inline dma_addr_t i2o_dma_map_single(struct i2o_controller *c, void *ptr,
741 size_t size, 695 size_t size,
742 enum dma_data_direction direction, 696 enum dma_data_direction direction,
743 u32 ** sg_ptr) 697 u32 ** sg_ptr);
744{ 698extern int i2o_dma_map_sg(struct i2o_controller *c,
745 u32 sg_flags;
746 u32 *mptr = *sg_ptr;
747 dma_addr_t dma_addr;
748
749 switch (direction) {
750 case DMA_TO_DEVICE:
751 sg_flags = 0xd4000000;
752 break;
753 case DMA_FROM_DEVICE:
754 sg_flags = 0xd0000000;
755 break;
756 default:
757 return 0;
758 }
759
760 dma_addr = dma_map_single(&c->pdev->dev, ptr, size, direction);
761 if (!dma_mapping_error(dma_addr)) {
762#ifdef CONFIG_I2O_EXT_ADAPTEC_DMA64
763 if ((sizeof(dma_addr_t) > 4) && c->pae_support) {
764 *mptr++ = cpu_to_le32(0x7C020002);
765 *mptr++ = cpu_to_le32(PAGE_SIZE);
766 }
767#endif
768
769 *mptr++ = cpu_to_le32(sg_flags | size);
770 *mptr++ = cpu_to_le32(i2o_dma_low(dma_addr));
771#ifdef CONFIG_I2O_EXT_ADAPTEC_DMA64
772 if ((sizeof(dma_addr_t) > 4) && c->pae_support)
773 *mptr++ = cpu_to_le32(i2o_dma_high(dma_addr));
774#endif
775 *sg_ptr = mptr;
776 }
777 return dma_addr;
778};
779
780/**
781 * i2o_dma_map_sg - Map a SG List to controller and fill in I2O message.
782 * @c: I2O controller
783 * @sg: SG list to be mapped
784 * @sg_count: number of elements in the SG list
785 * @direction: DMA_TO_DEVICE / DMA_FROM_DEVICE
786 * @sg_ptr: pointer to the SG list inside the I2O message
787 *
788 * This function does all necessary DMA handling and also writes the I2O
789 * SGL elements into the I2O message. For details on DMA handling see also
790 * dma_map_sg(). The pointer sg_ptr will only be set to the end of the SG
791 * list if the allocation was successful.
792 *
793 * Returns 0 on failure or 1 on success.
794 */
795static inline int i2o_dma_map_sg(struct i2o_controller *c,
796 struct scatterlist *sg, int sg_count, 699 struct scatterlist *sg, int sg_count,
797 enum dma_data_direction direction, 700 enum dma_data_direction direction,
798 u32 ** sg_ptr) 701 u32 ** sg_ptr);
799{ 702extern int i2o_dma_alloc(struct device *dev, struct i2o_dma *addr, size_t len);
800 u32 sg_flags; 703extern void i2o_dma_free(struct device *dev, struct i2o_dma *addr);
801 u32 *mptr = *sg_ptr; 704extern int i2o_dma_realloc(struct device *dev, struct i2o_dma *addr,
802 705 size_t len);
803 switch (direction) { 706extern int i2o_pool_alloc(struct i2o_pool *pool, const char *name,
804 case DMA_TO_DEVICE: 707 size_t size, int min_nr);
805 sg_flags = 0x14000000; 708extern void i2o_pool_free(struct i2o_pool *pool);
806 break;
807 case DMA_FROM_DEVICE:
808 sg_flags = 0x10000000;
809 break;
810 default:
811 return 0;
812 }
813
814 sg_count = dma_map_sg(&c->pdev->dev, sg, sg_count, direction);
815 if (!sg_count)
816 return 0;
817
818#ifdef CONFIG_I2O_EXT_ADAPTEC_DMA64
819 if ((sizeof(dma_addr_t) > 4) && c->pae_support) {
820 *mptr++ = cpu_to_le32(0x7C020002);
821 *mptr++ = cpu_to_le32(PAGE_SIZE);
822 }
823#endif
824
825 while (sg_count-- > 0) {
826 if (!sg_count)
827 sg_flags |= 0xC0000000;
828 *mptr++ = cpu_to_le32(sg_flags | sg_dma_len(sg));
829 *mptr++ = cpu_to_le32(i2o_dma_low(sg_dma_address(sg)));
830#ifdef CONFIG_I2O_EXT_ADAPTEC_DMA64
831 if ((sizeof(dma_addr_t) > 4) && c->pae_support)
832 *mptr++ = cpu_to_le32(i2o_dma_high(sg_dma_address(sg)));
833#endif
834 sg = sg_next(sg);
835 }
836 *sg_ptr = mptr;
837
838 return 1;
839};
840
841/**
842 * i2o_dma_alloc - Allocate DMA memory
843 * @dev: struct device pointer to the PCI device of the I2O controller
844 * @addr: i2o_dma struct which should get the DMA buffer
845 * @len: length of the new DMA memory
846 * @gfp_mask: GFP mask
847 *
848 * Allocate a coherent DMA memory and write the pointers into addr.
849 *
850 * Returns 0 on success or -ENOMEM on failure.
851 */
852static inline int i2o_dma_alloc(struct device *dev, struct i2o_dma *addr,
853 size_t len, gfp_t gfp_mask)
854{
855 struct pci_dev *pdev = to_pci_dev(dev);
856 int dma_64 = 0;
857
858 if ((sizeof(dma_addr_t) > 4) && (pdev->dma_mask == DMA_64BIT_MASK)) {
859 dma_64 = 1;
860 if (pci_set_dma_mask(pdev, DMA_32BIT_MASK))
861 return -ENOMEM;
862 }
863
864 addr->virt = dma_alloc_coherent(dev, len, &addr->phys, gfp_mask);
865
866 if ((sizeof(dma_addr_t) > 4) && dma_64)
867 if (pci_set_dma_mask(pdev, DMA_64BIT_MASK))
868 printk(KERN_WARNING "i2o: unable to set 64-bit DMA");
869
870 if (!addr->virt)
871 return -ENOMEM;
872
873 memset(addr->virt, 0, len);
874 addr->len = len;
875
876 return 0;
877};
878
879/**
880 * i2o_dma_free - Free DMA memory
881 * @dev: struct device pointer to the PCI device of the I2O controller
882 * @addr: i2o_dma struct which contains the DMA buffer
883 *
884 * Free a coherent DMA memory and set virtual address of addr to NULL.
885 */
886static inline void i2o_dma_free(struct device *dev, struct i2o_dma *addr)
887{
888 if (addr->virt) {
889 if (addr->phys)
890 dma_free_coherent(dev, addr->len, addr->virt,
891 addr->phys);
892 else
893 kfree(addr->virt);
894 addr->virt = NULL;
895 }
896};
897
898/**
899 * i2o_dma_realloc - Realloc DMA memory
900 * @dev: struct device pointer to the PCI device of the I2O controller
901 * @addr: pointer to a i2o_dma struct DMA buffer
902 * @len: new length of memory
903 * @gfp_mask: GFP mask
904 *
905 * If there was something allocated in the addr, free it first. If len > 0
906 * than try to allocate it and write the addresses back to the addr
907 * structure. If len == 0 set the virtual address to NULL.
908 *
909 * Returns the 0 on success or negative error code on failure.
910 */
911static inline int i2o_dma_realloc(struct device *dev, struct i2o_dma *addr,
912 size_t len, gfp_t gfp_mask)
913{
914 i2o_dma_free(dev, addr);
915
916 if (len)
917 return i2o_dma_alloc(dev, addr, len, gfp_mask);
918
919 return 0;
920};
921
922/*
923 * i2o_pool_alloc - Allocate an slab cache and mempool
924 * @mempool: pointer to struct i2o_pool to write data into.
925 * @name: name which is used to identify cache
926 * @size: size of each object
927 * @min_nr: minimum number of objects
928 *
929 * First allocates a slab cache with name and size. Then allocates a
930 * mempool which uses the slab cache for allocation and freeing.
931 *
932 * Returns 0 on success or negative error code on failure.
933 */
934static inline int i2o_pool_alloc(struct i2o_pool *pool, const char *name,
935 size_t size, int min_nr)
936{
937 pool->name = kmalloc(strlen(name) + 1, GFP_KERNEL);
938 if (!pool->name)
939 goto exit;
940 strcpy(pool->name, name);
941
942 pool->slab =
943 kmem_cache_create(pool->name, size, 0, SLAB_HWCACHE_ALIGN, NULL);
944 if (!pool->slab)
945 goto free_name;
946
947 pool->mempool = mempool_create_slab_pool(min_nr, pool->slab);
948 if (!pool->mempool)
949 goto free_slab;
950
951 return 0;
952
953 free_slab:
954 kmem_cache_destroy(pool->slab);
955
956 free_name:
957 kfree(pool->name);
958
959 exit:
960 return -ENOMEM;
961};
962
963/*
964 * i2o_pool_free - Free slab cache and mempool again
965 * @mempool: pointer to struct i2o_pool which should be freed
966 *
967 * Note that you have to return all objects to the mempool again before
968 * calling i2o_pool_free().
969 */
970static inline void i2o_pool_free(struct i2o_pool *pool)
971{
972 mempool_destroy(pool->mempool);
973 kmem_cache_destroy(pool->slab);
974 kfree(pool->name);
975};
976
977/* I2O driver (OSM) functions */ 709/* I2O driver (OSM) functions */
978extern int i2o_driver_register(struct i2o_driver *); 710extern int i2o_driver_register(struct i2o_driver *);
979extern void i2o_driver_unregister(struct i2o_driver *); 711extern void i2o_driver_unregister(struct i2o_driver *);
diff --git a/include/linux/icmpv6.h b/include/linux/icmpv6.h
index 03067443198a..a93a8dd33118 100644
--- a/include/linux/icmpv6.h
+++ b/include/linux/icmpv6.h
@@ -40,16 +40,18 @@ struct icmp6hdr {
40 struct icmpv6_nd_ra { 40 struct icmpv6_nd_ra {
41 __u8 hop_limit; 41 __u8 hop_limit;
42#if defined(__LITTLE_ENDIAN_BITFIELD) 42#if defined(__LITTLE_ENDIAN_BITFIELD)
43 __u8 reserved:4, 43 __u8 reserved:3,
44 router_pref:2, 44 router_pref:2,
45 home_agent:1,
45 other:1, 46 other:1,
46 managed:1; 47 managed:1;
47 48
48#elif defined(__BIG_ENDIAN_BITFIELD) 49#elif defined(__BIG_ENDIAN_BITFIELD)
49 __u8 managed:1, 50 __u8 managed:1,
50 other:1, 51 other:1,
52 home_agent:1,
51 router_pref:2, 53 router_pref:2,
52 reserved:4; 54 reserved:3;
53#else 55#else
54#error "Please fix <asm/byteorder.h>" 56#error "Please fix <asm/byteorder.h>"
55#endif 57#endif
diff --git a/include/linux/ide.h b/include/linux/ide.h
index 4726126f5a59..54525be4b5f8 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -8,7 +8,7 @@
8 8
9#include <linux/init.h> 9#include <linux/init.h>
10#include <linux/ioport.h> 10#include <linux/ioport.h>
11#include <linux/hdreg.h> 11#include <linux/ata.h>
12#include <linux/blkdev.h> 12#include <linux/blkdev.h>
13#include <linux/proc_fs.h> 13#include <linux/proc_fs.h>
14#include <linux/interrupt.h> 14#include <linux/interrupt.h>
@@ -17,6 +17,7 @@
17#include <linux/device.h> 17#include <linux/device.h>
18#include <linux/pci.h> 18#include <linux/pci.h>
19#include <linux/completion.h> 19#include <linux/completion.h>
20#include <linux/pm.h>
20#ifdef CONFIG_BLK_DEV_IDEACPI 21#ifdef CONFIG_BLK_DEV_IDEACPI
21#include <acpi/acpi.h> 22#include <acpi/acpi.h>
22#endif 23#endif
@@ -47,12 +48,6 @@ typedef unsigned char byte; /* used everywhere */
47#define ERROR_RESET 3 /* Reset controller every 4th retry */ 48#define ERROR_RESET 3 /* Reset controller every 4th retry */
48#define ERROR_RECAL 1 /* Recalibrate every 2nd retry */ 49#define ERROR_RECAL 1 /* Recalibrate every 2nd retry */
49 50
50/*
51 * state flags
52 */
53
54#define DMA_PIO_RETRY 1 /* retrying in PIO */
55
56#define HWIF(drive) ((ide_hwif_t *)((drive)->hwif)) 51#define HWIF(drive) ((ide_hwif_t *)((drive)->hwif))
57#define HWGROUP(drive) ((ide_hwgroup_t *)(HWIF(drive)->hwgroup)) 52#define HWGROUP(drive) ((ide_hwgroup_t *)(HWIF(drive)->hwgroup))
58 53
@@ -87,12 +82,13 @@ struct ide_io_ports {
87}; 82};
88 83
89#define OK_STAT(stat,good,bad) (((stat)&((good)|(bad)))==(good)) 84#define OK_STAT(stat,good,bad) (((stat)&((good)|(bad)))==(good))
90#define BAD_R_STAT (BUSY_STAT | ERR_STAT)
91#define BAD_W_STAT (BAD_R_STAT | WRERR_STAT)
92#define BAD_STAT (BAD_R_STAT | DRQ_STAT)
93#define DRIVE_READY (READY_STAT | SEEK_STAT)
94 85
95#define BAD_CRC (ABRT_ERR | ICRC_ERR) 86#define BAD_R_STAT (ATA_BUSY | ATA_ERR)
87#define BAD_W_STAT (BAD_R_STAT | ATA_DF)
88#define BAD_STAT (BAD_R_STAT | ATA_DRQ)
89#define DRIVE_READY (ATA_DRDY | ATA_DSC)
90
91#define BAD_CRC (ATA_ABORTED | ATA_ICRC)
96 92
97#define SATA_NR_PORTS (3) /* 16 possible ?? */ 93#define SATA_NR_PORTS (3) /* 16 possible ?? */
98 94
@@ -125,24 +121,43 @@ struct ide_io_ports {
125#define PARTN_BITS 6 /* number of minor dev bits for partitions */ 121#define PARTN_BITS 6 /* number of minor dev bits for partitions */
126#define MAX_DRIVES 2 /* per interface; 2 assumed by lots of code */ 122#define MAX_DRIVES 2 /* per interface; 2 assumed by lots of code */
127#define SECTOR_SIZE 512 123#define SECTOR_SIZE 512
128#define SECTOR_WORDS (SECTOR_SIZE / 4) /* number of 32bit words per sector */ 124
129#define IDE_LARGE_SEEK(b1,b2,t) (((b1) > (b2) + (t)) || ((b2) > (b1) + (t))) 125#define IDE_LARGE_SEEK(b1,b2,t) (((b1) > (b2) + (t)) || ((b2) > (b1) + (t)))
130 126
131/* 127/*
132 * Timeouts for various operations: 128 * Timeouts for various operations:
133 */ 129 */
134#define WAIT_DRQ (HZ/10) /* 100msec - spec allows up to 20ms */ 130enum {
135#define WAIT_READY (5*HZ) /* 5sec - some laptops are very slow */ 131 /* spec allows up to 20ms */
136#define WAIT_PIDENTIFY (10*HZ) /* 10sec - should be less than 3ms (?), if all ATAPI CD is closed at boot */ 132 WAIT_DRQ = HZ / 10, /* 100ms */
137#define WAIT_WORSTCASE (30*HZ) /* 30sec - worst case when spinning up */ 133 /* some laptops are very slow */
138#define WAIT_CMD (10*HZ) /* 10sec - maximum wait for an IRQ to happen */ 134 WAIT_READY = 5 * HZ, /* 5s */
139#define WAIT_MIN_SLEEP (2*HZ/100) /* 20msec - minimum sleep time */ 135 /* should be less than 3ms (?), if all ATAPI CD is closed at boot */
136 WAIT_PIDENTIFY = 10 * HZ, /* 10s */
137 /* worst case when spinning up */
138 WAIT_WORSTCASE = 30 * HZ, /* 30s */
139 /* maximum wait for an IRQ to happen */
140 WAIT_CMD = 10 * HZ, /* 10s */
141 /* Some drives require a longer IRQ timeout. */
142 WAIT_FLOPPY_CMD = 50 * HZ, /* 50s */
143 /*
144 * Some drives (for example, Seagate STT3401A Travan) require a very
145 * long timeout, because they don't return an interrupt or clear their
146 * BSY bit until after the command completes (even retension commands).
147 */
148 WAIT_TAPE_CMD = 900 * HZ, /* 900s */
149 /* minimum sleep time */
150 WAIT_MIN_SLEEP = HZ / 50, /* 20ms */
151};
140 152
141/* 153/*
142 * Op codes for special requests to be handled by ide_special_rq(). 154 * Op codes for special requests to be handled by ide_special_rq().
143 * Values should be in the range of 0x20 to 0x3f. 155 * Values should be in the range of 0x20 to 0x3f.
144 */ 156 */
145#define REQ_DRIVE_RESET 0x20 157#define REQ_DRIVE_RESET 0x20
158#define REQ_DEVSET_EXEC 0x21
159#define REQ_PARK_HEADS 0x22
160#define REQ_UNPARK_HEADS 0x23
146 161
147/* 162/*
148 * Check for an interrupt and acknowledge the interrupt status 163 * Check for an interrupt and acknowledge the interrupt status
@@ -178,6 +193,7 @@ typedef struct hw_regs_s {
178 ide_ack_intr_t *ack_intr; /* acknowledge interrupt */ 193 ide_ack_intr_t *ack_intr; /* acknowledge interrupt */
179 hwif_chipset_t chipset; 194 hwif_chipset_t chipset;
180 struct device *dev, *parent; 195 struct device *dev, *parent;
196 unsigned long config;
181} hw_regs_t; 197} hw_regs_t;
182 198
183void ide_init_port_data(struct hwif_s *, unsigned int); 199void ide_init_port_data(struct hwif_s *, unsigned int);
@@ -210,13 +226,16 @@ static inline int __ide_default_irq(unsigned long base)
210 return 0; 226 return 0;
211} 227}
212 228
229#if defined(CONFIG_ARM) || defined(CONFIG_FRV) || defined(CONFIG_M68K) || \
230 defined(CONFIG_MIPS) || defined(CONFIG_MN10300) || defined(CONFIG_PARISC) \
231 || defined(CONFIG_PPC) || defined(CONFIG_SPARC) || defined(CONFIG_SPARC64)
213#include <asm/ide.h> 232#include <asm/ide.h>
214 233#else
215#if !defined(MAX_HWIFS) || defined(CONFIG_EMBEDDED) 234#include <asm-generic/ide_iops.h>
216#undef MAX_HWIFS
217#define MAX_HWIFS CONFIG_IDE_MAX_HWIFS
218#endif 235#endif
219 236
237#define MAX_HWIFS 10
238
220/* Currently only m68k, apus and m8xx need it */ 239/* Currently only m68k, apus and m8xx need it */
221#ifndef IDE_ARCH_ACK_INTR 240#ifndef IDE_ARCH_ACK_INTR
222# define ide_ack_intr(hwif) (1) 241# define ide_ack_intr(hwif) (1)
@@ -245,8 +264,6 @@ static inline int __ide_default_irq(unsigned long base)
245 * set_geometry : respecify drive geometry 264 * set_geometry : respecify drive geometry
246 * recalibrate : seek to cyl 0 265 * recalibrate : seek to cyl 0
247 * set_multmode : set multmode count 266 * set_multmode : set multmode count
248 * set_tune : tune interface for drive
249 * serviced : service command
250 * reserved : unused 267 * reserved : unused
251 */ 268 */
252typedef union { 269typedef union {
@@ -255,43 +272,11 @@ typedef union {
255 unsigned set_geometry : 1; 272 unsigned set_geometry : 1;
256 unsigned recalibrate : 1; 273 unsigned recalibrate : 1;
257 unsigned set_multmode : 1; 274 unsigned set_multmode : 1;
258 unsigned set_tune : 1; 275 unsigned reserved : 5;
259 unsigned serviced : 1;
260 unsigned reserved : 3;
261 } b; 276 } b;
262} special_t; 277} special_t;
263 278
264/* 279/*
265 * ATA-IDE Select Register, aka Device-Head
266 *
267 * head : always zeros here
268 * unit : drive select number: 0/1
269 * bit5 : always 1
270 * lba : using LBA instead of CHS
271 * bit7 : always 1
272 */
273typedef union {
274 unsigned all : 8;
275 struct {
276#if defined(__LITTLE_ENDIAN_BITFIELD)
277 unsigned head : 4;
278 unsigned unit : 1;
279 unsigned bit5 : 1;
280 unsigned lba : 1;
281 unsigned bit7 : 1;
282#elif defined(__BIG_ENDIAN_BITFIELD)
283 unsigned bit7 : 1;
284 unsigned lba : 1;
285 unsigned bit5 : 1;
286 unsigned unit : 1;
287 unsigned head : 4;
288#else
289#error "Please fix <asm/byteorder.h>"
290#endif
291 } b;
292} select_t, ata_select_t;
293
294/*
295 * Status returned from various ide_ functions 280 * Status returned from various ide_ functions
296 */ 281 */
297typedef enum { 282typedef enum {
@@ -299,15 +284,318 @@ typedef enum {
299 ide_started, /* a drive operation was started, handler was set */ 284 ide_started, /* a drive operation was started, handler was set */
300} ide_startstop_t; 285} ide_startstop_t;
301 286
287enum {
288 IDE_TFLAG_LBA48 = (1 << 0),
289 IDE_TFLAG_FLAGGED = (1 << 2),
290 IDE_TFLAG_OUT_DATA = (1 << 3),
291 IDE_TFLAG_OUT_HOB_FEATURE = (1 << 4),
292 IDE_TFLAG_OUT_HOB_NSECT = (1 << 5),
293 IDE_TFLAG_OUT_HOB_LBAL = (1 << 6),
294 IDE_TFLAG_OUT_HOB_LBAM = (1 << 7),
295 IDE_TFLAG_OUT_HOB_LBAH = (1 << 8),
296 IDE_TFLAG_OUT_HOB = IDE_TFLAG_OUT_HOB_FEATURE |
297 IDE_TFLAG_OUT_HOB_NSECT |
298 IDE_TFLAG_OUT_HOB_LBAL |
299 IDE_TFLAG_OUT_HOB_LBAM |
300 IDE_TFLAG_OUT_HOB_LBAH,
301 IDE_TFLAG_OUT_FEATURE = (1 << 9),
302 IDE_TFLAG_OUT_NSECT = (1 << 10),
303 IDE_TFLAG_OUT_LBAL = (1 << 11),
304 IDE_TFLAG_OUT_LBAM = (1 << 12),
305 IDE_TFLAG_OUT_LBAH = (1 << 13),
306 IDE_TFLAG_OUT_TF = IDE_TFLAG_OUT_FEATURE |
307 IDE_TFLAG_OUT_NSECT |
308 IDE_TFLAG_OUT_LBAL |
309 IDE_TFLAG_OUT_LBAM |
310 IDE_TFLAG_OUT_LBAH,
311 IDE_TFLAG_OUT_DEVICE = (1 << 14),
312 IDE_TFLAG_WRITE = (1 << 15),
313 IDE_TFLAG_FLAGGED_SET_IN_FLAGS = (1 << 16),
314 IDE_TFLAG_IN_DATA = (1 << 17),
315 IDE_TFLAG_CUSTOM_HANDLER = (1 << 18),
316 IDE_TFLAG_DMA_PIO_FALLBACK = (1 << 19),
317 IDE_TFLAG_IN_HOB_FEATURE = (1 << 20),
318 IDE_TFLAG_IN_HOB_NSECT = (1 << 21),
319 IDE_TFLAG_IN_HOB_LBAL = (1 << 22),
320 IDE_TFLAG_IN_HOB_LBAM = (1 << 23),
321 IDE_TFLAG_IN_HOB_LBAH = (1 << 24),
322 IDE_TFLAG_IN_HOB_LBA = IDE_TFLAG_IN_HOB_LBAL |
323 IDE_TFLAG_IN_HOB_LBAM |
324 IDE_TFLAG_IN_HOB_LBAH,
325 IDE_TFLAG_IN_HOB = IDE_TFLAG_IN_HOB_FEATURE |
326 IDE_TFLAG_IN_HOB_NSECT |
327 IDE_TFLAG_IN_HOB_LBA,
328 IDE_TFLAG_IN_FEATURE = (1 << 1),
329 IDE_TFLAG_IN_NSECT = (1 << 25),
330 IDE_TFLAG_IN_LBAL = (1 << 26),
331 IDE_TFLAG_IN_LBAM = (1 << 27),
332 IDE_TFLAG_IN_LBAH = (1 << 28),
333 IDE_TFLAG_IN_LBA = IDE_TFLAG_IN_LBAL |
334 IDE_TFLAG_IN_LBAM |
335 IDE_TFLAG_IN_LBAH,
336 IDE_TFLAG_IN_TF = IDE_TFLAG_IN_NSECT |
337 IDE_TFLAG_IN_LBA,
338 IDE_TFLAG_IN_DEVICE = (1 << 29),
339 IDE_TFLAG_HOB = IDE_TFLAG_OUT_HOB |
340 IDE_TFLAG_IN_HOB,
341 IDE_TFLAG_TF = IDE_TFLAG_OUT_TF |
342 IDE_TFLAG_IN_TF,
343 IDE_TFLAG_DEVICE = IDE_TFLAG_OUT_DEVICE |
344 IDE_TFLAG_IN_DEVICE,
345 /* force 16-bit I/O operations */
346 IDE_TFLAG_IO_16BIT = (1 << 30),
347 /* ide_task_t was allocated using kmalloc() */
348 IDE_TFLAG_DYN = (1 << 31),
349};
350
351struct ide_taskfile {
352 u8 hob_data; /* 0: high data byte (for TASKFILE IOCTL) */
353
354 u8 hob_feature; /* 1-5: additional data to support LBA48 */
355 u8 hob_nsect;
356 u8 hob_lbal;
357 u8 hob_lbam;
358 u8 hob_lbah;
359
360 u8 data; /* 6: low data byte (for TASKFILE IOCTL) */
361
362 union { /*  7: */
363 u8 error; /* read: error */
364 u8 feature; /* write: feature */
365 };
366
367 u8 nsect; /* 8: number of sectors */
368 u8 lbal; /* 9: LBA low */
369 u8 lbam; /* 10: LBA mid */
370 u8 lbah; /* 11: LBA high */
371
372 u8 device; /* 12: device select */
373
374 union { /* 13: */
375 u8 status; /*  read: status  */
376 u8 command; /* write: command */
377 };
378};
379
380typedef struct ide_task_s {
381 union {
382 struct ide_taskfile tf;
383 u8 tf_array[14];
384 };
385 u32 tf_flags;
386 int data_phase;
387 struct request *rq; /* copy of request */
388 void *special; /* valid_t generally */
389} ide_task_t;
390
391/* ATAPI packet command flags */
392enum {
393 /* set when an error is considered normal - no retry (ide-tape) */
394 PC_FLAG_ABORT = (1 << 0),
395 PC_FLAG_SUPPRESS_ERROR = (1 << 1),
396 PC_FLAG_WAIT_FOR_DSC = (1 << 2),
397 PC_FLAG_DMA_OK = (1 << 3),
398 PC_FLAG_DMA_IN_PROGRESS = (1 << 4),
399 PC_FLAG_DMA_ERROR = (1 << 5),
400 PC_FLAG_WRITING = (1 << 6),
401 /* command timed out */
402 PC_FLAG_TIMEDOUT = (1 << 7),
403};
404
405/*
406 * With each packet command, we allocate a buffer of IDE_PC_BUFFER_SIZE bytes.
407 * This is used for several packet commands (not for READ/WRITE commands).
408 */
409#define IDE_PC_BUFFER_SIZE 256
410
411struct ide_atapi_pc {
412 /* actual packet bytes */
413 u8 c[12];
414 /* incremented on each retry */
415 int retries;
416 int error;
417
418 /* bytes to transfer */
419 int req_xfer;
420 /* bytes actually transferred */
421 int xferred;
422
423 /* data buffer */
424 u8 *buf;
425 /* current buffer position */
426 u8 *cur_pos;
427 int buf_size;
428 /* missing/available data on the current buffer */
429 int b_count;
430
431 /* the corresponding request */
432 struct request *rq;
433
434 unsigned long flags;
435
436 /*
437 * those are more or less driver-specific and some of them are subject
438 * to change/removal later.
439 */
440 u8 pc_buf[IDE_PC_BUFFER_SIZE];
441
442 /* idetape only */
443 struct idetape_bh *bh;
444 char *b_data;
445
446 /* idescsi only for now */
447 struct scatterlist *sg;
448 unsigned int sg_cnt;
449
450 struct scsi_cmnd *scsi_cmd;
451 void (*done) (struct scsi_cmnd *);
452
453 unsigned long timeout;
454};
455
456struct ide_devset;
302struct ide_driver_s; 457struct ide_driver_s;
303struct ide_settings_s;
304 458
305#ifdef CONFIG_BLK_DEV_IDEACPI 459#ifdef CONFIG_BLK_DEV_IDEACPI
306struct ide_acpi_drive_link; 460struct ide_acpi_drive_link;
307struct ide_acpi_hwif_link; 461struct ide_acpi_hwif_link;
308#endif 462#endif
309 463
310typedef struct ide_drive_s { 464struct ide_drive_s;
465
466struct ide_disk_ops {
467 int (*check)(struct ide_drive_s *, const char *);
468 int (*get_capacity)(struct ide_drive_s *);
469 void (*setup)(struct ide_drive_s *);
470 void (*flush)(struct ide_drive_s *);
471 int (*init_media)(struct ide_drive_s *, struct gendisk *);
472 int (*set_doorlock)(struct ide_drive_s *, struct gendisk *,
473 int);
474 ide_startstop_t (*do_request)(struct ide_drive_s *, struct request *,
475 sector_t);
476 int (*end_request)(struct ide_drive_s *, int, int);
477 int (*ioctl)(struct ide_drive_s *, struct block_device *,
478 fmode_t, unsigned int, unsigned long);
479};
480
481/* ATAPI device flags */
482enum {
483 IDE_AFLAG_DRQ_INTERRUPT = (1 << 0),
484
485 /* ide-cd */
486 /* Drive cannot eject the disc. */
487 IDE_AFLAG_NO_EJECT = (1 << 3),
488 /* Drive is a pre ATAPI 1.2 drive. */
489 IDE_AFLAG_PRE_ATAPI12 = (1 << 4),
490 /* TOC addresses are in BCD. */
491 IDE_AFLAG_TOCADDR_AS_BCD = (1 << 5),
492 /* TOC track numbers are in BCD. */
493 IDE_AFLAG_TOCTRACKS_AS_BCD = (1 << 6),
494 /*
495 * Drive does not provide data in multiples of SECTOR_SIZE
496 * when more than one interrupt is needed.
497 */
498 IDE_AFLAG_LIMIT_NFRAMES = (1 << 7),
499 /* Seeking in progress. */
500 IDE_AFLAG_SEEKING = (1 << 8),
501 /* Saved TOC information is current. */
502 IDE_AFLAG_TOC_VALID = (1 << 9),
503 /* We think that the drive door is locked. */
504 IDE_AFLAG_DOOR_LOCKED = (1 << 10),
505 /* SET_CD_SPEED command is unsupported. */
506 IDE_AFLAG_NO_SPEED_SELECT = (1 << 11),
507 IDE_AFLAG_VERTOS_300_SSD = (1 << 12),
508 IDE_AFLAG_VERTOS_600_ESD = (1 << 13),
509 IDE_AFLAG_SANYO_3CD = (1 << 14),
510 IDE_AFLAG_FULL_CAPS_PAGE = (1 << 15),
511 IDE_AFLAG_PLAY_AUDIO_OK = (1 << 16),
512 IDE_AFLAG_LE_SPEED_FIELDS = (1 << 17),
513
514 /* ide-floppy */
515 /* Avoid commands not supported in Clik drive */
516 IDE_AFLAG_CLIK_DRIVE = (1 << 19),
517 /* Requires BH algorithm for packets */
518 IDE_AFLAG_ZIP_DRIVE = (1 << 20),
519 /* Supports format progress report */
520 IDE_AFLAG_SRFP = (1 << 22),
521
522 /* ide-tape */
523 IDE_AFLAG_IGNORE_DSC = (1 << 23),
524 /* 0 When the tape position is unknown */
525 IDE_AFLAG_ADDRESS_VALID = (1 << 24),
526 /* Device already opened */
527 IDE_AFLAG_BUSY = (1 << 25),
528 /* Attempt to auto-detect the current user block size */
529 IDE_AFLAG_DETECT_BS = (1 << 26),
530 /* Currently on a filemark */
531 IDE_AFLAG_FILEMARK = (1 << 27),
532 /* 0 = no tape is loaded, so we don't rewind after ejecting */
533 IDE_AFLAG_MEDIUM_PRESENT = (1 << 28),
534
535 IDE_AFLAG_NO_AUTOCLOSE = (1 << 29),
536};
537
538/* device flags */
539enum {
540 /* restore settings after device reset */
541 IDE_DFLAG_KEEP_SETTINGS = (1 << 0),
542 /* device is using DMA for read/write */
543 IDE_DFLAG_USING_DMA = (1 << 1),
544 /* okay to unmask other IRQs */
545 IDE_DFLAG_UNMASK = (1 << 2),
546 /* don't attempt flushes */
547 IDE_DFLAG_NOFLUSH = (1 << 3),
548 /* DSC overlap */
549 IDE_DFLAG_DSC_OVERLAP = (1 << 4),
550 /* give potential excess bandwidth */
551 IDE_DFLAG_NICE1 = (1 << 5),
552 /* device is physically present */
553 IDE_DFLAG_PRESENT = (1 << 6),
554 /* device ejected hint */
555 IDE_DFLAG_DEAD = (1 << 7),
556 /* id read from device (synthetic if not set) */
557 IDE_DFLAG_ID_READ = (1 << 8),
558 IDE_DFLAG_NOPROBE = (1 << 9),
559 /* need to do check_media_change() */
560 IDE_DFLAG_REMOVABLE = (1 << 10),
561 /* needed for removable devices */
562 IDE_DFLAG_ATTACH = (1 << 11),
563 IDE_DFLAG_FORCED_GEOM = (1 << 12),
564 /* disallow setting unmask bit */
565 IDE_DFLAG_NO_UNMASK = (1 << 13),
566 /* disallow enabling 32-bit I/O */
567 IDE_DFLAG_NO_IO_32BIT = (1 << 14),
568 /* for removable only: door lock/unlock works */
569 IDE_DFLAG_DOORLOCKING = (1 << 15),
570 /* disallow DMA */
571 IDE_DFLAG_NODMA = (1 << 16),
572 /* powermanagment told us not to do anything, so sleep nicely */
573 IDE_DFLAG_BLOCKED = (1 << 17),
574 /* ide-scsi emulation */
575 IDE_DFLAG_SCSI = (1 << 18),
576 /* sleeping & sleep field valid */
577 IDE_DFLAG_SLEEPING = (1 << 19),
578 IDE_DFLAG_POST_RESET = (1 << 20),
579 IDE_DFLAG_UDMA33_WARNED = (1 << 21),
580 IDE_DFLAG_LBA48 = (1 << 22),
581 /* status of write cache */
582 IDE_DFLAG_WCACHE = (1 << 23),
583 /* used for ignoring ATA_DF */
584 IDE_DFLAG_NOWERR = (1 << 24),
585 /* retrying in PIO */
586 IDE_DFLAG_DMA_PIO_RETRY = (1 << 25),
587 IDE_DFLAG_LBA = (1 << 26),
588 /* don't unload heads */
589 IDE_DFLAG_NO_UNLOAD = (1 << 27),
590 /* heads unloaded, please don't reset port */
591 IDE_DFLAG_PARKED = (1 << 28),
592 IDE_DFLAG_MEDIA_CHANGED = (1 << 29),
593 /* write protect */
594 IDE_DFLAG_WP = (1 << 30),
595 IDE_DFLAG_FORMAT_IN_PROGRESS = (1 << 31),
596};
597
598struct ide_drive_s {
311 char name[4]; /* drive name, such as "hda" */ 599 char name[4]; /* drive name, such as "hda" */
312 char driver_req[10]; /* requests specific driver */ 600 char driver_req[10]; /* requests specific driver */
313 601
@@ -316,73 +604,49 @@ typedef struct ide_drive_s {
316 struct request *rq; /* current request */ 604 struct request *rq; /* current request */
317 struct ide_drive_s *next; /* circular list of hwgroup drives */ 605 struct ide_drive_s *next; /* circular list of hwgroup drives */
318 void *driver_data; /* extra driver data */ 606 void *driver_data; /* extra driver data */
319 struct hd_driveid *id; /* drive model identification info */ 607 u16 *id; /* identification info */
320#ifdef CONFIG_IDE_PROC_FS 608#ifdef CONFIG_IDE_PROC_FS
321 struct proc_dir_entry *proc; /* /proc/ide/ directory entry */ 609 struct proc_dir_entry *proc; /* /proc/ide/ directory entry */
322 struct ide_settings_s *settings;/* /proc/ide/ drive settings */ 610 const struct ide_proc_devset *settings; /* /proc/ide/ drive settings */
323#endif 611#endif
324 struct hwif_s *hwif; /* actually (ide_hwif_t *) */ 612 struct hwif_s *hwif; /* actually (ide_hwif_t *) */
325 613
614 const struct ide_disk_ops *disk_ops;
615
616 unsigned long dev_flags;
617
326 unsigned long sleep; /* sleep until this time */ 618 unsigned long sleep; /* sleep until this time */
327 unsigned long service_start; /* time we started last request */ 619 unsigned long service_start; /* time we started last request */
328 unsigned long service_time; /* service time of last request */ 620 unsigned long service_time; /* service time of last request */
329 unsigned long timeout; /* max time to wait for irq */ 621 unsigned long timeout; /* max time to wait for irq */
330 622
331 special_t special; /* special action flags */ 623 special_t special; /* special action flags */
332 select_t select; /* basic drive/head select reg value */
333 624
334 u8 keep_settings; /* restore settings after drive reset */ 625 u8 select; /* basic drive/head select reg value */
335 u8 using_dma; /* disk is using dma for read/write */
336 u8 retry_pio; /* retrying dma capable host in pio */ 626 u8 retry_pio; /* retrying dma capable host in pio */
337 u8 state; /* retry state */
338 u8 waiting_for_dma; /* dma currently in progress */ 627 u8 waiting_for_dma; /* dma currently in progress */
339 u8 unmask; /* okay to unmask other irqs */ 628 u8 dma; /* atapi dma flag */
340 u8 noflush; /* don't attempt flushes */ 629
341 u8 dsc_overlap; /* DSC overlap */
342 u8 nice1; /* give potential excess bandwidth */
343
344 unsigned present : 1; /* drive is physically present */
345 unsigned dead : 1; /* device ejected hint */
346 unsigned id_read : 1; /* 1=id read from disk 0 = synthetic */
347 unsigned noprobe : 1; /* from: hdx=noprobe */
348 unsigned removable : 1; /* 1 if need to do check_media_change */
349 unsigned attach : 1; /* needed for removable devices */
350 unsigned forced_geom : 1; /* 1 if hdx=c,h,s was given at boot */
351 unsigned no_unmask : 1; /* disallow setting unmask bit */
352 unsigned no_io_32bit : 1; /* disallow enabling 32bit I/O */
353 unsigned atapi_overlap : 1; /* ATAPI overlap (not supported) */
354 unsigned doorlocking : 1; /* for removable only: door lock/unlock works */
355 unsigned nodma : 1; /* disallow DMA */
356 unsigned remap_0_to_1 : 1; /* 0=noremap, 1=remap 0->1 (for EZDrive) */
357 unsigned blocked : 1; /* 1=powermanagment told us not to do anything, so sleep nicely */
358 unsigned vdma : 1; /* 1=doing PIO over DMA 0=doing normal DMA */
359 unsigned scsi : 1; /* 0=default, 1=ide-scsi emulation */
360 unsigned sleeping : 1; /* 1=sleeping & sleep field valid */
361 unsigned post_reset : 1;
362 unsigned udma33_warned : 1;
363
364 u8 addressing; /* 0=28-bit, 1=48-bit, 2=48-bit doing 28-bit */
365 u8 quirk_list; /* considered quirky, set for a specific host */ 630 u8 quirk_list; /* considered quirky, set for a specific host */
366 u8 init_speed; /* transfer rate set at boot */ 631 u8 init_speed; /* transfer rate set at boot */
367 u8 current_speed; /* current transfer rate set */ 632 u8 current_speed; /* current transfer rate set */
368 u8 desired_speed; /* desired transfer rate set */ 633 u8 desired_speed; /* desired transfer rate set */
369 u8 dn; /* now wide spread use */ 634 u8 dn; /* now wide spread use */
370 u8 wcache; /* status of write cache */
371 u8 acoustic; /* acoustic management */ 635 u8 acoustic; /* acoustic management */
372 u8 media; /* disk, cdrom, tape, floppy, ... */ 636 u8 media; /* disk, cdrom, tape, floppy, ... */
373 u8 ready_stat; /* min status value for drive ready */ 637 u8 ready_stat; /* min status value for drive ready */
374 u8 mult_count; /* current multiple sector setting */ 638 u8 mult_count; /* current multiple sector setting */
375 u8 mult_req; /* requested multiple sector setting */ 639 u8 mult_req; /* requested multiple sector setting */
376 u8 tune_req; /* requested drive tuning setting */
377 u8 io_32bit; /* 0=16-bit, 1=32-bit, 2/3=32bit+sync */ 640 u8 io_32bit; /* 0=16-bit, 1=32-bit, 2/3=32bit+sync */
378 u8 bad_wstat; /* used for ignoring WRERR_STAT */ 641 u8 bad_wstat; /* used for ignoring ATA_DF */
379 u8 nowerr; /* used for ignoring WRERR_STAT */
380 u8 sect0; /* offset of first sector for DM6:DDO */
381 u8 head; /* "real" number of heads */ 642 u8 head; /* "real" number of heads */
382 u8 sect; /* "real" sectors per track */ 643 u8 sect; /* "real" sectors per track */
383 u8 bios_head; /* BIOS/fdisk/LILO number of heads */ 644 u8 bios_head; /* BIOS/fdisk/LILO number of heads */
384 u8 bios_sect; /* BIOS/fdisk/LILO sectors per track */ 645 u8 bios_sect; /* BIOS/fdisk/LILO sectors per track */
385 646
647 /* delay this long before sending packet command */
648 u8 pc_delay;
649
386 unsigned int bios_cyl; /* BIOS/fdisk/LILO number of cyls */ 650 unsigned int bios_cyl; /* BIOS/fdisk/LILO number of cyls */
387 unsigned int cyl; /* "real" number of cyls */ 651 unsigned int cyl; /* "real" number of cyls */
388 unsigned int drive_data; /* used by set_pio_mode/selectproc */ 652 unsigned int drive_data; /* used by set_pio_mode/selectproc */
@@ -394,41 +658,93 @@ typedef struct ide_drive_s {
394 658
395 int lun; /* logical unit */ 659 int lun; /* logical unit */
396 int crc_count; /* crc counter to reduce drive speed */ 660 int crc_count; /* crc counter to reduce drive speed */
661
662 unsigned long debug_mask; /* debugging levels switch */
663
397#ifdef CONFIG_BLK_DEV_IDEACPI 664#ifdef CONFIG_BLK_DEV_IDEACPI
398 struct ide_acpi_drive_link *acpidata; 665 struct ide_acpi_drive_link *acpidata;
399#endif 666#endif
400 struct list_head list; 667 struct list_head list;
401 struct device gendev; 668 struct device gendev;
402 struct completion gendev_rel_comp; /* to deal with device release() */ 669 struct completion gendev_rel_comp; /* to deal with device release() */
403} ide_drive_t;
404 670
405#define to_ide_device(dev)container_of(dev, ide_drive_t, gendev) 671 /* current packet command */
672 struct ide_atapi_pc *pc;
673
674 /* callback for packet commands */
675 void (*pc_callback)(struct ide_drive_s *, int);
676
677 void (*pc_update_buffers)(struct ide_drive_s *, struct ide_atapi_pc *);
678 int (*pc_io_buffers)(struct ide_drive_s *, struct ide_atapi_pc *,
679 unsigned int, int);
680
681 unsigned long atapi_flags;
682
683 struct ide_atapi_pc request_sense_pc;
684 struct request request_sense_rq;
685};
686
687typedef struct ide_drive_s ide_drive_t;
688
689#define to_ide_device(dev) container_of(dev, ide_drive_t, gendev)
406 690
407#define IDE_CHIPSET_PCI_MASK \ 691#define to_ide_drv(obj, cont_type) \
408 ((1<<ide_pci)|(1<<ide_cmd646)|(1<<ide_ali14xx)) 692 container_of(obj, struct cont_type, kref)
409#define IDE_CHIPSET_IS_PCI(c) ((IDE_CHIPSET_PCI_MASK >> (c)) & 1) 693
694#define ide_drv_g(disk, cont_type) \
695 container_of((disk)->private_data, struct cont_type, driver)
410 696
411struct ide_port_info; 697struct ide_port_info;
412 698
699struct ide_tp_ops {
700 void (*exec_command)(struct hwif_s *, u8);
701 u8 (*read_status)(struct hwif_s *);
702 u8 (*read_altstatus)(struct hwif_s *);
703 u8 (*read_sff_dma_status)(struct hwif_s *);
704
705 void (*set_irq)(struct hwif_s *, int);
706
707 void (*tf_load)(ide_drive_t *, struct ide_task_s *);
708 void (*tf_read)(ide_drive_t *, struct ide_task_s *);
709
710 void (*input_data)(ide_drive_t *, struct request *, void *,
711 unsigned int);
712 void (*output_data)(ide_drive_t *, struct request *, void *,
713 unsigned int);
714};
715
716extern const struct ide_tp_ops default_tp_ops;
717
718/**
719 * struct ide_port_ops - IDE port operations
720 *
721 * @init_dev: host specific initialization of a device
722 * @set_pio_mode: routine to program host for PIO mode
723 * @set_dma_mode: routine to program host for DMA mode
724 * @selectproc: tweaks hardware to select drive
725 * @reset_poll: chipset polling based on hba specifics
726 * @pre_reset: chipset specific changes to default for device-hba resets
727 * @resetproc: routine to reset controller after a disk reset
728 * @maskproc: special host masking for drive selection
729 * @quirkproc: check host's drive quirk list
730 * @clear_irq: clear IRQ
731 *
732 * @mdma_filter: filter MDMA modes
733 * @udma_filter: filter UDMA modes
734 *
735 * @cable_detect: detect cable type
736 */
413struct ide_port_ops { 737struct ide_port_ops {
414 /* host specific initialization of a device */
415 void (*init_dev)(ide_drive_t *); 738 void (*init_dev)(ide_drive_t *);
416 /* routine to program host for PIO mode */
417 void (*set_pio_mode)(ide_drive_t *, const u8); 739 void (*set_pio_mode)(ide_drive_t *, const u8);
418 /* routine to program host for DMA mode */
419 void (*set_dma_mode)(ide_drive_t *, const u8); 740 void (*set_dma_mode)(ide_drive_t *, const u8);
420 /* tweaks hardware to select drive */
421 void (*selectproc)(ide_drive_t *); 741 void (*selectproc)(ide_drive_t *);
422 /* chipset polling based on hba specifics */
423 int (*reset_poll)(ide_drive_t *); 742 int (*reset_poll)(ide_drive_t *);
424 /* chipset specific changes to default for device-hba resets */
425 void (*pre_reset)(ide_drive_t *); 743 void (*pre_reset)(ide_drive_t *);
426 /* routine to reset controller after a disk reset */
427 void (*resetproc)(ide_drive_t *); 744 void (*resetproc)(ide_drive_t *);
428 /* special host masking for drive selection */
429 void (*maskproc)(ide_drive_t *, int); 745 void (*maskproc)(ide_drive_t *, int);
430 /* check host's drive quirk list */
431 void (*quirkproc)(ide_drive_t *); 746 void (*quirkproc)(ide_drive_t *);
747 void (*clear_irq)(ide_drive_t *);
432 748
433 u8 (*mdma_filter)(ide_drive_t *); 749 u8 (*mdma_filter)(ide_drive_t *);
434 u8 (*udma_filter)(ide_drive_t *); 750 u8 (*udma_filter)(ide_drive_t *);
@@ -447,7 +763,7 @@ struct ide_dma_ops {
447 void (*dma_timeout)(struct ide_drive_s *); 763 void (*dma_timeout)(struct ide_drive_s *);
448}; 764};
449 765
450struct ide_task_s; 766struct ide_host;
451 767
452typedef struct hwif_s { 768typedef struct hwif_s {
453 struct hwif_s *next; /* for linked-list in ide_hwgroup_t */ 769 struct hwif_s *next; /* for linked-list in ide_hwgroup_t */
@@ -455,6 +771,8 @@ typedef struct hwif_s {
455 struct hwgroup_s *hwgroup; /* actually (ide_hwgroup_t *) */ 771 struct hwgroup_s *hwgroup; /* actually (ide_hwgroup_t *) */
456 struct proc_dir_entry *proc; /* /proc/ide/ directory entry */ 772 struct proc_dir_entry *proc; /* /proc/ide/ directory entry */
457 773
774 struct ide_host *host;
775
458 char name[6]; /* name of interface, eg. "ide0" */ 776 char name[6]; /* name of interface, eg. "ide0" */
459 777
460 struct ide_io_ports io_ports; 778 struct ide_io_ports io_ports;
@@ -466,7 +784,6 @@ typedef struct hwif_s {
466 u8 major; /* our major number */ 784 u8 major; /* our major number */
467 u8 index; /* 0 for ide0; 1 for ide1; ... */ 785 u8 index; /* 0 for ide0; 1 for ide1; ... */
468 u8 channel; /* for dual-port chips: 0=primary, 1=secondary */ 786 u8 channel; /* for dual-port chips: 0=primary, 1=secondary */
469 u8 bus_state; /* power state of the IDE bus */
470 787
471 u32 host_flags; 788 u32 host_flags;
472 789
@@ -486,26 +803,20 @@ typedef struct hwif_s {
486 803
487 void (*rw_disk)(ide_drive_t *, struct request *); 804 void (*rw_disk)(ide_drive_t *, struct request *);
488 805
806 const struct ide_tp_ops *tp_ops;
489 const struct ide_port_ops *port_ops; 807 const struct ide_port_ops *port_ops;
490 const struct ide_dma_ops *dma_ops; 808 const struct ide_dma_ops *dma_ops;
491 809
492 void (*tf_load)(ide_drive_t *, struct ide_task_s *);
493 void (*tf_read)(ide_drive_t *, struct ide_task_s *);
494
495 void (*input_data)(ide_drive_t *, struct request *, void *, unsigned);
496 void (*output_data)(ide_drive_t *, struct request *, void *, unsigned);
497
498 void (*ide_dma_clear_irq)(ide_drive_t *drive);
499
500 void (*OUTB)(u8 addr, unsigned long port);
501 void (*OUTBSYNC)(struct hwif_s *hwif, u8 addr, unsigned long port);
502
503 u8 (*INB)(unsigned long port);
504
505 /* dma physical region descriptor table (cpu view) */ 810 /* dma physical region descriptor table (cpu view) */
506 unsigned int *dmatable_cpu; 811 unsigned int *dmatable_cpu;
507 /* dma physical region descriptor table (dma view) */ 812 /* dma physical region descriptor table (dma view) */
508 dma_addr_t dmatable_dma; 813 dma_addr_t dmatable_dma;
814
815 /* maximum number of PRD table entries */
816 int prd_max_nents;
817 /* PRD entry size in bytes */
818 int prd_ent_size;
819
509 /* Scatter-gather list used to build the above */ 820 /* Scatter-gather list used to build the above */
510 struct scatterlist *sg_table; 821 struct scatterlist *sg_table;
511 int sg_max_nents; /* Maximum number of entries in it */ 822 int sg_max_nents; /* Maximum number of entries in it */
@@ -515,6 +826,8 @@ typedef struct hwif_s {
515 /* data phase of the active command (currently only valid for PIO/DMA) */ 826 /* data phase of the active command (currently only valid for PIO/DMA) */
516 int data_phase; 827 int data_phase;
517 828
829 struct ide_task_s task; /* current command */
830
518 unsigned int nsect; 831 unsigned int nsect;
519 unsigned int nleft; 832 unsigned int nleft;
520 struct scatterlist *cursg; 833 struct scatterlist *cursg;
@@ -524,8 +837,6 @@ typedef struct hwif_s {
524 int irq; /* our irq number */ 837 int irq; /* our irq number */
525 838
526 unsigned long dma_base; /* base addr for dma ports */ 839 unsigned long dma_base; /* base addr for dma ports */
527 unsigned long dma_command; /* dma command register */
528 unsigned long dma_status; /* dma status register */
529 840
530 unsigned long config_data; /* for use by chipset-specific code */ 841 unsigned long config_data; /* for use by chipset-specific code */
531 unsigned long select_data; /* for use by chipset-specific code */ 842 unsigned long select_data; /* for use by chipset-specific code */
@@ -545,13 +856,22 @@ typedef struct hwif_s {
545 856
546 void *hwif_data; /* extra hwif data */ 857 void *hwif_data; /* extra hwif data */
547 858
548 unsigned dma;
549
550#ifdef CONFIG_BLK_DEV_IDEACPI 859#ifdef CONFIG_BLK_DEV_IDEACPI
551 struct ide_acpi_hwif_link *acpidata; 860 struct ide_acpi_hwif_link *acpidata;
552#endif 861#endif
553} ____cacheline_internodealigned_in_smp ide_hwif_t; 862} ____cacheline_internodealigned_in_smp ide_hwif_t;
554 863
864#define MAX_HOST_PORTS 4
865
866struct ide_host {
867 ide_hwif_t *ports[MAX_HOST_PORTS];
868 unsigned int n_ports;
869 struct device *dev[2];
870 unsigned int (*init_chipset)(struct pci_dev *);
871 unsigned long host_flags;
872 void *host_priv;
873};
874
555/* 875/*
556 * internal ide interrupt handler type 876 * internal ide interrupt handler type
557 */ 877 */
@@ -595,106 +915,116 @@ typedef struct ide_driver_s ide_driver_t;
595 915
596extern struct mutex ide_setting_mtx; 916extern struct mutex ide_setting_mtx;
597 917
598int set_io_32bit(ide_drive_t *, int); 918/*
599int set_pio_mode(ide_drive_t *, int); 919 * configurable drive settings
600int set_using_dma(ide_drive_t *, int); 920 */
601 921
602/* ATAPI packet command flags */ 922#define DS_SYNC (1 << 0)
603enum { 923
604 /* set when an error is considered normal - no retry (ide-tape) */ 924struct ide_devset {
605 PC_FLAG_ABORT = (1 << 0), 925 int (*get)(ide_drive_t *);
606 PC_FLAG_SUPPRESS_ERROR = (1 << 1), 926 int (*set)(ide_drive_t *, int);
607 PC_FLAG_WAIT_FOR_DSC = (1 << 2), 927 unsigned int flags;
608 PC_FLAG_DMA_OK = (1 << 3),
609 PC_FLAG_DMA_IN_PROGRESS = (1 << 4),
610 PC_FLAG_DMA_ERROR = (1 << 5),
611 PC_FLAG_WRITING = (1 << 6),
612 /* command timed out */
613 PC_FLAG_TIMEDOUT = (1 << 7),
614 PC_FLAG_ZIP_DRIVE = (1 << 8),
615 PC_FLAG_DRQ_INTERRUPT = (1 << 9),
616}; 928};
617 929
618struct ide_atapi_pc { 930#define __DEVSET(_flags, _get, _set) { \
619 /* actual packet bytes */ 931 .flags = _flags, \
620 u8 c[12]; 932 .get = _get, \
621 /* incremented on each retry */ 933 .set = _set, \
622 int retries; 934}
623 int error;
624 935
625 /* bytes to transfer */ 936#define ide_devset_get(name, field) \
626 int req_xfer; 937static int get_##name(ide_drive_t *drive) \
627 /* bytes actually transferred */ 938{ \
628 int xferred; 939 return drive->field; \
940}
629 941
630 /* data buffer */ 942#define ide_devset_set(name, field) \
631 u8 *buf; 943static int set_##name(ide_drive_t *drive, int arg) \
632 /* current buffer position */ 944{ \
633 u8 *cur_pos; 945 drive->field = arg; \
634 int buf_size; 946 return 0; \
635 /* missing/available data on the current buffer */ 947}
636 int b_count;
637 948
638 /* the corresponding request */ 949#define ide_devset_get_flag(name, flag) \
639 struct request *rq; 950static int get_##name(ide_drive_t *drive) \
951{ \
952 return !!(drive->dev_flags & flag); \
953}
640 954
641 unsigned long flags; 955#define ide_devset_set_flag(name, flag) \
956static int set_##name(ide_drive_t *drive, int arg) \
957{ \
958 if (arg) \
959 drive->dev_flags |= flag; \
960 else \
961 drive->dev_flags &= ~flag; \
962 return 0; \
963}
642 964
643 /* 965#define __IDE_DEVSET(_name, _flags, _get, _set) \
644 * those are more or less driver-specific and some of them are subject 966const struct ide_devset ide_devset_##_name = \
645 * to change/removal later. 967 __DEVSET(_flags, _get, _set)
646 */
647 u8 pc_buf[256];
648 968
649 void (*callback)(ide_drive_t *); 969#define IDE_DEVSET(_name, _flags, _get, _set) \
970static __IDE_DEVSET(_name, _flags, _get, _set)
650 971
651 /* idetape only */ 972#define ide_devset_rw(_name, _func) \
652 struct idetape_bh *bh; 973IDE_DEVSET(_name, 0, get_##_func, set_##_func)
653 char *b_data;
654 974
655 /* idescsi only for now */ 975#define ide_devset_w(_name, _func) \
656 struct scatterlist *sg; 976IDE_DEVSET(_name, 0, NULL, set_##_func)
657 unsigned int sg_cnt;
658 977
659 struct scsi_cmnd *scsi_cmd; 978#define ide_ext_devset_rw(_name, _func) \
660 void (*done) (struct scsi_cmnd *); 979__IDE_DEVSET(_name, 0, get_##_func, set_##_func)
661 980
662 unsigned long timeout; 981#define ide_ext_devset_rw_sync(_name, _func) \
663}; 982__IDE_DEVSET(_name, DS_SYNC, get_##_func, set_##_func)
983
984#define ide_decl_devset(_name) \
985extern const struct ide_devset ide_devset_##_name
986
987ide_decl_devset(io_32bit);
988ide_decl_devset(keepsettings);
989ide_decl_devset(pio_mode);
990ide_decl_devset(unmaskirq);
991ide_decl_devset(using_dma);
664 992
665#ifdef CONFIG_IDE_PROC_FS 993#ifdef CONFIG_IDE_PROC_FS
666/* 994/*
667 * configurable drive settings 995 * /proc/ide interface
668 */ 996 */
669 997
670#define TYPE_INT 0 998#define ide_devset_rw_field(_name, _field) \
671#define TYPE_BYTE 1 999ide_devset_get(_name, _field); \
672#define TYPE_SHORT 2 1000ide_devset_set(_name, _field); \
1001IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name)
1002
1003#define ide_devset_rw_flag(_name, _field) \
1004ide_devset_get_flag(_name, _field); \
1005ide_devset_set_flag(_name, _field); \
1006IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name)
1007
1008struct ide_proc_devset {
1009 const char *name;
1010 const struct ide_devset *setting;
1011 int min, max;
1012 int (*mulf)(ide_drive_t *);
1013 int (*divf)(ide_drive_t *);
1014};
673 1015
674#define SETTING_READ (1 << 0) 1016#define __IDE_PROC_DEVSET(_name, _min, _max, _mulf, _divf) { \
675#define SETTING_WRITE (1 << 1) 1017 .name = __stringify(_name), \
676#define SETTING_RW (SETTING_READ | SETTING_WRITE) 1018 .setting = &ide_devset_##_name, \
1019 .min = _min, \
1020 .max = _max, \
1021 .mulf = _mulf, \
1022 .divf = _divf, \
1023}
677 1024
678typedef int (ide_procset_t)(ide_drive_t *, int); 1025#define IDE_PROC_DEVSET(_name, _min, _max) \
679typedef struct ide_settings_s { 1026__IDE_PROC_DEVSET(_name, _min, _max, NULL, NULL)
680 char *name;
681 int rw;
682 int data_type;
683 int min;
684 int max;
685 int mul_factor;
686 int div_factor;
687 void *data;
688 ide_procset_t *set;
689 int auto_remove;
690 struct ide_settings_s *next;
691} ide_settings_t;
692
693int ide_add_setting(ide_drive_t *, const char *, int, int, int, int, int, int, void *, ide_procset_t *set);
694 1027
695/*
696 * /proc/ide interface
697 */
698typedef struct { 1028typedef struct {
699 const char *name; 1029 const char *name;
700 mode_t mode; 1030 mode_t mode;
@@ -711,8 +1041,6 @@ void ide_proc_unregister_port(ide_hwif_t *);
711void ide_proc_register_driver(ide_drive_t *, ide_driver_t *); 1041void ide_proc_register_driver(ide_drive_t *, ide_driver_t *);
712void ide_proc_unregister_driver(ide_drive_t *, ide_driver_t *); 1042void ide_proc_unregister_driver(ide_drive_t *, ide_driver_t *);
713 1043
714void ide_add_generic_settings(ide_drive_t *);
715
716read_proc_t proc_ide_read_capacity; 1044read_proc_t proc_ide_read_capacity;
717read_proc_t proc_ide_read_geometry; 1045read_proc_t proc_ide_read_geometry;
718 1046
@@ -740,41 +1068,58 @@ static inline void ide_proc_unregister_device(ide_drive_t *drive) { ; }
740static inline void ide_proc_unregister_port(ide_hwif_t *hwif) { ; } 1068static inline void ide_proc_unregister_port(ide_hwif_t *hwif) { ; }
741static inline void ide_proc_register_driver(ide_drive_t *drive, ide_driver_t *driver) { ; } 1069static inline void ide_proc_register_driver(ide_drive_t *drive, ide_driver_t *driver) { ; }
742static inline void ide_proc_unregister_driver(ide_drive_t *drive, ide_driver_t *driver) { ; } 1070static inline void ide_proc_unregister_driver(ide_drive_t *drive, ide_driver_t *driver) { ; }
743static inline void ide_add_generic_settings(ide_drive_t *drive) { ; }
744#define PROC_IDE_READ_RETURN(page,start,off,count,eof,len) return 0; 1071#define PROC_IDE_READ_RETURN(page,start,off,count,eof,len) return 0;
745#endif 1072#endif
746 1073
1074enum {
1075 /* enter/exit functions */
1076 IDE_DBG_FUNC = (1 << 0),
1077 /* sense key/asc handling */
1078 IDE_DBG_SENSE = (1 << 1),
1079 /* packet commands handling */
1080 IDE_DBG_PC = (1 << 2),
1081 /* request handling */
1082 IDE_DBG_RQ = (1 << 3),
1083 /* driver probing/setup */
1084 IDE_DBG_PROBE = (1 << 4),
1085};
1086
1087/* DRV_NAME has to be defined in the driver before using the macro below */
1088#define __ide_debug_log(lvl, fmt, args...) \
1089{ \
1090 if (unlikely(drive->debug_mask & lvl)) \
1091 printk(KERN_INFO DRV_NAME ": " fmt, ## args); \
1092}
1093
747/* 1094/*
748 * Power Management step value (rq->pm->pm_step). 1095 * Power Management state machine (rq->pm->pm_step).
749 *
750 * The step value starts at 0 (ide_pm_state_start_suspend) for a
751 * suspend operation or 1000 (ide_pm_state_start_resume) for a
752 * resume operation.
753 * 1096 *
754 * For each step, the core calls the subdriver start_power_step() first. 1097 * For each step, the core calls ide_start_power_step() first.
755 * This can return: 1098 * This can return:
756 * - ide_stopped : In this case, the core calls us back again unless 1099 * - ide_stopped : In this case, the core calls us back again unless
757 * step have been set to ide_power_state_completed. 1100 * step have been set to ide_power_state_completed.
758 * - ide_started : In this case, the channel is left busy until an 1101 * - ide_started : In this case, the channel is left busy until an
759 * async event (interrupt) occurs. 1102 * async event (interrupt) occurs.
760 * Typically, start_power_step() will issue a taskfile request with 1103 * Typically, ide_start_power_step() will issue a taskfile request with
761 * do_rw_taskfile(). 1104 * do_rw_taskfile().
762 * 1105 *
763 * Upon reception of the interrupt, the core will call complete_power_step() 1106 * Upon reception of the interrupt, the core will call ide_complete_power_step()
764 * with the error code if any. This routine should update the step value 1107 * with the error code if any. This routine should update the step value
765 * and return. It should not start a new request. The core will call 1108 * and return. It should not start a new request. The core will call
766 * start_power_step for the new step value, unless step have been set to 1109 * ide_start_power_step() for the new step value, unless step have been
767 * ide_power_state_completed. 1110 * set to IDE_PM_COMPLETED.
768 *
769 * Subdrivers are expected to define their own additional power
770 * steps from 1..999 for suspend and from 1001..1999 for resume,
771 * other values are reserved for future use.
772 */ 1111 */
773
774enum { 1112enum {
775 ide_pm_state_completed = -1, 1113 IDE_PM_START_SUSPEND,
776 ide_pm_state_start_suspend = 0, 1114 IDE_PM_FLUSH_CACHE = IDE_PM_START_SUSPEND,
777 ide_pm_state_start_resume = 1000, 1115 IDE_PM_STANDBY,
1116
1117 IDE_PM_START_RESUME,
1118 IDE_PM_RESTORE_PIO = IDE_PM_START_RESUME,
1119 IDE_PM_IDLE,
1120 IDE_PM_RESTORE_DMA,
1121
1122 IDE_PM_COMPLETED,
778}; 1123};
779 1124
780/* 1125/*
@@ -785,8 +1130,6 @@ enum {
785 */ 1130 */
786struct ide_driver_s { 1131struct ide_driver_s {
787 const char *version; 1132 const char *version;
788 u8 media;
789 unsigned supports_dsc_overlap : 1;
790 ide_startstop_t (*do_request)(ide_drive_t *, struct request *, sector_t); 1133 ide_startstop_t (*do_request)(ide_drive_t *, struct request *, sector_t);
791 int (*end_request)(ide_drive_t *, int, int); 1134 int (*end_request)(ide_drive_t *, int, int);
792 ide_startstop_t (*error)(ide_drive_t *, struct request *rq, u8, u8); 1135 ide_startstop_t (*error)(ide_drive_t *, struct request *rq, u8, u8);
@@ -796,23 +1139,29 @@ struct ide_driver_s {
796 void (*resume)(ide_drive_t *); 1139 void (*resume)(ide_drive_t *);
797 void (*shutdown)(ide_drive_t *); 1140 void (*shutdown)(ide_drive_t *);
798#ifdef CONFIG_IDE_PROC_FS 1141#ifdef CONFIG_IDE_PROC_FS
799 ide_proc_entry_t *proc; 1142 ide_proc_entry_t * (*proc_entries)(ide_drive_t *);
1143 const struct ide_proc_devset * (*proc_devsets)(ide_drive_t *);
800#endif 1144#endif
801}; 1145};
802 1146
803#define to_ide_driver(drv) container_of(drv, ide_driver_t, gen_driver) 1147#define to_ide_driver(drv) container_of(drv, ide_driver_t, gen_driver)
804 1148
805int generic_ide_ioctl(ide_drive_t *, struct file *, struct block_device *, unsigned, unsigned long); 1149int ide_device_get(ide_drive_t *);
1150void ide_device_put(ide_drive_t *);
806 1151
807extern int ide_vlb_clk; 1152struct ide_ioctl_devset {
808extern int ide_pci_clk; 1153 unsigned int get_ioctl;
1154 unsigned int set_ioctl;
1155 const struct ide_devset *setting;
1156};
809 1157
810ide_hwif_t *ide_find_port_slot(const struct ide_port_info *); 1158int ide_setting_ioctl(ide_drive_t *, struct block_device *, unsigned int,
1159 unsigned long, const struct ide_ioctl_devset *);
811 1160
812static inline ide_hwif_t *ide_find_port(void) 1161int generic_ide_ioctl(ide_drive_t *, struct block_device *, unsigned, unsigned long);
813{ 1162
814 return ide_find_port_slot(NULL); 1163extern int ide_vlb_clk;
815} 1164extern int ide_pci_clk;
816 1165
817extern int ide_end_request (ide_drive_t *drive, int uptodate, int nrsecs); 1166extern int ide_end_request (ide_drive_t *drive, int uptodate, int nrsecs);
818int ide_end_dequeued_request(ide_drive_t *drive, struct request *rq, 1167int ide_end_dequeued_request(ide_drive_t *drive, struct request *rq,
@@ -831,140 +1180,90 @@ ide_startstop_t __ide_error(ide_drive_t *, struct request *, u8, u8);
831 1180
832ide_startstop_t ide_error (ide_drive_t *drive, const char *msg, byte stat); 1181ide_startstop_t ide_error (ide_drive_t *drive, const char *msg, byte stat);
833 1182
834extern void ide_fix_driveid(struct hd_driveid *); 1183void ide_fix_driveid(u16 *);
835 1184
836extern void ide_fixstring(u8 *, const int, const int); 1185extern void ide_fixstring(u8 *, const int, const int);
837 1186
1187int ide_busy_sleep(ide_hwif_t *, unsigned long, int);
1188
838int ide_wait_stat(ide_startstop_t *, ide_drive_t *, u8, u8, unsigned long); 1189int ide_wait_stat(ide_startstop_t *, ide_drive_t *, u8, u8, unsigned long);
839 1190
840extern ide_startstop_t ide_do_reset (ide_drive_t *); 1191extern ide_startstop_t ide_do_reset (ide_drive_t *);
841 1192
1193extern int ide_devset_execute(ide_drive_t *drive,
1194 const struct ide_devset *setting, int arg);
1195
842extern void ide_do_drive_cmd(ide_drive_t *, struct request *); 1196extern void ide_do_drive_cmd(ide_drive_t *, struct request *);
843 1197
844extern void ide_end_drive_cmd(ide_drive_t *, u8, u8); 1198extern void ide_end_drive_cmd(ide_drive_t *, u8, u8);
845 1199
846enum { 1200void ide_tf_dump(const char *, struct ide_taskfile *);
847 IDE_TFLAG_LBA48 = (1 << 0),
848 IDE_TFLAG_FLAGGED = (1 << 2),
849 IDE_TFLAG_OUT_DATA = (1 << 3),
850 IDE_TFLAG_OUT_HOB_FEATURE = (1 << 4),
851 IDE_TFLAG_OUT_HOB_NSECT = (1 << 5),
852 IDE_TFLAG_OUT_HOB_LBAL = (1 << 6),
853 IDE_TFLAG_OUT_HOB_LBAM = (1 << 7),
854 IDE_TFLAG_OUT_HOB_LBAH = (1 << 8),
855 IDE_TFLAG_OUT_HOB = IDE_TFLAG_OUT_HOB_FEATURE |
856 IDE_TFLAG_OUT_HOB_NSECT |
857 IDE_TFLAG_OUT_HOB_LBAL |
858 IDE_TFLAG_OUT_HOB_LBAM |
859 IDE_TFLAG_OUT_HOB_LBAH,
860 IDE_TFLAG_OUT_FEATURE = (1 << 9),
861 IDE_TFLAG_OUT_NSECT = (1 << 10),
862 IDE_TFLAG_OUT_LBAL = (1 << 11),
863 IDE_TFLAG_OUT_LBAM = (1 << 12),
864 IDE_TFLAG_OUT_LBAH = (1 << 13),
865 IDE_TFLAG_OUT_TF = IDE_TFLAG_OUT_FEATURE |
866 IDE_TFLAG_OUT_NSECT |
867 IDE_TFLAG_OUT_LBAL |
868 IDE_TFLAG_OUT_LBAM |
869 IDE_TFLAG_OUT_LBAH,
870 IDE_TFLAG_OUT_DEVICE = (1 << 14),
871 IDE_TFLAG_WRITE = (1 << 15),
872 IDE_TFLAG_FLAGGED_SET_IN_FLAGS = (1 << 16),
873 IDE_TFLAG_IN_DATA = (1 << 17),
874 IDE_TFLAG_CUSTOM_HANDLER = (1 << 18),
875 IDE_TFLAG_DMA_PIO_FALLBACK = (1 << 19),
876 IDE_TFLAG_IN_HOB_FEATURE = (1 << 20),
877 IDE_TFLAG_IN_HOB_NSECT = (1 << 21),
878 IDE_TFLAG_IN_HOB_LBAL = (1 << 22),
879 IDE_TFLAG_IN_HOB_LBAM = (1 << 23),
880 IDE_TFLAG_IN_HOB_LBAH = (1 << 24),
881 IDE_TFLAG_IN_HOB_LBA = IDE_TFLAG_IN_HOB_LBAL |
882 IDE_TFLAG_IN_HOB_LBAM |
883 IDE_TFLAG_IN_HOB_LBAH,
884 IDE_TFLAG_IN_HOB = IDE_TFLAG_IN_HOB_FEATURE |
885 IDE_TFLAG_IN_HOB_NSECT |
886 IDE_TFLAG_IN_HOB_LBA,
887 IDE_TFLAG_IN_NSECT = (1 << 25),
888 IDE_TFLAG_IN_LBAL = (1 << 26),
889 IDE_TFLAG_IN_LBAM = (1 << 27),
890 IDE_TFLAG_IN_LBAH = (1 << 28),
891 IDE_TFLAG_IN_LBA = IDE_TFLAG_IN_LBAL |
892 IDE_TFLAG_IN_LBAM |
893 IDE_TFLAG_IN_LBAH,
894 IDE_TFLAG_IN_TF = IDE_TFLAG_IN_NSECT |
895 IDE_TFLAG_IN_LBA,
896 IDE_TFLAG_IN_DEVICE = (1 << 29),
897 IDE_TFLAG_HOB = IDE_TFLAG_OUT_HOB |
898 IDE_TFLAG_IN_HOB,
899 IDE_TFLAG_TF = IDE_TFLAG_OUT_TF |
900 IDE_TFLAG_IN_TF,
901 IDE_TFLAG_DEVICE = IDE_TFLAG_OUT_DEVICE |
902 IDE_TFLAG_IN_DEVICE,
903 /* force 16-bit I/O operations */
904 IDE_TFLAG_IO_16BIT = (1 << 30),
905 /* ide_task_t was allocated using kmalloc() */
906 IDE_TFLAG_DYN = (1 << 31),
907};
908
909struct ide_taskfile {
910 u8 hob_data; /* 0: high data byte (for TASKFILE IOCTL) */
911
912 u8 hob_feature; /* 1-5: additional data to support LBA48 */
913 u8 hob_nsect;
914 u8 hob_lbal;
915 u8 hob_lbam;
916 u8 hob_lbah;
917
918 u8 data; /* 6: low data byte (for TASKFILE IOCTL) */
919
920 union { /*  7: */
921 u8 error; /* read: error */
922 u8 feature; /* write: feature */
923 };
924 1201
925 u8 nsect; /* 8: number of sectors */ 1202void ide_exec_command(ide_hwif_t *, u8);
926 u8 lbal; /* 9: LBA low */ 1203u8 ide_read_status(ide_hwif_t *);
927 u8 lbam; /* 10: LBA mid */ 1204u8 ide_read_altstatus(ide_hwif_t *);
928 u8 lbah; /* 11: LBA high */ 1205u8 ide_read_sff_dma_status(ide_hwif_t *);
929 1206
930 u8 device; /* 12: device select */ 1207void ide_set_irq(ide_hwif_t *, int);
931 1208
932 union { /* 13: */ 1209void ide_tf_load(ide_drive_t *, ide_task_t *);
933 u8 status; /*  read: status  */ 1210void ide_tf_read(ide_drive_t *, ide_task_t *);
934 u8 command; /* write: command */
935 };
936};
937 1211
938typedef struct ide_task_s { 1212void ide_input_data(ide_drive_t *, struct request *, void *, unsigned int);
939 union { 1213void ide_output_data(ide_drive_t *, struct request *, void *, unsigned int);
940 struct ide_taskfile tf;
941 u8 tf_array[14];
942 };
943 u32 tf_flags;
944 int data_phase;
945 struct request *rq; /* copy of request */
946 void *special; /* valid_t generally */
947} ide_task_t;
948 1214
949void ide_tf_dump(const char *, struct ide_taskfile *); 1215int ide_io_buffers(ide_drive_t *, struct ide_atapi_pc *, unsigned int, int);
950 1216
951extern void SELECT_DRIVE(ide_drive_t *); 1217extern void SELECT_DRIVE(ide_drive_t *);
952void SELECT_MASK(ide_drive_t *, int); 1218void SELECT_MASK(ide_drive_t *, int);
953 1219
1220u8 ide_read_error(ide_drive_t *);
1221void ide_read_bcount_and_ireason(ide_drive_t *, u16 *, u8 *);
1222
954extern int drive_is_ready(ide_drive_t *); 1223extern int drive_is_ready(ide_drive_t *);
955 1224
956void ide_pktcmd_tf_load(ide_drive_t *, u32, u16, u8); 1225void ide_pktcmd_tf_load(ide_drive_t *, u32, u16, u8);
957 1226
958ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc, 1227int ide_check_atapi_device(ide_drive_t *, const char *);
959 ide_handler_t *handler, unsigned int timeout, ide_expiry_t *expiry, 1228
960 void (*update_buffers)(ide_drive_t *, struct ide_atapi_pc *), 1229void ide_init_pc(struct ide_atapi_pc *);
961 void (*retry_pc)(ide_drive_t *), void (*dsc_handle)(ide_drive_t *), 1230
962 void (*io_buffers)(ide_drive_t *, struct ide_atapi_pc *, unsigned int, 1231/* Disk head parking */
963 int)); 1232extern wait_queue_head_t ide_park_wq;
964ide_startstop_t ide_transfer_pc(ide_drive_t *, struct ide_atapi_pc *, 1233ssize_t ide_park_show(struct device *dev, struct device_attribute *attr,
965 ide_handler_t *, unsigned int, ide_expiry_t *); 1234 char *buf);
966ide_startstop_t ide_issue_pc(ide_drive_t *, struct ide_atapi_pc *, 1235ssize_t ide_park_store(struct device *dev, struct device_attribute *attr,
967 ide_handler_t *, unsigned int, ide_expiry_t *); 1236 const char *buf, size_t len);
1237
1238/*
1239 * Special requests for ide-tape block device strategy routine.
1240 *
1241 * In order to service a character device command, we add special requests to
1242 * the tail of our block device request queue and wait for their completion.
1243 */
1244enum {
1245 REQ_IDETAPE_PC1 = (1 << 0), /* packet command (first stage) */
1246 REQ_IDETAPE_PC2 = (1 << 1), /* packet command (second stage) */
1247 REQ_IDETAPE_READ = (1 << 2),
1248 REQ_IDETAPE_WRITE = (1 << 3),
1249};
1250
1251int ide_queue_pc_tail(ide_drive_t *, struct gendisk *, struct ide_atapi_pc *);
1252
1253int ide_do_test_unit_ready(ide_drive_t *, struct gendisk *);
1254int ide_do_start_stop(ide_drive_t *, struct gendisk *, int);
1255int ide_set_media_lock(ide_drive_t *, struct gendisk *, int);
1256void ide_create_request_sense_cmd(ide_drive_t *, struct ide_atapi_pc *);
1257void ide_retry_pc(ide_drive_t *, struct gendisk *);
1258
1259static inline unsigned long ide_scsi_get_timeout(struct ide_atapi_pc *pc)
1260{
1261 return max_t(unsigned long, WAIT_CMD, pc->timeout - jiffies);
1262}
1263
1264int ide_scsi_expiry(ide_drive_t *);
1265
1266ide_startstop_t ide_issue_pc(ide_drive_t *, unsigned int, ide_expiry_t *);
968 1267
969ide_startstop_t do_rw_taskfile(ide_drive_t *, ide_task_t *); 1268ide_startstop_t do_rw_taskfile(ide_drive_t *, ide_task_t *);
970 1269
@@ -974,8 +1273,6 @@ int ide_raw_taskfile(ide_drive_t *, ide_task_t *, u8 *, u16);
974int ide_no_data_taskfile(ide_drive_t *, ide_task_t *); 1273int ide_no_data_taskfile(ide_drive_t *, ide_task_t *);
975 1274
976int ide_taskfile_ioctl(ide_drive_t *, unsigned int, unsigned long); 1275int ide_taskfile_ioctl(ide_drive_t *, unsigned int, unsigned long);
977int ide_cmd_ioctl(ide_drive_t *, unsigned int, unsigned long);
978int ide_task_ioctl(ide_drive_t *, unsigned int, unsigned long);
979 1276
980extern int ide_driveid_update(ide_drive_t *); 1277extern int ide_driveid_update(ide_drive_t *);
981extern int ide_config_drive_speed(ide_drive_t *, u8); 1278extern int ide_config_drive_speed(ide_drive_t *, u8);
@@ -986,7 +1283,6 @@ extern int ide_wait_not_busy(ide_hwif_t *hwif, unsigned long timeout);
986 1283
987extern void ide_stall_queue(ide_drive_t *drive, unsigned long timeout); 1284extern void ide_stall_queue(ide_drive_t *drive, unsigned long timeout);
988 1285
989extern int ide_spin_wait_hwgroup(ide_drive_t *);
990extern void ide_timer_expiry(unsigned long); 1286extern void ide_timer_expiry(unsigned long);
991extern irqreturn_t ide_intr(int irq, void *dev_id); 1287extern irqreturn_t ide_intr(int irq, void *dev_id);
992extern void do_ide_request(struct request_queue *); 1288extern void do_ide_request(struct request_queue *);
@@ -1000,12 +1296,14 @@ extern int __ide_pci_register_driver(struct pci_driver *driver, struct module *o
1000#define ide_pci_register_driver(d) pci_register_driver(d) 1296#define ide_pci_register_driver(d) pci_register_driver(d)
1001#endif 1297#endif
1002 1298
1003void ide_pci_setup_ports(struct pci_dev *, const struct ide_port_info *, int, u8 *); 1299void ide_pci_setup_ports(struct pci_dev *, const struct ide_port_info *, int,
1300 hw_regs_t *, hw_regs_t **);
1004void ide_setup_pci_noise(struct pci_dev *, const struct ide_port_info *); 1301void ide_setup_pci_noise(struct pci_dev *, const struct ide_port_info *);
1005 1302
1006#ifdef CONFIG_BLK_DEV_IDEDMA_PCI 1303#ifdef CONFIG_BLK_DEV_IDEDMA_PCI
1007int ide_pci_set_master(struct pci_dev *, const char *); 1304int ide_pci_set_master(struct pci_dev *, const char *);
1008unsigned long ide_pci_dma_base(ide_hwif_t *, const struct ide_port_info *); 1305unsigned long ide_pci_dma_base(ide_hwif_t *, const struct ide_port_info *);
1306int ide_pci_check_simplex(ide_hwif_t *, const struct ide_port_info *);
1009int ide_hwif_setup_dma(ide_hwif_t *, const struct ide_port_info *); 1307int ide_hwif_setup_dma(ide_hwif_t *, const struct ide_port_info *);
1010#else 1308#else
1011static inline int ide_hwif_setup_dma(ide_hwif_t *hwif, 1309static inline int ide_hwif_setup_dma(ide_hwif_t *hwif,
@@ -1015,10 +1313,6 @@ static inline int ide_hwif_setup_dma(ide_hwif_t *hwif,
1015} 1313}
1016#endif 1314#endif
1017 1315
1018extern void default_hwif_iops(ide_hwif_t *);
1019extern void default_hwif_mmiops(ide_hwif_t *);
1020extern void default_hwif_transport(ide_hwif_t *);
1021
1022typedef struct ide_pci_enablebit_s { 1316typedef struct ide_pci_enablebit_s {
1023 u8 reg; /* byte pci reg holding the enable-bit */ 1317 u8 reg; /* byte pci reg holding the enable-bit */
1024 u8 mask; /* mask to isolate the enable-bit */ 1318 u8 mask; /* mask to isolate the enable-bit */
@@ -1081,7 +1375,6 @@ enum {
1081 IDE_HFLAG_IO_32BIT = (1 << 24), 1375 IDE_HFLAG_IO_32BIT = (1 << 24),
1082 /* unmask IRQs */ 1376 /* unmask IRQs */
1083 IDE_HFLAG_UNMASK_IRQS = (1 << 25), 1377 IDE_HFLAG_UNMASK_IRQS = (1 << 25),
1084 IDE_HFLAG_ABUSE_SET_DMA_MODE = (1 << 26),
1085 /* serialize ports if DMA is possible (for sl82c105) */ 1378 /* serialize ports if DMA is possible (for sl82c105) */
1086 IDE_HFLAG_SERIALIZE_DMA = (1 << 27), 1379 IDE_HFLAG_SERIALIZE_DMA = (1 << 27),
1087 /* force host out of "simplex" mode */ 1380 /* force host out of "simplex" mode */
@@ -1092,8 +1385,6 @@ enum {
1092 IDE_HFLAG_NO_IO_32BIT = (1 << 30), 1385 IDE_HFLAG_NO_IO_32BIT = (1 << 30),
1093 /* never unmask IRQs */ 1386 /* never unmask IRQs */
1094 IDE_HFLAG_NO_UNMASK_IRQS = (1 << 31), 1387 IDE_HFLAG_NO_UNMASK_IRQS = (1 << 31),
1095 /* host uses VDMA (disabled for now) */
1096 IDE_HFLAG_VDMA = 0,
1097}; 1388};
1098 1389
1099#ifdef CONFIG_BLK_DEV_OFFBOARD 1390#ifdef CONFIG_BLK_DEV_OFFBOARD
@@ -1104,12 +1395,13 @@ enum {
1104 1395
1105struct ide_port_info { 1396struct ide_port_info {
1106 char *name; 1397 char *name;
1107 unsigned int (*init_chipset)(struct pci_dev *, const char *); 1398 unsigned int (*init_chipset)(struct pci_dev *);
1108 void (*init_iops)(ide_hwif_t *); 1399 void (*init_iops)(ide_hwif_t *);
1109 void (*init_hwif)(ide_hwif_t *); 1400 void (*init_hwif)(ide_hwif_t *);
1110 int (*init_dma)(ide_hwif_t *, 1401 int (*init_dma)(ide_hwif_t *,
1111 const struct ide_port_info *); 1402 const struct ide_port_info *);
1112 1403
1404 const struct ide_tp_ops *tp_ops;
1113 const struct ide_port_ops *port_ops; 1405 const struct ide_port_ops *port_ops;
1114 const struct ide_dma_ops *dma_ops; 1406 const struct ide_dma_ops *dma_ops;
1115 1407
@@ -1122,8 +1414,18 @@ struct ide_port_info {
1122 u8 udma_mask; 1414 u8 udma_mask;
1123}; 1415};
1124 1416
1125int ide_setup_pci_device(struct pci_dev *, const struct ide_port_info *); 1417int ide_pci_init_one(struct pci_dev *, const struct ide_port_info *, void *);
1126int ide_setup_pci_devices(struct pci_dev *, struct pci_dev *, const struct ide_port_info *); 1418int ide_pci_init_two(struct pci_dev *, struct pci_dev *,
1419 const struct ide_port_info *, void *);
1420void ide_pci_remove(struct pci_dev *);
1421
1422#ifdef CONFIG_PM
1423int ide_pci_suspend(struct pci_dev *, pm_message_t);
1424int ide_pci_resume(struct pci_dev *);
1425#else
1426#define ide_pci_suspend NULL
1427#define ide_pci_resume NULL
1428#endif
1127 1429
1128void ide_map_sg(ide_drive_t *, struct request *); 1430void ide_map_sg(ide_drive_t *, struct request *);
1129void ide_init_sg_cmd(ide_drive_t *, struct request *); 1431void ide_init_sg_cmd(ide_drive_t *, struct request *);
@@ -1136,9 +1438,10 @@ struct drive_list_entry {
1136 const char *id_firmware; 1438 const char *id_firmware;
1137}; 1439};
1138 1440
1139int ide_in_drive_list(struct hd_driveid *, const struct drive_list_entry *); 1441int ide_in_drive_list(u16 *, const struct drive_list_entry *);
1140 1442
1141#ifdef CONFIG_BLK_DEV_IDEDMA 1443#ifdef CONFIG_BLK_DEV_IDEDMA
1444int ide_dma_good_drive(ide_drive_t *);
1142int __ide_dma_bad_drive(ide_drive_t *); 1445int __ide_dma_bad_drive(ide_drive_t *);
1143int ide_id_dma_bug(ide_drive_t *); 1446int ide_id_dma_bug(ide_drive_t *);
1144 1447
@@ -1156,25 +1459,29 @@ int ide_set_dma(ide_drive_t *);
1156void ide_check_dma_crc(ide_drive_t *); 1459void ide_check_dma_crc(ide_drive_t *);
1157ide_startstop_t ide_dma_intr(ide_drive_t *); 1460ide_startstop_t ide_dma_intr(ide_drive_t *);
1158 1461
1462int ide_allocate_dma_engine(ide_hwif_t *);
1463void ide_release_dma_engine(ide_hwif_t *);
1464
1159int ide_build_sglist(ide_drive_t *, struct request *); 1465int ide_build_sglist(ide_drive_t *, struct request *);
1160void ide_destroy_dmatable(ide_drive_t *); 1466void ide_destroy_dmatable(ide_drive_t *);
1161 1467
1162#ifdef CONFIG_BLK_DEV_IDEDMA_SFF 1468#ifdef CONFIG_BLK_DEV_IDEDMA_SFF
1469int config_drive_for_dma(ide_drive_t *);
1163extern int ide_build_dmatable(ide_drive_t *, struct request *); 1470extern int ide_build_dmatable(ide_drive_t *, struct request *);
1164int ide_allocate_dma_engine(ide_hwif_t *);
1165void ide_release_dma_engine(ide_hwif_t *);
1166void ide_setup_dma(ide_hwif_t *, unsigned long);
1167
1168void ide_dma_host_set(ide_drive_t *, int); 1471void ide_dma_host_set(ide_drive_t *, int);
1169extern int ide_dma_setup(ide_drive_t *); 1472extern int ide_dma_setup(ide_drive_t *);
1170void ide_dma_exec_cmd(ide_drive_t *, u8); 1473void ide_dma_exec_cmd(ide_drive_t *, u8);
1171extern void ide_dma_start(ide_drive_t *); 1474extern void ide_dma_start(ide_drive_t *);
1172extern int __ide_dma_end(ide_drive_t *); 1475int ide_dma_end(ide_drive_t *);
1173int ide_dma_test_irq(ide_drive_t *); 1476int ide_dma_test_irq(ide_drive_t *);
1174extern void ide_dma_lost_irq(ide_drive_t *); 1477extern const struct ide_dma_ops sff_dma_ops;
1175extern void ide_dma_timeout(ide_drive_t *); 1478#else
1479static inline int config_drive_for_dma(ide_drive_t *drive) { return 0; }
1176#endif /* CONFIG_BLK_DEV_IDEDMA_SFF */ 1480#endif /* CONFIG_BLK_DEV_IDEDMA_SFF */
1177 1481
1482void ide_dma_lost_irq(ide_drive_t *);
1483void ide_dma_timeout(ide_drive_t *);
1484
1178#else 1485#else
1179static inline int ide_id_dma_bug(ide_drive_t *drive) { return 0; } 1486static inline int ide_id_dma_bug(ide_drive_t *drive) { return 0; }
1180static inline u8 ide_find_dma_mode(ide_drive_t *drive, u8 speed) { return 0; } 1487static inline u8 ide_find_dma_mode(ide_drive_t *drive, u8 speed) { return 0; }
@@ -1185,11 +1492,8 @@ static inline void ide_dma_on(ide_drive_t *drive) { ; }
1185static inline void ide_dma_verbose(ide_drive_t *drive) { ; } 1492static inline void ide_dma_verbose(ide_drive_t *drive) { ; }
1186static inline int ide_set_dma(ide_drive_t *drive) { return 1; } 1493static inline int ide_set_dma(ide_drive_t *drive) { return 1; }
1187static inline void ide_check_dma_crc(ide_drive_t *drive) { ; } 1494static inline void ide_check_dma_crc(ide_drive_t *drive) { ; }
1188#endif /* CONFIG_BLK_DEV_IDEDMA */
1189
1190#ifndef CONFIG_BLK_DEV_IDEDMA_SFF
1191static inline void ide_release_dma_engine(ide_hwif_t *hwif) { ; } 1495static inline void ide_release_dma_engine(ide_hwif_t *hwif) { ; }
1192#endif 1496#endif /* CONFIG_BLK_DEV_IDEDMA */
1193 1497
1194#ifdef CONFIG_BLK_DEV_IDEACPI 1498#ifdef CONFIG_BLK_DEV_IDEACPI
1195extern int ide_acpi_exec_tfs(ide_drive_t *drive); 1499extern int ide_acpi_exec_tfs(ide_drive_t *drive);
@@ -1217,8 +1521,13 @@ void ide_undecoded_slave(ide_drive_t *);
1217 1521
1218void ide_port_apply_params(ide_hwif_t *); 1522void ide_port_apply_params(ide_hwif_t *);
1219 1523
1220int ide_device_add_all(u8 *idx, const struct ide_port_info *); 1524struct ide_host *ide_host_alloc(const struct ide_port_info *, hw_regs_t **);
1221int ide_device_add(u8 idx[4], const struct ide_port_info *); 1525void ide_host_free(struct ide_host *);
1526int ide_host_register(struct ide_host *, const struct ide_port_info *,
1527 hw_regs_t **);
1528int ide_host_add(const struct ide_port_info *, hw_regs_t **,
1529 struct ide_host **);
1530void ide_host_remove(struct ide_host *);
1222int ide_legacy_device_add(const struct ide_port_info *, unsigned long); 1531int ide_legacy_device_add(const struct ide_port_info *, unsigned long);
1223void ide_port_unregister_devices(ide_hwif_t *); 1532void ide_port_unregister_devices(ide_hwif_t *);
1224void ide_port_scan(ide_hwif_t *); 1533void ide_port_scan(ide_hwif_t *);
@@ -1237,24 +1546,6 @@ const char *ide_xfer_verbose(u8 mode);
1237extern void ide_toggle_bounce(ide_drive_t *drive, int on); 1546extern void ide_toggle_bounce(ide_drive_t *drive, int on);
1238extern int ide_set_xfer_rate(ide_drive_t *drive, u8 rate); 1547extern int ide_set_xfer_rate(ide_drive_t *drive, u8 rate);
1239 1548
1240static inline int ide_dev_has_iordy(struct hd_driveid *id)
1241{
1242 return ((id->field_valid & 2) && (id->capability & 8)) ? 1 : 0;
1243}
1244
1245static inline int ide_dev_is_sata(struct hd_driveid *id)
1246{
1247 /*
1248 * See if word 93 is 0 AND drive is at least ATA-5 compatible
1249 * verifying that word 80 by casting it to a signed type --
1250 * this trick allows us to filter out the reserved values of
1251 * 0x0000 and 0xffff along with the earlier ATA revisions...
1252 */
1253 if (id->hw_config == 0 && (short)id->major_rev_num >= 0x0020)
1254 return 1;
1255 return 0;
1256}
1257
1258u64 ide_get_lba_addr(struct ide_taskfile *, int); 1549u64 ide_get_lba_addr(struct ide_taskfile *, int);
1259u8 ide_dump_status(ide_drive_t *, const char *, u8); 1550u8 ide_dump_status(ide_drive_t *, const char *, u8);
1260 1551
@@ -1326,13 +1617,6 @@ extern struct mutex ide_cfg_mtx;
1326extern struct bus_type ide_bus_type; 1617extern struct bus_type ide_bus_type;
1327extern struct class *ide_port_class; 1618extern struct class *ide_port_class;
1328 1619
1329/* check if CACHE FLUSH (EXT) command is supported (bits defined in ATA-6) */
1330#define ide_id_has_flush_cache(id) ((id)->cfs_enable_2 & 0x3000)
1331
1332/* some Maxtor disks have bit 13 defined incorrectly so check bit 10 too */
1333#define ide_id_has_flush_cache_ext(id) \
1334 (((id)->cfs_enable_2 & 0x2400) == 0x2400)
1335
1336static inline void ide_dump_identify(u8 *id) 1620static inline void ide_dump_identify(u8 *id)
1337{ 1621{
1338 print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE, 16, 2, id, 512, 0); 1622 print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE, 16, 2, id, 512, 0);
@@ -1340,43 +1624,13 @@ static inline void ide_dump_identify(u8 *id)
1340 1624
1341static inline int hwif_to_node(ide_hwif_t *hwif) 1625static inline int hwif_to_node(ide_hwif_t *hwif)
1342{ 1626{
1343 struct pci_dev *dev = to_pci_dev(hwif->dev); 1627 return hwif->dev ? dev_to_node(hwif->dev) : -1;
1344 return hwif->dev ? pcibus_to_node(dev->bus) : -1;
1345}
1346
1347static inline ide_drive_t *ide_get_paired_drive(ide_drive_t *drive)
1348{
1349 ide_hwif_t *hwif = HWIF(drive);
1350
1351 return &hwif->drives[(drive->dn ^ 1) & 1];
1352}
1353
1354static inline void ide_set_irq(ide_drive_t *drive, int on)
1355{
1356 ide_hwif_t *hwif = drive->hwif;
1357
1358 hwif->OUTBSYNC(hwif, ATA_DEVCTL_OBS | (on ? 0 : 2),
1359 hwif->io_ports.ctl_addr);
1360}
1361
1362static inline u8 ide_read_status(ide_drive_t *drive)
1363{
1364 ide_hwif_t *hwif = drive->hwif;
1365
1366 return hwif->INB(hwif->io_ports.status_addr);
1367}
1368
1369static inline u8 ide_read_altstatus(ide_drive_t *drive)
1370{
1371 ide_hwif_t *hwif = drive->hwif;
1372
1373 return hwif->INB(hwif->io_ports.ctl_addr);
1374} 1628}
1375 1629
1376static inline u8 ide_read_error(ide_drive_t *drive) 1630static inline ide_drive_t *ide_get_pair_dev(ide_drive_t *drive)
1377{ 1631{
1378 ide_hwif_t *hwif = drive->hwif; 1632 ide_drive_t *peer = &drive->hwif->drives[(drive->dn ^ 1) & 1];
1379 1633
1380 return hwif->INB(hwif->io_ports.error_addr); 1634 return (peer->dev_flags & IDE_DFLAG_PRESENT) ? peer : NULL;
1381} 1635}
1382#endif /* _IDE_H */ 1636#endif /* _IDE_H */
diff --git a/include/linux/idr.h b/include/linux/idr.h
index 9a2d762124de..fa035f96f2a3 100644
--- a/include/linux/idr.h
+++ b/include/linux/idr.h
@@ -15,6 +15,7 @@
15#include <linux/types.h> 15#include <linux/types.h>
16#include <linux/bitops.h> 16#include <linux/bitops.h>
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/rcupdate.h>
18 19
19#if BITS_PER_LONG == 32 20#if BITS_PER_LONG == 32
20# define IDR_BITS 5 21# define IDR_BITS 5
@@ -51,6 +52,7 @@ struct idr_layer {
51 unsigned long bitmap; /* A zero bit means "space here" */ 52 unsigned long bitmap; /* A zero bit means "space here" */
52 struct idr_layer *ary[1<<IDR_BITS]; 53 struct idr_layer *ary[1<<IDR_BITS];
53 int count; /* When zero, we can release it */ 54 int count; /* When zero, we can release it */
55 struct rcu_head rcu_head;
54}; 56};
55 57
56struct idr { 58struct idr {
@@ -71,6 +73,28 @@ struct idr {
71} 73}
72#define DEFINE_IDR(name) struct idr name = IDR_INIT(name) 74#define DEFINE_IDR(name) struct idr name = IDR_INIT(name)
73 75
76/* Actions to be taken after a call to _idr_sub_alloc */
77#define IDR_NEED_TO_GROW -2
78#define IDR_NOMORE_SPACE -3
79
80#define _idr_rc_to_errno(rc) ((rc) == -1 ? -EAGAIN : -ENOSPC)
81
82/**
83 * idr synchronization (stolen from radix-tree.h)
84 *
85 * idr_find() is able to be called locklessly, using RCU. The caller must
86 * ensure calls to this function are made within rcu_read_lock() regions.
87 * Other readers (lock-free or otherwise) and modifications may be running
88 * concurrently.
89 *
90 * It is still required that the caller manage the synchronization and
91 * lifetimes of the items. So if RCU lock-free lookups are used, typically
92 * this would mean that the items have their own locks, or are amenable to
93 * lock-free access; and that the items are freed by RCU (or only freed after
94 * having been deleted from the idr tree *and* a synchronize_rcu() grace
95 * period).
96 */
97
74/* 98/*
75 * This is what we export. 99 * This is what we export.
76 */ 100 */
diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h
index 0b5e03eae6d2..14126bc36641 100644
--- a/include/linux/ieee80211.h
+++ b/include/linux/ieee80211.h
@@ -98,6 +98,9 @@
98 98
99#define IEEE80211_MAX_SSID_LEN 32 99#define IEEE80211_MAX_SSID_LEN 32
100#define IEEE80211_MAX_MESH_ID_LEN 32 100#define IEEE80211_MAX_MESH_ID_LEN 32
101#define IEEE80211_QOS_CTL_LEN 2
102#define IEEE80211_QOS_CTL_TID_MASK 0x000F
103#define IEEE80211_QOS_CTL_TAG1D_MASK 0x0007
101 104
102struct ieee80211_hdr { 105struct ieee80211_hdr {
103 __le16 frame_control; 106 __le16 frame_control;
@@ -109,6 +112,355 @@ struct ieee80211_hdr {
109 u8 addr4[6]; 112 u8 addr4[6];
110} __attribute__ ((packed)); 113} __attribute__ ((packed));
111 114
115/**
116 * ieee80211_has_tods - check if IEEE80211_FCTL_TODS is set
117 * @fc: frame control bytes in little-endian byteorder
118 */
119static inline int ieee80211_has_tods(__le16 fc)
120{
121 return (fc & cpu_to_le16(IEEE80211_FCTL_TODS)) != 0;
122}
123
124/**
125 * ieee80211_has_fromds - check if IEEE80211_FCTL_FROMDS is set
126 * @fc: frame control bytes in little-endian byteorder
127 */
128static inline int ieee80211_has_fromds(__le16 fc)
129{
130 return (fc & cpu_to_le16(IEEE80211_FCTL_FROMDS)) != 0;
131}
132
133/**
134 * ieee80211_has_a4 - check if IEEE80211_FCTL_TODS and IEEE80211_FCTL_FROMDS are set
135 * @fc: frame control bytes in little-endian byteorder
136 */
137static inline int ieee80211_has_a4(__le16 fc)
138{
139 __le16 tmp = cpu_to_le16(IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS);
140 return (fc & tmp) == tmp;
141}
142
143/**
144 * ieee80211_has_morefrags - check if IEEE80211_FCTL_MOREFRAGS is set
145 * @fc: frame control bytes in little-endian byteorder
146 */
147static inline int ieee80211_has_morefrags(__le16 fc)
148{
149 return (fc & cpu_to_le16(IEEE80211_FCTL_MOREFRAGS)) != 0;
150}
151
152/**
153 * ieee80211_has_retry - check if IEEE80211_FCTL_RETRY is set
154 * @fc: frame control bytes in little-endian byteorder
155 */
156static inline int ieee80211_has_retry(__le16 fc)
157{
158 return (fc & cpu_to_le16(IEEE80211_FCTL_RETRY)) != 0;
159}
160
161/**
162 * ieee80211_has_pm - check if IEEE80211_FCTL_PM is set
163 * @fc: frame control bytes in little-endian byteorder
164 */
165static inline int ieee80211_has_pm(__le16 fc)
166{
167 return (fc & cpu_to_le16(IEEE80211_FCTL_PM)) != 0;
168}
169
170/**
171 * ieee80211_has_moredata - check if IEEE80211_FCTL_MOREDATA is set
172 * @fc: frame control bytes in little-endian byteorder
173 */
174static inline int ieee80211_has_moredata(__le16 fc)
175{
176 return (fc & cpu_to_le16(IEEE80211_FCTL_MOREDATA)) != 0;
177}
178
179/**
180 * ieee80211_has_protected - check if IEEE80211_FCTL_PROTECTED is set
181 * @fc: frame control bytes in little-endian byteorder
182 */
183static inline int ieee80211_has_protected(__le16 fc)
184{
185 return (fc & cpu_to_le16(IEEE80211_FCTL_PROTECTED)) != 0;
186}
187
188/**
189 * ieee80211_has_order - check if IEEE80211_FCTL_ORDER is set
190 * @fc: frame control bytes in little-endian byteorder
191 */
192static inline int ieee80211_has_order(__le16 fc)
193{
194 return (fc & cpu_to_le16(IEEE80211_FCTL_ORDER)) != 0;
195}
196
197/**
198 * ieee80211_is_mgmt - check if type is IEEE80211_FTYPE_MGMT
199 * @fc: frame control bytes in little-endian byteorder
200 */
201static inline int ieee80211_is_mgmt(__le16 fc)
202{
203 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
204 cpu_to_le16(IEEE80211_FTYPE_MGMT);
205}
206
207/**
208 * ieee80211_is_ctl - check if type is IEEE80211_FTYPE_CTL
209 * @fc: frame control bytes in little-endian byteorder
210 */
211static inline int ieee80211_is_ctl(__le16 fc)
212{
213 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
214 cpu_to_le16(IEEE80211_FTYPE_CTL);
215}
216
217/**
218 * ieee80211_is_data - check if type is IEEE80211_FTYPE_DATA
219 * @fc: frame control bytes in little-endian byteorder
220 */
221static inline int ieee80211_is_data(__le16 fc)
222{
223 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
224 cpu_to_le16(IEEE80211_FTYPE_DATA);
225}
226
227/**
228 * ieee80211_is_data_qos - check if type is IEEE80211_FTYPE_DATA and IEEE80211_STYPE_QOS_DATA is set
229 * @fc: frame control bytes in little-endian byteorder
230 */
231static inline int ieee80211_is_data_qos(__le16 fc)
232{
233 /*
234 * mask with QOS_DATA rather than IEEE80211_FCTL_STYPE as we just need
235 * to check the one bit
236 */
237 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_STYPE_QOS_DATA)) ==
238 cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_QOS_DATA);
239}
240
241/**
242 * ieee80211_is_data_present - check if type is IEEE80211_FTYPE_DATA and has data
243 * @fc: frame control bytes in little-endian byteorder
244 */
245static inline int ieee80211_is_data_present(__le16 fc)
246{
247 /*
248 * mask with 0x40 and test that that bit is clear to only return true
249 * for the data-containing substypes.
250 */
251 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | 0x40)) ==
252 cpu_to_le16(IEEE80211_FTYPE_DATA);
253}
254
255/**
256 * ieee80211_is_assoc_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ASSOC_REQ
257 * @fc: frame control bytes in little-endian byteorder
258 */
259static inline int ieee80211_is_assoc_req(__le16 fc)
260{
261 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
262 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ASSOC_REQ);
263}
264
265/**
266 * ieee80211_is_assoc_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ASSOC_RESP
267 * @fc: frame control bytes in little-endian byteorder
268 */
269static inline int ieee80211_is_assoc_resp(__le16 fc)
270{
271 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
272 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ASSOC_RESP);
273}
274
275/**
276 * ieee80211_is_reassoc_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_REASSOC_REQ
277 * @fc: frame control bytes in little-endian byteorder
278 */
279static inline int ieee80211_is_reassoc_req(__le16 fc)
280{
281 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
282 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_REASSOC_REQ);
283}
284
285/**
286 * ieee80211_is_reassoc_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_REASSOC_RESP
287 * @fc: frame control bytes in little-endian byteorder
288 */
289static inline int ieee80211_is_reassoc_resp(__le16 fc)
290{
291 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
292 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_REASSOC_RESP);
293}
294
295/**
296 * ieee80211_is_probe_req - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_PROBE_REQ
297 * @fc: frame control bytes in little-endian byteorder
298 */
299static inline int ieee80211_is_probe_req(__le16 fc)
300{
301 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
302 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_REQ);
303}
304
305/**
306 * ieee80211_is_probe_resp - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_PROBE_RESP
307 * @fc: frame control bytes in little-endian byteorder
308 */
309static inline int ieee80211_is_probe_resp(__le16 fc)
310{
311 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
312 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
313}
314
315/**
316 * ieee80211_is_beacon - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_BEACON
317 * @fc: frame control bytes in little-endian byteorder
318 */
319static inline int ieee80211_is_beacon(__le16 fc)
320{
321 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
322 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
323}
324
325/**
326 * ieee80211_is_atim - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ATIM
327 * @fc: frame control bytes in little-endian byteorder
328 */
329static inline int ieee80211_is_atim(__le16 fc)
330{
331 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
332 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ATIM);
333}
334
335/**
336 * ieee80211_is_disassoc - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_DISASSOC
337 * @fc: frame control bytes in little-endian byteorder
338 */
339static inline int ieee80211_is_disassoc(__le16 fc)
340{
341 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
342 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_DISASSOC);
343}
344
345/**
346 * ieee80211_is_auth - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_AUTH
347 * @fc: frame control bytes in little-endian byteorder
348 */
349static inline int ieee80211_is_auth(__le16 fc)
350{
351 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
352 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_AUTH);
353}
354
355/**
356 * ieee80211_is_deauth - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_DEAUTH
357 * @fc: frame control bytes in little-endian byteorder
358 */
359static inline int ieee80211_is_deauth(__le16 fc)
360{
361 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
362 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_DEAUTH);
363}
364
365/**
366 * ieee80211_is_action - check if IEEE80211_FTYPE_MGMT && IEEE80211_STYPE_ACTION
367 * @fc: frame control bytes in little-endian byteorder
368 */
369static inline int ieee80211_is_action(__le16 fc)
370{
371 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
372 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ACTION);
373}
374
375/**
376 * ieee80211_is_back_req - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_BACK_REQ
377 * @fc: frame control bytes in little-endian byteorder
378 */
379static inline int ieee80211_is_back_req(__le16 fc)
380{
381 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
382 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_BACK_REQ);
383}
384
385/**
386 * ieee80211_is_back - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_BACK
387 * @fc: frame control bytes in little-endian byteorder
388 */
389static inline int ieee80211_is_back(__le16 fc)
390{
391 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
392 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_BACK);
393}
394
395/**
396 * ieee80211_is_pspoll - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_PSPOLL
397 * @fc: frame control bytes in little-endian byteorder
398 */
399static inline int ieee80211_is_pspoll(__le16 fc)
400{
401 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
402 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_PSPOLL);
403}
404
405/**
406 * ieee80211_is_rts - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_RTS
407 * @fc: frame control bytes in little-endian byteorder
408 */
409static inline int ieee80211_is_rts(__le16 fc)
410{
411 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
412 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_RTS);
413}
414
415/**
416 * ieee80211_is_cts - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CTS
417 * @fc: frame control bytes in little-endian byteorder
418 */
419static inline int ieee80211_is_cts(__le16 fc)
420{
421 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
422 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTS);
423}
424
425/**
426 * ieee80211_is_ack - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_ACK
427 * @fc: frame control bytes in little-endian byteorder
428 */
429static inline int ieee80211_is_ack(__le16 fc)
430{
431 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
432 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_ACK);
433}
434
435/**
436 * ieee80211_is_cfend - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CFEND
437 * @fc: frame control bytes in little-endian byteorder
438 */
439static inline int ieee80211_is_cfend(__le16 fc)
440{
441 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
442 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CFEND);
443}
444
445/**
446 * ieee80211_is_cfendack - check if IEEE80211_FTYPE_CTL && IEEE80211_STYPE_CFENDACK
447 * @fc: frame control bytes in little-endian byteorder
448 */
449static inline int ieee80211_is_cfendack(__le16 fc)
450{
451 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
452 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CFENDACK);
453}
454
455/**
456 * ieee80211_is_nullfunc - check if FTYPE=IEEE80211_FTYPE_DATA and STYPE=IEEE80211_STYPE_NULLFUNC
457 * @fc: frame control bytes in little-endian byteorder
458 */
459static inline int ieee80211_is_nullfunc(__le16 fc)
460{
461 return (fc & cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) ==
462 cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_NULLFUNC);
463}
112 464
113struct ieee80211s_hdr { 465struct ieee80211s_hdr {
114 u8 flags; 466 u8 flags;
@@ -119,6 +471,58 @@ struct ieee80211s_hdr {
119 u8 eaddr3[6]; 471 u8 eaddr3[6];
120} __attribute__ ((packed)); 472} __attribute__ ((packed));
121 473
474/* Mesh flags */
475#define MESH_FLAGS_AE_A4 0x1
476#define MESH_FLAGS_AE_A5_A6 0x2
477#define MESH_FLAGS_PS_DEEP 0x4
478
479/**
480 * struct ieee80211_quiet_ie
481 *
482 * This structure refers to "Quiet information element"
483 */
484struct ieee80211_quiet_ie {
485 u8 count;
486 u8 period;
487 __le16 duration;
488 __le16 offset;
489} __attribute__ ((packed));
490
491/**
492 * struct ieee80211_msrment_ie
493 *
494 * This structure refers to "Measurement Request/Report information element"
495 */
496struct ieee80211_msrment_ie {
497 u8 token;
498 u8 mode;
499 u8 type;
500 u8 request[0];
501} __attribute__ ((packed));
502
503/**
504 * struct ieee80211_channel_sw_ie
505 *
506 * This structure refers to "Channel Switch Announcement information element"
507 */
508struct ieee80211_channel_sw_ie {
509 u8 mode;
510 u8 new_ch_num;
511 u8 count;
512} __attribute__ ((packed));
513
514/**
515 * struct ieee80211_tim
516 *
517 * This structure refers to "Traffic Indication Map information element"
518 */
519struct ieee80211_tim_ie {
520 u8 dtim_count;
521 u8 dtim_period;
522 u8 bitmap_ctrl;
523 /* variable size: 1 - 251 bytes */
524 u8 virtual_map[0];
525} __attribute__ ((packed));
122 526
123struct ieee80211_mgmt { 527struct ieee80211_mgmt {
124 __le16 frame_control; 528 __le16 frame_control;
@@ -194,13 +598,18 @@ struct ieee80211_mgmt {
194 u8 action_code; 598 u8 action_code;
195 u8 element_id; 599 u8 element_id;
196 u8 length; 600 u8 length;
197 u8 switch_mode; 601 struct ieee80211_channel_sw_ie sw_elem;
198 u8 new_chan;
199 u8 switch_count;
200 } __attribute__((packed)) chan_switch; 602 } __attribute__((packed)) chan_switch;
201 struct{ 603 struct{
202 u8 action_code; 604 u8 action_code;
203 u8 dialog_token; 605 u8 dialog_token;
606 u8 element_id;
607 u8 length;
608 struct ieee80211_msrment_ie msr_elem;
609 } __attribute__((packed)) measurement;
610 struct{
611 u8 action_code;
612 u8 dialog_token;
204 __le16 capab; 613 __le16 capab;
205 __le16 timeout; 614 __le16 timeout;
206 __le16 start_seq_num; 615 __le16 start_seq_num;
@@ -239,6 +648,9 @@ struct ieee80211_mgmt {
239 } u; 648 } u;
240} __attribute__ ((packed)); 649} __attribute__ ((packed));
241 650
651/* mgmt header + 1 byte category code */
652#define IEEE80211_MIN_ACTION_SIZE offsetof(struct ieee80211_mgmt, u.action.u)
653
242 654
243/* Control frames */ 655/* Control frames */
244struct ieee80211_rts { 656struct ieee80211_rts {
@@ -269,6 +681,10 @@ struct ieee80211_bar {
269 __le16 start_seq_num; 681 __le16 start_seq_num;
270} __attribute__((packed)); 682} __attribute__((packed));
271 683
684/* 802.11 BAR control masks */
685#define IEEE80211_BAR_CTRL_ACK_POLICY_NORMAL 0x0000
686#define IEEE80211_BAR_CTRL_CBMTID_COMPRESSED_BA 0x0004
687
272/** 688/**
273 * struct ieee80211_ht_cap - HT capabilities 689 * struct ieee80211_ht_cap - HT capabilities
274 * 690 *
@@ -300,26 +716,55 @@ struct ieee80211_ht_addt_info {
300 716
301/* 802.11n HT capabilities masks */ 717/* 802.11n HT capabilities masks */
302#define IEEE80211_HT_CAP_SUP_WIDTH 0x0002 718#define IEEE80211_HT_CAP_SUP_WIDTH 0x0002
303#define IEEE80211_HT_CAP_MIMO_PS 0x000C 719#define IEEE80211_HT_CAP_SM_PS 0x000C
304#define IEEE80211_HT_CAP_GRN_FLD 0x0010 720#define IEEE80211_HT_CAP_GRN_FLD 0x0010
305#define IEEE80211_HT_CAP_SGI_20 0x0020 721#define IEEE80211_HT_CAP_SGI_20 0x0020
306#define IEEE80211_HT_CAP_SGI_40 0x0040 722#define IEEE80211_HT_CAP_SGI_40 0x0040
307#define IEEE80211_HT_CAP_DELAY_BA 0x0400 723#define IEEE80211_HT_CAP_DELAY_BA 0x0400
308#define IEEE80211_HT_CAP_MAX_AMSDU 0x0800 724#define IEEE80211_HT_CAP_MAX_AMSDU 0x0800
725#define IEEE80211_HT_CAP_DSSSCCK40 0x1000
726/* 802.11n HT capability AMPDU settings */
309#define IEEE80211_HT_CAP_AMPDU_FACTOR 0x03 727#define IEEE80211_HT_CAP_AMPDU_FACTOR 0x03
310#define IEEE80211_HT_CAP_AMPDU_DENSITY 0x1C 728#define IEEE80211_HT_CAP_AMPDU_DENSITY 0x1C
729/* 802.11n HT capability MSC set */
730#define IEEE80211_SUPP_MCS_SET_UEQM 4
731#define IEEE80211_HT_CAP_MAX_STREAMS 4
732#define IEEE80211_SUPP_MCS_SET_LEN 10
733/* maximum streams the spec allows */
734#define IEEE80211_HT_CAP_MCS_TX_DEFINED 0x01
735#define IEEE80211_HT_CAP_MCS_TX_RX_DIFF 0x02
736#define IEEE80211_HT_CAP_MCS_TX_STREAMS 0x0C
737#define IEEE80211_HT_CAP_MCS_TX_UEQM 0x10
311/* 802.11n HT IE masks */ 738/* 802.11n HT IE masks */
312#define IEEE80211_HT_IE_CHA_SEC_OFFSET 0x03 739#define IEEE80211_HT_IE_CHA_SEC_OFFSET 0x03
740#define IEEE80211_HT_IE_CHA_SEC_NONE 0x00
741#define IEEE80211_HT_IE_CHA_SEC_ABOVE 0x01
742#define IEEE80211_HT_IE_CHA_SEC_BELOW 0x03
313#define IEEE80211_HT_IE_CHA_WIDTH 0x04 743#define IEEE80211_HT_IE_CHA_WIDTH 0x04
314#define IEEE80211_HT_IE_HT_PROTECTION 0x0003 744#define IEEE80211_HT_IE_HT_PROTECTION 0x0003
315#define IEEE80211_HT_IE_NON_GF_STA_PRSNT 0x0004 745#define IEEE80211_HT_IE_NON_GF_STA_PRSNT 0x0004
316#define IEEE80211_HT_IE_NON_HT_STA_PRSNT 0x0010 746#define IEEE80211_HT_IE_NON_HT_STA_PRSNT 0x0010
317 747
318/* MIMO Power Save Modes */ 748/* block-ack parameters */
319#define WLAN_HT_CAP_MIMO_PS_STATIC 0 749#define IEEE80211_ADDBA_PARAM_POLICY_MASK 0x0002
320#define WLAN_HT_CAP_MIMO_PS_DYNAMIC 1 750#define IEEE80211_ADDBA_PARAM_TID_MASK 0x003C
321#define WLAN_HT_CAP_MIMO_PS_INVALID 2 751#define IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK 0xFFA0
322#define WLAN_HT_CAP_MIMO_PS_DISABLED 3 752#define IEEE80211_DELBA_PARAM_TID_MASK 0xF000
753#define IEEE80211_DELBA_PARAM_INITIATOR_MASK 0x0800
754
755/*
756 * A-PMDU buffer sizes
757 * According to IEEE802.11n spec size varies from 8K to 64K (in powers of 2)
758 */
759#define IEEE80211_MIN_AMPDU_BUF 0x8
760#define IEEE80211_MAX_AMPDU_BUF 0x40
761
762
763/* Spatial Multiplexing Power Save Modes */
764#define WLAN_HT_CAP_SM_PS_STATIC 0
765#define WLAN_HT_CAP_SM_PS_DYNAMIC 1
766#define WLAN_HT_CAP_SM_PS_INVALID 2
767#define WLAN_HT_CAP_SM_PS_DISABLED 3
323 768
324/* Authentication algorithms */ 769/* Authentication algorithms */
325#define WLAN_AUTH_OPEN 0 770#define WLAN_AUTH_OPEN 0
@@ -337,11 +782,21 @@ struct ieee80211_ht_addt_info {
337#define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5) 782#define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5)
338#define WLAN_CAPABILITY_PBCC (1<<6) 783#define WLAN_CAPABILITY_PBCC (1<<6)
339#define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7) 784#define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7)
785
340/* 802.11h */ 786/* 802.11h */
341#define WLAN_CAPABILITY_SPECTRUM_MGMT (1<<8) 787#define WLAN_CAPABILITY_SPECTRUM_MGMT (1<<8)
342#define WLAN_CAPABILITY_QOS (1<<9) 788#define WLAN_CAPABILITY_QOS (1<<9)
343#define WLAN_CAPABILITY_SHORT_SLOT_TIME (1<<10) 789#define WLAN_CAPABILITY_SHORT_SLOT_TIME (1<<10)
344#define WLAN_CAPABILITY_DSSS_OFDM (1<<13) 790#define WLAN_CAPABILITY_DSSS_OFDM (1<<13)
791/* measurement */
792#define IEEE80211_SPCT_MSR_RPRT_MODE_LATE (1<<0)
793#define IEEE80211_SPCT_MSR_RPRT_MODE_INCAPABLE (1<<1)
794#define IEEE80211_SPCT_MSR_RPRT_MODE_REFUSED (1<<2)
795
796#define IEEE80211_SPCT_MSR_RPRT_TYPE_BASIC 0
797#define IEEE80211_SPCT_MSR_RPRT_TYPE_CCA 1
798#define IEEE80211_SPCT_MSR_RPRT_TYPE_RPI 2
799
345 800
346/* 802.11g ERP information element */ 801/* 802.11g ERP information element */
347#define WLAN_ERP_NON_ERP_PRESENT (1<<0) 802#define WLAN_ERP_NON_ERP_PRESENT (1<<0)
@@ -512,6 +967,15 @@ enum ieee80211_category {
512 WLAN_CATEGORY_WMM = 17, 967 WLAN_CATEGORY_WMM = 17,
513}; 968};
514 969
970/* SPECTRUM_MGMT action code */
971enum ieee80211_spectrum_mgmt_actioncode {
972 WLAN_ACTION_SPCT_MSR_REQ = 0,
973 WLAN_ACTION_SPCT_MSR_RPRT = 1,
974 WLAN_ACTION_SPCT_TPC_REQ = 2,
975 WLAN_ACTION_SPCT_TPC_RPRT = 3,
976 WLAN_ACTION_SPCT_CHL_SWITCH = 4,
977};
978
515/* BACK action code */ 979/* BACK action code */
516enum ieee80211_back_actioncode { 980enum ieee80211_back_actioncode {
517 WLAN_ACTION_ADDBA_REQ = 0, 981 WLAN_ACTION_ADDBA_REQ = 0,
@@ -540,63 +1004,57 @@ enum ieee80211_back_parties {
540#define WLAN_MAX_KEY_LEN 32 1004#define WLAN_MAX_KEY_LEN 32
541 1005
542/** 1006/**
1007 * ieee80211_get_qos_ctl - get pointer to qos control bytes
1008 * @hdr: the frame
1009 *
1010 * The qos ctrl bytes come after the frame_control, duration, seq_num
1011 * and 3 or 4 addresses of length ETH_ALEN.
1012 * 3 addr: 2 + 2 + 2 + 3*6 = 24
1013 * 4 addr: 2 + 2 + 2 + 4*6 = 30
1014 */
1015static inline u8 *ieee80211_get_qos_ctl(struct ieee80211_hdr *hdr)
1016{
1017 if (ieee80211_has_a4(hdr->frame_control))
1018 return (u8 *)hdr + 30;
1019 else
1020 return (u8 *)hdr + 24;
1021}
1022
1023/**
543 * ieee80211_get_SA - get pointer to SA 1024 * ieee80211_get_SA - get pointer to SA
1025 * @hdr: the frame
544 * 1026 *
545 * Given an 802.11 frame, this function returns the offset 1027 * Given an 802.11 frame, this function returns the offset
546 * to the source address (SA). It does not verify that the 1028 * to the source address (SA). It does not verify that the
547 * header is long enough to contain the address, and the 1029 * header is long enough to contain the address, and the
548 * header must be long enough to contain the frame control 1030 * header must be long enough to contain the frame control
549 * field. 1031 * field.
550 *
551 * @hdr: the frame
552 */ 1032 */
553static inline u8 *ieee80211_get_SA(struct ieee80211_hdr *hdr) 1033static inline u8 *ieee80211_get_SA(struct ieee80211_hdr *hdr)
554{ 1034{
555 u8 *raw = (u8 *) hdr; 1035 if (ieee80211_has_a4(hdr->frame_control))
556 u8 tofrom = (*(raw+1)) & 3; /* get the TODS and FROMDS bits */ 1036 return hdr->addr4;
557 1037 if (ieee80211_has_fromds(hdr->frame_control))
558 switch (tofrom) { 1038 return hdr->addr3;
559 case 2:
560 return hdr->addr3;
561 case 3:
562 return hdr->addr4;
563 }
564 return hdr->addr2; 1039 return hdr->addr2;
565} 1040}
566 1041
567/** 1042/**
568 * ieee80211_get_DA - get pointer to DA 1043 * ieee80211_get_DA - get pointer to DA
1044 * @hdr: the frame
569 * 1045 *
570 * Given an 802.11 frame, this function returns the offset 1046 * Given an 802.11 frame, this function returns the offset
571 * to the destination address (DA). It does not verify that 1047 * to the destination address (DA). It does not verify that
572 * the header is long enough to contain the address, and the 1048 * the header is long enough to contain the address, and the
573 * header must be long enough to contain the frame control 1049 * header must be long enough to contain the frame control
574 * field. 1050 * field.
575 *
576 * @hdr: the frame
577 */ 1051 */
578static inline u8 *ieee80211_get_DA(struct ieee80211_hdr *hdr) 1052static inline u8 *ieee80211_get_DA(struct ieee80211_hdr *hdr)
579{ 1053{
580 u8 *raw = (u8 *) hdr; 1054 if (ieee80211_has_tods(hdr->frame_control))
581 u8 to_ds = (*(raw+1)) & 1; /* get the TODS bit */
582
583 if (to_ds)
584 return hdr->addr3; 1055 return hdr->addr3;
585 return hdr->addr1; 1056 else
586} 1057 return hdr->addr1;
587
588/**
589 * ieee80211_get_morefrag - determine whether the MOREFRAGS bit is set
590 *
591 * This function determines whether the "more fragments" bit is set
592 * in the frame.
593 *
594 * @hdr: the frame
595 */
596static inline int ieee80211_get_morefrag(struct ieee80211_hdr *hdr)
597{
598 return (le16_to_cpu(hdr->frame_control) &
599 IEEE80211_FCTL_MOREFRAGS) != 0;
600} 1058}
601 1059
602#endif /* IEEE80211_H */ 1060#endif /* IEEE80211_H */
diff --git a/include/linux/if.h b/include/linux/if.h
index 5c9d1fa93fef..65246846c844 100644
--- a/include/linux/if.h
+++ b/include/linux/if.h
@@ -24,6 +24,7 @@
24#include <linux/compiler.h> /* for "__user" et al */ 24#include <linux/compiler.h> /* for "__user" et al */
25 25
26#define IFNAMSIZ 16 26#define IFNAMSIZ 16
27#define IFALIASZ 256
27#include <linux/hdlc/ioctl.h> 28#include <linux/hdlc/ioctl.h>
28 29
29/* Standard interface flags (netdevice->flags). */ 30/* Standard interface flags (netdevice->flags). */
diff --git a/include/linux/if_bridge.h b/include/linux/if_bridge.h
index 950e13d09e06..6badb3e2c4e4 100644
--- a/include/linux/if_bridge.h
+++ b/include/linux/if_bridge.h
@@ -4,8 +4,6 @@
4 * Authors: 4 * Authors:
5 * Lennert Buytenhek <buytenh@gnu.org> 5 * Lennert Buytenhek <buytenh@gnu.org>
6 * 6 *
7 * $Id: if_bridge.h,v 1.1 2000/02/18 16:47:01 davem Exp $
8 *
9 * This program is free software; you can redistribute it and/or 7 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License 8 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 9 * as published by the Free Software Foundation; either version
diff --git a/include/linux/if_ether.h b/include/linux/if_ether.h
index e157c1399b61..7f3c735f422b 100644
--- a/include/linux/if_ether.h
+++ b/include/linux/if_ether.h
@@ -9,7 +9,7 @@
9 * 9 *
10 * Author: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> 10 * Author: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
11 * Donald Becker, <becker@super.org> 11 * Donald Becker, <becker@super.org>
12 * Alan Cox, <alan@redhat.com> 12 * Alan Cox, <alan@lxorguk.ukuu.org.uk>
13 * Steve Whitehouse, <gw7rrm@eeshack3.swan.ac.uk> 13 * Steve Whitehouse, <gw7rrm@eeshack3.swan.ac.uk>
14 * 14 *
15 * This program is free software; you can redistribute it and/or 15 * This program is free software; you can redistribute it and/or
@@ -56,6 +56,7 @@
56#define ETH_P_DIAG 0x6005 /* DEC Diagnostics */ 56#define ETH_P_DIAG 0x6005 /* DEC Diagnostics */
57#define ETH_P_CUST 0x6006 /* DEC Customer use */ 57#define ETH_P_CUST 0x6006 /* DEC Customer use */
58#define ETH_P_SCA 0x6007 /* DEC Systems Comms Arch */ 58#define ETH_P_SCA 0x6007 /* DEC Systems Comms Arch */
59#define ETH_P_TEB 0x6558 /* Trans Ether Bridging */
59#define ETH_P_RARP 0x8035 /* Reverse Addr Res packet */ 60#define ETH_P_RARP 0x8035 /* Reverse Addr Res packet */
60#define ETH_P_ATALK 0x809B /* Appletalk DDP */ 61#define ETH_P_ATALK 0x809B /* Appletalk DDP */
61#define ETH_P_AARP 0x80F3 /* Appletalk AARP */ 62#define ETH_P_AARP 0x80F3 /* Appletalk AARP */
@@ -74,8 +75,10 @@
74#define ETH_P_ATMFATE 0x8884 /* Frame-based ATM Transport 75#define ETH_P_ATMFATE 0x8884 /* Frame-based ATM Transport
75 * over Ethernet 76 * over Ethernet
76 */ 77 */
78#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
77#define ETH_P_AOE 0x88A2 /* ATA over Ethernet */ 79#define ETH_P_AOE 0x88A2 /* ATA over Ethernet */
78#define ETH_P_TIPC 0x88CA /* TIPC */ 80#define ETH_P_TIPC 0x88CA /* TIPC */
81#define ETH_P_EDSA 0xDADA /* Ethertype DSA [ NOT AN OFFICIALLY REGISTERED ID ] */
79 82
80/* 83/*
81 * Non DIX types. Won't clash for 1500 types. 84 * Non DIX types. Won't clash for 1500 types.
@@ -99,6 +102,9 @@
99#define ETH_P_ECONET 0x0018 /* Acorn Econet */ 102#define ETH_P_ECONET 0x0018 /* Acorn Econet */
100#define ETH_P_HDLC 0x0019 /* HDLC frames */ 103#define ETH_P_HDLC 0x0019 /* HDLC frames */
101#define ETH_P_ARCNET 0x001A /* 1A for ArcNet :-) */ 104#define ETH_P_ARCNET 0x001A /* 1A for ArcNet :-) */
105#define ETH_P_DSA 0x001B /* Distributed Switch Arch. */
106#define ETH_P_TRAILER 0x001C /* Trailer switch tagging */
107#define ETH_P_PHONET 0x00F5 /* Nokia Phonet frames */
102 108
103/* 109/*
104 * This is an Ethernet frame header. 110 * This is an Ethernet frame header.
diff --git a/include/linux/if_fddi.h b/include/linux/if_fddi.h
index ae77daed6c2f..45de1046dbbf 100644
--- a/include/linux/if_fddi.h
+++ b/include/linux/if_fddi.h
@@ -12,7 +12,7 @@
12 * if_fddi.h is based on previous if_ether.h and if_tr.h work by 12 * if_fddi.h is based on previous if_ether.h and if_tr.h work by
13 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> 13 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
14 * Donald Becker, <becker@super.org> 14 * Donald Becker, <becker@super.org>
15 * Alan Cox, <alan@redhat.com> 15 * Alan Cox, <alan@lxorguk.ukuu.org.uk>
16 * Steve Whitehouse, <gw7rrm@eeshack3.swan.ac.uk> 16 * Steve Whitehouse, <gw7rrm@eeshack3.swan.ac.uk>
17 * Peter De Schrijver, <stud11@cc4.kuleuven.ac.be> 17 * Peter De Schrijver, <stud11@cc4.kuleuven.ac.be>
18 * 18 *
diff --git a/include/linux/if_hippi.h b/include/linux/if_hippi.h
index 94d31ca7d71a..f0f23516bb59 100644
--- a/include/linux/if_hippi.h
+++ b/include/linux/if_hippi.h
@@ -9,7 +9,7 @@
9 * 9 *
10 * Author: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> 10 * Author: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
11 * Donald Becker, <becker@super.org> 11 * Donald Becker, <becker@super.org>
12 * Alan Cox, <alan@redhat.com> 12 * Alan Cox, <alan@lxorguk.ukuu.org.uk>
13 * Steve Whitehouse, <gw7rrm@eeshack3.swan.ac.uk> 13 * Steve Whitehouse, <gw7rrm@eeshack3.swan.ac.uk>
14 * Jes Sorensen, <Jes.Sorensen@cern.ch> 14 * Jes Sorensen, <Jes.Sorensen@cern.ch>
15 * 15 *
diff --git a/include/linux/if_link.h b/include/linux/if_link.h
index 84c3492ae5cb..f9032c88716a 100644
--- a/include/linux/if_link.h
+++ b/include/linux/if_link.h
@@ -79,6 +79,7 @@ enum
79 IFLA_LINKINFO, 79 IFLA_LINKINFO,
80#define IFLA_LINKINFO IFLA_LINKINFO 80#define IFLA_LINKINFO IFLA_LINKINFO
81 IFLA_NET_NS_PID, 81 IFLA_NET_NS_PID,
82 IFLA_IFALIAS,
82 __IFLA_MAX 83 __IFLA_MAX
83}; 84};
84 85
diff --git a/include/linux/if_packet.h b/include/linux/if_packet.h
index ad09609227ff..18db0668065a 100644
--- a/include/linux/if_packet.h
+++ b/include/linux/if_packet.h
@@ -43,6 +43,9 @@ struct sockaddr_ll
43#define PACKET_COPY_THRESH 7 43#define PACKET_COPY_THRESH 7
44#define PACKET_AUXDATA 8 44#define PACKET_AUXDATA 8
45#define PACKET_ORIGDEV 9 45#define PACKET_ORIGDEV 9
46#define PACKET_VERSION 10
47#define PACKET_HDRLEN 11
48#define PACKET_RESERVE 12
46 49
47struct tpacket_stats 50struct tpacket_stats
48{ 51{
@@ -57,6 +60,7 @@ struct tpacket_auxdata
57 __u32 tp_snaplen; 60 __u32 tp_snaplen;
58 __u16 tp_mac; 61 __u16 tp_mac;
59 __u16 tp_net; 62 __u16 tp_net;
63 __u16 tp_vlan_tci;
60}; 64};
61 65
62struct tpacket_hdr 66struct tpacket_hdr
@@ -79,6 +83,26 @@ struct tpacket_hdr
79#define TPACKET_ALIGN(x) (((x)+TPACKET_ALIGNMENT-1)&~(TPACKET_ALIGNMENT-1)) 83#define TPACKET_ALIGN(x) (((x)+TPACKET_ALIGNMENT-1)&~(TPACKET_ALIGNMENT-1))
80#define TPACKET_HDRLEN (TPACKET_ALIGN(sizeof(struct tpacket_hdr)) + sizeof(struct sockaddr_ll)) 84#define TPACKET_HDRLEN (TPACKET_ALIGN(sizeof(struct tpacket_hdr)) + sizeof(struct sockaddr_ll))
81 85
86struct tpacket2_hdr
87{
88 __u32 tp_status;
89 __u32 tp_len;
90 __u32 tp_snaplen;
91 __u16 tp_mac;
92 __u16 tp_net;
93 __u32 tp_sec;
94 __u32 tp_nsec;
95 __u16 tp_vlan_tci;
96};
97
98#define TPACKET2_HDRLEN (TPACKET_ALIGN(sizeof(struct tpacket2_hdr)) + sizeof(struct sockaddr_ll))
99
100enum tpacket_versions
101{
102 TPACKET_V1,
103 TPACKET_V2,
104};
105
82/* 106/*
83 Frame structure: 107 Frame structure:
84 108
diff --git a/include/linux/if_phonet.h b/include/linux/if_phonet.h
new file mode 100644
index 000000000000..d70034bcec05
--- /dev/null
+++ b/include/linux/if_phonet.h
@@ -0,0 +1,19 @@
1/*
2 * File: if_phonet.h
3 *
4 * Phonet interface kernel definitions
5 *
6 * Copyright (C) 2008 Nokia Corporation. All rights reserved.
7 */
8#ifndef LINUX_IF_PHONET_H
9#define LINUX_IF_PHONET_H
10
11#define PHONET_MIN_MTU 6 /* pn_length = 0 */
12#define PHONET_MAX_MTU 65541 /* pn_length = 0xffff */
13#define PHONET_DEV_MTU PHONET_MAX_MTU
14
15#ifdef __KERNEL__
16extern struct header_ops phonet_header_ops;
17#endif
18
19#endif
diff --git a/include/linux/if_ppp.h b/include/linux/if_ppp.h
index 0f2f70d4e48c..c3b1f8562709 100644
--- a/include/linux/if_ppp.h
+++ b/include/linux/if_ppp.h
@@ -1,5 +1,3 @@
1/* $Id: if_ppp.h,v 1.21 2000/03/27 06:03:36 paulus Exp $ */
2
3/* 1/*
4 * if_ppp.h - Point-to-Point Protocol definitions. 2 * if_ppp.h - Point-to-Point Protocol definitions.
5 * 3 *
diff --git a/include/linux/if_tun.h b/include/linux/if_tun.h
index 8c71fe2fb1f5..8529f57ba263 100644
--- a/include/linux/if_tun.h
+++ b/include/linux/if_tun.h
@@ -11,14 +11,13 @@
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 *
15 * $Id: if_tun.h,v 1.2 2001/06/01 18:39:47 davem Exp $
16 */ 14 */
17 15
18#ifndef __IF_TUN_H 16#ifndef __IF_TUN_H
19#define __IF_TUN_H 17#define __IF_TUN_H
20 18
21#include <linux/types.h> 19#include <linux/types.h>
20#include <linux/if_ether.h>
22 21
23/* Read queue size */ 22/* Read queue size */
24#define TUN_READQ_SIZE 500 23#define TUN_READQ_SIZE 500
@@ -33,6 +32,7 @@
33#define TUN_NO_PI 0x0040 32#define TUN_NO_PI 0x0040
34#define TUN_ONE_QUEUE 0x0080 33#define TUN_ONE_QUEUE 0x0080
35#define TUN_PERSIST 0x0100 34#define TUN_PERSIST 0x0100
35#define TUN_VNET_HDR 0x0200
36 36
37/* Ioctl defines */ 37/* Ioctl defines */
38#define TUNSETNOCSUM _IOW('T', 200, int) 38#define TUNSETNOCSUM _IOW('T', 200, int)
@@ -42,17 +42,44 @@
42#define TUNSETOWNER _IOW('T', 204, int) 42#define TUNSETOWNER _IOW('T', 204, int)
43#define TUNSETLINK _IOW('T', 205, int) 43#define TUNSETLINK _IOW('T', 205, int)
44#define TUNSETGROUP _IOW('T', 206, int) 44#define TUNSETGROUP _IOW('T', 206, int)
45#define TUNGETFEATURES _IOR('T', 207, unsigned int)
46#define TUNSETOFFLOAD _IOW('T', 208, unsigned int)
47#define TUNSETTXFILTER _IOW('T', 209, unsigned int)
48#define TUNGETIFF _IOR('T', 210, unsigned int)
45 49
46/* TUNSETIFF ifr flags */ 50/* TUNSETIFF ifr flags */
47#define IFF_TUN 0x0001 51#define IFF_TUN 0x0001
48#define IFF_TAP 0x0002 52#define IFF_TAP 0x0002
49#define IFF_NO_PI 0x1000 53#define IFF_NO_PI 0x1000
50#define IFF_ONE_QUEUE 0x2000 54#define IFF_ONE_QUEUE 0x2000
55#define IFF_VNET_HDR 0x4000
56
57/* Features for GSO (TUNSETOFFLOAD). */
58#define TUN_F_CSUM 0x01 /* You can hand me unchecksummed packets. */
59#define TUN_F_TSO4 0x02 /* I can handle TSO for IPv4 packets */
60#define TUN_F_TSO6 0x04 /* I can handle TSO for IPv6 packets */
61#define TUN_F_TSO_ECN 0x08 /* I can handle TSO with ECN bits. */
51 62
63/* Protocol info prepended to the packets (when IFF_NO_PI is not set) */
64#define TUN_PKT_STRIP 0x0001
52struct tun_pi { 65struct tun_pi {
53 unsigned short flags; 66 __u16 flags;
54 __be16 proto; 67 __be16 proto;
55}; 68};
56#define TUN_PKT_STRIP 0x0001 69
70/*
71 * Filter spec (used for SETXXFILTER ioctls)
72 * This stuff is applicable only to the TAP (Ethernet) devices.
73 * If the count is zero the filter is disabled and the driver accepts
74 * all packets (promisc mode).
75 * If the filter is enabled in order to accept broadcast packets
76 * broadcast addr must be explicitly included in the addr list.
77 */
78#define TUN_FLT_ALLMULTI 0x0001 /* Accept all multicast packets */
79struct tun_filter {
80 __u16 flags; /* TUN_FLT_ flags see above */
81 __u16 count; /* Number of addresses */
82 __u8 addr[0][ETH_ALEN];
83};
57 84
58#endif /* __IF_TUN_H */ 85#endif /* __IF_TUN_H */
diff --git a/include/linux/if_tunnel.h b/include/linux/if_tunnel.h
index d4efe4014705..aeab2cb32a9c 100644
--- a/include/linux/if_tunnel.h
+++ b/include/linux/if_tunnel.h
@@ -2,6 +2,7 @@
2#define _IF_TUNNEL_H_ 2#define _IF_TUNNEL_H_
3 3
4#include <linux/types.h> 4#include <linux/types.h>
5#include <linux/ip.h>
5 6
6#define SIOCGETTUNNEL (SIOCDEVPRIVATE + 0) 7#define SIOCGETTUNNEL (SIOCDEVPRIVATE + 0)
7#define SIOCADDTUNNEL (SIOCDEVPRIVATE + 1) 8#define SIOCADDTUNNEL (SIOCDEVPRIVATE + 1)
@@ -47,4 +48,22 @@ struct ip_tunnel_prl {
47/* PRL flags */ 48/* PRL flags */
48#define PRL_DEFAULT 0x0001 49#define PRL_DEFAULT 0x0001
49 50
51enum
52{
53 IFLA_GRE_UNSPEC,
54 IFLA_GRE_LINK,
55 IFLA_GRE_IFLAGS,
56 IFLA_GRE_OFLAGS,
57 IFLA_GRE_IKEY,
58 IFLA_GRE_OKEY,
59 IFLA_GRE_LOCAL,
60 IFLA_GRE_REMOTE,
61 IFLA_GRE_TTL,
62 IFLA_GRE_TOS,
63 IFLA_GRE_PMTUDISC,
64 __IFLA_GRE_MAX,
65};
66
67#define IFLA_GRE_MAX (__IFLA_GRE_MAX - 1)
68
50#endif /* _IF_TUNNEL_H_ */ 69#endif /* _IF_TUNNEL_H_ */
diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index 15ace02b7b24..9e7b49b8062d 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -14,10 +14,6 @@
14#define _LINUX_IF_VLAN_H_ 14#define _LINUX_IF_VLAN_H_
15 15
16#ifdef __KERNEL__ 16#ifdef __KERNEL__
17
18/* externally defined structs */
19struct hlist_node;
20
21#include <linux/netdevice.h> 17#include <linux/netdevice.h>
22#include <linux/etherdevice.h> 18#include <linux/etherdevice.h>
23 19
@@ -91,7 +87,7 @@ struct vlan_group {
91}; 87};
92 88
93static inline struct net_device *vlan_group_get_device(struct vlan_group *vg, 89static inline struct net_device *vlan_group_get_device(struct vlan_group *vg,
94 unsigned int vlan_id) 90 u16 vlan_id)
95{ 91{
96 struct net_device **array; 92 struct net_device **array;
97 array = vg->vlan_devices_arrays[vlan_id / VLAN_GROUP_ARRAY_PART_LEN]; 93 array = vg->vlan_devices_arrays[vlan_id / VLAN_GROUP_ARRAY_PART_LEN];
@@ -99,7 +95,7 @@ static inline struct net_device *vlan_group_get_device(struct vlan_group *vg,
99} 95}
100 96
101static inline void vlan_group_set_device(struct vlan_group *vg, 97static inline void vlan_group_set_device(struct vlan_group *vg,
102 unsigned int vlan_id, 98 u16 vlan_id,
103 struct net_device *dev) 99 struct net_device *dev)
104{ 100{
105 struct net_device **array; 101 struct net_device **array;
@@ -109,164 +105,81 @@ static inline void vlan_group_set_device(struct vlan_group *vg,
109 array[vlan_id % VLAN_GROUP_ARRAY_PART_LEN] = dev; 105 array[vlan_id % VLAN_GROUP_ARRAY_PART_LEN] = dev;
110} 106}
111 107
112struct vlan_priority_tci_mapping { 108#define vlan_tx_tag_present(__skb) ((__skb)->vlan_tci)
113 u32 priority; 109#define vlan_tx_tag_get(__skb) ((__skb)->vlan_tci)
114 unsigned short vlan_qos; /* This should be shifted when first set, so we only do it
115 * at provisioning time.
116 * ((skb->priority << 13) & 0xE000)
117 */
118 struct vlan_priority_tci_mapping *next;
119};
120 110
121/* Holds information that makes sense if this device is a VLAN device. */ 111#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
122struct vlan_dev_info { 112extern struct net_device *vlan_dev_real_dev(const struct net_device *dev);
123 /** This will be the mapping that correlates skb->priority to 113extern u16 vlan_dev_vlan_id(const struct net_device *dev);
124 * 3 bits of VLAN QOS tags...
125 */
126 unsigned int nr_ingress_mappings;
127 u32 ingress_priority_map[8];
128
129 unsigned int nr_egress_mappings;
130 struct vlan_priority_tci_mapping *egress_priority_map[16]; /* hash table */
131
132 unsigned short vlan_id; /* The VLAN Identifier for this interface. */
133 unsigned short flags; /* (1 << 0) re_order_header This option will cause the
134 * VLAN code to move around the ethernet header on
135 * ingress to make the skb look **exactly** like it
136 * came in from an ethernet port. This destroys some of
137 * the VLAN information in the skb, but it fixes programs
138 * like DHCP that use packet-filtering and don't understand
139 * 802.1Q
140 */
141 struct net_device *real_dev; /* the underlying device/interface */
142 unsigned char real_dev_addr[ETH_ALEN];
143 struct proc_dir_entry *dent; /* Holds the proc data */
144 unsigned long cnt_inc_headroom_on_tx; /* How many times did we have to grow the skb on TX. */
145 unsigned long cnt_encap_on_xmit; /* How many times did we have to encapsulate the skb on TX. */
146};
147 114
148static inline struct vlan_dev_info *vlan_dev_info(const struct net_device *dev) 115extern int __vlan_hwaccel_rx(struct sk_buff *skb, struct vlan_group *grp,
116 u16 vlan_tci, int polling);
117#else
118static inline struct net_device *vlan_dev_real_dev(const struct net_device *dev)
149{ 119{
150 return netdev_priv(dev); 120 BUG();
121 return NULL;
151} 122}
152 123
153/* inline functions */ 124static inline u16 vlan_dev_vlan_id(const struct net_device *dev)
154static inline __u32 vlan_get_ingress_priority(struct net_device *dev,
155 unsigned short vlan_tag)
156{ 125{
157 struct vlan_dev_info *vip = vlan_dev_info(dev); 126 BUG();
158 127 return 0;
159 return vip->ingress_priority_map[(vlan_tag >> 13) & 0x7];
160} 128}
161 129
162/* VLAN tx hw acceleration helpers. */ 130static inline int __vlan_hwaccel_rx(struct sk_buff *skb, struct vlan_group *grp,
163struct vlan_skb_tx_cookie { 131 u16 vlan_tci, int polling)
164 u32 magic;
165 u32 vlan_tag;
166};
167
168#define VLAN_TX_COOKIE_MAGIC 0x564c414e /* "VLAN" in ascii. */
169#define VLAN_TX_SKB_CB(__skb) ((struct vlan_skb_tx_cookie *)&((__skb)->cb[0]))
170#define vlan_tx_tag_present(__skb) \
171 (VLAN_TX_SKB_CB(__skb)->magic == VLAN_TX_COOKIE_MAGIC)
172#define vlan_tx_tag_get(__skb) (VLAN_TX_SKB_CB(__skb)->vlan_tag)
173
174/* VLAN rx hw acceleration helper. This acts like netif_{rx,receive_skb}(). */
175static inline int __vlan_hwaccel_rx(struct sk_buff *skb,
176 struct vlan_group *grp,
177 unsigned short vlan_tag, int polling)
178{ 132{
179 struct net_device_stats *stats; 133 BUG();
180 134 return NET_XMIT_SUCCESS;
181 if (skb_bond_should_drop(skb)) {
182 dev_kfree_skb_any(skb);
183 return NET_RX_DROP;
184 }
185
186 skb->dev = vlan_group_get_device(grp, vlan_tag & VLAN_VID_MASK);
187 if (skb->dev == NULL) {
188 dev_kfree_skb_any(skb);
189
190 /* Not NET_RX_DROP, this is not being dropped
191 * due to congestion.
192 */
193 return 0;
194 }
195
196 skb->dev->last_rx = jiffies;
197
198 stats = &skb->dev->stats;
199 stats->rx_packets++;
200 stats->rx_bytes += skb->len;
201
202 skb->priority = vlan_get_ingress_priority(skb->dev, vlan_tag);
203 switch (skb->pkt_type) {
204 case PACKET_BROADCAST:
205 break;
206
207 case PACKET_MULTICAST:
208 stats->multicast++;
209 break;
210
211 case PACKET_OTHERHOST:
212 /* Our lower layer thinks this is not local, let's make sure.
213 * This allows the VLAN to have a different MAC than the underlying
214 * device, and still route correctly.
215 */
216 if (!compare_ether_addr(eth_hdr(skb)->h_dest,
217 skb->dev->dev_addr))
218 skb->pkt_type = PACKET_HOST;
219 break;
220 };
221
222 return (polling ? netif_receive_skb(skb) : netif_rx(skb));
223} 135}
136#endif
224 137
138/**
139 * vlan_hwaccel_rx - netif_rx wrapper for VLAN RX acceleration
140 * @skb: buffer
141 * @grp: vlan group
142 * @vlan_tci: VLAN TCI as received from the card
143 */
225static inline int vlan_hwaccel_rx(struct sk_buff *skb, 144static inline int vlan_hwaccel_rx(struct sk_buff *skb,
226 struct vlan_group *grp, 145 struct vlan_group *grp,
227 unsigned short vlan_tag) 146 u16 vlan_tci)
228{ 147{
229 return __vlan_hwaccel_rx(skb, grp, vlan_tag, 0); 148 return __vlan_hwaccel_rx(skb, grp, vlan_tci, 0);
230} 149}
231 150
151/**
152 * vlan_hwaccel_receive_skb - netif_receive_skb wrapper for VLAN RX acceleration
153 * @skb: buffer
154 * @grp: vlan group
155 * @vlan_tci: VLAN TCI as received from the card
156 */
232static inline int vlan_hwaccel_receive_skb(struct sk_buff *skb, 157static inline int vlan_hwaccel_receive_skb(struct sk_buff *skb,
233 struct vlan_group *grp, 158 struct vlan_group *grp,
234 unsigned short vlan_tag) 159 u16 vlan_tci)
235{ 160{
236 return __vlan_hwaccel_rx(skb, grp, vlan_tag, 1); 161 return __vlan_hwaccel_rx(skb, grp, vlan_tci, 1);
237} 162}
238 163
239/** 164/**
240 * __vlan_put_tag - regular VLAN tag inserting 165 * __vlan_put_tag - regular VLAN tag inserting
241 * @skb: skbuff to tag 166 * @skb: skbuff to tag
242 * @tag: VLAN tag to insert 167 * @vlan_tci: VLAN TCI to insert
243 * 168 *
244 * Inserts the VLAN tag into @skb as part of the payload 169 * Inserts the VLAN tag into @skb as part of the payload
245 * Returns a VLAN tagged skb. If a new skb is created, @skb is freed. 170 * Returns a VLAN tagged skb. If a new skb is created, @skb is freed.
246 * 171 *
247 * Following the skb_unshare() example, in case of error, the calling function 172 * Following the skb_unshare() example, in case of error, the calling function
248 * doesn't have to worry about freeing the original skb. 173 * doesn't have to worry about freeing the original skb.
249 */ 174 */
250static inline struct sk_buff *__vlan_put_tag(struct sk_buff *skb, unsigned short tag) 175static inline struct sk_buff *__vlan_put_tag(struct sk_buff *skb, u16 vlan_tci)
251{ 176{
252 struct vlan_ethhdr *veth; 177 struct vlan_ethhdr *veth;
253 178
254 if (skb_headroom(skb) < VLAN_HLEN) { 179 if (skb_cow_head(skb, VLAN_HLEN) < 0) {
255 struct sk_buff *sk_tmp = skb; 180 kfree_skb(skb);
256 skb = skb_realloc_headroom(sk_tmp, VLAN_HLEN); 181 return NULL;
257 kfree_skb(sk_tmp);
258 if (!skb) {
259 printk(KERN_ERR "vlan: failed to realloc headroom\n");
260 return NULL;
261 }
262 } else {
263 skb = skb_unshare(skb, GFP_ATOMIC);
264 if (!skb) {
265 printk(KERN_ERR "vlan: failed to unshare skbuff\n");
266 return NULL;
267 }
268 } 182 }
269
270 veth = (struct vlan_ethhdr *)skb_push(skb, VLAN_HLEN); 183 veth = (struct vlan_ethhdr *)skb_push(skb, VLAN_HLEN);
271 184
272 /* Move the mac addresses to the beginning of the new header. */ 185 /* Move the mac addresses to the beginning of the new header. */
@@ -275,12 +188,10 @@ static inline struct sk_buff *__vlan_put_tag(struct sk_buff *skb, unsigned short
275 /* first, the ethernet type */ 188 /* first, the ethernet type */
276 veth->h_vlan_proto = htons(ETH_P_8021Q); 189 veth->h_vlan_proto = htons(ETH_P_8021Q);
277 190
278 /* now, the tag */ 191 /* now, the TCI */
279 veth->h_vlan_TCI = htons(tag); 192 veth->h_vlan_TCI = htons(vlan_tci);
280 193
281 skb->protocol = htons(ETH_P_8021Q); 194 skb->protocol = htons(ETH_P_8021Q);
282 skb->mac_header -= VLAN_HLEN;
283 skb->network_header -= VLAN_HLEN;
284 195
285 return skb; 196 return skb;
286} 197}
@@ -288,18 +199,14 @@ static inline struct sk_buff *__vlan_put_tag(struct sk_buff *skb, unsigned short
288/** 199/**
289 * __vlan_hwaccel_put_tag - hardware accelerated VLAN inserting 200 * __vlan_hwaccel_put_tag - hardware accelerated VLAN inserting
290 * @skb: skbuff to tag 201 * @skb: skbuff to tag
291 * @tag: VLAN tag to insert 202 * @vlan_tci: VLAN TCI to insert
292 * 203 *
293 * Puts the VLAN tag in @skb->cb[] and lets the device do the rest 204 * Puts the VLAN TCI in @skb->vlan_tci and lets the device do the rest
294 */ 205 */
295static inline struct sk_buff *__vlan_hwaccel_put_tag(struct sk_buff *skb, unsigned short tag) 206static inline struct sk_buff *__vlan_hwaccel_put_tag(struct sk_buff *skb,
207 u16 vlan_tci)
296{ 208{
297 struct vlan_skb_tx_cookie *cookie; 209 skb->vlan_tci = vlan_tci;
298
299 cookie = VLAN_TX_SKB_CB(skb);
300 cookie->magic = VLAN_TX_COOKIE_MAGIC;
301 cookie->vlan_tag = tag;
302
303 return skb; 210 return skb;
304} 211}
305 212
@@ -308,28 +215,28 @@ static inline struct sk_buff *__vlan_hwaccel_put_tag(struct sk_buff *skb, unsign
308/** 215/**
309 * vlan_put_tag - inserts VLAN tag according to device features 216 * vlan_put_tag - inserts VLAN tag according to device features
310 * @skb: skbuff to tag 217 * @skb: skbuff to tag
311 * @tag: VLAN tag to insert 218 * @vlan_tci: VLAN TCI to insert
312 * 219 *
313 * Assumes skb->dev is the target that will xmit this frame. 220 * Assumes skb->dev is the target that will xmit this frame.
314 * Returns a VLAN tagged skb. 221 * Returns a VLAN tagged skb.
315 */ 222 */
316static inline struct sk_buff *vlan_put_tag(struct sk_buff *skb, unsigned short tag) 223static inline struct sk_buff *vlan_put_tag(struct sk_buff *skb, u16 vlan_tci)
317{ 224{
318 if (skb->dev->features & NETIF_F_HW_VLAN_TX) { 225 if (skb->dev->features & NETIF_F_HW_VLAN_TX) {
319 return __vlan_hwaccel_put_tag(skb, tag); 226 return __vlan_hwaccel_put_tag(skb, vlan_tci);
320 } else { 227 } else {
321 return __vlan_put_tag(skb, tag); 228 return __vlan_put_tag(skb, vlan_tci);
322 } 229 }
323} 230}
324 231
325/** 232/**
326 * __vlan_get_tag - get the VLAN ID that is part of the payload 233 * __vlan_get_tag - get the VLAN ID that is part of the payload
327 * @skb: skbuff to query 234 * @skb: skbuff to query
328 * @tag: buffer to store vlaue 235 * @vlan_tci: buffer to store vlaue
329 * 236 *
330 * Returns error if the skb is not of VLAN type 237 * Returns error if the skb is not of VLAN type
331 */ 238 */
332static inline int __vlan_get_tag(const struct sk_buff *skb, unsigned short *tag) 239static inline int __vlan_get_tag(const struct sk_buff *skb, u16 *vlan_tci)
333{ 240{
334 struct vlan_ethhdr *veth = (struct vlan_ethhdr *)skb->data; 241 struct vlan_ethhdr *veth = (struct vlan_ethhdr *)skb->data;
335 242
@@ -337,29 +244,25 @@ static inline int __vlan_get_tag(const struct sk_buff *skb, unsigned short *tag)
337 return -EINVAL; 244 return -EINVAL;
338 } 245 }
339 246
340 *tag = ntohs(veth->h_vlan_TCI); 247 *vlan_tci = ntohs(veth->h_vlan_TCI);
341
342 return 0; 248 return 0;
343} 249}
344 250
345/** 251/**
346 * __vlan_hwaccel_get_tag - get the VLAN ID that is in @skb->cb[] 252 * __vlan_hwaccel_get_tag - get the VLAN ID that is in @skb->cb[]
347 * @skb: skbuff to query 253 * @skb: skbuff to query
348 * @tag: buffer to store vlaue 254 * @vlan_tci: buffer to store vlaue
349 * 255 *
350 * Returns error if @skb->cb[] is not set correctly 256 * Returns error if @skb->vlan_tci is not set correctly
351 */ 257 */
352static inline int __vlan_hwaccel_get_tag(const struct sk_buff *skb, 258static inline int __vlan_hwaccel_get_tag(const struct sk_buff *skb,
353 unsigned short *tag) 259 u16 *vlan_tci)
354{ 260{
355 struct vlan_skb_tx_cookie *cookie; 261 if (vlan_tx_tag_present(skb)) {
356 262 *vlan_tci = skb->vlan_tci;
357 cookie = VLAN_TX_SKB_CB(skb);
358 if (cookie->magic == VLAN_TX_COOKIE_MAGIC) {
359 *tag = cookie->vlan_tag;
360 return 0; 263 return 0;
361 } else { 264 } else {
362 *tag = 0; 265 *vlan_tci = 0;
363 return -EINVAL; 266 return -EINVAL;
364 } 267 }
365} 268}
@@ -369,16 +272,16 @@ static inline int __vlan_hwaccel_get_tag(const struct sk_buff *skb,
369/** 272/**
370 * vlan_get_tag - get the VLAN ID from the skb 273 * vlan_get_tag - get the VLAN ID from the skb
371 * @skb: skbuff to query 274 * @skb: skbuff to query
372 * @tag: buffer to store vlaue 275 * @vlan_tci: buffer to store vlaue
373 * 276 *
374 * Returns error if the skb is not VLAN tagged 277 * Returns error if the skb is not VLAN tagged
375 */ 278 */
376static inline int vlan_get_tag(const struct sk_buff *skb, unsigned short *tag) 279static inline int vlan_get_tag(const struct sk_buff *skb, u16 *vlan_tci)
377{ 280{
378 if (skb->dev->features & NETIF_F_HW_VLAN_TX) { 281 if (skb->dev->features & NETIF_F_HW_VLAN_TX) {
379 return __vlan_hwaccel_get_tag(skb, tag); 282 return __vlan_hwaccel_get_tag(skb, vlan_tci);
380 } else { 283 } else {
381 return __vlan_get_tag(skb, tag); 284 return __vlan_get_tag(skb, vlan_tci);
382 } 285 }
383} 286}
384 287
@@ -402,6 +305,7 @@ enum vlan_ioctl_cmds {
402 305
403enum vlan_flags { 306enum vlan_flags {
404 VLAN_FLAG_REORDER_HDR = 0x1, 307 VLAN_FLAG_REORDER_HDR = 0x1,
308 VLAN_FLAG_GVRP = 0x2,
405}; 309};
406 310
407enum vlan_name_types { 311enum vlan_name_types {
diff --git a/include/linux/igmp.h b/include/linux/igmp.h
index f5a1a0db2e8e..f734a0ba0698 100644
--- a/include/linux/igmp.h
+++ b/include/linux/igmp.h
@@ -2,7 +2,7 @@
2 * Linux NET3: Internet Group Management Protocol [IGMP] 2 * Linux NET3: Internet Group Management Protocol [IGMP]
3 * 3 *
4 * Authors: 4 * Authors:
5 * Alan Cox <Alan.Cox@linux.org> 5 * Alan Cox <alan@lxorguk.ukuu.org.uk>
6 * 6 *
7 * Extended to talk the BSD extended IGMP protocol of mrouted 3.6 7 * Extended to talk the BSD extended IGMP protocol of mrouted 3.6
8 * 8 *
@@ -228,7 +228,6 @@ extern int ip_mc_msfget(struct sock *sk, struct ip_msfilter *msf,
228extern int ip_mc_gsfget(struct sock *sk, struct group_filter *gsf, 228extern int ip_mc_gsfget(struct sock *sk, struct group_filter *gsf,
229 struct group_filter __user *optval, int __user *optlen); 229 struct group_filter __user *optval, int __user *optlen);
230extern int ip_mc_sf_allow(struct sock *sk, __be32 local, __be32 rmt, int dif); 230extern int ip_mc_sf_allow(struct sock *sk, __be32 local, __be32 rmt, int dif);
231extern void ip_mr_init(void);
232extern void ip_mc_init_dev(struct in_device *); 231extern void ip_mc_init_dev(struct in_device *);
233extern void ip_mc_destroy_dev(struct in_device *); 232extern void ip_mc_destroy_dev(struct in_device *);
234extern void ip_mc_up(struct in_device *); 233extern void ip_mc_up(struct in_device *);
diff --git a/include/linux/ihex.h b/include/linux/ihex.h
index 2baace2788a7..31d8629e75a1 100644
--- a/include/linux/ihex.h
+++ b/include/linux/ihex.h
@@ -18,7 +18,7 @@ struct ihex_binrec {
18 __be32 addr; 18 __be32 addr;
19 __be16 len; 19 __be16 len;
20 uint8_t data[0]; 20 uint8_t data[0];
21} __attribute__((aligned(4))); 21} __attribute__((packed));
22 22
23/* Find the next record, taking into account the 4-byte alignment */ 23/* Find the next record, taking into account the 4-byte alignment */
24static inline const struct ihex_binrec * 24static inline const struct ihex_binrec *
diff --git a/include/linux/in.h b/include/linux/in.h
index 4065313cd7ee..db458beef19d 100644
--- a/include/linux/in.h
+++ b/include/linux/in.h
@@ -75,6 +75,7 @@ struct in_addr {
75#define IP_IPSEC_POLICY 16 75#define IP_IPSEC_POLICY 16
76#define IP_XFRM_POLICY 17 76#define IP_XFRM_POLICY 17
77#define IP_PASSSEC 18 77#define IP_PASSSEC 18
78#define IP_TRANSPARENT 19
78 79
79/* BSD compatibility */ 80/* BSD compatibility */
80#define IP_RECVRETOPTS IP_RETOPTS 81#define IP_RECVRETOPTS IP_RETOPTS
diff --git a/include/linux/inetdevice.h b/include/linux/inetdevice.h
index c6f51ad52d5b..06fcdb45106b 100644
--- a/include/linux/inetdevice.h
+++ b/include/linux/inetdevice.h
@@ -25,6 +25,7 @@ struct in_device
25 struct in_ifaddr *ifa_list; /* IP ifaddr chain */ 25 struct in_ifaddr *ifa_list; /* IP ifaddr chain */
26 rwlock_t mc_list_lock; 26 rwlock_t mc_list_lock;
27 struct ip_mc_list *mc_list; /* IP multicast filter chain */ 27 struct ip_mc_list *mc_list; /* IP multicast filter chain */
28 int mc_count; /* Number of installed mcasts */
28 spinlock_t mc_tomb_lock; 29 spinlock_t mc_tomb_lock;
29 struct ip_mc_list *mc_tomb; 30 struct ip_mc_list *mc_tomb;
30 unsigned long mr_v1_seen; 31 unsigned long mr_v1_seen;
diff --git a/include/linux/init.h b/include/linux/init.h
index 21d658cdfa27..0c1264668be0 100644
--- a/include/linux/init.h
+++ b/include/linux/init.h
@@ -40,7 +40,7 @@
40 40
41/* These are for everybody (although not all archs will actually 41/* These are for everybody (although not all archs will actually
42 discard it in modules) */ 42 discard it in modules) */
43#define __init __section(.init.text) __cold 43#define __init __section(.init.text) __cold notrace
44#define __initdata __section(.init.data) 44#define __initdata __section(.init.data)
45#define __initconst __section(.init.rodata) 45#define __initconst __section(.init.rodata)
46#define __exitdata __section(.exit.data) 46#define __exitdata __section(.exit.data)
@@ -139,6 +139,7 @@ extern initcall_t __con_initcall_start[], __con_initcall_end[];
139extern initcall_t __security_initcall_start[], __security_initcall_end[]; 139extern initcall_t __security_initcall_start[], __security_initcall_end[];
140 140
141/* Defined in init/main.c */ 141/* Defined in init/main.c */
142extern int do_one_initcall(initcall_t fn);
142extern char __initdata boot_command_line[]; 143extern char __initdata boot_command_line[];
143extern char *saved_command_line; 144extern char *saved_command_line;
144extern unsigned int reset_devices; 145extern unsigned int reset_devices;
@@ -170,6 +171,13 @@ extern void (*late_time_init)(void);
170 __attribute__((__section__(".initcall" level ".init"))) = fn 171 __attribute__((__section__(".initcall" level ".init"))) = fn
171 172
172/* 173/*
174 * Early initcalls run before initializing SMP.
175 *
176 * Only for built-in code, not modules.
177 */
178#define early_initcall(fn) __define_initcall("early",fn,early)
179
180/*
173 * A "pure" initcall has no dependencies on anything else, and purely 181 * A "pure" initcall has no dependencies on anything else, and purely
174 * initializes variables that couldn't be statically initialized. 182 * initializes variables that couldn't be statically initialized.
175 * 183 *
@@ -225,9 +233,6 @@ struct obs_kernel_param {
225 __attribute__((aligned((sizeof(long))))) \ 233 __attribute__((aligned((sizeof(long))))) \
226 = { __setup_str_##unique_id, fn, early } 234 = { __setup_str_##unique_id, fn, early }
227 235
228#define __setup_null_param(str, unique_id) \
229 __setup_param(str, unique_id, NULL, 0)
230
231#define __setup(str, fn) \ 236#define __setup(str, fn) \
232 __setup_param(str, fn, fn, 0) 237 __setup_param(str, fn, fn, 0)
233 238
@@ -275,13 +280,7 @@ void __init parse_early_param(void);
275 280
276#define security_initcall(fn) module_init(fn) 281#define security_initcall(fn) module_init(fn)
277 282
278/* These macros create a dummy inline: gcc 2.9x does not count alias 283/* Each module must use one module_init(). */
279 as usage, hence the `unused function' warning when __init functions
280 are declared static. We use the dummy __*_module_inline functions
281 both to kill the warning and check the type of the init/cleanup
282 function. */
283
284/* Each module must use one module_init(), or one no_module_init */
285#define module_init(initfn) \ 284#define module_init(initfn) \
286 static inline initcall_t __inittest(void) \ 285 static inline initcall_t __inittest(void) \
287 { return initfn; } \ 286 { return initfn; } \
@@ -294,7 +293,6 @@ void __init parse_early_param(void);
294 void cleanup_module(void) __attribute__((alias(#exitfn))); 293 void cleanup_module(void) __attribute__((alias(#exitfn)));
295 294
296#define __setup_param(str, unique_id, fn) /* nothing */ 295#define __setup_param(str, unique_id, fn) /* nothing */
297#define __setup_null_param(str, unique_id) /* nothing */
298#define __setup(str, func) /* nothing */ 296#define __setup(str, func) /* nothing */
299#endif 297#endif
300 298
diff --git a/include/linux/init_task.h b/include/linux/init_task.h
index 93c45acf249a..23fd8909b9e5 100644
--- a/include/linux/init_task.h
+++ b/include/linux/init_task.h
@@ -122,7 +122,7 @@ extern struct group_info init_groups;
122 .state = 0, \ 122 .state = 0, \
123 .stack = &init_thread_info, \ 123 .stack = &init_thread_info, \
124 .usage = ATOMIC_INIT(2), \ 124 .usage = ATOMIC_INIT(2), \
125 .flags = 0, \ 125 .flags = PF_KTHREAD, \
126 .lock_depth = -1, \ 126 .lock_depth = -1, \
127 .prio = MAX_PRIO-20, \ 127 .prio = MAX_PRIO-20, \
128 .static_prio = MAX_PRIO-20, \ 128 .static_prio = MAX_PRIO-20, \
@@ -170,6 +170,7 @@ extern struct group_info init_groups;
170 .cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \ 170 .cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \
171 .fs_excl = ATOMIC_INIT(0), \ 171 .fs_excl = ATOMIC_INIT(0), \
172 .pi_lock = __SPIN_LOCK_UNLOCKED(tsk.pi_lock), \ 172 .pi_lock = __SPIN_LOCK_UNLOCKED(tsk.pi_lock), \
173 .timer_slack_ns = 50000, /* 50 usec default slack */ \
173 .pids = { \ 174 .pids = { \
174 [PIDTYPE_PID] = INIT_PID_LINK(PIDTYPE_PID), \ 175 [PIDTYPE_PID] = INIT_PID_LINK(PIDTYPE_PID), \
175 [PIDTYPE_PGID] = INIT_PID_LINK(PIDTYPE_PGID), \ 176 [PIDTYPE_PGID] = INIT_PID_LINK(PIDTYPE_PGID), \
diff --git a/include/linux/inotify.h b/include/linux/inotify.h
index 742b917e7d1b..bd578578a8b9 100644
--- a/include/linux/inotify.h
+++ b/include/linux/inotify.h
@@ -7,6 +7,8 @@
7#ifndef _LINUX_INOTIFY_H 7#ifndef _LINUX_INOTIFY_H
8#define _LINUX_INOTIFY_H 8#define _LINUX_INOTIFY_H
9 9
10/* For O_CLOEXEC and O_NONBLOCK */
11#include <linux/fcntl.h>
10#include <linux/types.h> 12#include <linux/types.h>
11 13
12/* 14/*
@@ -63,6 +65,10 @@ struct inotify_event {
63 IN_MOVED_TO | IN_DELETE | IN_CREATE | IN_DELETE_SELF | \ 65 IN_MOVED_TO | IN_DELETE | IN_CREATE | IN_DELETE_SELF | \
64 IN_MOVE_SELF) 66 IN_MOVE_SELF)
65 67
68/* Flags for sys_inotify_init1. */
69#define IN_CLOEXEC O_CLOEXEC
70#define IN_NONBLOCK O_NONBLOCK
71
66#ifdef __KERNEL__ 72#ifdef __KERNEL__
67 73
68#include <linux/dcache.h> 74#include <linux/dcache.h>
diff --git a/include/linux/input.h b/include/linux/input.h
index d150c57e5f0a..b86fb5581ce6 100644
--- a/include/linux/input.h
+++ b/include/linux/input.h
@@ -373,6 +373,8 @@ struct input_absinfo {
373 373
374#define KEY_WIMAX 246 374#define KEY_WIMAX 246
375 375
376/* Range 248 - 255 is reserved for special needs of AT keyboard driver */
377
376#define BTN_MISC 0x100 378#define BTN_MISC 0x100
377#define BTN_0 0x100 379#define BTN_0 0x100
378#define BTN_1 0x101 380#define BTN_1 0x101
@@ -575,9 +577,22 @@ struct input_absinfo {
575#define KEY_BRL_DOT9 0x1f9 577#define KEY_BRL_DOT9 0x1f9
576#define KEY_BRL_DOT10 0x1fa 578#define KEY_BRL_DOT10 0x1fa
577 579
580#define KEY_NUMERIC_0 0x200 /* used by phones, remote controls, */
581#define KEY_NUMERIC_1 0x201 /* and other keypads */
582#define KEY_NUMERIC_2 0x202
583#define KEY_NUMERIC_3 0x203
584#define KEY_NUMERIC_4 0x204
585#define KEY_NUMERIC_5 0x205
586#define KEY_NUMERIC_6 0x206
587#define KEY_NUMERIC_7 0x207
588#define KEY_NUMERIC_8 0x208
589#define KEY_NUMERIC_9 0x209
590#define KEY_NUMERIC_STAR 0x20a
591#define KEY_NUMERIC_POUND 0x20b
592
578/* We avoid low common keys in module aliases so they don't get huge. */ 593/* We avoid low common keys in module aliases so they don't get huge. */
579#define KEY_MIN_INTERESTING KEY_MUTE 594#define KEY_MIN_INTERESTING KEY_MUTE
580#define KEY_MAX 0x1ff 595#define KEY_MAX 0x2ff
581#define KEY_CNT (KEY_MAX+1) 596#define KEY_CNT (KEY_MAX+1)
582 597
583/* 598/*
@@ -640,6 +655,8 @@ struct input_absinfo {
640#define SW_RFKILL_ALL 0x03 /* rfkill master switch, type "any" 655#define SW_RFKILL_ALL 0x03 /* rfkill master switch, type "any"
641 set = radio enabled */ 656 set = radio enabled */
642#define SW_RADIO SW_RFKILL_ALL /* deprecated */ 657#define SW_RADIO SW_RFKILL_ALL /* deprecated */
658#define SW_MICROPHONE_INSERT 0x04 /* set = inserted */
659#define SW_DOCK 0x05 /* set = plugged into dock */
643#define SW_MAX 0x0f 660#define SW_MAX 0x0f
644#define SW_CNT (SW_MAX+1) 661#define SW_CNT (SW_MAX+1)
645 662
@@ -1215,11 +1232,6 @@ struct input_handle {
1215 struct list_head h_node; 1232 struct list_head h_node;
1216}; 1233};
1217 1234
1218#define to_dev(n) container_of(n, struct input_dev, node)
1219#define to_handler(n) container_of(n, struct input_handler, node)
1220#define to_handle(n) container_of(n, struct input_handle, d_node)
1221#define to_handle_h(n) container_of(n, struct input_handle, h_node)
1222
1223struct input_dev *input_allocate_device(void); 1235struct input_dev *input_allocate_device(void);
1224void input_free_device(struct input_dev *dev); 1236void input_free_device(struct input_dev *dev);
1225 1237
diff --git a/include/linux/intel-iommu.h b/include/linux/intel-iommu.h
new file mode 100644
index 000000000000..3d017cfd245b
--- /dev/null
+++ b/include/linux/intel-iommu.h
@@ -0,0 +1,363 @@
1/*
2 * Copyright (c) 2006, Intel Corporation.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
15 * Place - Suite 330, Boston, MA 02111-1307 USA.
16 *
17 * Copyright (C) 2006-2008 Intel Corporation
18 * Author: Ashok Raj <ashok.raj@intel.com>
19 * Author: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
20 */
21
22#ifndef _INTEL_IOMMU_H_
23#define _INTEL_IOMMU_H_
24
25#include <linux/types.h>
26#include <linux/msi.h>
27#include <linux/sysdev.h>
28#include <linux/iova.h>
29#include <linux/io.h>
30#include <linux/dma_remapping.h>
31#include <asm/cacheflush.h>
32#include <asm/iommu.h>
33
34/*
35 * Intel IOMMU register specification per version 1.0 public spec.
36 */
37
38#define DMAR_VER_REG 0x0 /* Arch version supported by this IOMMU */
39#define DMAR_CAP_REG 0x8 /* Hardware supported capabilities */
40#define DMAR_ECAP_REG 0x10 /* Extended capabilities supported */
41#define DMAR_GCMD_REG 0x18 /* Global command register */
42#define DMAR_GSTS_REG 0x1c /* Global status register */
43#define DMAR_RTADDR_REG 0x20 /* Root entry table */
44#define DMAR_CCMD_REG 0x28 /* Context command reg */
45#define DMAR_FSTS_REG 0x34 /* Fault Status register */
46#define DMAR_FECTL_REG 0x38 /* Fault control register */
47#define DMAR_FEDATA_REG 0x3c /* Fault event interrupt data register */
48#define DMAR_FEADDR_REG 0x40 /* Fault event interrupt addr register */
49#define DMAR_FEUADDR_REG 0x44 /* Upper address register */
50#define DMAR_AFLOG_REG 0x58 /* Advanced Fault control */
51#define DMAR_PMEN_REG 0x64 /* Enable Protected Memory Region */
52#define DMAR_PLMBASE_REG 0x68 /* PMRR Low addr */
53#define DMAR_PLMLIMIT_REG 0x6c /* PMRR low limit */
54#define DMAR_PHMBASE_REG 0x70 /* pmrr high base addr */
55#define DMAR_PHMLIMIT_REG 0x78 /* pmrr high limit */
56#define DMAR_IQH_REG 0x80 /* Invalidation queue head register */
57#define DMAR_IQT_REG 0x88 /* Invalidation queue tail register */
58#define DMAR_IQA_REG 0x90 /* Invalidation queue addr register */
59#define DMAR_ICS_REG 0x98 /* Invalidation complete status register */
60#define DMAR_IRTA_REG 0xb8 /* Interrupt remapping table addr register */
61
62#define OFFSET_STRIDE (9)
63/*
64#define dmar_readl(dmar, reg) readl(dmar + reg)
65#define dmar_readq(dmar, reg) ({ \
66 u32 lo, hi; \
67 lo = readl(dmar + reg); \
68 hi = readl(dmar + reg + 4); \
69 (((u64) hi) << 32) + lo; })
70*/
71static inline u64 dmar_readq(void __iomem *addr)
72{
73 u32 lo, hi;
74 lo = readl(addr);
75 hi = readl(addr + 4);
76 return (((u64) hi) << 32) + lo;
77}
78
79static inline void dmar_writeq(void __iomem *addr, u64 val)
80{
81 writel((u32)val, addr);
82 writel((u32)(val >> 32), addr + 4);
83}
84
85#define DMAR_VER_MAJOR(v) (((v) & 0xf0) >> 4)
86#define DMAR_VER_MINOR(v) ((v) & 0x0f)
87
88/*
89 * Decoding Capability Register
90 */
91#define cap_read_drain(c) (((c) >> 55) & 1)
92#define cap_write_drain(c) (((c) >> 54) & 1)
93#define cap_max_amask_val(c) (((c) >> 48) & 0x3f)
94#define cap_num_fault_regs(c) ((((c) >> 40) & 0xff) + 1)
95#define cap_pgsel_inv(c) (((c) >> 39) & 1)
96
97#define cap_super_page_val(c) (((c) >> 34) & 0xf)
98#define cap_super_offset(c) (((find_first_bit(&cap_super_page_val(c), 4)) \
99 * OFFSET_STRIDE) + 21)
100
101#define cap_fault_reg_offset(c) ((((c) >> 24) & 0x3ff) * 16)
102#define cap_max_fault_reg_offset(c) \
103 (cap_fault_reg_offset(c) + cap_num_fault_regs(c) * 16)
104
105#define cap_zlr(c) (((c) >> 22) & 1)
106#define cap_isoch(c) (((c) >> 23) & 1)
107#define cap_mgaw(c) ((((c) >> 16) & 0x3f) + 1)
108#define cap_sagaw(c) (((c) >> 8) & 0x1f)
109#define cap_caching_mode(c) (((c) >> 7) & 1)
110#define cap_phmr(c) (((c) >> 6) & 1)
111#define cap_plmr(c) (((c) >> 5) & 1)
112#define cap_rwbf(c) (((c) >> 4) & 1)
113#define cap_afl(c) (((c) >> 3) & 1)
114#define cap_ndoms(c) (((unsigned long)1) << (4 + 2 * ((c) & 0x7)))
115/*
116 * Extended Capability Register
117 */
118
119#define ecap_niotlb_iunits(e) ((((e) >> 24) & 0xff) + 1)
120#define ecap_iotlb_offset(e) ((((e) >> 8) & 0x3ff) * 16)
121#define ecap_max_iotlb_offset(e) \
122 (ecap_iotlb_offset(e) + ecap_niotlb_iunits(e) * 16)
123#define ecap_coherent(e) ((e) & 0x1)
124#define ecap_qis(e) ((e) & 0x2)
125#define ecap_eim_support(e) ((e >> 4) & 0x1)
126#define ecap_ir_support(e) ((e >> 3) & 0x1)
127#define ecap_max_handle_mask(e) ((e >> 20) & 0xf)
128
129
130/* IOTLB_REG */
131#define DMA_TLB_FLUSH_GRANU_OFFSET 60
132#define DMA_TLB_GLOBAL_FLUSH (((u64)1) << 60)
133#define DMA_TLB_DSI_FLUSH (((u64)2) << 60)
134#define DMA_TLB_PSI_FLUSH (((u64)3) << 60)
135#define DMA_TLB_IIRG(type) ((type >> 60) & 7)
136#define DMA_TLB_IAIG(val) (((val) >> 57) & 7)
137#define DMA_TLB_READ_DRAIN (((u64)1) << 49)
138#define DMA_TLB_WRITE_DRAIN (((u64)1) << 48)
139#define DMA_TLB_DID(id) (((u64)((id) & 0xffff)) << 32)
140#define DMA_TLB_IVT (((u64)1) << 63)
141#define DMA_TLB_IH_NONLEAF (((u64)1) << 6)
142#define DMA_TLB_MAX_SIZE (0x3f)
143
144/* INVALID_DESC */
145#define DMA_CCMD_INVL_GRANU_OFFSET 61
146#define DMA_ID_TLB_GLOBAL_FLUSH (((u64)1) << 3)
147#define DMA_ID_TLB_DSI_FLUSH (((u64)2) << 3)
148#define DMA_ID_TLB_PSI_FLUSH (((u64)3) << 3)
149#define DMA_ID_TLB_READ_DRAIN (((u64)1) << 7)
150#define DMA_ID_TLB_WRITE_DRAIN (((u64)1) << 6)
151#define DMA_ID_TLB_DID(id) (((u64)((id & 0xffff) << 16)))
152#define DMA_ID_TLB_IH_NONLEAF (((u64)1) << 6)
153#define DMA_ID_TLB_ADDR(addr) (addr)
154#define DMA_ID_TLB_ADDR_MASK(mask) (mask)
155
156/* PMEN_REG */
157#define DMA_PMEN_EPM (((u32)1)<<31)
158#define DMA_PMEN_PRS (((u32)1)<<0)
159
160/* GCMD_REG */
161#define DMA_GCMD_TE (((u32)1) << 31)
162#define DMA_GCMD_SRTP (((u32)1) << 30)
163#define DMA_GCMD_SFL (((u32)1) << 29)
164#define DMA_GCMD_EAFL (((u32)1) << 28)
165#define DMA_GCMD_WBF (((u32)1) << 27)
166#define DMA_GCMD_QIE (((u32)1) << 26)
167#define DMA_GCMD_SIRTP (((u32)1) << 24)
168#define DMA_GCMD_IRE (((u32) 1) << 25)
169
170/* GSTS_REG */
171#define DMA_GSTS_TES (((u32)1) << 31)
172#define DMA_GSTS_RTPS (((u32)1) << 30)
173#define DMA_GSTS_FLS (((u32)1) << 29)
174#define DMA_GSTS_AFLS (((u32)1) << 28)
175#define DMA_GSTS_WBFS (((u32)1) << 27)
176#define DMA_GSTS_QIES (((u32)1) << 26)
177#define DMA_GSTS_IRTPS (((u32)1) << 24)
178#define DMA_GSTS_IRES (((u32)1) << 25)
179
180/* CCMD_REG */
181#define DMA_CCMD_ICC (((u64)1) << 63)
182#define DMA_CCMD_GLOBAL_INVL (((u64)1) << 61)
183#define DMA_CCMD_DOMAIN_INVL (((u64)2) << 61)
184#define DMA_CCMD_DEVICE_INVL (((u64)3) << 61)
185#define DMA_CCMD_FM(m) (((u64)((m) & 0x3)) << 32)
186#define DMA_CCMD_MASK_NOBIT 0
187#define DMA_CCMD_MASK_1BIT 1
188#define DMA_CCMD_MASK_2BIT 2
189#define DMA_CCMD_MASK_3BIT 3
190#define DMA_CCMD_SID(s) (((u64)((s) & 0xffff)) << 16)
191#define DMA_CCMD_DID(d) ((u64)((d) & 0xffff))
192
193/* FECTL_REG */
194#define DMA_FECTL_IM (((u32)1) << 31)
195
196/* FSTS_REG */
197#define DMA_FSTS_PPF ((u32)2)
198#define DMA_FSTS_PFO ((u32)1)
199#define dma_fsts_fault_record_index(s) (((s) >> 8) & 0xff)
200
201/* FRCD_REG, 32 bits access */
202#define DMA_FRCD_F (((u32)1) << 31)
203#define dma_frcd_type(d) ((d >> 30) & 1)
204#define dma_frcd_fault_reason(c) (c & 0xff)
205#define dma_frcd_source_id(c) (c & 0xffff)
206/* low 64 bit */
207#define dma_frcd_page_addr(d) (d & (((u64)-1) << PAGE_SHIFT))
208
209#define IOMMU_WAIT_OP(iommu, offset, op, cond, sts) \
210do { \
211 cycles_t start_time = get_cycles(); \
212 while (1) { \
213 sts = op(iommu->reg + offset); \
214 if (cond) \
215 break; \
216 if (DMAR_OPERATION_TIMEOUT < (get_cycles() - start_time))\
217 panic("DMAR hardware is malfunctioning\n"); \
218 cpu_relax(); \
219 } \
220} while (0)
221
222#define QI_LENGTH 256 /* queue length */
223
224enum {
225 QI_FREE,
226 QI_IN_USE,
227 QI_DONE
228};
229
230#define QI_CC_TYPE 0x1
231#define QI_IOTLB_TYPE 0x2
232#define QI_DIOTLB_TYPE 0x3
233#define QI_IEC_TYPE 0x4
234#define QI_IWD_TYPE 0x5
235
236#define QI_IEC_SELECTIVE (((u64)1) << 4)
237#define QI_IEC_IIDEX(idx) (((u64)(idx & 0xffff) << 32))
238#define QI_IEC_IM(m) (((u64)(m & 0x1f) << 27))
239
240#define QI_IWD_STATUS_DATA(d) (((u64)d) << 32)
241#define QI_IWD_STATUS_WRITE (((u64)1) << 5)
242
243#define QI_IOTLB_DID(did) (((u64)did) << 16)
244#define QI_IOTLB_DR(dr) (((u64)dr) << 7)
245#define QI_IOTLB_DW(dw) (((u64)dw) << 6)
246#define QI_IOTLB_GRAN(gran) (((u64)gran) >> (DMA_TLB_FLUSH_GRANU_OFFSET-4))
247#define QI_IOTLB_ADDR(addr) (((u64)addr) & VTD_PAGE_MASK)
248#define QI_IOTLB_IH(ih) (((u64)ih) << 6)
249#define QI_IOTLB_AM(am) (((u8)am))
250
251#define QI_CC_FM(fm) (((u64)fm) << 48)
252#define QI_CC_SID(sid) (((u64)sid) << 32)
253#define QI_CC_DID(did) (((u64)did) << 16)
254#define QI_CC_GRAN(gran) (((u64)gran) >> (DMA_CCMD_INVL_GRANU_OFFSET-4))
255
256struct qi_desc {
257 u64 low, high;
258};
259
260struct q_inval {
261 spinlock_t q_lock;
262 struct qi_desc *desc; /* invalidation queue */
263 int *desc_status; /* desc status */
264 int free_head; /* first free entry */
265 int free_tail; /* last free entry */
266 int free_cnt;
267};
268
269#ifdef CONFIG_INTR_REMAP
270/* 1MB - maximum possible interrupt remapping table size */
271#define INTR_REMAP_PAGE_ORDER 8
272#define INTR_REMAP_TABLE_REG_SIZE 0xf
273
274#define INTR_REMAP_TABLE_ENTRIES 65536
275
276struct ir_table {
277 struct irte *base;
278};
279#endif
280
281struct iommu_flush {
282 int (*flush_context)(struct intel_iommu *iommu, u16 did, u16 sid, u8 fm,
283 u64 type, int non_present_entry_flush);
284 int (*flush_iotlb)(struct intel_iommu *iommu, u16 did, u64 addr,
285 unsigned int size_order, u64 type, int non_present_entry_flush);
286};
287
288struct intel_iommu {
289 void __iomem *reg; /* Pointer to hardware regs, virtual addr */
290 u64 cap;
291 u64 ecap;
292 int seg;
293 u32 gcmd; /* Holds TE, EAFL. Don't need SRTP, SFL, WBF */
294 spinlock_t register_lock; /* protect register handling */
295 int seq_id; /* sequence id of the iommu */
296
297#ifdef CONFIG_DMAR
298 unsigned long *domain_ids; /* bitmap of domains */
299 struct dmar_domain **domains; /* ptr to domains */
300 spinlock_t lock; /* protect context, domain ids */
301 struct root_entry *root_entry; /* virtual address */
302
303 unsigned int irq;
304 unsigned char name[7]; /* Device Name */
305 struct msi_msg saved_msg;
306 struct sys_device sysdev;
307 struct iommu_flush flush;
308#endif
309 struct q_inval *qi; /* Queued invalidation info */
310#ifdef CONFIG_INTR_REMAP
311 struct ir_table *ir_table; /* Interrupt remapping info */
312#endif
313};
314
315static inline void __iommu_flush_cache(
316 struct intel_iommu *iommu, void *addr, int size)
317{
318 if (!ecap_coherent(iommu->ecap))
319 clflush_cache_range(addr, size);
320}
321
322extern struct dmar_drhd_unit * dmar_find_matched_drhd_unit(struct pci_dev *dev);
323
324extern int alloc_iommu(struct dmar_drhd_unit *drhd);
325extern void free_iommu(struct intel_iommu *iommu);
326extern int dmar_enable_qi(struct intel_iommu *iommu);
327extern void qi_global_iec(struct intel_iommu *iommu);
328
329extern int qi_flush_context(struct intel_iommu *iommu, u16 did, u16 sid,
330 u8 fm, u64 type, int non_present_entry_flush);
331extern int qi_flush_iotlb(struct intel_iommu *iommu, u16 did, u64 addr,
332 unsigned int size_order, u64 type,
333 int non_present_entry_flush);
334
335extern void qi_submit_sync(struct qi_desc *desc, struct intel_iommu *iommu);
336
337void intel_iommu_domain_exit(struct dmar_domain *domain);
338struct dmar_domain *intel_iommu_domain_alloc(struct pci_dev *pdev);
339int intel_iommu_context_mapping(struct dmar_domain *domain,
340 struct pci_dev *pdev);
341int intel_iommu_page_mapping(struct dmar_domain *domain, dma_addr_t iova,
342 u64 hpa, size_t size, int prot);
343void intel_iommu_detach_dev(struct dmar_domain *domain, u8 bus, u8 devfn);
344struct dmar_domain *intel_iommu_find_domain(struct pci_dev *pdev);
345u64 intel_iommu_iova_to_pfn(struct dmar_domain *domain, u64 iova);
346
347#ifdef CONFIG_DMAR
348int intel_iommu_found(void);
349#else /* CONFIG_DMAR */
350static inline int intel_iommu_found(void)
351{
352 return 0;
353}
354#endif /* CONFIG_DMAR */
355
356extern void *intel_alloc_coherent(struct device *, size_t, dma_addr_t *, gfp_t);
357extern void intel_free_coherent(struct device *, size_t, void *, dma_addr_t);
358extern dma_addr_t intel_map_single(struct device *, phys_addr_t, size_t, int);
359extern void intel_unmap_single(struct device *, dma_addr_t, size_t, int);
360extern int intel_map_sg(struct device *, struct scatterlist *, int, int);
361extern void intel_unmap_sg(struct device *, struct scatterlist *, int, int);
362
363#endif
diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index 62aa4f895abe..f58a0cf8929a 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -8,9 +8,12 @@
8#include <linux/preempt.h> 8#include <linux/preempt.h>
9#include <linux/cpumask.h> 9#include <linux/cpumask.h>
10#include <linux/irqreturn.h> 10#include <linux/irqreturn.h>
11#include <linux/irqnr.h>
11#include <linux/hardirq.h> 12#include <linux/hardirq.h>
12#include <linux/sched.h> 13#include <linux/sched.h>
13#include <linux/irqflags.h> 14#include <linux/irqflags.h>
15#include <linux/smp.h>
16#include <linux/percpu.h>
14#include <asm/atomic.h> 17#include <asm/atomic.h>
15#include <asm/ptrace.h> 18#include <asm/ptrace.h>
16#include <asm/system.h> 19#include <asm/system.h>
@@ -223,35 +226,6 @@ static inline int disable_irq_wake(unsigned int irq)
223#define or_softirq_pending(x) (local_softirq_pending() |= (x)) 226#define or_softirq_pending(x) (local_softirq_pending() |= (x))
224#endif 227#endif
225 228
226/*
227 * Temporary defines for UP kernels, until all code gets fixed.
228 */
229#ifndef CONFIG_SMP
230static inline void __deprecated cli(void)
231{
232 local_irq_disable();
233}
234static inline void __deprecated sti(void)
235{
236 local_irq_enable();
237}
238static inline void __deprecated save_flags(unsigned long *x)
239{
240 local_save_flags(*x);
241}
242#define save_flags(x) save_flags(&x)
243static inline void __deprecated restore_flags(unsigned long x)
244{
245 local_irq_restore(x);
246}
247
248static inline void __deprecated save_and_cli(unsigned long *x)
249{
250 local_irq_save(*x);
251}
252#define save_and_cli(x) save_and_cli(&x)
253#endif /* CONFIG_SMP */
254
255/* Some architectures might implement lazy enabling/disabling of 229/* Some architectures might implement lazy enabling/disabling of
256 * interrupts. In some cases, such as stop_machine, we might want 230 * interrupts. In some cases, such as stop_machine, we might want
257 * to ensure that after a local_irq_disable(), interrupts have 231 * to ensure that after a local_irq_disable(), interrupts have
@@ -281,6 +255,8 @@ enum
281 HRTIMER_SOFTIRQ, 255 HRTIMER_SOFTIRQ,
282#endif 256#endif
283 RCU_SOFTIRQ, /* Preferable RCU should always be the last softirq */ 257 RCU_SOFTIRQ, /* Preferable RCU should always be the last softirq */
258
259 NR_SOFTIRQS
284}; 260};
285 261
286/* softirq mask and active fields moved to irq_cpustat_t in 262/* softirq mask and active fields moved to irq_cpustat_t in
@@ -300,6 +276,25 @@ extern void softirq_init(void);
300extern void raise_softirq_irqoff(unsigned int nr); 276extern void raise_softirq_irqoff(unsigned int nr);
301extern void raise_softirq(unsigned int nr); 277extern void raise_softirq(unsigned int nr);
302 278
279/* This is the worklist that queues up per-cpu softirq work.
280 *
281 * send_remote_sendirq() adds work to these lists, and
282 * the softirq handler itself dequeues from them. The queues
283 * are protected by disabling local cpu interrupts and they must
284 * only be accessed by the local cpu that they are for.
285 */
286DECLARE_PER_CPU(struct list_head [NR_SOFTIRQS], softirq_work_list);
287
288/* Try to send a softirq to a remote cpu. If this cannot be done, the
289 * work will be queued to the local cpu.
290 */
291extern void send_remote_softirq(struct call_single_data *cp, int cpu, int softirq);
292
293/* Like send_remote_softirq(), but the caller must disable local cpu interrupts
294 * and compute the current cpu, passed in as 'this_cpu'.
295 */
296extern void __send_remote_softirq(struct call_single_data *cp, int cpu,
297 int this_cpu, int softirq);
303 298
304/* Tasklets --- multithreaded analogue of BHs. 299/* Tasklets --- multithreaded analogue of BHs.
305 300
diff --git a/include/linux/iommu-helper.h b/include/linux/iommu-helper.h
index c975caf75385..3b068e5b5671 100644
--- a/include/linux/iommu-helper.h
+++ b/include/linux/iommu-helper.h
@@ -1,6 +1,20 @@
1#ifndef _LINUX_IOMMU_HELPER_H
2#define _LINUX_IOMMU_HELPER_H
3
4static inline unsigned long iommu_device_max_index(unsigned long size,
5 unsigned long offset,
6 u64 dma_mask)
7{
8 if (size + offset > dma_mask)
9 return dma_mask - offset + 1;
10 else
11 return size;
12}
13
1extern int iommu_is_span_boundary(unsigned int index, unsigned int nr, 14extern int iommu_is_span_boundary(unsigned int index, unsigned int nr,
2 unsigned long shift, 15 unsigned long shift,
3 unsigned long boundary_size); 16 unsigned long boundary_size);
17extern void iommu_area_reserve(unsigned long *map, unsigned long i, int len);
4extern unsigned long iommu_area_alloc(unsigned long *map, unsigned long size, 18extern unsigned long iommu_area_alloc(unsigned long *map, unsigned long size,
5 unsigned long start, unsigned int nr, 19 unsigned long start, unsigned int nr,
6 unsigned long shift, 20 unsigned long shift,
@@ -8,3 +22,8 @@ extern unsigned long iommu_area_alloc(unsigned long *map, unsigned long size,
8 unsigned long align_mask); 22 unsigned long align_mask);
9extern void iommu_area_free(unsigned long *map, unsigned long start, 23extern void iommu_area_free(unsigned long *map, unsigned long start,
10 unsigned int nr); 24 unsigned int nr);
25
26extern unsigned long iommu_num_pages(unsigned long addr, unsigned long len,
27 unsigned long io_page_size);
28
29#endif
diff --git a/include/linux/ioport.h b/include/linux/ioport.h
index 2cd07cc29687..041e95aac2bf 100644
--- a/include/linux/ioport.h
+++ b/include/linux/ioport.h
@@ -34,7 +34,8 @@ struct resource_list {
34 */ 34 */
35#define IORESOURCE_BITS 0x000000ff /* Bus-specific bits */ 35#define IORESOURCE_BITS 0x000000ff /* Bus-specific bits */
36 36
37#define IORESOURCE_IO 0x00000100 /* Resource type */ 37#define IORESOURCE_TYPE_BITS 0x00000f00 /* Resource type */
38#define IORESOURCE_IO 0x00000100
38#define IORESOURCE_MEM 0x00000200 39#define IORESOURCE_MEM 0x00000200
39#define IORESOURCE_IRQ 0x00000400 40#define IORESOURCE_IRQ 0x00000400
40#define IORESOURCE_DMA 0x00000800 41#define IORESOURCE_DMA 0x00000800
@@ -108,7 +109,11 @@ extern struct resource iomem_resource;
108 109
109extern int request_resource(struct resource *root, struct resource *new); 110extern int request_resource(struct resource *root, struct resource *new);
110extern int release_resource(struct resource *new); 111extern int release_resource(struct resource *new);
112extern void reserve_region_with_split(struct resource *root,
113 resource_size_t start, resource_size_t end,
114 const char *name);
111extern int insert_resource(struct resource *parent, struct resource *new); 115extern int insert_resource(struct resource *parent, struct resource *new);
116extern void insert_resource_expand_to_fit(struct resource *root, struct resource *new);
112extern int allocate_resource(struct resource *root, struct resource *new, 117extern int allocate_resource(struct resource *root, struct resource *new,
113 resource_size_t size, resource_size_t min, 118 resource_size_t size, resource_size_t min,
114 resource_size_t max, resource_size_t align, 119 resource_size_t max, resource_size_t align,
@@ -118,6 +123,14 @@ extern int allocate_resource(struct resource *root, struct resource *new,
118int adjust_resource(struct resource *res, resource_size_t start, 123int adjust_resource(struct resource *res, resource_size_t start,
119 resource_size_t size); 124 resource_size_t size);
120resource_size_t resource_alignment(struct resource *res); 125resource_size_t resource_alignment(struct resource *res);
126static inline resource_size_t resource_size(struct resource *res)
127{
128 return res->end - res->start + 1;
129}
130static inline unsigned long resource_type(struct resource *res)
131{
132 return res->flags & IORESOURCE_TYPE_BITS;
133}
121 134
122/* Convenience shorthand with allocation */ 135/* Convenience shorthand with allocation */
123#define request_region(start,n,name) __request_region(&ioport_resource, (start), (n), (name)) 136#define request_region(start,n,name) __request_region(&ioport_resource, (start), (n), (name))
@@ -154,13 +167,14 @@ extern struct resource * __devm_request_region(struct device *dev,
154 struct resource *parent, resource_size_t start, 167 struct resource *parent, resource_size_t start,
155 resource_size_t n, const char *name); 168 resource_size_t n, const char *name);
156 169
157#define devm_release_region(start,n) \ 170#define devm_release_region(dev, start, n) \
158 __devm_release_region(dev, &ioport_resource, (start), (n)) 171 __devm_release_region(dev, &ioport_resource, (start), (n))
159#define devm_release_mem_region(start,n) \ 172#define devm_release_mem_region(dev, start, n) \
160 __devm_release_region(dev, &iomem_resource, (start), (n)) 173 __devm_release_region(dev, &iomem_resource, (start), (n))
161 174
162extern void __devm_release_region(struct device *dev, struct resource *parent, 175extern void __devm_release_region(struct device *dev, struct resource *parent,
163 resource_size_t start, resource_size_t n); 176 resource_size_t start, resource_size_t n);
177extern int iomem_map_sanity_check(resource_size_t addr, unsigned long size);
164 178
165#endif /* __ASSEMBLY__ */ 179#endif /* __ASSEMBLY__ */
166#endif /* _LINUX_IOPORT_H */ 180#endif /* _LINUX_IOPORT_H */
diff --git a/include/linux/iova.h b/include/linux/iova.h
new file mode 100644
index 000000000000..228f6c94b69c
--- /dev/null
+++ b/include/linux/iova.h
@@ -0,0 +1,52 @@
1/*
2 * Copyright (c) 2006, Intel Corporation.
3 *
4 * This file is released under the GPLv2.
5 *
6 * Copyright (C) 2006-2008 Intel Corporation
7 * Author: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
8 *
9 */
10
11#ifndef _IOVA_H_
12#define _IOVA_H_
13
14#include <linux/types.h>
15#include <linux/kernel.h>
16#include <linux/rbtree.h>
17#include <linux/dma-mapping.h>
18
19/* IO virtual address start page frame number */
20#define IOVA_START_PFN (1)
21
22/* iova structure */
23struct iova {
24 struct rb_node node;
25 unsigned long pfn_hi; /* IOMMU dish out addr hi */
26 unsigned long pfn_lo; /* IOMMU dish out addr lo */
27};
28
29/* holds all the iova translations for a domain */
30struct iova_domain {
31 spinlock_t iova_alloc_lock;/* Lock to protect iova allocation */
32 spinlock_t iova_rbtree_lock; /* Lock to protect update of rbtree */
33 struct rb_root rbroot; /* iova domain rbtree root */
34 struct rb_node *cached32_node; /* Save last alloced node */
35 unsigned long dma_32bit_pfn;
36};
37
38struct iova *alloc_iova_mem(void);
39void free_iova_mem(struct iova *iova);
40void free_iova(struct iova_domain *iovad, unsigned long pfn);
41void __free_iova(struct iova_domain *iovad, struct iova *iova);
42struct iova *alloc_iova(struct iova_domain *iovad, unsigned long size,
43 unsigned long limit_pfn,
44 bool size_aligned);
45struct iova *reserve_iova(struct iova_domain *iovad, unsigned long pfn_lo,
46 unsigned long pfn_hi);
47void copy_reserved_iova(struct iova_domain *from, struct iova_domain *to);
48void init_iova_domain(struct iova_domain *iovad, unsigned long pfn_32bit);
49struct iova *find_iova(struct iova_domain *iovad, unsigned long pfn);
50void put_iova_domain(struct iova_domain *iovad);
51
52#endif
diff --git a/include/linux/ip6_tunnel.h b/include/linux/ip6_tunnel.h
index af3f4a70f3df..1e7cc4af40de 100644
--- a/include/linux/ip6_tunnel.h
+++ b/include/linux/ip6_tunnel.h
@@ -1,7 +1,3 @@
1/*
2 * $Id$
3 */
4
5#ifndef _IP6_TUNNEL_H 1#ifndef _IP6_TUNNEL_H
6#define _IP6_TUNNEL_H 2#define _IP6_TUNNEL_H
7 3
diff --git a/include/linux/ip_vs.h b/include/linux/ip_vs.h
new file mode 100644
index 000000000000..0f434a28fb58
--- /dev/null
+++ b/include/linux/ip_vs.h
@@ -0,0 +1,405 @@
1/*
2 * IP Virtual Server
3 * data structure and functionality definitions
4 */
5
6#ifndef _IP_VS_H
7#define _IP_VS_H
8
9#include <linux/types.h> /* For __beXX types in userland */
10
11#define IP_VS_VERSION_CODE 0x010201
12#define NVERSION(version) \
13 (version >> 16) & 0xFF, \
14 (version >> 8) & 0xFF, \
15 version & 0xFF
16
17/*
18 * Virtual Service Flags
19 */
20#define IP_VS_SVC_F_PERSISTENT 0x0001 /* persistent port */
21#define IP_VS_SVC_F_HASHED 0x0002 /* hashed entry */
22
23/*
24 * Destination Server Flags
25 */
26#define IP_VS_DEST_F_AVAILABLE 0x0001 /* server is available */
27#define IP_VS_DEST_F_OVERLOAD 0x0002 /* server is overloaded */
28
29/*
30 * IPVS sync daemon states
31 */
32#define IP_VS_STATE_NONE 0x0000 /* daemon is stopped */
33#define IP_VS_STATE_MASTER 0x0001 /* started as master */
34#define IP_VS_STATE_BACKUP 0x0002 /* started as backup */
35
36/*
37 * IPVS socket options
38 */
39#define IP_VS_BASE_CTL (64+1024+64) /* base */
40
41#define IP_VS_SO_SET_NONE IP_VS_BASE_CTL /* just peek */
42#define IP_VS_SO_SET_INSERT (IP_VS_BASE_CTL+1)
43#define IP_VS_SO_SET_ADD (IP_VS_BASE_CTL+2)
44#define IP_VS_SO_SET_EDIT (IP_VS_BASE_CTL+3)
45#define IP_VS_SO_SET_DEL (IP_VS_BASE_CTL+4)
46#define IP_VS_SO_SET_FLUSH (IP_VS_BASE_CTL+5)
47#define IP_VS_SO_SET_LIST (IP_VS_BASE_CTL+6)
48#define IP_VS_SO_SET_ADDDEST (IP_VS_BASE_CTL+7)
49#define IP_VS_SO_SET_DELDEST (IP_VS_BASE_CTL+8)
50#define IP_VS_SO_SET_EDITDEST (IP_VS_BASE_CTL+9)
51#define IP_VS_SO_SET_TIMEOUT (IP_VS_BASE_CTL+10)
52#define IP_VS_SO_SET_STARTDAEMON (IP_VS_BASE_CTL+11)
53#define IP_VS_SO_SET_STOPDAEMON (IP_VS_BASE_CTL+12)
54#define IP_VS_SO_SET_RESTORE (IP_VS_BASE_CTL+13)
55#define IP_VS_SO_SET_SAVE (IP_VS_BASE_CTL+14)
56#define IP_VS_SO_SET_ZERO (IP_VS_BASE_CTL+15)
57#define IP_VS_SO_SET_MAX IP_VS_SO_SET_ZERO
58
59#define IP_VS_SO_GET_VERSION IP_VS_BASE_CTL
60#define IP_VS_SO_GET_INFO (IP_VS_BASE_CTL+1)
61#define IP_VS_SO_GET_SERVICES (IP_VS_BASE_CTL+2)
62#define IP_VS_SO_GET_SERVICE (IP_VS_BASE_CTL+3)
63#define IP_VS_SO_GET_DESTS (IP_VS_BASE_CTL+4)
64#define IP_VS_SO_GET_DEST (IP_VS_BASE_CTL+5) /* not used now */
65#define IP_VS_SO_GET_TIMEOUT (IP_VS_BASE_CTL+6)
66#define IP_VS_SO_GET_DAEMON (IP_VS_BASE_CTL+7)
67#define IP_VS_SO_GET_MAX IP_VS_SO_GET_DAEMON
68
69
70/*
71 * IPVS Connection Flags
72 */
73#define IP_VS_CONN_F_FWD_MASK 0x0007 /* mask for the fwd methods */
74#define IP_VS_CONN_F_MASQ 0x0000 /* masquerading/NAT */
75#define IP_VS_CONN_F_LOCALNODE 0x0001 /* local node */
76#define IP_VS_CONN_F_TUNNEL 0x0002 /* tunneling */
77#define IP_VS_CONN_F_DROUTE 0x0003 /* direct routing */
78#define IP_VS_CONN_F_BYPASS 0x0004 /* cache bypass */
79#define IP_VS_CONN_F_SYNC 0x0020 /* entry created by sync */
80#define IP_VS_CONN_F_HASHED 0x0040 /* hashed entry */
81#define IP_VS_CONN_F_NOOUTPUT 0x0080 /* no output packets */
82#define IP_VS_CONN_F_INACTIVE 0x0100 /* not established */
83#define IP_VS_CONN_F_OUT_SEQ 0x0200 /* must do output seq adjust */
84#define IP_VS_CONN_F_IN_SEQ 0x0400 /* must do input seq adjust */
85#define IP_VS_CONN_F_SEQ_MASK 0x0600 /* in/out sequence mask */
86#define IP_VS_CONN_F_NO_CPORT 0x0800 /* no client port set yet */
87#define IP_VS_CONN_F_TEMPLATE 0x1000 /* template, not connection */
88
89#define IP_VS_SCHEDNAME_MAXLEN 16
90#define IP_VS_IFNAME_MAXLEN 16
91
92
93/*
94 * The struct ip_vs_service_user and struct ip_vs_dest_user are
95 * used to set IPVS rules through setsockopt.
96 */
97struct ip_vs_service_user {
98 /* virtual service addresses */
99 u_int16_t protocol;
100 __be32 addr; /* virtual ip address */
101 __be16 port;
102 u_int32_t fwmark; /* firwall mark of service */
103
104 /* virtual service options */
105 char sched_name[IP_VS_SCHEDNAME_MAXLEN];
106 unsigned flags; /* virtual service flags */
107 unsigned timeout; /* persistent timeout in sec */
108 __be32 netmask; /* persistent netmask */
109};
110
111
112struct ip_vs_dest_user {
113 /* destination server address */
114 __be32 addr;
115 __be16 port;
116
117 /* real server options */
118 unsigned conn_flags; /* connection flags */
119 int weight; /* destination weight */
120
121 /* thresholds for active connections */
122 u_int32_t u_threshold; /* upper threshold */
123 u_int32_t l_threshold; /* lower threshold */
124};
125
126
127/*
128 * IPVS statistics object (for user space)
129 */
130struct ip_vs_stats_user
131{
132 __u32 conns; /* connections scheduled */
133 __u32 inpkts; /* incoming packets */
134 __u32 outpkts; /* outgoing packets */
135 __u64 inbytes; /* incoming bytes */
136 __u64 outbytes; /* outgoing bytes */
137
138 __u32 cps; /* current connection rate */
139 __u32 inpps; /* current in packet rate */
140 __u32 outpps; /* current out packet rate */
141 __u32 inbps; /* current in byte rate */
142 __u32 outbps; /* current out byte rate */
143};
144
145
146/* The argument to IP_VS_SO_GET_INFO */
147struct ip_vs_getinfo {
148 /* version number */
149 unsigned int version;
150
151 /* size of connection hash table */
152 unsigned int size;
153
154 /* number of virtual services */
155 unsigned int num_services;
156};
157
158
159/* The argument to IP_VS_SO_GET_SERVICE */
160struct ip_vs_service_entry {
161 /* which service: user fills in these */
162 u_int16_t protocol;
163 __be32 addr; /* virtual address */
164 __be16 port;
165 u_int32_t fwmark; /* firwall mark of service */
166
167 /* service options */
168 char sched_name[IP_VS_SCHEDNAME_MAXLEN];
169 unsigned flags; /* virtual service flags */
170 unsigned timeout; /* persistent timeout */
171 __be32 netmask; /* persistent netmask */
172
173 /* number of real servers */
174 unsigned int num_dests;
175
176 /* statistics */
177 struct ip_vs_stats_user stats;
178};
179
180
181struct ip_vs_dest_entry {
182 __be32 addr; /* destination address */
183 __be16 port;
184 unsigned conn_flags; /* connection flags */
185 int weight; /* destination weight */
186
187 u_int32_t u_threshold; /* upper threshold */
188 u_int32_t l_threshold; /* lower threshold */
189
190 u_int32_t activeconns; /* active connections */
191 u_int32_t inactconns; /* inactive connections */
192 u_int32_t persistconns; /* persistent connections */
193
194 /* statistics */
195 struct ip_vs_stats_user stats;
196};
197
198
199/* The argument to IP_VS_SO_GET_DESTS */
200struct ip_vs_get_dests {
201 /* which service: user fills in these */
202 u_int16_t protocol;
203 __be32 addr; /* virtual address */
204 __be16 port;
205 u_int32_t fwmark; /* firwall mark of service */
206
207 /* number of real servers */
208 unsigned int num_dests;
209
210 /* the real servers */
211 struct ip_vs_dest_entry entrytable[0];
212};
213
214
215/* The argument to IP_VS_SO_GET_SERVICES */
216struct ip_vs_get_services {
217 /* number of virtual services */
218 unsigned int num_services;
219
220 /* service table */
221 struct ip_vs_service_entry entrytable[0];
222};
223
224
225/* The argument to IP_VS_SO_GET_TIMEOUT */
226struct ip_vs_timeout_user {
227 int tcp_timeout;
228 int tcp_fin_timeout;
229 int udp_timeout;
230};
231
232
233/* The argument to IP_VS_SO_GET_DAEMON */
234struct ip_vs_daemon_user {
235 /* sync daemon state (master/backup) */
236 int state;
237
238 /* multicast interface name */
239 char mcast_ifn[IP_VS_IFNAME_MAXLEN];
240
241 /* SyncID we belong to */
242 int syncid;
243};
244
245/*
246 *
247 * IPVS Generic Netlink interface definitions
248 *
249 */
250
251/* Generic Netlink family info */
252
253#define IPVS_GENL_NAME "IPVS"
254#define IPVS_GENL_VERSION 0x1
255
256struct ip_vs_flags {
257 __be32 flags;
258 __be32 mask;
259};
260
261/* Generic Netlink command attributes */
262enum {
263 IPVS_CMD_UNSPEC = 0,
264
265 IPVS_CMD_NEW_SERVICE, /* add service */
266 IPVS_CMD_SET_SERVICE, /* modify service */
267 IPVS_CMD_DEL_SERVICE, /* delete service */
268 IPVS_CMD_GET_SERVICE, /* get service info */
269
270 IPVS_CMD_NEW_DEST, /* add destination */
271 IPVS_CMD_SET_DEST, /* modify destination */
272 IPVS_CMD_DEL_DEST, /* delete destination */
273 IPVS_CMD_GET_DEST, /* get destination info */
274
275 IPVS_CMD_NEW_DAEMON, /* start sync daemon */
276 IPVS_CMD_DEL_DAEMON, /* stop sync daemon */
277 IPVS_CMD_GET_DAEMON, /* get sync daemon status */
278
279 IPVS_CMD_SET_CONFIG, /* set config settings */
280 IPVS_CMD_GET_CONFIG, /* get config settings */
281
282 IPVS_CMD_SET_INFO, /* only used in GET_INFO reply */
283 IPVS_CMD_GET_INFO, /* get general IPVS info */
284
285 IPVS_CMD_ZERO, /* zero all counters and stats */
286 IPVS_CMD_FLUSH, /* flush services and dests */
287
288 __IPVS_CMD_MAX,
289};
290
291#define IPVS_CMD_MAX (__IPVS_CMD_MAX - 1)
292
293/* Attributes used in the first level of commands */
294enum {
295 IPVS_CMD_ATTR_UNSPEC = 0,
296 IPVS_CMD_ATTR_SERVICE, /* nested service attribute */
297 IPVS_CMD_ATTR_DEST, /* nested destination attribute */
298 IPVS_CMD_ATTR_DAEMON, /* nested sync daemon attribute */
299 IPVS_CMD_ATTR_TIMEOUT_TCP, /* TCP connection timeout */
300 IPVS_CMD_ATTR_TIMEOUT_TCP_FIN, /* TCP FIN wait timeout */
301 IPVS_CMD_ATTR_TIMEOUT_UDP, /* UDP timeout */
302 __IPVS_CMD_ATTR_MAX,
303};
304
305#define IPVS_CMD_ATTR_MAX (__IPVS_SVC_ATTR_MAX - 1)
306
307/*
308 * Attributes used to describe a service
309 *
310 * Used inside nested attribute IPVS_CMD_ATTR_SERVICE
311 */
312enum {
313 IPVS_SVC_ATTR_UNSPEC = 0,
314 IPVS_SVC_ATTR_AF, /* address family */
315 IPVS_SVC_ATTR_PROTOCOL, /* virtual service protocol */
316 IPVS_SVC_ATTR_ADDR, /* virtual service address */
317 IPVS_SVC_ATTR_PORT, /* virtual service port */
318 IPVS_SVC_ATTR_FWMARK, /* firewall mark of service */
319
320 IPVS_SVC_ATTR_SCHED_NAME, /* name of scheduler */
321 IPVS_SVC_ATTR_FLAGS, /* virtual service flags */
322 IPVS_SVC_ATTR_TIMEOUT, /* persistent timeout */
323 IPVS_SVC_ATTR_NETMASK, /* persistent netmask */
324
325 IPVS_SVC_ATTR_STATS, /* nested attribute for service stats */
326 __IPVS_SVC_ATTR_MAX,
327};
328
329#define IPVS_SVC_ATTR_MAX (__IPVS_SVC_ATTR_MAX - 1)
330
331/*
332 * Attributes used to describe a destination (real server)
333 *
334 * Used inside nested attribute IPVS_CMD_ATTR_DEST
335 */
336enum {
337 IPVS_DEST_ATTR_UNSPEC = 0,
338 IPVS_DEST_ATTR_ADDR, /* real server address */
339 IPVS_DEST_ATTR_PORT, /* real server port */
340
341 IPVS_DEST_ATTR_FWD_METHOD, /* forwarding method */
342 IPVS_DEST_ATTR_WEIGHT, /* destination weight */
343
344 IPVS_DEST_ATTR_U_THRESH, /* upper threshold */
345 IPVS_DEST_ATTR_L_THRESH, /* lower threshold */
346
347 IPVS_DEST_ATTR_ACTIVE_CONNS, /* active connections */
348 IPVS_DEST_ATTR_INACT_CONNS, /* inactive connections */
349 IPVS_DEST_ATTR_PERSIST_CONNS, /* persistent connections */
350
351 IPVS_DEST_ATTR_STATS, /* nested attribute for dest stats */
352 __IPVS_DEST_ATTR_MAX,
353};
354
355#define IPVS_DEST_ATTR_MAX (__IPVS_DEST_ATTR_MAX - 1)
356
357/*
358 * Attributes describing a sync daemon
359 *
360 * Used inside nested attribute IPVS_CMD_ATTR_DAEMON
361 */
362enum {
363 IPVS_DAEMON_ATTR_UNSPEC = 0,
364 IPVS_DAEMON_ATTR_STATE, /* sync daemon state (master/backup) */
365 IPVS_DAEMON_ATTR_MCAST_IFN, /* multicast interface name */
366 IPVS_DAEMON_ATTR_SYNC_ID, /* SyncID we belong to */
367 __IPVS_DAEMON_ATTR_MAX,
368};
369
370#define IPVS_DAEMON_ATTR_MAX (__IPVS_DAEMON_ATTR_MAX - 1)
371
372/*
373 * Attributes used to describe service or destination entry statistics
374 *
375 * Used inside nested attributes IPVS_SVC_ATTR_STATS and IPVS_DEST_ATTR_STATS
376 */
377enum {
378 IPVS_STATS_ATTR_UNSPEC = 0,
379 IPVS_STATS_ATTR_CONNS, /* connections scheduled */
380 IPVS_STATS_ATTR_INPKTS, /* incoming packets */
381 IPVS_STATS_ATTR_OUTPKTS, /* outgoing packets */
382 IPVS_STATS_ATTR_INBYTES, /* incoming bytes */
383 IPVS_STATS_ATTR_OUTBYTES, /* outgoing bytes */
384
385 IPVS_STATS_ATTR_CPS, /* current connection rate */
386 IPVS_STATS_ATTR_INPPS, /* current in packet rate */
387 IPVS_STATS_ATTR_OUTPPS, /* current out packet rate */
388 IPVS_STATS_ATTR_INBPS, /* current in byte rate */
389 IPVS_STATS_ATTR_OUTBPS, /* current out byte rate */
390 __IPVS_STATS_ATTR_MAX,
391};
392
393#define IPVS_STATS_ATTR_MAX (__IPVS_STATS_ATTR_MAX - 1)
394
395/* Attributes used in response to IPVS_CMD_GET_INFO command */
396enum {
397 IPVS_INFO_ATTR_UNSPEC = 0,
398 IPVS_INFO_ATTR_VERSION, /* IPVS version number */
399 IPVS_INFO_ATTR_CONN_TAB_SIZE, /* size of connection hash table */
400 __IPVS_INFO_ATTR_MAX,
401};
402
403#define IPVS_INFO_ATTR_MAX (__IPVS_INFO_ATTR_MAX - 1)
404
405#endif /* _IP_VS_H */
diff --git a/include/linux/ipc_namespace.h b/include/linux/ipc_namespace.h
index ea6c18a8b0d4..ea330f9e7100 100644
--- a/include/linux/ipc_namespace.h
+++ b/include/linux/ipc_namespace.h
@@ -36,6 +36,7 @@ struct ipc_namespace {
36 int msg_ctlmni; 36 int msg_ctlmni;
37 atomic_t msg_bytes; 37 atomic_t msg_bytes;
38 atomic_t msg_hdrs; 38 atomic_t msg_hdrs;
39 int auto_msgmni;
39 40
40 size_t shm_ctlmax; 41 size_t shm_ctlmax;
41 size_t shm_ctlall; 42 size_t shm_ctlall;
@@ -53,7 +54,7 @@ extern atomic_t nr_ipc_ns;
53 54
54extern int register_ipcns_notifier(struct ipc_namespace *); 55extern int register_ipcns_notifier(struct ipc_namespace *);
55extern int cond_register_ipcns_notifier(struct ipc_namespace *); 56extern int cond_register_ipcns_notifier(struct ipc_namespace *);
56extern int unregister_ipcns_notifier(struct ipc_namespace *); 57extern void unregister_ipcns_notifier(struct ipc_namespace *);
57extern int ipcns_notify(unsigned long); 58extern int ipcns_notify(unsigned long);
58 59
59#else /* CONFIG_SYSVIPC */ 60#else /* CONFIG_SYSVIPC */
diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h
index cde056e08181..641e026eee8f 100644
--- a/include/linux/ipv6.h
+++ b/include/linux/ipv6.h
@@ -123,6 +123,7 @@ struct ipv6hdr {
123 struct in6_addr daddr; 123 struct in6_addr daddr;
124}; 124};
125 125
126#ifdef __KERNEL__
126/* 127/*
127 * This structure contains configuration options per IPv6 link. 128 * This structure contains configuration options per IPv6 link.
128 */ 129 */
@@ -163,8 +164,11 @@ struct ipv6_devconf {
163#ifdef CONFIG_IPV6_MROUTE 164#ifdef CONFIG_IPV6_MROUTE
164 __s32 mc_forwarding; 165 __s32 mc_forwarding;
165#endif 166#endif
167 __s32 disable_ipv6;
168 __s32 accept_dad;
166 void *sysctl; 169 void *sysctl;
167}; 170};
171#endif
168 172
169/* index values for the variables in ipv6_devconf */ 173/* index values for the variables in ipv6_devconf */
170enum { 174enum {
@@ -194,6 +198,8 @@ enum {
194 DEVCONF_OPTIMISTIC_DAD, 198 DEVCONF_OPTIMISTIC_DAD,
195 DEVCONF_ACCEPT_SOURCE_ROUTE, 199 DEVCONF_ACCEPT_SOURCE_ROUTE,
196 DEVCONF_MC_FORWARDING, 200 DEVCONF_MC_FORWARDING,
201 DEVCONF_DISABLE_IPV6,
202 DEVCONF_ACCEPT_DAD,
197 DEVCONF_MAX 203 DEVCONF_MAX
198}; 204};
199 205
diff --git a/include/linux/irq.h b/include/linux/irq.h
index 8ccb462ea42c..d058c57be02d 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -18,6 +18,7 @@
18#include <linux/spinlock.h> 18#include <linux/spinlock.h>
19#include <linux/cpumask.h> 19#include <linux/cpumask.h>
20#include <linux/irqreturn.h> 20#include <linux/irqreturn.h>
21#include <linux/irqnr.h>
21#include <linux/errno.h> 22#include <linux/errno.h>
22 23
23#include <asm/irq.h> 24#include <asm/irq.h>
@@ -62,6 +63,7 @@ typedef void (*irq_flow_handler_t)(unsigned int irq,
62#define IRQ_MOVE_PENDING 0x00200000 /* need to re-target IRQ destination */ 63#define IRQ_MOVE_PENDING 0x00200000 /* need to re-target IRQ destination */
63#define IRQ_NO_BALANCING 0x00400000 /* IRQ is excluded from balancing */ 64#define IRQ_NO_BALANCING 0x00400000 /* IRQ is excluded from balancing */
64#define IRQ_SPURIOUS_DISABLED 0x00800000 /* IRQ was disabled by the spurious trap */ 65#define IRQ_SPURIOUS_DISABLED 0x00800000 /* IRQ was disabled by the spurious trap */
66#define IRQ_MOVE_PCNTXT 0x01000000 /* IRQ migration from process context */
65 67
66#ifdef CONFIG_IRQ_PER_CPU 68#ifdef CONFIG_IRQ_PER_CPU
67# define CHECK_IRQ_PER_CPU(var) ((var) & IRQ_PER_CPU) 69# define CHECK_IRQ_PER_CPU(var) ((var) & IRQ_PER_CPU)
@@ -151,6 +153,7 @@ struct irq_chip {
151 * @name: flow handler name for /proc/interrupts output 153 * @name: flow handler name for /proc/interrupts output
152 */ 154 */
153struct irq_desc { 155struct irq_desc {
156 unsigned int irq;
154 irq_flow_handler_t handle_irq; 157 irq_flow_handler_t handle_irq;
155 struct irq_chip *chip; 158 struct irq_chip *chip;
156 struct msi_desc *msi_desc; 159 struct msi_desc *msi_desc;
@@ -169,7 +172,7 @@ struct irq_desc {
169 cpumask_t affinity; 172 cpumask_t affinity;
170 unsigned int cpu; 173 unsigned int cpu;
171#endif 174#endif
172#if defined(CONFIG_GENERIC_PENDING_IRQ) || defined(CONFIG_IRQBALANCE) 175#ifdef CONFIG_GENERIC_PENDING_IRQ
173 cpumask_t pending_mask; 176 cpumask_t pending_mask;
174#endif 177#endif
175#ifdef CONFIG_PROC_FS 178#ifdef CONFIG_PROC_FS
@@ -178,8 +181,14 @@ struct irq_desc {
178 const char *name; 181 const char *name;
179} ____cacheline_internodealigned_in_smp; 182} ____cacheline_internodealigned_in_smp;
180 183
184
181extern struct irq_desc irq_desc[NR_IRQS]; 185extern struct irq_desc irq_desc[NR_IRQS];
182 186
187static inline struct irq_desc *irq_to_desc(unsigned int irq)
188{
189 return (irq < nr_irqs) ? irq_desc + irq : NULL;
190}
191
183/* 192/*
184 * Migration helpers for obsolete names, they will go away: 193 * Migration helpers for obsolete names, they will go away:
185 */ 194 */
@@ -197,19 +206,15 @@ extern int setup_irq(unsigned int irq, struct irqaction *new);
197 206
198#ifdef CONFIG_GENERIC_HARDIRQS 207#ifdef CONFIG_GENERIC_HARDIRQS
199 208
200#ifndef handle_dynamic_tick
201# define handle_dynamic_tick(a) do { } while (0)
202#endif
203
204#ifdef CONFIG_SMP 209#ifdef CONFIG_SMP
205 210
206#if defined(CONFIG_GENERIC_PENDING_IRQ) || defined(CONFIG_IRQBALANCE) 211#ifdef CONFIG_GENERIC_PENDING_IRQ
207 212
208void set_pending_irq(unsigned int irq, cpumask_t mask); 213void set_pending_irq(unsigned int irq, cpumask_t mask);
209void move_native_irq(int irq); 214void move_native_irq(int irq);
210void move_masked_irq(int irq); 215void move_masked_irq(int irq);
211 216
212#else /* CONFIG_GENERIC_PENDING_IRQ || CONFIG_IRQBALANCE */ 217#else /* CONFIG_GENERIC_PENDING_IRQ */
213 218
214static inline void move_irq(int irq) 219static inline void move_irq(int irq)
215{ 220{
@@ -236,19 +241,14 @@ static inline void set_pending_irq(unsigned int irq, cpumask_t mask)
236 241
237#endif /* CONFIG_SMP */ 242#endif /* CONFIG_SMP */
238 243
239#ifdef CONFIG_IRQBALANCE
240extern void set_balance_irq_affinity(unsigned int irq, cpumask_t mask);
241#else
242static inline void set_balance_irq_affinity(unsigned int irq, cpumask_t mask)
243{
244}
245#endif
246
247extern int no_irq_affinity; 244extern int no_irq_affinity;
248 245
249static inline int irq_balancing_disabled(unsigned int irq) 246static inline int irq_balancing_disabled(unsigned int irq)
250{ 247{
251 return irq_desc[irq].status & IRQ_NO_BALANCING_MASK; 248 struct irq_desc *desc;
249
250 desc = irq_to_desc(irq);
251 return desc->status & IRQ_NO_BALANCING_MASK;
252} 252}
253 253
254/* Handle irq action chains: */ 254/* Handle irq action chains: */
@@ -278,10 +278,8 @@ extern unsigned int __do_IRQ(unsigned int irq);
278 * irqchip-style controller then we call the ->handle_irq() handler, 278 * irqchip-style controller then we call the ->handle_irq() handler,
279 * and it calls __do_IRQ() if it's attached to an irqtype-style controller. 279 * and it calls __do_IRQ() if it's attached to an irqtype-style controller.
280 */ 280 */
281static inline void generic_handle_irq(unsigned int irq) 281static inline void generic_handle_irq_desc(unsigned int irq, struct irq_desc *desc)
282{ 282{
283 struct irq_desc *desc = irq_desc + irq;
284
285#ifdef CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ 283#ifdef CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ
286 desc->handle_irq(irq, desc); 284 desc->handle_irq(irq, desc);
287#else 285#else
@@ -292,6 +290,11 @@ static inline void generic_handle_irq(unsigned int irq)
292#endif 290#endif
293} 291}
294 292
293static inline void generic_handle_irq(unsigned int irq)
294{
295 generic_handle_irq_desc(irq, irq_to_desc(irq));
296}
297
295/* Handling of unhandled and spurious interrupts: */ 298/* Handling of unhandled and spurious interrupts: */
296extern void note_interrupt(unsigned int irq, struct irq_desc *desc, 299extern void note_interrupt(unsigned int irq, struct irq_desc *desc,
297 int action_ret); 300 int action_ret);
@@ -324,7 +327,10 @@ __set_irq_handler(unsigned int irq, irq_flow_handler_t handle, int is_chained,
324static inline void __set_irq_handler_unlocked(int irq, 327static inline void __set_irq_handler_unlocked(int irq,
325 irq_flow_handler_t handler) 328 irq_flow_handler_t handler)
326{ 329{
327 irq_desc[irq].handle_irq = handler; 330 struct irq_desc *desc;
331
332 desc = irq_to_desc(irq);
333 desc->handle_irq = handler;
328} 334}
329 335
330/* 336/*
@@ -352,13 +358,14 @@ extern void set_irq_noprobe(unsigned int irq);
352extern void set_irq_probe(unsigned int irq); 358extern void set_irq_probe(unsigned int irq);
353 359
354/* Handle dynamic irq creation and destruction */ 360/* Handle dynamic irq creation and destruction */
361extern unsigned int create_irq_nr(unsigned int irq_want);
355extern int create_irq(void); 362extern int create_irq(void);
356extern void destroy_irq(unsigned int irq); 363extern void destroy_irq(unsigned int irq);
357 364
358/* Test to see if a driver has successfully requested an irq */ 365/* Test to see if a driver has successfully requested an irq */
359static inline int irq_has_action(unsigned int irq) 366static inline int irq_has_action(unsigned int irq)
360{ 367{
361 struct irq_desc *desc = irq_desc + irq; 368 struct irq_desc *desc = irq_to_desc(irq);
362 return desc->action != NULL; 369 return desc->action != NULL;
363} 370}
364 371
@@ -373,10 +380,10 @@ extern int set_irq_chip_data(unsigned int irq, void *data);
373extern int set_irq_type(unsigned int irq, unsigned int type); 380extern int set_irq_type(unsigned int irq, unsigned int type);
374extern int set_irq_msi(unsigned int irq, struct msi_desc *entry); 381extern int set_irq_msi(unsigned int irq, struct msi_desc *entry);
375 382
376#define get_irq_chip(irq) (irq_desc[irq].chip) 383#define get_irq_chip(irq) (irq_to_desc(irq)->chip)
377#define get_irq_chip_data(irq) (irq_desc[irq].chip_data) 384#define get_irq_chip_data(irq) (irq_to_desc(irq)->chip_data)
378#define get_irq_data(irq) (irq_desc[irq].handler_data) 385#define get_irq_data(irq) (irq_to_desc(irq)->handler_data)
379#define get_irq_msi(irq) (irq_desc[irq].msi_desc) 386#define get_irq_msi(irq) (irq_to_desc(irq)->msi_desc)
380 387
381#endif /* CONFIG_GENERIC_HARDIRQS */ 388#endif /* CONFIG_GENERIC_HARDIRQS */
382 389
diff --git a/include/linux/irqflags.h b/include/linux/irqflags.h
index 2b1c2e58566e..74bde13224c9 100644
--- a/include/linux/irqflags.h
+++ b/include/linux/irqflags.h
@@ -11,6 +11,8 @@
11#ifndef _LINUX_TRACE_IRQFLAGS_H 11#ifndef _LINUX_TRACE_IRQFLAGS_H
12#define _LINUX_TRACE_IRQFLAGS_H 12#define _LINUX_TRACE_IRQFLAGS_H
13 13
14#include <linux/typecheck.h>
15
14#ifdef CONFIG_TRACE_IRQFLAGS 16#ifdef CONFIG_TRACE_IRQFLAGS
15 extern void trace_softirqs_on(unsigned long ip); 17 extern void trace_softirqs_on(unsigned long ip);
16 extern void trace_softirqs_off(unsigned long ip); 18 extern void trace_softirqs_off(unsigned long ip);
@@ -58,18 +60,24 @@
58 do { trace_hardirqs_on(); raw_local_irq_enable(); } while (0) 60 do { trace_hardirqs_on(); raw_local_irq_enable(); } while (0)
59#define local_irq_disable() \ 61#define local_irq_disable() \
60 do { raw_local_irq_disable(); trace_hardirqs_off(); } while (0) 62 do { raw_local_irq_disable(); trace_hardirqs_off(); } while (0)
61#define local_irq_save(flags) \ 63#define local_irq_save(flags) \
62 do { raw_local_irq_save(flags); trace_hardirqs_off(); } while (0) 64 do { \
65 typecheck(unsigned long, flags); \
66 raw_local_irq_save(flags); \
67 trace_hardirqs_off(); \
68 } while (0)
63 69
64#define local_irq_restore(flags) \ 70
65 do { \ 71#define local_irq_restore(flags) \
66 if (raw_irqs_disabled_flags(flags)) { \ 72 do { \
67 raw_local_irq_restore(flags); \ 73 typecheck(unsigned long, flags); \
68 trace_hardirqs_off(); \ 74 if (raw_irqs_disabled_flags(flags)) { \
69 } else { \ 75 raw_local_irq_restore(flags); \
70 trace_hardirqs_on(); \ 76 trace_hardirqs_off(); \
71 raw_local_irq_restore(flags); \ 77 } else { \
72 } \ 78 trace_hardirqs_on(); \
79 raw_local_irq_restore(flags); \
80 } \
73 } while (0) 81 } while (0)
74#else /* !CONFIG_TRACE_IRQFLAGS_SUPPORT */ 82#else /* !CONFIG_TRACE_IRQFLAGS_SUPPORT */
75/* 83/*
@@ -78,8 +86,16 @@
78 */ 86 */
79# define raw_local_irq_disable() local_irq_disable() 87# define raw_local_irq_disable() local_irq_disable()
80# define raw_local_irq_enable() local_irq_enable() 88# define raw_local_irq_enable() local_irq_enable()
81# define raw_local_irq_save(flags) local_irq_save(flags) 89# define raw_local_irq_save(flags) \
82# define raw_local_irq_restore(flags) local_irq_restore(flags) 90 do { \
91 typecheck(unsigned long, flags); \
92 local_irq_save(flags); \
93 } while (0)
94# define raw_local_irq_restore(flags) \
95 do { \
96 typecheck(unsigned long, flags); \
97 local_irq_restore(flags); \
98 } while (0)
83#endif /* CONFIG_TRACE_IRQFLAGS_SUPPORT */ 99#endif /* CONFIG_TRACE_IRQFLAGS_SUPPORT */
84 100
85#ifdef CONFIG_TRACE_IRQFLAGS_SUPPORT 101#ifdef CONFIG_TRACE_IRQFLAGS_SUPPORT
@@ -89,7 +105,11 @@
89 raw_safe_halt(); \ 105 raw_safe_halt(); \
90 } while (0) 106 } while (0)
91 107
92#define local_save_flags(flags) raw_local_save_flags(flags) 108#define local_save_flags(flags) \
109 do { \
110 typecheck(unsigned long, flags); \
111 raw_local_save_flags(flags); \
112 } while (0)
93 113
94#define irqs_disabled() \ 114#define irqs_disabled() \
95({ \ 115({ \
@@ -99,7 +119,11 @@
99 raw_irqs_disabled_flags(_flags); \ 119 raw_irqs_disabled_flags(_flags); \
100}) 120})
101 121
102#define irqs_disabled_flags(flags) raw_irqs_disabled_flags(flags) 122#define irqs_disabled_flags(flags) \
123({ \
124 typecheck(unsigned long, flags); \
125 raw_irqs_disabled_flags(flags); \
126})
103#endif /* CONFIG_X86 */ 127#endif /* CONFIG_X86 */
104 128
105#endif 129#endif
diff --git a/include/linux/irqnr.h b/include/linux/irqnr.h
new file mode 100644
index 000000000000..452c280c8115
--- /dev/null
+++ b/include/linux/irqnr.h
@@ -0,0 +1,24 @@
1#ifndef _LINUX_IRQNR_H
2#define _LINUX_IRQNR_H
3
4#ifndef CONFIG_GENERIC_HARDIRQS
5#include <asm/irq.h>
6# define nr_irqs NR_IRQS
7
8# define for_each_irq_desc(irq, desc) \
9 for (irq = 0; irq < nr_irqs; irq++)
10#else
11extern int nr_irqs;
12
13# define for_each_irq_desc(irq, desc) \
14 for (irq = 0, desc = irq_desc; irq < nr_irqs; irq++, desc++)
15
16# define for_each_irq_desc_reverse(irq, desc) \
17 for (irq = nr_irqs - 1, desc = irq_desc + (nr_irqs - 1); \
18 irq >= 0; irq--, desc--)
19#endif
20
21#define for_each_irq_nr(irq) \
22 for (irq = 0; irq < nr_irqs; irq++)
23
24#endif
diff --git a/include/linux/isdn_ppp.h b/include/linux/isdn_ppp.h
index 8687a7dc0632..4c218ee7587a 100644
--- a/include/linux/isdn_ppp.h
+++ b/include/linux/isdn_ppp.h
@@ -157,7 +157,7 @@ typedef struct {
157 157
158typedef struct { 158typedef struct {
159 int mp_mrru; /* unused */ 159 int mp_mrru; /* unused */
160 struct sk_buff * frags; /* fragments sl list -- use skb->next */ 160 struct sk_buff_head frags; /* fragments sl list */
161 long frames; /* number of frames in the frame list */ 161 long frames; /* number of frames in the frame list */
162 unsigned int seq; /* last processed packet seq #: any packets 162 unsigned int seq; /* last processed packet seq #: any packets
163 * with smaller seq # will be dropped 163 * with smaller seq # will be dropped
diff --git a/include/linux/istallion.h b/include/linux/istallion.h
index 5a84fe944b74..0d1840723249 100644
--- a/include/linux/istallion.h
+++ b/include/linux/istallion.h
@@ -51,25 +51,21 @@
51 */ 51 */
52struct stliport { 52struct stliport {
53 unsigned long magic; 53 unsigned long magic;
54 struct tty_port port;
54 unsigned int portnr; 55 unsigned int portnr;
55 unsigned int panelnr; 56 unsigned int panelnr;
56 unsigned int brdnr; 57 unsigned int brdnr;
57 unsigned long state; 58 unsigned long state;
58 unsigned int devnr; 59 unsigned int devnr;
59 int flags;
60 int baud_base; 60 int baud_base;
61 int custom_divisor; 61 int custom_divisor;
62 int close_delay; 62 int close_delay;
63 int closing_wait; 63 int closing_wait;
64 int refcount;
65 int openwaitcnt; 64 int openwaitcnt;
66 int rc; 65 int rc;
67 int argsize; 66 int argsize;
68 void *argp; 67 void *argp;
69 unsigned int rxmarkmsk; 68 unsigned int rxmarkmsk;
70 struct tty_struct *tty;
71 wait_queue_head_t open_wait;
72 wait_queue_head_t close_wait;
73 wait_queue_head_t raw_wait; 69 wait_queue_head_t raw_wait;
74 struct asysigs asig; 70 struct asysigs asig;
75 unsigned long addr; 71 unsigned long addr;
diff --git a/include/linux/ivtv.h b/include/linux/ivtv.h
index 794b8daa9378..f2720280b9ec 100644
--- a/include/linux/ivtv.h
+++ b/include/linux/ivtv.h
@@ -21,12 +21,9 @@
21#ifndef __LINUX_IVTV_H__ 21#ifndef __LINUX_IVTV_H__
22#define __LINUX_IVTV_H__ 22#define __LINUX_IVTV_H__
23 23
24#ifdef __KERNEL__ 24#include <linux/compiler.h>
25#include <linux/compiler.h> /* need __user */
26#else
27#define __user
28#endif
29#include <linux/types.h> 25#include <linux/types.h>
26#include <linux/videodev2.h>
30 27
31/* ivtv knows several distinct output modes: MPEG streaming, 28/* ivtv knows several distinct output modes: MPEG streaming,
32 YUV streaming, YUV updates through user DMA and the passthrough 29 YUV streaming, YUV updates through user DMA and the passthrough
diff --git a/include/linux/ivtvfb.h b/include/linux/ivtvfb.h
index e980ba62ddcc..e20af47b59ad 100644
--- a/include/linux/ivtvfb.h
+++ b/include/linux/ivtvfb.h
@@ -21,11 +21,7 @@
21#ifndef __LINUX_IVTVFB_H__ 21#ifndef __LINUX_IVTVFB_H__
22#define __LINUX_IVTVFB_H__ 22#define __LINUX_IVTVFB_H__
23 23
24#ifdef __KERNEL__ 24#include <linux/compiler.h>
25#include <linux/compiler.h> /* need __user */
26#else
27#define __user
28#endif
29#include <linux/types.h> 25#include <linux/types.h>
30 26
31/* Framebuffer external API */ 27/* Framebuffer external API */
diff --git a/include/linux/jbd.h b/include/linux/jbd.h
index 07a9b52a2654..346e2b80be7d 100644
--- a/include/linux/jbd.h
+++ b/include/linux/jbd.h
@@ -61,7 +61,7 @@ extern u8 journal_enable_debug;
61 do { \ 61 do { \
62 if ((n) <= journal_enable_debug) { \ 62 if ((n) <= journal_enable_debug) { \
63 printk (KERN_DEBUG "(%s, %d): %s: ", \ 63 printk (KERN_DEBUG "(%s, %d): %s: ", \
64 __FILE__, __LINE__, __FUNCTION__); \ 64 __FILE__, __LINE__, __func__); \
65 printk (f, ## a); \ 65 printk (f, ## a); \
66 } \ 66 } \
67 } while (0) 67 } while (0)
@@ -816,6 +816,9 @@ struct journal_s
816#define JFS_FLUSHED 0x008 /* The journal superblock has been flushed */ 816#define JFS_FLUSHED 0x008 /* The journal superblock has been flushed */
817#define JFS_LOADED 0x010 /* The journal superblock has been loaded */ 817#define JFS_LOADED 0x010 /* The journal superblock has been loaded */
818#define JFS_BARRIER 0x020 /* Use IDE barriers */ 818#define JFS_BARRIER 0x020 /* Use IDE barriers */
819#define JFS_ABORT_ON_SYNCDATA_ERR 0x040 /* Abort the journal on file
820 * data write error in ordered
821 * mode */
819 822
820/* 823/*
821 * Function declarations for the journaling transaction and buffer 824 * Function declarations for the journaling transaction and buffer
@@ -908,7 +911,7 @@ extern int journal_set_features
908 (journal_t *, unsigned long, unsigned long, unsigned long); 911 (journal_t *, unsigned long, unsigned long, unsigned long);
909extern int journal_create (journal_t *); 912extern int journal_create (journal_t *);
910extern int journal_load (journal_t *journal); 913extern int journal_load (journal_t *journal);
911extern void journal_destroy (journal_t *); 914extern int journal_destroy (journal_t *);
912extern int journal_recover (journal_t *journal); 915extern int journal_recover (journal_t *journal);
913extern int journal_wipe (journal_t *, int); 916extern int journal_wipe (journal_t *, int);
914extern int journal_skip_recovery (journal_t *); 917extern int journal_skip_recovery (journal_t *);
@@ -984,7 +987,7 @@ extern int cleanup_journal_tail(journal_t *);
984 987
985#define jbd_ENOSYS() \ 988#define jbd_ENOSYS() \
986do { \ 989do { \
987 printk (KERN_ERR "JBD unimplemented function %s\n", __FUNCTION__); \ 990 printk (KERN_ERR "JBD unimplemented function %s\n", __func__); \
988 current->state = TASK_UNINTERRUPTIBLE; \ 991 current->state = TASK_UNINTERRUPTIBLE; \
989 schedule(); \ 992 schedule(); \
990} while (1) 993} while (1)
diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h
index 3dd209007098..c7d106ef22e2 100644
--- a/include/linux/jbd2.h
+++ b/include/linux/jbd2.h
@@ -61,7 +61,7 @@ extern u8 jbd2_journal_enable_debug;
61 do { \ 61 do { \
62 if ((n) <= jbd2_journal_enable_debug) { \ 62 if ((n) <= jbd2_journal_enable_debug) { \
63 printk (KERN_DEBUG "(%s, %d): %s: ", \ 63 printk (KERN_DEBUG "(%s, %d): %s: ", \
64 __FILE__, __LINE__, __FUNCTION__); \ 64 __FILE__, __LINE__, __func__); \
65 printk (f, ## a); \ 65 printk (f, ## a); \
66 } \ 66 } \
67 } while (0) 67 } while (0)
@@ -641,6 +641,11 @@ struct transaction_s
641 */ 641 */
642 int t_handle_count; 642 int t_handle_count;
643 643
644 /*
645 * For use by the filesystem to store fs-specific data
646 * structures associated with the transaction
647 */
648 struct list_head t_private_list;
644}; 649};
645 650
646struct transaction_run_stats_s { 651struct transaction_run_stats_s {
@@ -850,7 +855,8 @@ struct journal_s
850 */ 855 */
851 struct block_device *j_dev; 856 struct block_device *j_dev;
852 int j_blocksize; 857 int j_blocksize;
853 unsigned long long j_blk_offset; 858 unsigned long long j_blk_offset;
859 char j_devname[BDEVNAME_SIZE+24];
854 860
855 /* 861 /*
856 * Device which holds the client fs. For internal journal this will be 862 * Device which holds the client fs. For internal journal this will be
@@ -934,6 +940,10 @@ struct journal_s
934 940
935 pid_t j_last_sync_writer; 941 pid_t j_last_sync_writer;
936 942
943 /* This function is called when a transaction is closed */
944 void (*j_commit_callback)(journal_t *,
945 transaction_t *);
946
937 /* 947 /*
938 * Journal statistics 948 * Journal statistics
939 */ 949 */
@@ -966,6 +976,9 @@ struct journal_s
966#define JBD2_FLUSHED 0x008 /* The journal superblock has been flushed */ 976#define JBD2_FLUSHED 0x008 /* The journal superblock has been flushed */
967#define JBD2_LOADED 0x010 /* The journal superblock has been loaded */ 977#define JBD2_LOADED 0x010 /* The journal superblock has been loaded */
968#define JBD2_BARRIER 0x020 /* Use IDE barriers */ 978#define JBD2_BARRIER 0x020 /* Use IDE barriers */
979#define JBD2_ABORT_ON_SYNCDATA_ERR 0x040 /* Abort the journal on file
980 * data write error in ordered
981 * mode */
969 982
970/* 983/*
971 * Function declarations for the journaling transaction and buffer 984 * Function declarations for the journaling transaction and buffer
@@ -1059,7 +1072,7 @@ extern void jbd2_journal_clear_features
1059 (journal_t *, unsigned long, unsigned long, unsigned long); 1072 (journal_t *, unsigned long, unsigned long, unsigned long);
1060extern int jbd2_journal_create (journal_t *); 1073extern int jbd2_journal_create (journal_t *);
1061extern int jbd2_journal_load (journal_t *journal); 1074extern int jbd2_journal_load (journal_t *journal);
1062extern void jbd2_journal_destroy (journal_t *); 1075extern int jbd2_journal_destroy (journal_t *);
1063extern int jbd2_journal_recover (journal_t *journal); 1076extern int jbd2_journal_recover (journal_t *journal);
1064extern int jbd2_journal_wipe (journal_t *, int); 1077extern int jbd2_journal_wipe (journal_t *, int);
1065extern int jbd2_journal_skip_recovery (journal_t *); 1078extern int jbd2_journal_skip_recovery (journal_t *);
@@ -1139,7 +1152,7 @@ extern int jbd2_cleanup_journal_tail(journal_t *);
1139 1152
1140#define jbd_ENOSYS() \ 1153#define jbd_ENOSYS() \
1141do { \ 1154do { \
1142 printk (KERN_ERR "JBD unimplemented function %s\n", __FUNCTION__); \ 1155 printk (KERN_ERR "JBD unimplemented function %s\n", __func__); \
1143 current->state = TASK_UNINTERRUPTIBLE; \ 1156 current->state = TASK_UNINTERRUPTIBLE; \
1144 schedule(); \ 1157 schedule(); \
1145} while (1) 1158} while (1)
diff --git a/include/linux/jffs2.h b/include/linux/jffs2.h
index 6b563cae23df..da720bc3eb15 100644
--- a/include/linux/jffs2.h
+++ b/include/linux/jffs2.h
@@ -7,9 +7,6 @@
7 * 7 *
8 * For licensing information, see the file 'LICENCE' in the 8 * For licensing information, see the file 'LICENCE' in the
9 * jffs2 directory. 9 * jffs2 directory.
10 *
11 * $Id: jffs2.h,v 1.38 2005/09/26 11:37:23 havasi Exp $
12 *
13 */ 10 */
14 11
15#ifndef __LINUX_JFFS2_H__ 12#ifndef __LINUX_JFFS2_H__
diff --git a/include/linux/journal-head.h b/include/linux/journal-head.h
index 8a62d1e84b9b..bb70ebb6a2d5 100644
--- a/include/linux/journal-head.h
+++ b/include/linux/journal-head.h
@@ -3,7 +3,7 @@
3 * 3 *
4 * buffer_head fields for JBD 4 * buffer_head fields for JBD
5 * 5 *
6 * 27 May 2001 Andrew Morton <akpm@digeo.com> 6 * 27 May 2001 Andrew Morton
7 * Created - pulled out of fs.h 7 * Created - pulled out of fs.h
8 */ 8 */
9 9
diff --git a/include/linux/joystick.h b/include/linux/joystick.h
index e2d3a18af456..b5e051295a67 100644
--- a/include/linux/joystick.h
+++ b/include/linux/joystick.h
@@ -2,8 +2,6 @@
2#define _LINUX_JOYSTICK_H 2#define _LINUX_JOYSTICK_H
3 3
4/* 4/*
5 * $Id: joystick.h,v 1.3 2000/11/30 11:07:05 vojtech Exp $
6 *
7 * Copyright (C) 1996-2000 Vojtech Pavlik 5 * Copyright (C) 1996-2000 Vojtech Pavlik
8 * 6 *
9 * Sponsored by SuSE 7 * Sponsored by SuSE
diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
index 00c1801099fa..f3fe34391d8e 100644
--- a/include/linux/kallsyms.h
+++ b/include/linux/kallsyms.h
@@ -6,6 +6,7 @@
6#define _LINUX_KALLSYMS_H 6#define _LINUX_KALLSYMS_H
7 7
8#include <linux/errno.h> 8#include <linux/errno.h>
9#include <linux/kernel.h>
9#include <linux/stddef.h> 10#include <linux/stddef.h>
10 11
11#define KSYM_NAME_LEN 128 12#define KSYM_NAME_LEN 128
@@ -92,12 +93,10 @@ static inline void print_symbol(const char *fmt, unsigned long addr)
92} 93}
93 94
94/* 95/*
95 * Pretty-print a function pointer. 96 * Pretty-print a function pointer. This function is deprecated.
96 * 97 * Please use the "%pF" vsprintf format instead.
97 * ia64 and ppc64 function pointers are really function descriptors,
98 * which contain a pointer the real address.
99 */ 98 */
100static inline void print_fn_descriptor_symbol(const char *fmt, void *addr) 99static inline void __deprecated print_fn_descriptor_symbol(const char *fmt, void *addr)
101{ 100{
102#if defined(CONFIG_IA64) || defined(CONFIG_PPC64) 101#if defined(CONFIG_IA64) || defined(CONFIG_PPC64)
103 addr = *(void **)addr; 102 addr = *(void **)addr;
@@ -105,18 +104,9 @@ static inline void print_fn_descriptor_symbol(const char *fmt, void *addr)
105 print_symbol(fmt, (unsigned long)addr); 104 print_symbol(fmt, (unsigned long)addr);
106} 105}
107 106
108#ifndef CONFIG_64BIT 107static inline void print_ip_sym(unsigned long ip)
109#define print_ip_sym(ip) \ 108{
110do { \ 109 printk("[<%p>] %pS\n", (void *) ip, (void *) ip);
111 printk("[<%08lx>]", ip); \ 110}
112 print_symbol(" %s\n", ip); \
113} while(0)
114#else
115#define print_ip_sym(ip) \
116do { \
117 printk("[<%016lx>]", ip); \
118 print_symbol(" %s\n", ip); \
119} while(0)
120#endif
121 111
122#endif /*_LINUX_KALLSYMS_H*/ 112#endif /*_LINUX_KALLSYMS_H*/
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index f9cd7a513f9c..396a350b87a6 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -14,6 +14,9 @@
14#include <linux/compiler.h> 14#include <linux/compiler.h>
15#include <linux/bitops.h> 15#include <linux/bitops.h>
16#include <linux/log2.h> 16#include <linux/log2.h>
17#include <linux/typecheck.h>
18#include <linux/ratelimit.h>
19#include <linux/dynamic_printk.h>
17#include <asm/byteorder.h> 20#include <asm/byteorder.h>
18#include <asm/bug.h> 21#include <asm/bug.h>
19 22
@@ -73,6 +76,12 @@ extern const char linux_proc_banner[];
73 */ 76 */
74#define upper_32_bits(n) ((u32)(((n) >> 16) >> 16)) 77#define upper_32_bits(n) ((u32)(((n) >> 16) >> 16))
75 78
79/**
80 * lower_32_bits - return bits 0-31 of a number
81 * @n: the number we're accessing
82 */
83#define lower_32_bits(n) ((u32)(n))
84
76#define KERN_EMERG "<0>" /* system is unusable */ 85#define KERN_EMERG "<0>" /* system is unusable */
77#define KERN_ALERT "<1>" /* action must be taken immediately */ 86#define KERN_ALERT "<1>" /* action must be taken immediately */
78#define KERN_CRIT "<2>" /* critical conditions */ 87#define KERN_CRIT "<2>" /* critical conditions */
@@ -100,6 +109,13 @@ struct completion;
100struct pt_regs; 109struct pt_regs;
101struct user; 110struct user;
102 111
112#ifdef CONFIG_PREEMPT_VOLUNTARY
113extern int _cond_resched(void);
114# define might_resched() _cond_resched()
115#else
116# define might_resched() do { } while (0)
117#endif
118
103/** 119/**
104 * might_sleep - annotation for functions that can sleep 120 * might_sleep - annotation for functions that can sleep
105 * 121 *
@@ -110,13 +126,6 @@ struct user;
110 * be bitten later when the calling function happens to sleep when it is not 126 * be bitten later when the calling function happens to sleep when it is not
111 * supposed to. 127 * supposed to.
112 */ 128 */
113#ifdef CONFIG_PREEMPT_VOLUNTARY
114extern int _cond_resched(void);
115# define might_resched() _cond_resched()
116#else
117# define might_resched() do { } while (0)
118#endif
119
120#ifdef CONFIG_DEBUG_SPINLOCK_SLEEP 129#ifdef CONFIG_DEBUG_SPINLOCK_SLEEP
121 void __might_sleep(char *file, int line); 130 void __might_sleep(char *file, int line);
122# define might_sleep() \ 131# define might_sleep() \
@@ -174,7 +183,7 @@ extern int vsscanf(const char *, const char *, va_list)
174 183
175extern int get_option(char **str, int *pint); 184extern int get_option(char **str, int *pint);
176extern char *get_options(const char *str, int nints, int *ints); 185extern char *get_options(const char *str, int nints, int *ints);
177extern unsigned long long memparse(char *ptr, char **retptr); 186extern unsigned long long memparse(const char *ptr, char **retptr);
178 187
179extern int core_kernel_text(unsigned long addr); 188extern int core_kernel_text(unsigned long addr);
180extern int __kernel_text_address(unsigned long addr); 189extern int __kernel_text_address(unsigned long addr);
@@ -182,17 +191,38 @@ extern int kernel_text_address(unsigned long addr);
182struct pid; 191struct pid;
183extern struct pid *session_of_pgrp(struct pid *pgrp); 192extern struct pid *session_of_pgrp(struct pid *pgrp);
184 193
194/*
195 * FW_BUG
196 * Add this to a message where you are sure the firmware is buggy or behaves
197 * really stupid or out of spec. Be aware that the responsible BIOS developer
198 * should be able to fix this issue or at least get a concrete idea of the
199 * problem by reading your message without the need of looking at the kernel
200 * code.
201 *
202 * Use it for definite and high priority BIOS bugs.
203 *
204 * FW_WARN
205 * Use it for not that clear (e.g. could the kernel messed up things already?)
206 * and medium priority BIOS bugs.
207 *
208 * FW_INFO
209 * Use this one if you want to tell the user or vendor about something
210 * suspicious, but generally harmless related to the firmware.
211 *
212 * Use it for information or very low priority BIOS bugs.
213 */
214#define FW_BUG "[Firmware Bug]: "
215#define FW_WARN "[Firmware Warn]: "
216#define FW_INFO "[Firmware Info]: "
217
185#ifdef CONFIG_PRINTK 218#ifdef CONFIG_PRINTK
186asmlinkage int vprintk(const char *fmt, va_list args) 219asmlinkage int vprintk(const char *fmt, va_list args)
187 __attribute__ ((format (printf, 1, 0))); 220 __attribute__ ((format (printf, 1, 0)));
188asmlinkage int printk(const char * fmt, ...) 221asmlinkage int printk(const char * fmt, ...)
189 __attribute__ ((format (printf, 1, 2))) __cold; 222 __attribute__ ((format (printf, 1, 2))) __cold;
190 223
191extern int printk_ratelimit_jiffies; 224extern struct ratelimit_state printk_ratelimit_state;
192extern int printk_ratelimit_burst;
193extern int printk_ratelimit(void); 225extern int printk_ratelimit(void);
194extern int __ratelimit(int ratelimit_jiffies, int ratelimit_burst);
195extern int __printk_ratelimit(int ratelimit_jiffies, int ratelimit_burst);
196extern bool printk_timed_ratelimit(unsigned long *caller_jiffies, 226extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
197 unsigned int interval_msec); 227 unsigned int interval_msec);
198#else 228#else
@@ -203,13 +233,14 @@ static inline int printk(const char *s, ...)
203 __attribute__ ((format (printf, 1, 2))); 233 __attribute__ ((format (printf, 1, 2)));
204static inline int __cold printk(const char *s, ...) { return 0; } 234static inline int __cold printk(const char *s, ...) { return 0; }
205static inline int printk_ratelimit(void) { return 0; } 235static inline int printk_ratelimit(void) { return 0; }
206static inline int __printk_ratelimit(int ratelimit_jiffies, \
207 int ratelimit_burst) { return 0; }
208static inline bool printk_timed_ratelimit(unsigned long *caller_jiffies, \ 236static inline bool printk_timed_ratelimit(unsigned long *caller_jiffies, \
209 unsigned int interval_msec) \ 237 unsigned int interval_msec) \
210 { return false; } 238 { return false; }
211#endif 239#endif
212 240
241extern int printk_needs_cpu(int cpu);
242extern void printk_tick(void);
243
213extern void asmlinkage __attribute__((format(printf, 1, 2))) 244extern void asmlinkage __attribute__((format(printf, 1, 2)))
214 early_printk(const char *fmt, ...); 245 early_printk(const char *fmt, ...);
215 246
@@ -232,9 +263,10 @@ extern int oops_in_progress; /* If set, an oops, panic(), BUG() or die() is in
232extern int panic_timeout; 263extern int panic_timeout;
233extern int panic_on_oops; 264extern int panic_on_oops;
234extern int panic_on_unrecovered_nmi; 265extern int panic_on_unrecovered_nmi;
235extern int tainted;
236extern const char *print_tainted(void); 266extern const char *print_tainted(void);
237extern void add_taint(unsigned); 267extern void add_taint(unsigned flag);
268extern int test_taint(unsigned flag);
269extern unsigned long get_taint(void);
238extern int root_mountflags; 270extern int root_mountflags;
239 271
240/* Values used for system_state */ 272/* Values used for system_state */
@@ -247,16 +279,17 @@ extern enum system_states {
247 SYSTEM_SUSPEND_DISK, 279 SYSTEM_SUSPEND_DISK,
248} system_state; 280} system_state;
249 281
250#define TAINT_PROPRIETARY_MODULE (1<<0) 282#define TAINT_PROPRIETARY_MODULE 0
251#define TAINT_FORCED_MODULE (1<<1) 283#define TAINT_FORCED_MODULE 1
252#define TAINT_UNSAFE_SMP (1<<2) 284#define TAINT_UNSAFE_SMP 2
253#define TAINT_FORCED_RMMOD (1<<3) 285#define TAINT_FORCED_RMMOD 3
254#define TAINT_MACHINE_CHECK (1<<4) 286#define TAINT_MACHINE_CHECK 4
255#define TAINT_BAD_PAGE (1<<5) 287#define TAINT_BAD_PAGE 5
256#define TAINT_USER (1<<6) 288#define TAINT_USER 6
257#define TAINT_DIE (1<<7) 289#define TAINT_DIE 7
258#define TAINT_OVERRIDDEN_ACPI_TABLE (1<<8) 290#define TAINT_OVERRIDDEN_ACPI_TABLE 8
259#define TAINT_WARN (1<<9) 291#define TAINT_WARN 9
292#define TAINT_CRAP 10
260 293
261extern void dump_stack(void) __cold; 294extern void dump_stack(void) __cold;
262 295
@@ -300,8 +333,12 @@ static inline char *pack_hex_byte(char *buf, u8 byte)
300#define pr_info(fmt, arg...) \ 333#define pr_info(fmt, arg...) \
301 printk(KERN_INFO fmt, ##arg) 334 printk(KERN_INFO fmt, ##arg)
302 335
303#ifdef DEBUG
304/* If you are writing a driver, please use dev_dbg instead */ 336/* If you are writing a driver, please use dev_dbg instead */
337#if defined(CONFIG_DYNAMIC_PRINTK_DEBUG)
338#define pr_debug(fmt, ...) do { \
339 dynamic_pr_debug(fmt, ##__VA_ARGS__); \
340 } while (0)
341#elif defined(DEBUG)
305#define pr_debug(fmt, arg...) \ 342#define pr_debug(fmt, arg...) \
306 printk(KERN_DEBUG fmt, ##arg) 343 printk(KERN_DEBUG fmt, ##arg)
307#else 344#else
@@ -441,26 +478,6 @@ static inline char *pack_hex_byte(char *buf, u8 byte)
441 const typeof( ((type *)0)->member ) *__mptr = (ptr); \ 478 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
442 (type *)( (char *)__mptr - offsetof(type,member) );}) 479 (type *)( (char *)__mptr - offsetof(type,member) );})
443 480
444/*
445 * Check at compile time that something is of a particular type.
446 * Always evaluates to 1 so you may use it easily in comparisons.
447 */
448#define typecheck(type,x) \
449({ type __dummy; \
450 typeof(x) __dummy2; \
451 (void)(&__dummy == &__dummy2); \
452 1; \
453})
454
455/*
456 * Check at compile time that 'function' is a certain type, or is a pointer
457 * to that type (needs to use typedef for the function type.)
458 */
459#define typecheck_fn(type,function) \
460({ typeof(type) __tmp = function; \
461 (void)__tmp; \
462})
463
464struct sysinfo; 481struct sysinfo;
465extern int do_sysinfo(struct sysinfo *info); 482extern int do_sysinfo(struct sysinfo *info);
466 483
@@ -503,4 +520,9 @@ struct sysinfo {
503#define NUMA_BUILD 0 520#define NUMA_BUILD 0
504#endif 521#endif
505 522
523/* Rebuild everything on CONFIG_FTRACE_MCOUNT_RECORD */
524#ifdef CONFIG_FTRACE_MCOUNT_RECORD
525# define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD
526#endif
527
506#endif 528#endif
diff --git a/include/linux/kernel_stat.h b/include/linux/kernel_stat.h
index cf9f40a91c9c..4a145caeee07 100644
--- a/include/linux/kernel_stat.h
+++ b/include/linux/kernel_stat.h
@@ -39,19 +39,34 @@ DECLARE_PER_CPU(struct kernel_stat, kstat);
39 39
40extern unsigned long long nr_context_switches(void); 40extern unsigned long long nr_context_switches(void);
41 41
42struct irq_desc;
43
44static inline void kstat_incr_irqs_this_cpu(unsigned int irq,
45 struct irq_desc *desc)
46{
47 kstat_this_cpu.irqs[irq]++;
48}
49
50static inline unsigned int kstat_irqs_cpu(unsigned int irq, int cpu)
51{
52 return kstat_cpu(cpu).irqs[irq];
53}
54
42/* 55/*
43 * Number of interrupts per specific IRQ source, since bootup 56 * Number of interrupts per specific IRQ source, since bootup
44 */ 57 */
45static inline int kstat_irqs(int irq) 58static inline unsigned int kstat_irqs(unsigned int irq)
46{ 59{
47 int cpu, sum = 0; 60 unsigned int sum = 0;
61 int cpu;
48 62
49 for_each_possible_cpu(cpu) 63 for_each_possible_cpu(cpu)
50 sum += kstat_cpu(cpu).irqs[irq]; 64 sum += kstat_irqs_cpu(irq, cpu);
51 65
52 return sum; 66 return sum;
53} 67}
54 68
69extern unsigned long long task_delta_exec(struct task_struct *);
55extern void account_user_time(struct task_struct *, cputime_t); 70extern void account_user_time(struct task_struct *, cputime_t);
56extern void account_user_time_scaled(struct task_struct *, cputime_t); 71extern void account_user_time_scaled(struct task_struct *, cputime_t);
57extern void account_system_time(struct task_struct *, int, cputime_t); 72extern void account_system_time(struct task_struct *, int, cputime_t);
diff --git a/include/linux/kexec.h b/include/linux/kexec.h
index 3265968cd2cd..17f76fc05173 100644
--- a/include/linux/kexec.h
+++ b/include/linux/kexec.h
@@ -25,8 +25,8 @@
25#error KEXEC_CONTROL_MEMORY_LIMIT not defined 25#error KEXEC_CONTROL_MEMORY_LIMIT not defined
26#endif 26#endif
27 27
28#ifndef KEXEC_CONTROL_CODE_SIZE 28#ifndef KEXEC_CONTROL_PAGE_SIZE
29#error KEXEC_CONTROL_CODE_SIZE not defined 29#error KEXEC_CONTROL_PAGE_SIZE not defined
30#endif 30#endif
31 31
32#ifndef KEXEC_ARCH 32#ifndef KEXEC_ARCH
@@ -83,6 +83,7 @@ struct kimage {
83 83
84 unsigned long start; 84 unsigned long start;
85 struct page *control_code_page; 85 struct page *control_code_page;
86 struct page *swap_page;
86 87
87 unsigned long nr_segments; 88 unsigned long nr_segments;
88 struct kexec_segment segment[KEXEC_SEGMENT_MAX]; 89 struct kexec_segment segment[KEXEC_SEGMENT_MAX];
@@ -98,18 +99,20 @@ struct kimage {
98 unsigned int type : 1; 99 unsigned int type : 1;
99#define KEXEC_TYPE_DEFAULT 0 100#define KEXEC_TYPE_DEFAULT 0
100#define KEXEC_TYPE_CRASH 1 101#define KEXEC_TYPE_CRASH 1
102 unsigned int preserve_context : 1;
101}; 103};
102 104
103 105
104 106
105/* kexec interface functions */ 107/* kexec interface functions */
106extern NORET_TYPE void machine_kexec(struct kimage *image) ATTRIB_NORET; 108extern void machine_kexec(struct kimage *image);
107extern int machine_kexec_prepare(struct kimage *image); 109extern int machine_kexec_prepare(struct kimage *image);
108extern void machine_kexec_cleanup(struct kimage *image); 110extern void machine_kexec_cleanup(struct kimage *image);
109extern asmlinkage long sys_kexec_load(unsigned long entry, 111extern asmlinkage long sys_kexec_load(unsigned long entry,
110 unsigned long nr_segments, 112 unsigned long nr_segments,
111 struct kexec_segment __user *segments, 113 struct kexec_segment __user *segments,
112 unsigned long flags); 114 unsigned long flags);
115extern int kernel_kexec(void);
113#ifdef CONFIG_COMPAT 116#ifdef CONFIG_COMPAT
114extern asmlinkage long compat_sys_kexec_load(unsigned long entry, 117extern asmlinkage long compat_sys_kexec_load(unsigned long entry,
115 unsigned long nr_segments, 118 unsigned long nr_segments,
@@ -127,8 +130,8 @@ void vmcoreinfo_append_str(const char *fmt, ...)
127 __attribute__ ((format (printf, 1, 2))); 130 __attribute__ ((format (printf, 1, 2)));
128unsigned long paddr_vmcoreinfo_note(void); 131unsigned long paddr_vmcoreinfo_note(void);
129 132
130#define VMCOREINFO_OSRELEASE(name) \ 133#define VMCOREINFO_OSRELEASE(value) \
131 vmcoreinfo_append_str("OSRELEASE=%s\n", #name) 134 vmcoreinfo_append_str("OSRELEASE=%s\n", value)
132#define VMCOREINFO_PAGESIZE(value) \ 135#define VMCOREINFO_PAGESIZE(value) \
133 vmcoreinfo_append_str("PAGESIZE=%ld\n", value) 136 vmcoreinfo_append_str("PAGESIZE=%ld\n", value)
134#define VMCOREINFO_SYMBOL(name) \ 137#define VMCOREINFO_SYMBOL(name) \
@@ -156,8 +159,9 @@ extern struct kimage *kexec_crash_image;
156#define kexec_flush_icache_page(page) 159#define kexec_flush_icache_page(page)
157#endif 160#endif
158 161
159#define KEXEC_ON_CRASH 0x00000001 162#define KEXEC_ON_CRASH 0x00000001
160#define KEXEC_ARCH_MASK 0xffff0000 163#define KEXEC_PRESERVE_CONTEXT 0x00000002
164#define KEXEC_ARCH_MASK 0xffff0000
161 165
162/* These values match the ELF architecture values. 166/* These values match the ELF architecture values.
163 * Unless there is a good reason that should continue to be the case. 167 * Unless there is a good reason that should continue to be the case.
@@ -174,7 +178,12 @@ extern struct kimage *kexec_crash_image;
174#define KEXEC_ARCH_MIPS_LE (10 << 16) 178#define KEXEC_ARCH_MIPS_LE (10 << 16)
175#define KEXEC_ARCH_MIPS ( 8 << 16) 179#define KEXEC_ARCH_MIPS ( 8 << 16)
176 180
177#define KEXEC_FLAGS (KEXEC_ON_CRASH) /* List of defined/legal kexec flags */ 181/* List of defined/legal kexec flags */
182#ifndef CONFIG_KEXEC_JUMP
183#define KEXEC_FLAGS KEXEC_ON_CRASH
184#else
185#define KEXEC_FLAGS (KEXEC_ON_CRASH | KEXEC_PRESERVE_CONTEXT)
186#endif
178 187
179#define VMCOREINFO_BYTES (4096) 188#define VMCOREINFO_BYTES (4096)
180#define VMCOREINFO_NOTE_NAME "VMCOREINFO" 189#define VMCOREINFO_NOTE_NAME "VMCOREINFO"
diff --git a/include/linux/key.h b/include/linux/key.h
index c45c962d1cc5..1b70e35a71e3 100644
--- a/include/linux/key.h
+++ b/include/linux/key.h
@@ -299,6 +299,7 @@ extern void key_init(void);
299#define key_validate(k) 0 299#define key_validate(k) 0
300#define key_serial(k) 0 300#define key_serial(k) 0
301#define key_get(k) ({ NULL; }) 301#define key_get(k) ({ NULL; })
302#define key_revoke(k) do { } while(0)
302#define key_put(k) do { } while(0) 303#define key_put(k) do { } while(0)
303#define key_ref_put(k) do { } while(0) 304#define key_ref_put(k) do { } while(0)
304#define make_key_ref(k, p) ({ NULL; }) 305#define make_key_ref(k, p) ({ NULL; })
diff --git a/include/linux/klist.h b/include/linux/klist.h
index 06c338ef7f1b..8ea98db223e5 100644
--- a/include/linux/klist.h
+++ b/include/linux/klist.h
@@ -38,7 +38,7 @@ extern void klist_init(struct klist *k, void (*get)(struct klist_node *),
38 void (*put)(struct klist_node *)); 38 void (*put)(struct klist_node *));
39 39
40struct klist_node { 40struct klist_node {
41 struct klist *n_klist; 41 void *n_klist; /* never access directly */
42 struct list_head n_node; 42 struct list_head n_node;
43 struct kref n_ref; 43 struct kref n_ref;
44 struct completion n_removed; 44 struct completion n_removed;
@@ -57,7 +57,6 @@ extern int klist_node_attached(struct klist_node *n);
57 57
58struct klist_iter { 58struct klist_iter {
59 struct klist *i_klist; 59 struct klist *i_klist;
60 struct list_head *i_head;
61 struct klist_node *i_cur; 60 struct klist_node *i_cur;
62}; 61};
63 62
diff --git a/include/linux/kmod.h b/include/linux/kmod.h
index 5dc13848891b..92213a9194e1 100644
--- a/include/linux/kmod.h
+++ b/include/linux/kmod.h
@@ -19,29 +19,31 @@
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 20 */
21 21
22#include <linux/gfp.h>
22#include <linux/stddef.h> 23#include <linux/stddef.h>
23#include <linux/errno.h> 24#include <linux/errno.h>
24#include <linux/compiler.h> 25#include <linux/compiler.h>
25 26
26#define KMOD_PATH_LEN 256 27#define KMOD_PATH_LEN 256
27 28
28#ifdef CONFIG_KMOD 29#ifdef CONFIG_MODULES
29/* modprobe exit status on success, -ve on error. Return value 30/* modprobe exit status on success, -ve on error. Return value
30 * usually useless though. */ 31 * usually useless though. */
31extern int request_module(const char * name, ...) __attribute__ ((format (printf, 1, 2))); 32extern int request_module(const char * name, ...) __attribute__ ((format (printf, 1, 2)));
33#define try_then_request_module(x, mod...) ((x) ?: (request_module(mod), (x)))
32#else 34#else
33static inline int request_module(const char * name, ...) { return -ENOSYS; } 35static inline int request_module(const char * name, ...) { return -ENOSYS; }
36#define try_then_request_module(x, mod...) (x)
34#endif 37#endif
35 38
36#define try_then_request_module(x, mod...) ((x) ?: (request_module(mod), (x)))
37 39
38struct key; 40struct key;
39struct file; 41struct file;
40struct subprocess_info; 42struct subprocess_info;
41 43
42/* Allocate a subprocess_info structure */ 44/* Allocate a subprocess_info structure */
43struct subprocess_info *call_usermodehelper_setup(char *path, 45struct subprocess_info *call_usermodehelper_setup(char *path, char **argv,
44 char **argv, char **envp); 46 char **envp, gfp_t gfp_mask);
45 47
46/* Set various pieces of state into the subprocess_info structure */ 48/* Set various pieces of state into the subprocess_info structure */
47void call_usermodehelper_setkeys(struct subprocess_info *info, 49void call_usermodehelper_setkeys(struct subprocess_info *info,
@@ -68,8 +70,9 @@ static inline int
68call_usermodehelper(char *path, char **argv, char **envp, enum umh_wait wait) 70call_usermodehelper(char *path, char **argv, char **envp, enum umh_wait wait)
69{ 71{
70 struct subprocess_info *info; 72 struct subprocess_info *info;
73 gfp_t gfp_mask = (wait == UMH_NO_WAIT) ? GFP_ATOMIC : GFP_KERNEL;
71 74
72 info = call_usermodehelper_setup(path, argv, envp); 75 info = call_usermodehelper_setup(path, argv, envp, gfp_mask);
73 if (info == NULL) 76 if (info == NULL)
74 return -ENOMEM; 77 return -ENOMEM;
75 return call_usermodehelper_exec(info, wait); 78 return call_usermodehelper_exec(info, wait);
@@ -80,8 +83,9 @@ call_usermodehelper_keys(char *path, char **argv, char **envp,
80 struct key *session_keyring, enum umh_wait wait) 83 struct key *session_keyring, enum umh_wait wait)
81{ 84{
82 struct subprocess_info *info; 85 struct subprocess_info *info;
86 gfp_t gfp_mask = (wait == UMH_NO_WAIT) ? GFP_ATOMIC : GFP_KERNEL;
83 87
84 info = call_usermodehelper_setup(path, argv, envp); 88 info = call_usermodehelper_setup(path, argv, envp, gfp_mask);
85 if (info == NULL) 89 if (info == NULL)
86 return -ENOMEM; 90 return -ENOMEM;
87 91
@@ -95,4 +99,7 @@ struct file;
95extern int call_usermodehelper_pipe(char *path, char *argv[], char *envp[], 99extern int call_usermodehelper_pipe(char *path, char *argv[], char *envp[],
96 struct file **filp); 100 struct file **filp);
97 101
102extern int usermodehelper_disable(void);
103extern void usermodehelper_enable(void);
104
98#endif /* __LINUX_KMOD_H__ */ 105#endif /* __LINUX_KMOD_H__ */
diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index 39e709f88aa0..5437ac0276e2 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -26,7 +26,6 @@
26#include <linux/wait.h> 26#include <linux/wait.h>
27#include <asm/atomic.h> 27#include <asm/atomic.h>
28 28
29#define KOBJ_NAME_LEN 20
30#define UEVENT_HELPER_PATH_LEN 256 29#define UEVENT_HELPER_PATH_LEN 256
31#define UEVENT_NUM_ENVP 32 /* number of env pointers */ 30#define UEVENT_NUM_ENVP 32 /* number of env pointers */
32#define UEVENT_BUFFER_SIZE 2048 /* buffer for the variables */ 31#define UEVENT_BUFFER_SIZE 2048 /* buffer for the variables */
@@ -59,12 +58,12 @@ enum kobject_action {
59 58
60struct kobject { 59struct kobject {
61 const char *name; 60 const char *name;
62 struct kref kref;
63 struct list_head entry; 61 struct list_head entry;
64 struct kobject *parent; 62 struct kobject *parent;
65 struct kset *kset; 63 struct kset *kset;
66 struct kobj_type *ktype; 64 struct kobj_type *ktype;
67 struct sysfs_dirent *sd; 65 struct sysfs_dirent *sd;
66 struct kref kref;
68 unsigned int state_initialized:1; 67 unsigned int state_initialized:1;
69 unsigned int state_in_sysfs:1; 68 unsigned int state_in_sysfs:1;
70 unsigned int state_add_uevent_sent:1; 69 unsigned int state_add_uevent_sent:1;
@@ -187,6 +186,8 @@ extern struct kobject *kset_find_obj(struct kset *, const char *);
187 186
188/* The global /sys/kernel/ kobject for people to chain off of */ 187/* The global /sys/kernel/ kobject for people to chain off of */
189extern struct kobject *kernel_kobj; 188extern struct kobject *kernel_kobj;
189/* The global /sys/kernel/mm/ kobject for people to chain off of */
190extern struct kobject *mm_kobj;
190/* The global /sys/hypervisor/ kobject for people to chain off of */ 191/* The global /sys/hypervisor/ kobject for people to chain off of */
191extern struct kobject *hypervisor_kobj; 192extern struct kobject *hypervisor_kobj;
192/* The global /sys/power/ kobject for people to chain off of */ 193/* The global /sys/power/ kobject for people to chain off of */
diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h
index 04a3556bdea6..497b1d1f7a05 100644
--- a/include/linux/kprobes.h
+++ b/include/linux/kprobes.h
@@ -29,6 +29,7 @@
29 * <jkenisto@us.ibm.com> and Prasanna S Panchamukhi 29 * <jkenisto@us.ibm.com> and Prasanna S Panchamukhi
30 * <prasanna@in.ibm.com> added function-return probes. 30 * <prasanna@in.ibm.com> added function-return probes.
31 */ 31 */
32#include <linux/linkage.h>
32#include <linux/list.h> 33#include <linux/list.h>
33#include <linux/notifier.h> 34#include <linux/notifier.h>
34#include <linux/smp.h> 35#include <linux/smp.h>
@@ -47,7 +48,7 @@
47#define KPROBE_HIT_SSDONE 0x00000008 48#define KPROBE_HIT_SSDONE 0x00000008
48 49
49/* Attach to insert probes on any functions which should be ignored*/ 50/* Attach to insert probes on any functions which should be ignored*/
50#define __kprobes __attribute__((__section__(".kprobes.text"))) 51#define __kprobes __attribute__((__section__(".kprobes.text"))) notrace
51 52
52struct kprobe; 53struct kprobe;
53struct pt_regs; 54struct pt_regs;
@@ -157,11 +158,10 @@ struct kretprobe {
157 int nmissed; 158 int nmissed;
158 size_t data_size; 159 size_t data_size;
159 struct hlist_head free_instances; 160 struct hlist_head free_instances;
160 struct hlist_head used_instances; 161 spinlock_t lock;
161}; 162};
162 163
163struct kretprobe_instance { 164struct kretprobe_instance {
164 struct hlist_node uflist; /* either on free list or used list */
165 struct hlist_node hlist; 165 struct hlist_node hlist;
166 struct kretprobe *rp; 166 struct kretprobe *rp;
167 kprobe_opcode_t *ret_addr; 167 kprobe_opcode_t *ret_addr;
@@ -201,7 +201,6 @@ static inline int init_test_probes(void)
201} 201}
202#endif /* CONFIG_KPROBES_SANITY_TEST */ 202#endif /* CONFIG_KPROBES_SANITY_TEST */
203 203
204extern spinlock_t kretprobe_lock;
205extern struct mutex kprobe_mutex; 204extern struct mutex kprobe_mutex;
206extern int arch_prepare_kprobe(struct kprobe *p); 205extern int arch_prepare_kprobe(struct kprobe *p);
207extern void arch_arm_kprobe(struct kprobe *p); 206extern void arch_arm_kprobe(struct kprobe *p);
@@ -214,6 +213,9 @@ extern void kprobes_inc_nmissed_count(struct kprobe *p);
214 213
215/* Get the kprobe at this addr (if any) - called with preemption disabled */ 214/* Get the kprobe at this addr (if any) - called with preemption disabled */
216struct kprobe *get_kprobe(void *addr); 215struct kprobe *get_kprobe(void *addr);
216void kretprobe_hash_lock(struct task_struct *tsk,
217 struct hlist_head **head, unsigned long *flags);
218void kretprobe_hash_unlock(struct task_struct *tsk, unsigned long *flags);
217struct hlist_head * kretprobe_inst_table_head(struct task_struct *tsk); 219struct hlist_head * kretprobe_inst_table_head(struct task_struct *tsk);
218 220
219/* kprobe_running() will just return the current_kprobe on this CPU */ 221/* kprobe_running() will just return the current_kprobe on this CPU */
@@ -255,7 +257,7 @@ void recycle_rp_inst(struct kretprobe_instance *ri, struct hlist_head *head);
255 257
256#else /* CONFIG_KPROBES */ 258#else /* CONFIG_KPROBES */
257 259
258#define __kprobes /**/ 260#define __kprobes notrace
259struct jprobe; 261struct jprobe;
260struct kretprobe; 262struct kretprobe;
261 263
diff --git a/include/linux/kthread.h b/include/linux/kthread.h
index 00dd957e245b..aabc8a13ba71 100644
--- a/include/linux/kthread.h
+++ b/include/linux/kthread.h
@@ -6,7 +6,8 @@
6 6
7struct task_struct *kthread_create(int (*threadfn)(void *data), 7struct task_struct *kthread_create(int (*threadfn)(void *data),
8 void *data, 8 void *data,
9 const char namefmt[], ...); 9 const char namefmt[], ...)
10 __attribute__((format(printf, 3, 4)));
10 11
11/** 12/**
12 * kthread_run - create and wake a thread. 13 * kthread_run - create and wake a thread.
diff --git a/include/linux/kvm.h b/include/linux/kvm.h
index a281afeddfbb..797fcd781242 100644
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -173,6 +173,30 @@ struct kvm_run {
173 }; 173 };
174}; 174};
175 175
176/* for KVM_REGISTER_COALESCED_MMIO / KVM_UNREGISTER_COALESCED_MMIO */
177
178struct kvm_coalesced_mmio_zone {
179 __u64 addr;
180 __u32 size;
181 __u32 pad;
182};
183
184struct kvm_coalesced_mmio {
185 __u64 phys_addr;
186 __u32 len;
187 __u32 pad;
188 __u8 data[8];
189};
190
191struct kvm_coalesced_mmio_ring {
192 __u32 first, last;
193 struct kvm_coalesced_mmio coalesced_mmio[0];
194};
195
196#define KVM_COALESCED_MMIO_MAX \
197 ((PAGE_SIZE - sizeof(struct kvm_coalesced_mmio_ring)) / \
198 sizeof(struct kvm_coalesced_mmio))
199
176/* for KVM_TRANSLATE */ 200/* for KVM_TRANSLATE */
177struct kvm_translation { 201struct kvm_translation {
178 /* in */ 202 /* in */
@@ -287,22 +311,33 @@ struct kvm_s390_interrupt {
287 311
288/* This structure represents a single trace buffer record. */ 312/* This structure represents a single trace buffer record. */
289struct kvm_trace_rec { 313struct kvm_trace_rec {
290 __u32 event:28; 314 /* variable rec_val
291 __u32 extra_u32:3; 315 * is split into:
292 __u32 cycle_in:1; 316 * bits 0 - 27 -> event id
317 * bits 28 -30 -> number of extra data args of size u32
318 * bits 31 -> binary indicator for if tsc is in record
319 */
320 __u32 rec_val;
293 __u32 pid; 321 __u32 pid;
294 __u32 vcpu_id; 322 __u32 vcpu_id;
295 union { 323 union {
296 struct { 324 struct {
297 __u32 cycle_lo, cycle_hi; 325 __u64 timestamp;
298 __u32 extra_u32[KVM_TRC_EXTRA_MAX]; 326 __u32 extra_u32[KVM_TRC_EXTRA_MAX];
299 } cycle; 327 } __attribute__((packed)) timestamp;
300 struct { 328 struct {
301 __u32 extra_u32[KVM_TRC_EXTRA_MAX]; 329 __u32 extra_u32[KVM_TRC_EXTRA_MAX];
302 } nocycle; 330 } notimestamp;
303 } u; 331 } u;
304}; 332};
305 333
334#define TRACE_REC_EVENT_ID(val) \
335 (0x0fffffff & (val))
336#define TRACE_REC_NUM_DATA_ARGS(val) \
337 (0x70000000 & ((val) << 28))
338#define TRACE_REC_TCS(val) \
339 (0x80000000 & ((val) << 31))
340
306#define KVMIO 0xAE 341#define KVMIO 0xAE
307 342
308/* 343/*
@@ -346,6 +381,12 @@ struct kvm_trace_rec {
346#define KVM_CAP_NOP_IO_DELAY 12 381#define KVM_CAP_NOP_IO_DELAY 12
347#define KVM_CAP_PV_MMU 13 382#define KVM_CAP_PV_MMU 13
348#define KVM_CAP_MP_STATE 14 383#define KVM_CAP_MP_STATE 14
384#define KVM_CAP_COALESCED_MMIO 15
385#define KVM_CAP_SYNC_MMU 16 /* Changes to host mmap are reflected in guest */
386#if defined(CONFIG_X86)||defined(CONFIG_IA64)
387#define KVM_CAP_DEVICE_ASSIGNMENT 17
388#endif
389#define KVM_CAP_IOMMU 18
349 390
350/* 391/*
351 * ioctls for VM fds 392 * ioctls for VM fds
@@ -371,6 +412,14 @@ struct kvm_trace_rec {
371#define KVM_CREATE_PIT _IO(KVMIO, 0x64) 412#define KVM_CREATE_PIT _IO(KVMIO, 0x64)
372#define KVM_GET_PIT _IOWR(KVMIO, 0x65, struct kvm_pit_state) 413#define KVM_GET_PIT _IOWR(KVMIO, 0x65, struct kvm_pit_state)
373#define KVM_SET_PIT _IOR(KVMIO, 0x66, struct kvm_pit_state) 414#define KVM_SET_PIT _IOR(KVMIO, 0x66, struct kvm_pit_state)
415#define KVM_REGISTER_COALESCED_MMIO \
416 _IOW(KVMIO, 0x67, struct kvm_coalesced_mmio_zone)
417#define KVM_UNREGISTER_COALESCED_MMIO \
418 _IOW(KVMIO, 0x68, struct kvm_coalesced_mmio_zone)
419#define KVM_ASSIGN_PCI_DEVICE _IOR(KVMIO, 0x69, \
420 struct kvm_assigned_pci_dev)
421#define KVM_ASSIGN_IRQ _IOR(KVMIO, 0x70, \
422 struct kvm_assigned_irq)
374 423
375/* 424/*
376 * ioctls for vcpu fds 425 * ioctls for vcpu fds
@@ -410,4 +459,45 @@ struct kvm_trace_rec {
410#define KVM_GET_MP_STATE _IOR(KVMIO, 0x98, struct kvm_mp_state) 459#define KVM_GET_MP_STATE _IOR(KVMIO, 0x98, struct kvm_mp_state)
411#define KVM_SET_MP_STATE _IOW(KVMIO, 0x99, struct kvm_mp_state) 460#define KVM_SET_MP_STATE _IOW(KVMIO, 0x99, struct kvm_mp_state)
412 461
462#define KVM_TRC_INJ_VIRQ (KVM_TRC_HANDLER + 0x02)
463#define KVM_TRC_REDELIVER_EVT (KVM_TRC_HANDLER + 0x03)
464#define KVM_TRC_PEND_INTR (KVM_TRC_HANDLER + 0x04)
465#define KVM_TRC_IO_READ (KVM_TRC_HANDLER + 0x05)
466#define KVM_TRC_IO_WRITE (KVM_TRC_HANDLER + 0x06)
467#define KVM_TRC_CR_READ (KVM_TRC_HANDLER + 0x07)
468#define KVM_TRC_CR_WRITE (KVM_TRC_HANDLER + 0x08)
469#define KVM_TRC_DR_READ (KVM_TRC_HANDLER + 0x09)
470#define KVM_TRC_DR_WRITE (KVM_TRC_HANDLER + 0x0A)
471#define KVM_TRC_MSR_READ (KVM_TRC_HANDLER + 0x0B)
472#define KVM_TRC_MSR_WRITE (KVM_TRC_HANDLER + 0x0C)
473#define KVM_TRC_CPUID (KVM_TRC_HANDLER + 0x0D)
474#define KVM_TRC_INTR (KVM_TRC_HANDLER + 0x0E)
475#define KVM_TRC_NMI (KVM_TRC_HANDLER + 0x0F)
476#define KVM_TRC_VMMCALL (KVM_TRC_HANDLER + 0x10)
477#define KVM_TRC_HLT (KVM_TRC_HANDLER + 0x11)
478#define KVM_TRC_CLTS (KVM_TRC_HANDLER + 0x12)
479#define KVM_TRC_LMSW (KVM_TRC_HANDLER + 0x13)
480#define KVM_TRC_APIC_ACCESS (KVM_TRC_HANDLER + 0x14)
481#define KVM_TRC_TDP_FAULT (KVM_TRC_HANDLER + 0x15)
482#define KVM_TRC_GTLB_WRITE (KVM_TRC_HANDLER + 0x16)
483#define KVM_TRC_STLB_WRITE (KVM_TRC_HANDLER + 0x17)
484#define KVM_TRC_STLB_INVAL (KVM_TRC_HANDLER + 0x18)
485#define KVM_TRC_PPC_INSTR (KVM_TRC_HANDLER + 0x19)
486
487struct kvm_assigned_pci_dev {
488 __u32 assigned_dev_id;
489 __u32 busnr;
490 __u32 devfn;
491 __u32 flags;
492};
493
494struct kvm_assigned_irq {
495 __u32 assigned_dev_id;
496 __u32 host_irq;
497 __u32 guest_irq;
498 __u32 flags;
499};
500
501#define KVM_DEV_ASSIGN_ENABLE_IOMMU (1 << 0)
502
413#endif 503#endif
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index de9d1df4bba2..3833c48fae3a 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -34,6 +34,8 @@
34#define KVM_REQ_MMU_RELOAD 3 34#define KVM_REQ_MMU_RELOAD 3
35#define KVM_REQ_TRIPLE_FAULT 4 35#define KVM_REQ_TRIPLE_FAULT 4
36#define KVM_REQ_PENDING_TIMER 5 36#define KVM_REQ_PENDING_TIMER 5
37#define KVM_REQ_UNHALT 6
38#define KVM_REQ_MMU_SYNC 7
37 39
38struct kvm_vcpu; 40struct kvm_vcpu;
39extern struct kmem_cache *kvm_vcpu_cache; 41extern struct kmem_cache *kvm_vcpu_cache;
@@ -52,7 +54,8 @@ struct kvm_io_bus {
52 54
53void kvm_io_bus_init(struct kvm_io_bus *bus); 55void kvm_io_bus_init(struct kvm_io_bus *bus);
54void kvm_io_bus_destroy(struct kvm_io_bus *bus); 56void kvm_io_bus_destroy(struct kvm_io_bus *bus);
55struct kvm_io_device *kvm_io_bus_find_dev(struct kvm_io_bus *bus, gpa_t addr); 57struct kvm_io_device *kvm_io_bus_find_dev(struct kvm_io_bus *bus,
58 gpa_t addr, int len, int is_write);
56void kvm_io_bus_register_dev(struct kvm_io_bus *bus, 59void kvm_io_bus_register_dev(struct kvm_io_bus *bus,
57 struct kvm_io_device *dev); 60 struct kvm_io_device *dev);
58 61
@@ -116,6 +119,16 @@ struct kvm {
116 struct kvm_vm_stat stat; 119 struct kvm_vm_stat stat;
117 struct kvm_arch arch; 120 struct kvm_arch arch;
118 atomic_t users_count; 121 atomic_t users_count;
122#ifdef KVM_COALESCED_MMIO_PAGE_OFFSET
123 struct kvm_coalesced_mmio_dev *coalesced_mmio_dev;
124 struct kvm_coalesced_mmio_ring *coalesced_mmio_ring;
125#endif
126
127#ifdef KVM_ARCH_WANT_MMU_NOTIFIER
128 struct mmu_notifier mmu_notifier;
129 unsigned long mmu_notifier_seq;
130 long mmu_notifier_count;
131#endif
119}; 132};
120 133
121/* The guest did something we don't support. */ 134/* The guest did something we don't support. */
@@ -135,9 +148,6 @@ void kvm_vcpu_uninit(struct kvm_vcpu *vcpu);
135void vcpu_load(struct kvm_vcpu *vcpu); 148void vcpu_load(struct kvm_vcpu *vcpu);
136void vcpu_put(struct kvm_vcpu *vcpu); 149void vcpu_put(struct kvm_vcpu *vcpu);
137 150
138void decache_vcpus_on_cpu(int cpu);
139
140
141int kvm_init(void *opaque, unsigned int vcpu_size, 151int kvm_init(void *opaque, unsigned int vcpu_size,
142 struct module *module); 152 struct module *module);
143void kvm_exit(void); 153void kvm_exit(void);
@@ -166,6 +176,7 @@ int kvm_arch_set_memory_region(struct kvm *kvm,
166 struct kvm_userspace_memory_region *mem, 176 struct kvm_userspace_memory_region *mem,
167 struct kvm_memory_slot old, 177 struct kvm_memory_slot old,
168 int user_alloc); 178 int user_alloc);
179void kvm_arch_flush_shadow(struct kvm *kvm);
169gfn_t unalias_gfn(struct kvm *kvm, gfn_t gfn); 180gfn_t unalias_gfn(struct kvm *kvm, gfn_t gfn);
170struct page *gfn_to_page(struct kvm *kvm, gfn_t gfn); 181struct page *gfn_to_page(struct kvm *kvm, gfn_t gfn);
171unsigned long gfn_to_hva(struct kvm *kvm, gfn_t gfn); 182unsigned long gfn_to_hva(struct kvm *kvm, gfn_t gfn);
@@ -270,12 +281,68 @@ void kvm_free_physmem(struct kvm *kvm);
270 281
271struct kvm *kvm_arch_create_vm(void); 282struct kvm *kvm_arch_create_vm(void);
272void kvm_arch_destroy_vm(struct kvm *kvm); 283void kvm_arch_destroy_vm(struct kvm *kvm);
284void kvm_free_all_assigned_devices(struct kvm *kvm);
273 285
274int kvm_cpu_get_interrupt(struct kvm_vcpu *v); 286int kvm_cpu_get_interrupt(struct kvm_vcpu *v);
275int kvm_cpu_has_interrupt(struct kvm_vcpu *v); 287int kvm_cpu_has_interrupt(struct kvm_vcpu *v);
276int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu); 288int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu);
277void kvm_vcpu_kick(struct kvm_vcpu *vcpu); 289void kvm_vcpu_kick(struct kvm_vcpu *vcpu);
278 290
291int kvm_is_mmio_pfn(pfn_t pfn);
292
293struct kvm_irq_ack_notifier {
294 struct hlist_node link;
295 unsigned gsi;
296 void (*irq_acked)(struct kvm_irq_ack_notifier *kian);
297};
298
299struct kvm_assigned_dev_kernel {
300 struct kvm_irq_ack_notifier ack_notifier;
301 struct work_struct interrupt_work;
302 struct list_head list;
303 int assigned_dev_id;
304 int host_busnr;
305 int host_devfn;
306 int host_irq;
307 int guest_irq;
308 int irq_requested;
309 struct pci_dev *dev;
310 struct kvm *kvm;
311};
312void kvm_set_irq(struct kvm *kvm, int irq, int level);
313void kvm_notify_acked_irq(struct kvm *kvm, unsigned gsi);
314void kvm_register_irq_ack_notifier(struct kvm *kvm,
315 struct kvm_irq_ack_notifier *kian);
316void kvm_unregister_irq_ack_notifier(struct kvm *kvm,
317 struct kvm_irq_ack_notifier *kian);
318
319#ifdef CONFIG_DMAR
320int kvm_iommu_map_pages(struct kvm *kvm, gfn_t base_gfn,
321 unsigned long npages);
322int kvm_iommu_map_guest(struct kvm *kvm,
323 struct kvm_assigned_dev_kernel *assigned_dev);
324int kvm_iommu_unmap_guest(struct kvm *kvm);
325#else /* CONFIG_DMAR */
326static inline int kvm_iommu_map_pages(struct kvm *kvm,
327 gfn_t base_gfn,
328 unsigned long npages)
329{
330 return 0;
331}
332
333static inline int kvm_iommu_map_guest(struct kvm *kvm,
334 struct kvm_assigned_dev_kernel
335 *assigned_dev)
336{
337 return -ENODEV;
338}
339
340static inline int kvm_iommu_unmap_guest(struct kvm *kvm)
341{
342 return 0;
343}
344#endif /* CONFIG_DMAR */
345
279static inline void kvm_guest_enter(void) 346static inline void kvm_guest_enter(void)
280{ 347{
281 account_system_vtime(current); 348 account_system_vtime(current);
@@ -298,6 +365,11 @@ static inline gpa_t gfn_to_gpa(gfn_t gfn)
298 return (gpa_t)gfn << PAGE_SHIFT; 365 return (gpa_t)gfn << PAGE_SHIFT;
299} 366}
300 367
368static inline hpa_t pfn_to_hpa(pfn_t pfn)
369{
370 return (hpa_t)pfn << PAGE_SHIFT;
371}
372
301static inline void kvm_migrate_timers(struct kvm_vcpu *vcpu) 373static inline void kvm_migrate_timers(struct kvm_vcpu *vcpu)
302{ 374{
303 set_bit(KVM_REQ_MIGRATE_TIMER, &vcpu->requests); 375 set_bit(KVM_REQ_MIGRATE_TIMER, &vcpu->requests);
@@ -317,6 +389,25 @@ struct kvm_stats_debugfs_item {
317extern struct kvm_stats_debugfs_item debugfs_entries[]; 389extern struct kvm_stats_debugfs_item debugfs_entries[];
318extern struct dentry *kvm_debugfs_dir; 390extern struct dentry *kvm_debugfs_dir;
319 391
392#define KVMTRACE_5D(evt, vcpu, d1, d2, d3, d4, d5, name) \
393 trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \
394 vcpu, 5, d1, d2, d3, d4, d5)
395#define KVMTRACE_4D(evt, vcpu, d1, d2, d3, d4, name) \
396 trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \
397 vcpu, 4, d1, d2, d3, d4, 0)
398#define KVMTRACE_3D(evt, vcpu, d1, d2, d3, name) \
399 trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \
400 vcpu, 3, d1, d2, d3, 0, 0)
401#define KVMTRACE_2D(evt, vcpu, d1, d2, name) \
402 trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \
403 vcpu, 2, d1, d2, 0, 0, 0)
404#define KVMTRACE_1D(evt, vcpu, d1, name) \
405 trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \
406 vcpu, 1, d1, 0, 0, 0, 0)
407#define KVMTRACE_0D(evt, vcpu, name) \
408 trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \
409 vcpu, 0, 0, 0, 0, 0, 0)
410
320#ifdef CONFIG_KVM_TRACE 411#ifdef CONFIG_KVM_TRACE
321int kvm_trace_ioctl(unsigned int ioctl, unsigned long arg); 412int kvm_trace_ioctl(unsigned int ioctl, unsigned long arg);
322void kvm_trace_cleanup(void); 413void kvm_trace_cleanup(void);
@@ -329,4 +420,22 @@ int kvm_trace_ioctl(unsigned int ioctl, unsigned long arg)
329#define kvm_trace_cleanup() ((void)0) 420#define kvm_trace_cleanup() ((void)0)
330#endif 421#endif
331 422
423#ifdef KVM_ARCH_WANT_MMU_NOTIFIER
424static inline int mmu_notifier_retry(struct kvm_vcpu *vcpu, unsigned long mmu_seq)
425{
426 if (unlikely(vcpu->kvm->mmu_notifier_count))
427 return 1;
428 /*
429 * Both reads happen under the mmu_lock and both values are
430 * modified under mmu_lock, so there's no need of smb_rmb()
431 * here in between, otherwise mmu_notifier_count should be
432 * read before mmu_notifier_seq, see
433 * mmu_notifier_invalidate_range_end write side.
434 */
435 if (vcpu->kvm->mmu_notifier_seq != mmu_seq)
436 return 1;
437 return 0;
438}
439#endif
440
332#endif 441#endif
diff --git a/include/linux/lcd.h b/include/linux/lcd.h
index 1d379787f2e7..c67fecafff90 100644
--- a/include/linux/lcd.h
+++ b/include/linux/lcd.h
@@ -11,6 +11,7 @@
11#include <linux/device.h> 11#include <linux/device.h>
12#include <linux/mutex.h> 12#include <linux/mutex.h>
13#include <linux/notifier.h> 13#include <linux/notifier.h>
14#include <linux/fb.h>
14 15
15/* Notes on locking: 16/* Notes on locking:
16 * 17 *
@@ -45,9 +46,11 @@ struct lcd_ops {
45 int (*get_contrast)(struct lcd_device *); 46 int (*get_contrast)(struct lcd_device *);
46 /* Set LCD panel contrast */ 47 /* Set LCD panel contrast */
47 int (*set_contrast)(struct lcd_device *, int contrast); 48 int (*set_contrast)(struct lcd_device *, int contrast);
49 /* Set LCD panel mode (resolutions ...) */
50 int (*set_mode)(struct lcd_device *, struct fb_videomode *);
48 /* Check if given framebuffer device is the one LCD is bound to; 51 /* Check if given framebuffer device is the one LCD is bound to;
49 return 0 if not, !=0 if it is. If NULL, lcd always matches the fb. */ 52 return 0 if not, !=0 if it is. If NULL, lcd always matches the fb. */
50 int (*check_fb)(struct fb_info *); 53 int (*check_fb)(struct lcd_device *, struct fb_info *);
51}; 54};
52 55
53struct lcd_device { 56struct lcd_device {
diff --git a/include/linux/leds-pca9532.h b/include/linux/leds-pca9532.h
new file mode 100644
index 000000000000..81b4207deb95
--- /dev/null
+++ b/include/linux/leds-pca9532.h
@@ -0,0 +1,45 @@
1/*
2 * pca9532.h - platform data structure for pca9532 led controller
3 *
4 * Copyright (C) 2008 Riku Voipio <riku.voipio@movial.fi>
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; version 2 of the License.
9 *
10 * Datasheet: http://www.nxp.com/acrobat/datasheets/PCA9532_3.pdf
11 *
12 */
13
14#ifndef __LINUX_PCA9532_H
15#define __LINUX_PCA9532_H
16
17#include <linux/leds.h>
18
19enum pca9532_state {
20 PCA9532_OFF = 0x0,
21 PCA9532_ON = 0x1,
22 PCA9532_PWM0 = 0x2,
23 PCA9532_PWM1 = 0x3
24};
25
26enum pca9532_type { PCA9532_TYPE_NONE, PCA9532_TYPE_LED,
27 PCA9532_TYPE_N2100_BEEP };
28
29struct pca9532_led {
30 u8 id;
31 struct i2c_client *client;
32 char *name;
33 struct led_classdev ldev;
34 enum pca9532_type type;
35 enum pca9532_state state;
36};
37
38struct pca9532_platform_data {
39 struct pca9532_led leds[16];
40 u8 pwm[2];
41 u8 psc[2];
42};
43
44#endif /* __LINUX_PCA9532_H */
45
diff --git a/include/linux/leds.h b/include/linux/leds.h
index 519df72e939d..d3a73f5a48c3 100644
--- a/include/linux/leds.h
+++ b/include/linux/leds.h
@@ -48,7 +48,7 @@ struct led_classdev {
48 48
49 struct device *dev; 49 struct device *dev;
50 struct list_head node; /* LED Device list */ 50 struct list_head node; /* LED Device list */
51 char *default_trigger; /* Trigger to use */ 51 const char *default_trigger; /* Trigger to use */
52 52
53#ifdef CONFIG_LEDS_TRIGGERS 53#ifdef CONFIG_LEDS_TRIGGERS
54 /* Protects the trigger data below */ 54 /* Protects the trigger data below */
@@ -118,10 +118,24 @@ extern void ledtrig_ide_activity(void);
118#define ledtrig_ide_activity() do {} while(0) 118#define ledtrig_ide_activity() do {} while(0)
119#endif 119#endif
120 120
121/*
122 * Generic LED platform data for describing LED names and default triggers.
123 */
124struct led_info {
125 const char *name;
126 const char *default_trigger;
127 int flags;
128};
129
130struct led_platform_data {
131 int num_leds;
132 struct led_info *leds;
133};
134
121/* For the leds-gpio driver */ 135/* For the leds-gpio driver */
122struct gpio_led { 136struct gpio_led {
123 const char *name; 137 const char *name;
124 char *default_trigger; 138 const char *default_trigger;
125 unsigned gpio; 139 unsigned gpio;
126 u8 active_low; 140 u8 active_low;
127}; 141};
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 5b247b8a6b3b..507f53ef8038 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -60,9 +60,9 @@
60 60
61/* note: prints function name for you */ 61/* note: prints function name for you */
62#ifdef ATA_DEBUG 62#ifdef ATA_DEBUG
63#define DPRINTK(fmt, args...) printk(KERN_ERR "%s: " fmt, __FUNCTION__, ## args) 63#define DPRINTK(fmt, args...) printk(KERN_ERR "%s: " fmt, __func__, ## args)
64#ifdef ATA_VERBOSE_DEBUG 64#ifdef ATA_VERBOSE_DEBUG
65#define VPRINTK(fmt, args...) printk(KERN_ERR "%s: " fmt, __FUNCTION__, ## args) 65#define VPRINTK(fmt, args...) printk(KERN_ERR "%s: " fmt, __func__, ## args)
66#else 66#else
67#define VPRINTK(fmt, args...) 67#define VPRINTK(fmt, args...)
68#endif /* ATA_VERBOSE_DEBUG */ 68#endif /* ATA_VERBOSE_DEBUG */
@@ -71,7 +71,7 @@
71#define VPRINTK(fmt, args...) 71#define VPRINTK(fmt, args...)
72#endif /* ATA_DEBUG */ 72#endif /* ATA_DEBUG */
73 73
74#define BPRINTK(fmt, args...) if (ap->flags & ATA_FLAG_DEBUGMSG) printk(KERN_ERR "%s: " fmt, __FUNCTION__, ## args) 74#define BPRINTK(fmt, args...) if (ap->flags & ATA_FLAG_DEBUGMSG) printk(KERN_ERR "%s: " fmt, __func__, ## args)
75 75
76/* NEW: debug levels */ 76/* NEW: debug levels */
77#define HAVE_LIBATA_MSG 1 77#define HAVE_LIBATA_MSG 1
@@ -146,6 +146,7 @@ enum {
146 ATA_DFLAG_SPUNDOWN = (1 << 14), /* XXX: for spindown_compat */ 146 ATA_DFLAG_SPUNDOWN = (1 << 14), /* XXX: for spindown_compat */
147 ATA_DFLAG_SLEEPING = (1 << 15), /* device is sleeping */ 147 ATA_DFLAG_SLEEPING = (1 << 15), /* device is sleeping */
148 ATA_DFLAG_DUBIOUS_XFER = (1 << 16), /* data transfer not verified */ 148 ATA_DFLAG_DUBIOUS_XFER = (1 << 16), /* data transfer not verified */
149 ATA_DFLAG_NO_UNLOAD = (1 << 17), /* device doesn't support unload */
149 ATA_DFLAG_INIT_MASK = (1 << 24) - 1, 150 ATA_DFLAG_INIT_MASK = (1 << 24) - 1,
150 151
151 ATA_DFLAG_DETACH = (1 << 24), 152 ATA_DFLAG_DETACH = (1 << 24),
@@ -163,6 +164,7 @@ enum {
163 ATA_DEV_NONE = 9, /* no device */ 164 ATA_DEV_NONE = 9, /* no device */
164 165
165 /* struct ata_link flags */ 166 /* struct ata_link flags */
167 ATA_LFLAG_NO_HRST = (1 << 1), /* avoid hardreset */
166 ATA_LFLAG_NO_SRST = (1 << 2), /* avoid softreset */ 168 ATA_LFLAG_NO_SRST = (1 << 2), /* avoid softreset */
167 ATA_LFLAG_ASSUME_ATA = (1 << 3), /* assume ATA class */ 169 ATA_LFLAG_ASSUME_ATA = (1 << 3), /* assume ATA class */
168 ATA_LFLAG_ASSUME_SEMB = (1 << 4), /* assume SEMB class */ 170 ATA_LFLAG_ASSUME_SEMB = (1 << 4), /* assume SEMB class */
@@ -243,6 +245,7 @@ enum {
243 ATA_TMOUT_BOOT = 30000, /* heuristic */ 245 ATA_TMOUT_BOOT = 30000, /* heuristic */
244 ATA_TMOUT_BOOT_QUICK = 7000, /* heuristic */ 246 ATA_TMOUT_BOOT_QUICK = 7000, /* heuristic */
245 ATA_TMOUT_INTERNAL_QUICK = 5000, 247 ATA_TMOUT_INTERNAL_QUICK = 5000,
248 ATA_TMOUT_MAX_PARK = 30000,
246 249
247 /* FIXME: GoVault needs 2s but we can't afford that without 250 /* FIXME: GoVault needs 2s but we can't afford that without
248 * parallel probing. 800ms is enough for iVDR disk 251 * parallel probing. 800ms is enough for iVDR disk
@@ -318,8 +321,11 @@ enum {
318 ATA_EH_RESET = ATA_EH_SOFTRESET | ATA_EH_HARDRESET, 321 ATA_EH_RESET = ATA_EH_SOFTRESET | ATA_EH_HARDRESET,
319 ATA_EH_ENABLE_LINK = (1 << 3), 322 ATA_EH_ENABLE_LINK = (1 << 3),
320 ATA_EH_LPM = (1 << 4), /* link power management action */ 323 ATA_EH_LPM = (1 << 4), /* link power management action */
324 ATA_EH_PARK = (1 << 5), /* unload heads and stop I/O */
321 325
322 ATA_EH_PERDEV_MASK = ATA_EH_REVALIDATE, 326 ATA_EH_PERDEV_MASK = ATA_EH_REVALIDATE | ATA_EH_PARK,
327 ATA_EH_ALL_ACTIONS = ATA_EH_REVALIDATE | ATA_EH_RESET |
328 ATA_EH_ENABLE_LINK | ATA_EH_LPM,
323 329
324 /* ata_eh_info->flags */ 330 /* ata_eh_info->flags */
325 ATA_EHI_HOTPLUGGED = (1 << 0), /* could have been hotplugged */ 331 ATA_EHI_HOTPLUGGED = (1 << 0), /* could have been hotplugged */
@@ -334,6 +340,9 @@ enum {
334 340
335 ATA_EHI_DID_RESET = ATA_EHI_DID_SOFTRESET | ATA_EHI_DID_HARDRESET, 341 ATA_EHI_DID_RESET = ATA_EHI_DID_SOFTRESET | ATA_EHI_DID_HARDRESET,
336 342
343 /* mask of flags to transfer *to* the slave link */
344 ATA_EHI_TO_SLAVE_MASK = ATA_EHI_NO_AUTOPSY | ATA_EHI_QUIET,
345
337 /* max tries if error condition is still set after ->error_handler */ 346 /* max tries if error condition is still set after ->error_handler */
338 ATA_EH_MAX_TRIES = 5, 347 ATA_EH_MAX_TRIES = 5,
339 348
@@ -451,6 +460,7 @@ enum link_pm {
451 MEDIUM_POWER, 460 MEDIUM_POWER,
452}; 461};
453extern struct device_attribute dev_attr_link_power_management_policy; 462extern struct device_attribute dev_attr_link_power_management_policy;
463extern struct device_attribute dev_attr_unload_heads;
454extern struct device_attribute dev_attr_em_message_type; 464extern struct device_attribute dev_attr_em_message_type;
455extern struct device_attribute dev_attr_em_message; 465extern struct device_attribute dev_attr_em_message;
456extern struct device_attribute dev_attr_sw_activity; 466extern struct device_attribute dev_attr_sw_activity;
@@ -553,8 +563,8 @@ struct ata_ering {
553struct ata_device { 563struct ata_device {
554 struct ata_link *link; 564 struct ata_link *link;
555 unsigned int devno; /* 0 or 1 */ 565 unsigned int devno; /* 0 or 1 */
556 unsigned long flags; /* ATA_DFLAG_xxx */
557 unsigned int horkage; /* List of broken features */ 566 unsigned int horkage; /* List of broken features */
567 unsigned long flags; /* ATA_DFLAG_xxx */
558 struct scsi_device *sdev; /* attached SCSI device */ 568 struct scsi_device *sdev; /* attached SCSI device */
559#ifdef CONFIG_ATA_ACPI 569#ifdef CONFIG_ATA_ACPI
560 acpi_handle acpi_handle; 570 acpi_handle acpi_handle;
@@ -563,6 +573,7 @@ struct ata_device {
563 /* n_sector is used as CLEAR_OFFSET, read comment above CLEAR_OFFSET */ 573 /* n_sector is used as CLEAR_OFFSET, read comment above CLEAR_OFFSET */
564 u64 n_sectors; /* size of device, if ATA */ 574 u64 n_sectors; /* size of device, if ATA */
565 unsigned int class; /* ATA_DEV_xxx */ 575 unsigned int class; /* ATA_DEV_xxx */
576 unsigned long unpark_deadline;
566 577
567 u8 pio_mode; 578 u8 pio_mode;
568 u8 dma_mode; 579 u8 dma_mode;
@@ -620,6 +631,7 @@ struct ata_eh_context {
620 [ATA_EH_CMD_TIMEOUT_TABLE_SIZE]; 631 [ATA_EH_CMD_TIMEOUT_TABLE_SIZE];
621 unsigned int classes[ATA_MAX_DEVICES]; 632 unsigned int classes[ATA_MAX_DEVICES];
622 unsigned int did_probe_mask; 633 unsigned int did_probe_mask;
634 unsigned int unloaded_mask;
623 unsigned int saved_ncq_enabled; 635 unsigned int saved_ncq_enabled;
624 u8 saved_xfer_mode[ATA_MAX_DEVICES]; 636 u8 saved_xfer_mode[ATA_MAX_DEVICES];
625 /* timestamp for the last reset attempt or success */ 637 /* timestamp for the last reset attempt or success */
@@ -646,6 +658,7 @@ struct ata_link {
646 658
647 unsigned int flags; /* ATA_LFLAG_xxx */ 659 unsigned int flags; /* ATA_LFLAG_xxx */
648 660
661 u32 saved_scontrol; /* SControl on probe */
649 unsigned int hw_sata_spd_limit; 662 unsigned int hw_sata_spd_limit;
650 unsigned int sata_spd_limit; 663 unsigned int sata_spd_limit;
651 unsigned int sata_spd; /* current SATA PHY speed */ 664 unsigned int sata_spd; /* current SATA PHY speed */
@@ -682,11 +695,11 @@ struct ata_port {
682 unsigned int cbl; /* cable type; ATA_CBL_xxx */ 695 unsigned int cbl; /* cable type; ATA_CBL_xxx */
683 696
684 struct ata_queued_cmd qcmd[ATA_MAX_QUEUE]; 697 struct ata_queued_cmd qcmd[ATA_MAX_QUEUE];
685 unsigned long qc_allocated;
686 unsigned int qc_active; 698 unsigned int qc_active;
687 int nr_active_links; /* #links with active qcs */ 699 int nr_active_links; /* #links with active qcs */
688 700
689 struct ata_link link; /* host default link */ 701 struct ata_link link; /* host default link */
702 struct ata_link *slave_link; /* see ata_slave_link_init() */
690 703
691 int nr_pmp_links; /* nr of available PMP links */ 704 int nr_pmp_links; /* nr of available PMP links */
692 struct ata_link *pmp_link; /* array of PMP links */ 705 struct ata_link *pmp_link; /* array of PMP links */
@@ -707,6 +720,7 @@ struct ata_port {
707 struct list_head eh_done_q; 720 struct list_head eh_done_q;
708 wait_queue_head_t eh_wait_q; 721 wait_queue_head_t eh_wait_q;
709 int eh_tries; 722 int eh_tries;
723 struct completion park_req_pending;
710 724
711 pm_message_t pm_mesg; 725 pm_message_t pm_mesg;
712 int *pm_result; 726 int *pm_result;
@@ -750,6 +764,7 @@ struct ata_port_operations {
750 void (*set_piomode)(struct ata_port *ap, struct ata_device *dev); 764 void (*set_piomode)(struct ata_port *ap, struct ata_device *dev);
751 void (*set_dmamode)(struct ata_port *ap, struct ata_device *dev); 765 void (*set_dmamode)(struct ata_port *ap, struct ata_device *dev);
752 int (*set_mode)(struct ata_link *link, struct ata_device **r_failed_dev); 766 int (*set_mode)(struct ata_link *link, struct ata_device **r_failed_dev);
767 unsigned int (*read_id)(struct ata_device *dev, struct ata_taskfile *tf, u16 *id);
753 768
754 void (*dev_config)(struct ata_device *dev); 769 void (*dev_config)(struct ata_device *dev);
755 770
@@ -769,8 +784,8 @@ struct ata_port_operations {
769 /* 784 /*
770 * Optional features 785 * Optional features
771 */ 786 */
772 int (*scr_read)(struct ata_port *ap, unsigned int sc_reg, u32 *val); 787 int (*scr_read)(struct ata_link *link, unsigned int sc_reg, u32 *val);
773 int (*scr_write)(struct ata_port *ap, unsigned int sc_reg, u32 val); 788 int (*scr_write)(struct ata_link *link, unsigned int sc_reg, u32 val);
774 void (*pmp_attach)(struct ata_port *ap); 789 void (*pmp_attach)(struct ata_port *ap);
775 void (*pmp_detach)(struct ata_port *ap); 790 void (*pmp_detach)(struct ata_port *ap);
776 int (*enable_pm)(struct ata_port *ap, enum link_pm policy); 791 int (*enable_pm)(struct ata_port *ap, enum link_pm policy);
@@ -892,6 +907,7 @@ extern void ata_port_disable(struct ata_port *);
892extern struct ata_host *ata_host_alloc(struct device *dev, int max_ports); 907extern struct ata_host *ata_host_alloc(struct device *dev, int max_ports);
893extern struct ata_host *ata_host_alloc_pinfo(struct device *dev, 908extern struct ata_host *ata_host_alloc_pinfo(struct device *dev,
894 const struct ata_port_info * const * ppi, int n_ports); 909 const struct ata_port_info * const * ppi, int n_ports);
910extern int ata_slave_link_init(struct ata_port *ap);
895extern int ata_host_start(struct ata_host *host); 911extern int ata_host_start(struct ata_host *host);
896extern int ata_host_register(struct ata_host *host, 912extern int ata_host_register(struct ata_host *host,
897 struct scsi_host_template *sht); 913 struct scsi_host_template *sht);
@@ -917,8 +933,8 @@ extern int sata_scr_valid(struct ata_link *link);
917extern int sata_scr_read(struct ata_link *link, int reg, u32 *val); 933extern int sata_scr_read(struct ata_link *link, int reg, u32 *val);
918extern int sata_scr_write(struct ata_link *link, int reg, u32 val); 934extern int sata_scr_write(struct ata_link *link, int reg, u32 val);
919extern int sata_scr_write_flush(struct ata_link *link, int reg, u32 val); 935extern int sata_scr_write_flush(struct ata_link *link, int reg, u32 val);
920extern int ata_link_online(struct ata_link *link); 936extern bool ata_link_online(struct ata_link *link);
921extern int ata_link_offline(struct ata_link *link); 937extern bool ata_link_offline(struct ata_link *link);
922#ifdef CONFIG_PM 938#ifdef CONFIG_PM
923extern int ata_host_suspend(struct ata_host *host, pm_message_t mesg); 939extern int ata_host_suspend(struct ata_host *host, pm_message_t mesg);
924extern void ata_host_resume(struct ata_host *host); 940extern void ata_host_resume(struct ata_host *host);
@@ -951,6 +967,8 @@ extern void ata_id_string(const u16 *id, unsigned char *s,
951 unsigned int ofs, unsigned int len); 967 unsigned int ofs, unsigned int len);
952extern void ata_id_c_string(const u16 *id, unsigned char *s, 968extern void ata_id_c_string(const u16 *id, unsigned char *s,
953 unsigned int ofs, unsigned int len); 969 unsigned int ofs, unsigned int len);
970extern unsigned int ata_do_dev_read_id(struct ata_device *dev,
971 struct ata_taskfile *tf, u16 *id);
954extern void ata_qc_complete(struct ata_queued_cmd *qc); 972extern void ata_qc_complete(struct ata_queued_cmd *qc);
955extern int ata_qc_complete_multiple(struct ata_port *ap, u32 qc_active); 973extern int ata_qc_complete_multiple(struct ata_port *ap, u32 qc_active);
956extern void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd, 974extern void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd,
@@ -1093,6 +1111,7 @@ extern void ata_std_error_handler(struct ata_port *ap);
1093 */ 1111 */
1094extern const struct ata_port_operations ata_base_port_ops; 1112extern const struct ata_port_operations ata_base_port_ops;
1095extern const struct ata_port_operations sata_port_ops; 1113extern const struct ata_port_operations sata_port_ops;
1114extern struct device_attribute *ata_common_sdev_attrs[];
1096 1115
1097#define ATA_BASE_SHT(drv_name) \ 1116#define ATA_BASE_SHT(drv_name) \
1098 .module = THIS_MODULE, \ 1117 .module = THIS_MODULE, \
@@ -1107,7 +1126,8 @@ extern const struct ata_port_operations sata_port_ops;
1107 .proc_name = drv_name, \ 1126 .proc_name = drv_name, \
1108 .slave_configure = ata_scsi_slave_config, \ 1127 .slave_configure = ata_scsi_slave_config, \
1109 .slave_destroy = ata_scsi_slave_destroy, \ 1128 .slave_destroy = ata_scsi_slave_destroy, \
1110 .bios_param = ata_std_bios_param 1129 .bios_param = ata_std_bios_param, \
1130 .sdev_attrs = ata_common_sdev_attrs
1111 1131
1112#define ATA_NCQ_SHT(drv_name) \ 1132#define ATA_NCQ_SHT(drv_name) \
1113 ATA_BASE_SHT(drv_name), \ 1133 ATA_BASE_SHT(drv_name), \
@@ -1129,7 +1149,7 @@ static inline bool sata_pmp_attached(struct ata_port *ap)
1129 1149
1130static inline int ata_is_host_link(const struct ata_link *link) 1150static inline int ata_is_host_link(const struct ata_link *link)
1131{ 1151{
1132 return link == &link->ap->link; 1152 return link == &link->ap->link || link == link->ap->slave_link;
1133} 1153}
1134#else /* CONFIG_SATA_PMP */ 1154#else /* CONFIG_SATA_PMP */
1135static inline bool sata_pmp_supported(struct ata_port *ap) 1155static inline bool sata_pmp_supported(struct ata_port *ap)
@@ -1162,7 +1182,7 @@ static inline int sata_srst_pmp(struct ata_link *link)
1162 printk("%sata%u: "fmt, lv, (ap)->print_id , ##args) 1182 printk("%sata%u: "fmt, lv, (ap)->print_id , ##args)
1163 1183
1164#define ata_link_printk(link, lv, fmt, args...) do { \ 1184#define ata_link_printk(link, lv, fmt, args...) do { \
1165 if (sata_pmp_attached((link)->ap)) \ 1185 if (sata_pmp_attached((link)->ap) || (link)->ap->slave_link) \
1166 printk("%sata%u.%02u: "fmt, lv, (link)->ap->print_id, \ 1186 printk("%sata%u.%02u: "fmt, lv, (link)->ap->print_id, \
1167 (link)->pmp , ##args); \ 1187 (link)->pmp , ##args); \
1168 else \ 1188 else \
@@ -1260,34 +1280,17 @@ static inline int ata_link_active(struct ata_link *link)
1260 return ata_tag_valid(link->active_tag) || link->sactive; 1280 return ata_tag_valid(link->active_tag) || link->sactive;
1261} 1281}
1262 1282
1263static inline struct ata_link *ata_port_first_link(struct ata_port *ap) 1283extern struct ata_link *__ata_port_next_link(struct ata_port *ap,
1264{ 1284 struct ata_link *link,
1265 if (sata_pmp_attached(ap)) 1285 bool dev_only);
1266 return ap->pmp_link;
1267 return &ap->link;
1268}
1269
1270static inline struct ata_link *ata_port_next_link(struct ata_link *link)
1271{
1272 struct ata_port *ap = link->ap;
1273
1274 if (ata_is_host_link(link)) {
1275 if (!sata_pmp_attached(ap))
1276 return NULL;
1277 return ap->pmp_link;
1278 }
1279
1280 if (++link < ap->nr_pmp_links + ap->pmp_link)
1281 return link;
1282 return NULL;
1283}
1284 1286
1285#define __ata_port_for_each_link(lk, ap) \ 1287#define __ata_port_for_each_link(link, ap) \
1286 for ((lk) = &(ap)->link; (lk); (lk) = ata_port_next_link(lk)) 1288 for ((link) = __ata_port_next_link((ap), NULL, false); (link); \
1289 (link) = __ata_port_next_link((ap), (link), false))
1287 1290
1288#define ata_port_for_each_link(link, ap) \ 1291#define ata_port_for_each_link(link, ap) \
1289 for ((link) = ata_port_first_link(ap); (link); \ 1292 for ((link) = __ata_port_next_link((ap), NULL, true); (link); \
1290 (link) = ata_port_next_link(link)) 1293 (link) = __ata_port_next_link((ap), (link), true))
1291 1294
1292#define ata_link_for_each_dev(dev, link) \ 1295#define ata_link_for_each_dev(dev, link) \
1293 for ((dev) = (link)->device; \ 1296 for ((dev) = (link)->device; \
@@ -1424,6 +1427,28 @@ static inline unsigned long ata_deadline(unsigned long from_jiffies,
1424 return from_jiffies + msecs_to_jiffies(timeout_msecs); 1427 return from_jiffies + msecs_to_jiffies(timeout_msecs);
1425} 1428}
1426 1429
1430/* Don't open code these in drivers as there are traps. Firstly the range may
1431 change in future hardware and specs, secondly 0xFF means 'no DMA' but is
1432 > UDMA_0. Dyma ddreigiau */
1433
1434static inline int ata_using_mwdma(struct ata_device *adev)
1435{
1436 if (adev->dma_mode >= XFER_MW_DMA_0 && adev->dma_mode <= XFER_MW_DMA_4)
1437 return 1;
1438 return 0;
1439}
1440
1441static inline int ata_using_udma(struct ata_device *adev)
1442{
1443 if (adev->dma_mode >= XFER_UDMA_0 && adev->dma_mode <= XFER_UDMA_7)
1444 return 1;
1445 return 0;
1446}
1447
1448static inline int ata_dma_enabled(struct ata_device *adev)
1449{
1450 return (adev->dma_mode == 0xFF ? 0 : 1);
1451}
1427 1452
1428/************************************************************************** 1453/**************************************************************************
1429 * PMP - drivers/ata/libata-pmp.c 1454 * PMP - drivers/ata/libata-pmp.c
diff --git a/include/linux/libps2.h b/include/linux/libps2.h
index f6f301e2b0f5..afc413369101 100644
--- a/include/linux/libps2.h
+++ b/include/linux/libps2.h
@@ -43,7 +43,6 @@ void ps2_init(struct ps2dev *ps2dev, struct serio *serio);
43int ps2_sendbyte(struct ps2dev *ps2dev, unsigned char byte, int timeout); 43int ps2_sendbyte(struct ps2dev *ps2dev, unsigned char byte, int timeout);
44void ps2_drain(struct ps2dev *ps2dev, int maxbytes, int timeout); 44void ps2_drain(struct ps2dev *ps2dev, int maxbytes, int timeout);
45int ps2_command(struct ps2dev *ps2dev, unsigned char *param, int command); 45int ps2_command(struct ps2dev *ps2dev, unsigned char *param, int command);
46int ps2_schedule_command(struct ps2dev *ps2dev, unsigned char *param, int command);
47int ps2_handle_ack(struct ps2dev *ps2dev, unsigned char data); 46int ps2_handle_ack(struct ps2dev *ps2dev, unsigned char data);
48int ps2_handle_response(struct ps2dev *ps2dev, unsigned char data); 47int ps2_handle_response(struct ps2dev *ps2dev, unsigned char data);
49void ps2_cmd_aborted(struct ps2dev *ps2dev); 48void ps2_cmd_aborted(struct ps2dev *ps2dev);
diff --git a/include/linux/linkage.h b/include/linux/linkage.h
index 56ba37394656..9fd1f859021b 100644
--- a/include/linux/linkage.h
+++ b/include/linux/linkage.h
@@ -4,8 +4,6 @@
4#include <linux/compiler.h> 4#include <linux/compiler.h>
5#include <asm/linkage.h> 5#include <asm/linkage.h>
6 6
7#define notrace __attribute__((no_instrument_function))
8
9#ifdef __cplusplus 7#ifdef __cplusplus
10#define CPP_ASMLINKAGE extern "C" 8#define CPP_ASMLINKAGE extern "C"
11#else 9#else
diff --git a/include/linux/list.h b/include/linux/list.h
index 139ec41d9c2e..969f6e92d089 100644
--- a/include/linux/list.h
+++ b/include/linux/list.h
@@ -61,14 +61,10 @@ extern void __list_add(struct list_head *new,
61 * Insert a new entry after the specified head. 61 * Insert a new entry after the specified head.
62 * This is good for implementing stacks. 62 * This is good for implementing stacks.
63 */ 63 */
64#ifndef CONFIG_DEBUG_LIST
65static inline void list_add(struct list_head *new, struct list_head *head) 64static inline void list_add(struct list_head *new, struct list_head *head)
66{ 65{
67 __list_add(new, head, head->next); 66 __list_add(new, head, head->next);
68} 67}
69#else
70extern void list_add(struct list_head *new, struct list_head *head);
71#endif
72 68
73 69
74/** 70/**
@@ -218,22 +214,62 @@ static inline int list_is_singular(const struct list_head *head)
218 return !list_empty(head) && (head->next == head->prev); 214 return !list_empty(head) && (head->next == head->prev);
219} 215}
220 216
217static inline void __list_cut_position(struct list_head *list,
218 struct list_head *head, struct list_head *entry)
219{
220 struct list_head *new_first = entry->next;
221 list->next = head->next;
222 list->next->prev = list;
223 list->prev = entry;
224 entry->next = list;
225 head->next = new_first;
226 new_first->prev = head;
227}
228
229/**
230 * list_cut_position - cut a list into two
231 * @list: a new list to add all removed entries
232 * @head: a list with entries
233 * @entry: an entry within head, could be the head itself
234 * and if so we won't cut the list
235 *
236 * This helper moves the initial part of @head, up to and
237 * including @entry, from @head to @list. You should
238 * pass on @entry an element you know is on @head. @list
239 * should be an empty list or a list you do not care about
240 * losing its data.
241 *
242 */
243static inline void list_cut_position(struct list_head *list,
244 struct list_head *head, struct list_head *entry)
245{
246 if (list_empty(head))
247 return;
248 if (list_is_singular(head) &&
249 (head->next != entry && head != entry))
250 return;
251 if (entry == head)
252 INIT_LIST_HEAD(list);
253 else
254 __list_cut_position(list, head, entry);
255}
256
221static inline void __list_splice(const struct list_head *list, 257static inline void __list_splice(const struct list_head *list,
222 struct list_head *head) 258 struct list_head *prev,
259 struct list_head *next)
223{ 260{
224 struct list_head *first = list->next; 261 struct list_head *first = list->next;
225 struct list_head *last = list->prev; 262 struct list_head *last = list->prev;
226 struct list_head *at = head->next;
227 263
228 first->prev = head; 264 first->prev = prev;
229 head->next = first; 265 prev->next = first;
230 266
231 last->next = at; 267 last->next = next;
232 at->prev = last; 268 next->prev = last;
233} 269}
234 270
235/** 271/**
236 * list_splice - join two lists 272 * list_splice - join two lists, this is designed for stacks
237 * @list: the new list to add. 273 * @list: the new list to add.
238 * @head: the place to add it in the first list. 274 * @head: the place to add it in the first list.
239 */ 275 */
@@ -241,7 +277,19 @@ static inline void list_splice(const struct list_head *list,
241 struct list_head *head) 277 struct list_head *head)
242{ 278{
243 if (!list_empty(list)) 279 if (!list_empty(list))
244 __list_splice(list, head); 280 __list_splice(list, head, head->next);
281}
282
283/**
284 * list_splice_tail - join two lists, each list being a queue
285 * @list: the new list to add.
286 * @head: the place to add it in the first list.
287 */
288static inline void list_splice_tail(struct list_head *list,
289 struct list_head *head)
290{
291 if (!list_empty(list))
292 __list_splice(list, head->prev, head);
245} 293}
246 294
247/** 295/**
@@ -255,7 +303,24 @@ static inline void list_splice_init(struct list_head *list,
255 struct list_head *head) 303 struct list_head *head)
256{ 304{
257 if (!list_empty(list)) { 305 if (!list_empty(list)) {
258 __list_splice(list, head); 306 __list_splice(list, head, head->next);
307 INIT_LIST_HEAD(list);
308 }
309}
310
311/**
312 * list_splice_tail_init - join two lists and reinitialise the emptied list
313 * @list: the new list to add.
314 * @head: the place to add it in the first list.
315 *
316 * Each of the lists is a queue.
317 * The list at @list is reinitialised
318 */
319static inline void list_splice_tail_init(struct list_head *list,
320 struct list_head *head)
321{
322 if (!list_empty(list)) {
323 __list_splice(list, head->prev, head);
259 INIT_LIST_HEAD(list); 324 INIT_LIST_HEAD(list);
260 } 325 }
261} 326}
@@ -554,6 +619,19 @@ static inline void hlist_add_after(struct hlist_node *n,
554 next->next->pprev = &next->next; 619 next->next->pprev = &next->next;
555} 620}
556 621
622/*
623 * Move a list from one list head to another. Fixup the pprev
624 * reference of the first entry if it exists.
625 */
626static inline void hlist_move_list(struct hlist_head *old,
627 struct hlist_head *new)
628{
629 new->first = old->first;
630 if (new->first)
631 new->first->pprev = &new->first;
632 old->first = NULL;
633}
634
557#define hlist_entry(ptr, type, member) container_of(ptr,type,member) 635#define hlist_entry(ptr, type, member) container_of(ptr,type,member)
558 636
559#define hlist_for_each(pos, head) \ 637#define hlist_for_each(pos, head) \
diff --git a/include/linux/lockd/bind.h b/include/linux/lockd/bind.h
index 3d25bcd139d1..e5872dc994c0 100644
--- a/include/linux/lockd/bind.h
+++ b/include/linux/lockd/bind.h
@@ -27,7 +27,6 @@ struct nlmsvc_binding {
27 struct nfs_fh *, 27 struct nfs_fh *,
28 struct file **); 28 struct file **);
29 void (*fclose)(struct file *); 29 void (*fclose)(struct file *);
30 unsigned long (*get_grace_period)(void);
31}; 30};
32 31
33extern struct nlmsvc_binding * nlmsvc_ops; 32extern struct nlmsvc_binding * nlmsvc_ops;
@@ -53,15 +52,7 @@ extern void nlmclnt_done(struct nlm_host *host);
53 52
54extern int nlmclnt_proc(struct nlm_host *host, int cmd, 53extern int nlmclnt_proc(struct nlm_host *host, int cmd,
55 struct file_lock *fl); 54 struct file_lock *fl);
56extern int lockd_up(int proto); 55extern int lockd_up(void);
57extern void lockd_down(void); 56extern void lockd_down(void);
58 57
59unsigned long get_nfs_grace_period(void);
60
61#ifdef CONFIG_NFSD_V4
62unsigned long get_nfs4_grace_period(void);
63#else
64static inline unsigned long get_nfs4_grace_period(void) {return 0;}
65#endif
66
67#endif /* LINUX_LOCKD_BIND_H */ 58#endif /* LINUX_LOCKD_BIND_H */
diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h
index 102d928f7206..b56d5aa9b194 100644
--- a/include/linux/lockd/lockd.h
+++ b/include/linux/lockd/lockd.h
@@ -12,6 +12,8 @@
12#ifdef __KERNEL__ 12#ifdef __KERNEL__
13 13
14#include <linux/in.h> 14#include <linux/in.h>
15#include <linux/in6.h>
16#include <net/ipv6.h>
15#include <linux/fs.h> 17#include <linux/fs.h>
16#include <linux/kref.h> 18#include <linux/kref.h>
17#include <linux/utsname.h> 19#include <linux/utsname.h>
@@ -38,8 +40,9 @@
38 */ 40 */
39struct nlm_host { 41struct nlm_host {
40 struct hlist_node h_hash; /* doubly linked list */ 42 struct hlist_node h_hash; /* doubly linked list */
41 struct sockaddr_in h_addr; /* peer address */ 43 struct sockaddr_storage h_addr; /* peer address */
42 struct sockaddr_in h_saddr; /* our address (optional) */ 44 size_t h_addrlen;
45 struct sockaddr_storage h_srcaddr; /* our address (optional) */
43 struct rpc_clnt * h_rpcclnt; /* RPC client to talk to peer */ 46 struct rpc_clnt * h_rpcclnt; /* RPC client to talk to peer */
44 char * h_name; /* remote hostname */ 47 char * h_name; /* remote hostname */
45 u32 h_version; /* interface version */ 48 u32 h_version; /* interface version */
@@ -61,18 +64,56 @@ struct nlm_host {
61 struct list_head h_granted; /* Locks in GRANTED state */ 64 struct list_head h_granted; /* Locks in GRANTED state */
62 struct list_head h_reclaim; /* Locks in RECLAIM state */ 65 struct list_head h_reclaim; /* Locks in RECLAIM state */
63 struct nsm_handle * h_nsmhandle; /* NSM status handle */ 66 struct nsm_handle * h_nsmhandle; /* NSM status handle */
67
68 char h_addrbuf[48], /* address eyecatchers */
69 h_srcaddrbuf[48];
64}; 70};
65 71
66struct nsm_handle { 72struct nsm_handle {
67 struct list_head sm_link; 73 struct list_head sm_link;
68 atomic_t sm_count; 74 atomic_t sm_count;
69 char * sm_name; 75 char * sm_name;
70 struct sockaddr_in sm_addr; 76 struct sockaddr_storage sm_addr;
77 size_t sm_addrlen;
71 unsigned int sm_monitored : 1, 78 unsigned int sm_monitored : 1,
72 sm_sticky : 1; /* don't unmonitor */ 79 sm_sticky : 1; /* don't unmonitor */
80 char sm_addrbuf[48]; /* address eyecatcher */
73}; 81};
74 82
75/* 83/*
84 * Rigorous type checking on sockaddr type conversions
85 */
86static inline struct sockaddr_in *nlm_addr_in(const struct nlm_host *host)
87{
88 return (struct sockaddr_in *)&host->h_addr;
89}
90
91static inline struct sockaddr *nlm_addr(const struct nlm_host *host)
92{
93 return (struct sockaddr *)&host->h_addr;
94}
95
96static inline struct sockaddr_in *nlm_srcaddr_in(const struct nlm_host *host)
97{
98 return (struct sockaddr_in *)&host->h_srcaddr;
99}
100
101static inline struct sockaddr *nlm_srcaddr(const struct nlm_host *host)
102{
103 return (struct sockaddr *)&host->h_srcaddr;
104}
105
106static inline struct sockaddr_in *nsm_addr_in(const struct nsm_handle *handle)
107{
108 return (struct sockaddr_in *)&handle->sm_addr;
109}
110
111static inline struct sockaddr *nsm_addr(const struct nsm_handle *handle)
112{
113 return (struct sockaddr *)&handle->sm_addr;
114}
115
116/*
76 * Map an fl_owner_t into a unique 32-bit "pid" 117 * Map an fl_owner_t into a unique 32-bit "pid"
77 */ 118 */
78struct nlm_lockowner { 119struct nlm_lockowner {
@@ -166,7 +207,8 @@ int nlm_async_reply(struct nlm_rqst *, u32, const struct rpc_call_ops *);
166struct nlm_wait * nlmclnt_prepare_block(struct nlm_host *host, struct file_lock *fl); 207struct nlm_wait * nlmclnt_prepare_block(struct nlm_host *host, struct file_lock *fl);
167void nlmclnt_finish_block(struct nlm_wait *block); 208void nlmclnt_finish_block(struct nlm_wait *block);
168int nlmclnt_block(struct nlm_wait *block, struct nlm_rqst *req, long timeout); 209int nlmclnt_block(struct nlm_wait *block, struct nlm_rqst *req, long timeout);
169__be32 nlmclnt_grant(const struct sockaddr_in *addr, const struct nlm_lock *); 210__be32 nlmclnt_grant(const struct sockaddr *addr,
211 const struct nlm_lock *lock);
170void nlmclnt_recovery(struct nlm_host *); 212void nlmclnt_recovery(struct nlm_host *);
171int nlmclnt_reclaim(struct nlm_host *, struct file_lock *); 213int nlmclnt_reclaim(struct nlm_host *, struct file_lock *);
172void nlmclnt_next_cookie(struct nlm_cookie *); 214void nlmclnt_next_cookie(struct nlm_cookie *);
@@ -174,12 +216,14 @@ void nlmclnt_next_cookie(struct nlm_cookie *);
174/* 216/*
175 * Host cache 217 * Host cache
176 */ 218 */
177struct nlm_host *nlmclnt_lookup_host(const struct sockaddr_in *sin, 219struct nlm_host *nlmclnt_lookup_host(const struct sockaddr *sap,
178 int proto, u32 version, 220 const size_t salen,
221 const unsigned short protocol,
222 const u32 version,
223 const char *hostname);
224struct nlm_host *nlmsvc_lookup_host(const struct svc_rqst *rqstp,
179 const char *hostname, 225 const char *hostname,
180 unsigned int hostname_len); 226 const size_t hostname_len);
181struct nlm_host *nlmsvc_lookup_host(struct svc_rqst *, const char *,
182 unsigned int);
183struct rpc_clnt * nlm_bind_host(struct nlm_host *); 227struct rpc_clnt * nlm_bind_host(struct nlm_host *);
184void nlm_rebind_host(struct nlm_host *); 228void nlm_rebind_host(struct nlm_host *);
185struct nlm_host * nlm_get_host(struct nlm_host *); 229struct nlm_host * nlm_get_host(struct nlm_host *);
@@ -200,10 +244,12 @@ typedef int (*nlm_host_match_fn_t)(void *cur, struct nlm_host *ref);
200 * Server-side lock handling 244 * Server-side lock handling
201 */ 245 */
202__be32 nlmsvc_lock(struct svc_rqst *, struct nlm_file *, 246__be32 nlmsvc_lock(struct svc_rqst *, struct nlm_file *,
203 struct nlm_lock *, int, struct nlm_cookie *); 247 struct nlm_host *, struct nlm_lock *, int,
248 struct nlm_cookie *, int);
204__be32 nlmsvc_unlock(struct nlm_file *, struct nlm_lock *); 249__be32 nlmsvc_unlock(struct nlm_file *, struct nlm_lock *);
205__be32 nlmsvc_testlock(struct svc_rqst *, struct nlm_file *, 250__be32 nlmsvc_testlock(struct svc_rqst *, struct nlm_file *,
206 struct nlm_lock *, struct nlm_lock *, struct nlm_cookie *); 251 struct nlm_host *, struct nlm_lock *,
252 struct nlm_lock *, struct nlm_cookie *);
207__be32 nlmsvc_cancel_blocked(struct nlm_file *, struct nlm_lock *); 253__be32 nlmsvc_cancel_blocked(struct nlm_file *, struct nlm_lock *);
208unsigned long nlmsvc_retry_blocked(void); 254unsigned long nlmsvc_retry_blocked(void);
209void nlmsvc_traverse_blocks(struct nlm_host *, struct nlm_file *, 255void nlmsvc_traverse_blocks(struct nlm_host *, struct nlm_file *,
@@ -224,22 +270,89 @@ void nlmsvc_invalidate_all(void);
224 * Cluster failover support 270 * Cluster failover support
225 */ 271 */
226int nlmsvc_unlock_all_by_sb(struct super_block *sb); 272int nlmsvc_unlock_all_by_sb(struct super_block *sb);
227int nlmsvc_unlock_all_by_ip(__be32 server_addr); 273int nlmsvc_unlock_all_by_ip(struct sockaddr *server_addr);
228 274
229static inline struct inode *nlmsvc_file_inode(struct nlm_file *file) 275static inline struct inode *nlmsvc_file_inode(struct nlm_file *file)
230{ 276{
231 return file->f_file->f_path.dentry->d_inode; 277 return file->f_file->f_path.dentry->d_inode;
232} 278}
233 279
280static inline int __nlm_privileged_request4(const struct sockaddr *sap)
281{
282 const struct sockaddr_in *sin = (struct sockaddr_in *)sap;
283 return (sin->sin_addr.s_addr == htonl(INADDR_LOOPBACK)) &&
284 (ntohs(sin->sin_port) < 1024);
285}
286
287#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
288static inline int __nlm_privileged_request6(const struct sockaddr *sap)
289{
290 const struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sap;
291 return (ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LOOPBACK) &&
292 (ntohs(sin6->sin6_port) < 1024);
293}
294#else /* defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */
295static inline int __nlm_privileged_request6(const struct sockaddr *sap)
296{
297 return 0;
298}
299#endif /* defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */
300
234/* 301/*
235 * Compare two host addresses (needs modifying for ipv6) 302 * Ensure incoming requests are from local privileged callers.
303 *
304 * Return TRUE if sender is local and is connecting via a privileged port;
305 * otherwise return FALSE.
236 */ 306 */
237static inline int nlm_cmp_addr(const struct sockaddr_in *sin1, 307static inline int nlm_privileged_requester(const struct svc_rqst *rqstp)
238 const struct sockaddr_in *sin2)
239{ 308{
309 const struct sockaddr *sap = svc_addr(rqstp);
310
311 switch (sap->sa_family) {
312 case AF_INET:
313 return __nlm_privileged_request4(sap);
314 case AF_INET6:
315 return __nlm_privileged_request6(sap);
316 default:
317 return 0;
318 }
319}
320
321static inline int __nlm_cmp_addr4(const struct sockaddr *sap1,
322 const struct sockaddr *sap2)
323{
324 const struct sockaddr_in *sin1 = (const struct sockaddr_in *)sap1;
325 const struct sockaddr_in *sin2 = (const struct sockaddr_in *)sap2;
240 return sin1->sin_addr.s_addr == sin2->sin_addr.s_addr; 326 return sin1->sin_addr.s_addr == sin2->sin_addr.s_addr;
241} 327}
242 328
329static inline int __nlm_cmp_addr6(const struct sockaddr *sap1,
330 const struct sockaddr *sap2)
331{
332 const struct sockaddr_in6 *sin1 = (const struct sockaddr_in6 *)sap1;
333 const struct sockaddr_in6 *sin2 = (const struct sockaddr_in6 *)sap2;
334 return ipv6_addr_equal(&sin1->sin6_addr, &sin2->sin6_addr);
335}
336
337/*
338 * Compare two host addresses
339 *
340 * Return TRUE if the addresses are the same; otherwise FALSE.
341 */
342static inline int nlm_cmp_addr(const struct sockaddr *sap1,
343 const struct sockaddr *sap2)
344{
345 if (sap1->sa_family == sap2->sa_family) {
346 switch (sap1->sa_family) {
347 case AF_INET:
348 return __nlm_cmp_addr4(sap1, sap2);
349 case AF_INET6:
350 return __nlm_cmp_addr6(sap1, sap2);
351 }
352 }
353 return 0;
354}
355
243/* 356/*
244 * Compare two NLM locks. 357 * Compare two NLM locks.
245 * When the second lock is of type F_UNLCK, this acts like a wildcard. 358 * When the second lock is of type F_UNLCK, this acts like a wildcard.
diff --git a/include/linux/lockd/xdr.h b/include/linux/lockd/xdr.h
index df18fa053bcd..d6b3a802c046 100644
--- a/include/linux/lockd/xdr.h
+++ b/include/linux/lockd/xdr.h
@@ -81,8 +81,6 @@ struct nlm_reboot {
81 unsigned int len; 81 unsigned int len;
82 u32 state; 82 u32 state;
83 __be32 addr; 83 __be32 addr;
84 __be32 vers;
85 __be32 proto;
86}; 84};
87 85
88/* 86/*
diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h
index 2486eb4edbf1..331e5f1c2d8e 100644
--- a/include/linux/lockdep.h
+++ b/include/linux/lockdep.h
@@ -89,6 +89,7 @@ struct lock_class {
89 89
90 struct lockdep_subclass_key *key; 90 struct lockdep_subclass_key *key;
91 unsigned int subclass; 91 unsigned int subclass;
92 unsigned int dep_gen_id;
92 93
93 /* 94 /*
94 * IRQ/softirq usage tracking bits: 95 * IRQ/softirq usage tracking bits:
@@ -189,6 +190,14 @@ struct lock_chain {
189 u64 chain_key; 190 u64 chain_key;
190}; 191};
191 192
193#define MAX_LOCKDEP_KEYS_BITS 13
194/*
195 * Subtract one because we offset hlock->class_idx by 1 in order
196 * to make 0 mean no class. This avoids overflowing the class_idx
197 * bitfield and hitting the BUG in hlock_class().
198 */
199#define MAX_LOCKDEP_KEYS ((1UL << MAX_LOCKDEP_KEYS_BITS) - 1)
200
192struct held_lock { 201struct held_lock {
193 /* 202 /*
194 * One-way hash of the dependency chain up to this point. We 203 * One-way hash of the dependency chain up to this point. We
@@ -205,14 +214,14 @@ struct held_lock {
205 * with zero), here we store the previous hash value: 214 * with zero), here we store the previous hash value:
206 */ 215 */
207 u64 prev_chain_key; 216 u64 prev_chain_key;
208 struct lock_class *class;
209 unsigned long acquire_ip; 217 unsigned long acquire_ip;
210 struct lockdep_map *instance; 218 struct lockdep_map *instance;
211 219 struct lockdep_map *nest_lock;
212#ifdef CONFIG_LOCK_STAT 220#ifdef CONFIG_LOCK_STAT
213 u64 waittime_stamp; 221 u64 waittime_stamp;
214 u64 holdtime_stamp; 222 u64 holdtime_stamp;
215#endif 223#endif
224 unsigned int class_idx:MAX_LOCKDEP_KEYS_BITS;
216 /* 225 /*
217 * The lock-stack is unified in that the lock chains of interrupt 226 * The lock-stack is unified in that the lock chains of interrupt
218 * contexts nest ontop of process context chains, but we 'separate' 227 * contexts nest ontop of process context chains, but we 'separate'
@@ -226,11 +235,11 @@ struct held_lock {
226 * The following field is used to detect when we cross into an 235 * The following field is used to detect when we cross into an
227 * interrupt context: 236 * interrupt context:
228 */ 237 */
229 int irq_context; 238 unsigned int irq_context:2; /* bit 0 - soft, bit 1 - hard */
230 int trylock; 239 unsigned int trylock:1;
231 int read; 240 unsigned int read:2; /* see lock_acquire() comment */
232 int check; 241 unsigned int check:2; /* see lock_acquire() comment */
233 int hardirqs_off; 242 unsigned int hardirqs_off:1;
234}; 243};
235 244
236/* 245/*
@@ -294,11 +303,15 @@ extern void lockdep_init_map(struct lockdep_map *lock, const char *name,
294 * 2: full validation 303 * 2: full validation
295 */ 304 */
296extern void lock_acquire(struct lockdep_map *lock, unsigned int subclass, 305extern void lock_acquire(struct lockdep_map *lock, unsigned int subclass,
297 int trylock, int read, int check, unsigned long ip); 306 int trylock, int read, int check,
307 struct lockdep_map *nest_lock, unsigned long ip);
298 308
299extern void lock_release(struct lockdep_map *lock, int nested, 309extern void lock_release(struct lockdep_map *lock, int nested,
300 unsigned long ip); 310 unsigned long ip);
301 311
312extern void lock_set_subclass(struct lockdep_map *lock, unsigned int subclass,
313 unsigned long ip);
314
302# define INIT_LOCKDEP .lockdep_recursion = 0, 315# define INIT_LOCKDEP .lockdep_recursion = 0,
303 316
304#define lockdep_depth(tsk) (debug_locks ? (tsk)->lockdep_depth : 0) 317#define lockdep_depth(tsk) (debug_locks ? (tsk)->lockdep_depth : 0)
@@ -313,8 +326,9 @@ static inline void lockdep_on(void)
313{ 326{
314} 327}
315 328
316# define lock_acquire(l, s, t, r, c, i) do { } while (0) 329# define lock_acquire(l, s, t, r, c, n, i) do { } while (0)
317# define lock_release(l, n, i) do { } while (0) 330# define lock_release(l, n, i) do { } while (0)
331# define lock_set_subclass(l, s, i) do { } while (0)
318# define lockdep_init() do { } while (0) 332# define lockdep_init() do { } while (0)
319# define lockdep_info() do { } while (0) 333# define lockdep_info() do { } while (0)
320# define lockdep_init_map(lock, name, key, sub) do { (void)(key); } while (0) 334# define lockdep_init_map(lock, name, key, sub) do { (void)(key); } while (0)
@@ -400,9 +414,11 @@ static inline void print_irqtrace_events(struct task_struct *curr)
400 414
401#ifdef CONFIG_DEBUG_LOCK_ALLOC 415#ifdef CONFIG_DEBUG_LOCK_ALLOC
402# ifdef CONFIG_PROVE_LOCKING 416# ifdef CONFIG_PROVE_LOCKING
403# define spin_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 2, i) 417# define spin_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 2, NULL, i)
418# define spin_acquire_nest(l, s, t, n, i) lock_acquire(l, s, t, 0, 2, n, i)
404# else 419# else
405# define spin_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 1, i) 420# define spin_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 1, NULL, i)
421# define spin_acquire_nest(l, s, t, n, i) lock_acquire(l, s, t, 0, 1, NULL, i)
406# endif 422# endif
407# define spin_release(l, n, i) lock_release(l, n, i) 423# define spin_release(l, n, i) lock_release(l, n, i)
408#else 424#else
@@ -412,11 +428,11 @@ static inline void print_irqtrace_events(struct task_struct *curr)
412 428
413#ifdef CONFIG_DEBUG_LOCK_ALLOC 429#ifdef CONFIG_DEBUG_LOCK_ALLOC
414# ifdef CONFIG_PROVE_LOCKING 430# ifdef CONFIG_PROVE_LOCKING
415# define rwlock_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 2, i) 431# define rwlock_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 2, NULL, i)
416# define rwlock_acquire_read(l, s, t, i) lock_acquire(l, s, t, 2, 2, i) 432# define rwlock_acquire_read(l, s, t, i) lock_acquire(l, s, t, 2, 2, NULL, i)
417# else 433# else
418# define rwlock_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 1, i) 434# define rwlock_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 1, NULL, i)
419# define rwlock_acquire_read(l, s, t, i) lock_acquire(l, s, t, 2, 1, i) 435# define rwlock_acquire_read(l, s, t, i) lock_acquire(l, s, t, 2, 1, NULL, i)
420# endif 436# endif
421# define rwlock_release(l, n, i) lock_release(l, n, i) 437# define rwlock_release(l, n, i) lock_release(l, n, i)
422#else 438#else
@@ -427,9 +443,9 @@ static inline void print_irqtrace_events(struct task_struct *curr)
427 443
428#ifdef CONFIG_DEBUG_LOCK_ALLOC 444#ifdef CONFIG_DEBUG_LOCK_ALLOC
429# ifdef CONFIG_PROVE_LOCKING 445# ifdef CONFIG_PROVE_LOCKING
430# define mutex_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 2, i) 446# define mutex_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 2, NULL, i)
431# else 447# else
432# define mutex_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 1, i) 448# define mutex_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 1, NULL, i)
433# endif 449# endif
434# define mutex_release(l, n, i) lock_release(l, n, i) 450# define mutex_release(l, n, i) lock_release(l, n, i)
435#else 451#else
@@ -439,11 +455,11 @@ static inline void print_irqtrace_events(struct task_struct *curr)
439 455
440#ifdef CONFIG_DEBUG_LOCK_ALLOC 456#ifdef CONFIG_DEBUG_LOCK_ALLOC
441# ifdef CONFIG_PROVE_LOCKING 457# ifdef CONFIG_PROVE_LOCKING
442# define rwsem_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 2, i) 458# define rwsem_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 2, NULL, i)
443# define rwsem_acquire_read(l, s, t, i) lock_acquire(l, s, t, 1, 2, i) 459# define rwsem_acquire_read(l, s, t, i) lock_acquire(l, s, t, 1, 2, NULL, i)
444# else 460# else
445# define rwsem_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 1, i) 461# define rwsem_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 1, NULL, i)
446# define rwsem_acquire_read(l, s, t, i) lock_acquire(l, s, t, 1, 1, i) 462# define rwsem_acquire_read(l, s, t, i) lock_acquire(l, s, t, 1, 1, NULL, i)
447# endif 463# endif
448# define rwsem_release(l, n, i) lock_release(l, n, i) 464# define rwsem_release(l, n, i) lock_release(l, n, i)
449#else 465#else
@@ -452,4 +468,16 @@ static inline void print_irqtrace_events(struct task_struct *curr)
452# define rwsem_release(l, n, i) do { } while (0) 468# define rwsem_release(l, n, i) do { } while (0)
453#endif 469#endif
454 470
471#ifdef CONFIG_DEBUG_LOCK_ALLOC
472# ifdef CONFIG_PROVE_LOCKING
473# define lock_map_acquire(l) lock_acquire(l, 0, 0, 0, 2, NULL, _THIS_IP_)
474# else
475# define lock_map_acquire(l) lock_acquire(l, 0, 0, 0, 1, NULL, _THIS_IP_)
476# endif
477# define lock_map_release(l) lock_release(l, 1, _THIS_IP_)
478#else
479# define lock_map_acquire(l) do { } while (0)
480# define lock_map_release(l) do { } while (0)
481#endif
482
455#endif /* __LINUX_LOCKDEP_H */ 483#endif /* __LINUX_LOCKDEP_H */
diff --git a/include/linux/mISDNdsp.h b/include/linux/mISDNdsp.h
new file mode 100644
index 000000000000..6b71d2dce508
--- /dev/null
+++ b/include/linux/mISDNdsp.h
@@ -0,0 +1,37 @@
1#ifndef __mISDNdsp_H__
2#define __mISDNdsp_H__
3
4struct mISDN_dsp_element_arg {
5 char *name;
6 char *def;
7 char *desc;
8};
9
10struct mISDN_dsp_element {
11 char *name;
12 void *(*new)(const char *arg);
13 void (*free)(void *p);
14 void (*process_tx)(void *p, unsigned char *data, int len);
15 void (*process_rx)(void *p, unsigned char *data, int len);
16 int num_args;
17 struct mISDN_dsp_element_arg
18 *args;
19};
20
21extern int mISDN_dsp_element_register(struct mISDN_dsp_element *elem);
22extern void mISDN_dsp_element_unregister(struct mISDN_dsp_element *elem);
23
24struct dsp_features {
25 int hfc_id; /* unique id to identify the chip (or -1) */
26 int hfc_dtmf; /* set if HFCmulti card supports dtmf */
27 int hfc_loops; /* set if card supports tone loops */
28 int hfc_echocanhw; /* set if card supports echocancelation*/
29 int pcm_id; /* unique id to identify the pcm bus (or -1) */
30 int pcm_slots; /* number of slots on the pcm bus */
31 int pcm_banks; /* number of IO banks of pcm bus */
32 int unclocked; /* data is not clocked (has jitter/loss) */
33 int unordered; /* data is unordered (packets have index) */
34};
35
36#endif
37
diff --git a/include/linux/mISDNhw.h b/include/linux/mISDNhw.h
new file mode 100644
index 000000000000..e794dfb87504
--- /dev/null
+++ b/include/linux/mISDNhw.h
@@ -0,0 +1,193 @@
1/*
2 *
3 * Author Karsten Keil <kkeil@novell.com>
4 *
5 * Basic declarations for the mISDN HW channels
6 *
7 * Copyright 2008 by Karsten Keil <kkeil@novell.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 */
19
20#ifndef MISDNHW_H
21#define MISDNHW_H
22#include <linux/mISDNif.h>
23#include <linux/timer.h>
24
25/*
26 * HW DEBUG 0xHHHHGGGG
27 * H - hardware driver specific bits
28 * G - for all drivers
29 */
30
31#define DEBUG_HW 0x00000001
32#define DEBUG_HW_OPEN 0x00000002
33#define DEBUG_HW_DCHANNEL 0x00000100
34#define DEBUG_HW_DFIFO 0x00000200
35#define DEBUG_HW_BCHANNEL 0x00001000
36#define DEBUG_HW_BFIFO 0x00002000
37
38#define MAX_DFRAME_LEN_L1 300
39#define MAX_MON_FRAME 32
40#define MAX_LOG_SPACE 2048
41#define MISDN_COPY_SIZE 32
42
43/* channel->Flags bit field */
44#define FLG_TX_BUSY 0 /* tx_buf in use */
45#define FLG_TX_NEXT 1 /* next_skb in use */
46#define FLG_L1_BUSY 2 /* L1 is permanent busy */
47#define FLG_L2_ACTIVATED 3 /* activated from L2 */
48#define FLG_OPEN 5 /* channel is in use */
49#define FLG_ACTIVE 6 /* channel is activated */
50#define FLG_BUSY_TIMER 7
51/* channel type */
52#define FLG_DCHANNEL 8 /* channel is D-channel */
53#define FLG_BCHANNEL 9 /* channel is B-channel */
54#define FLG_ECHANNEL 10 /* channel is E-channel */
55#define FLG_TRANSPARENT 12 /* channel use transparent data */
56#define FLG_HDLC 13 /* channel use hdlc data */
57#define FLG_L2DATA 14 /* channel use L2 DATA primitivs */
58#define FLG_ORIGIN 15 /* channel is on origin site */
59/* channel specific stuff */
60/* arcofi specific */
61#define FLG_ARCOFI_TIMER 16
62#define FLG_ARCOFI_ERROR 17
63/* isar specific */
64#define FLG_INITIALIZED 16
65#define FLG_DLEETX 17
66#define FLG_LASTDLE 18
67#define FLG_FIRST 19
68#define FLG_LASTDATA 20
69#define FLG_NMD_DATA 21
70#define FLG_FTI_RUN 22
71#define FLG_LL_OK 23
72#define FLG_LL_CONN 24
73#define FLG_DTMFSEND 25
74
75/* workq events */
76#define FLG_RECVQUEUE 30
77#define FLG_PHCHANGE 31
78
79#define schedule_event(s, ev) do { \
80 test_and_set_bit(ev, &((s)->Flags)); \
81 schedule_work(&((s)->workq)); \
82 } while (0)
83
84struct dchannel {
85 struct mISDNdevice dev;
86 u_long Flags;
87 struct work_struct workq;
88 void (*phfunc) (struct dchannel *);
89 u_int state;
90 void *l1;
91 /* HW access */
92 u_char (*read_reg) (void *, u_char);
93 void (*write_reg) (void *, u_char, u_char);
94 void (*read_fifo) (void *, u_char *, int);
95 void (*write_fifo) (void *, u_char *, int);
96 void *hw;
97 int slot; /* multiport card channel slot */
98 struct timer_list timer;
99 /* receive data */
100 struct sk_buff *rx_skb;
101 int maxlen;
102 /* send data */
103 struct sk_buff_head squeue;
104 struct sk_buff_head rqueue;
105 struct sk_buff *tx_skb;
106 int tx_idx;
107 int debug;
108 /* statistics */
109 int err_crc;
110 int err_tx;
111 int err_rx;
112};
113
114typedef int (dchannel_l1callback)(struct dchannel *, u_int);
115extern int create_l1(struct dchannel *, dchannel_l1callback *);
116
117/* private L1 commands */
118#define INFO0 0x8002
119#define INFO1 0x8102
120#define INFO2 0x8202
121#define INFO3_P8 0x8302
122#define INFO3_P10 0x8402
123#define INFO4_P8 0x8502
124#define INFO4_P10 0x8602
125#define LOSTFRAMING 0x8702
126#define ANYSIGNAL 0x8802
127#define HW_POWERDOWN 0x8902
128#define HW_RESET_REQ 0x8a02
129#define HW_POWERUP_REQ 0x8b02
130#define HW_DEACT_REQ 0x8c02
131#define HW_ACTIVATE_REQ 0x8e02
132#define HW_D_NOBLOCKED 0x8f02
133#define HW_RESET_IND 0x9002
134#define HW_POWERUP_IND 0x9102
135#define HW_DEACT_IND 0x9202
136#define HW_ACTIVATE_IND 0x9302
137#define HW_DEACT_CNF 0x9402
138#define HW_TESTLOOP 0x9502
139#define HW_TESTRX_RAW 0x9602
140#define HW_TESTRX_HDLC 0x9702
141#define HW_TESTRX_OFF 0x9802
142
143struct layer1;
144extern int l1_event(struct layer1 *, u_int);
145
146
147struct bchannel {
148 struct mISDNchannel ch;
149 int nr;
150 u_long Flags;
151 struct work_struct workq;
152 u_int state;
153 /* HW access */
154 u_char (*read_reg) (void *, u_char);
155 void (*write_reg) (void *, u_char, u_char);
156 void (*read_fifo) (void *, u_char *, int);
157 void (*write_fifo) (void *, u_char *, int);
158 void *hw;
159 int slot; /* multiport card channel slot */
160 struct timer_list timer;
161 /* receive data */
162 struct sk_buff *rx_skb;
163 int maxlen;
164 /* send data */
165 struct sk_buff *next_skb;
166 struct sk_buff *tx_skb;
167 struct sk_buff_head rqueue;
168 int rcount;
169 int tx_idx;
170 int debug;
171 /* statistics */
172 int err_crc;
173 int err_tx;
174 int err_rx;
175};
176
177extern int mISDN_initdchannel(struct dchannel *, int, void *);
178extern int mISDN_initbchannel(struct bchannel *, int);
179extern int mISDN_freedchannel(struct dchannel *);
180extern int mISDN_freebchannel(struct bchannel *);
181extern void queue_ch_frame(struct mISDNchannel *, u_int,
182 int, struct sk_buff *);
183extern int dchannel_senddata(struct dchannel *, struct sk_buff *);
184extern int bchannel_senddata(struct bchannel *, struct sk_buff *);
185extern void recv_Dchannel(struct dchannel *);
186extern void recv_Bchannel(struct bchannel *);
187extern void recv_Dchannel_skb(struct dchannel *, struct sk_buff *);
188extern void recv_Bchannel_skb(struct bchannel *, struct sk_buff *);
189extern void confirm_Bsend(struct bchannel *bch);
190extern int get_next_bframe(struct bchannel *);
191extern int get_next_dframe(struct dchannel *);
192
193#endif
diff --git a/include/linux/mISDNif.h b/include/linux/mISDNif.h
new file mode 100644
index 000000000000..8f2d60da04e7
--- /dev/null
+++ b/include/linux/mISDNif.h
@@ -0,0 +1,509 @@
1/*
2 *
3 * Author Karsten Keil <kkeil@novell.com>
4 *
5 * Copyright 2008 by Karsten Keil <kkeil@novell.com>
6 *
7 * This code is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE
9 * version 2.1 as published by the Free Software Foundation.
10 *
11 * This code 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 LESSER GENERAL PUBLIC LICENSE for more details.
15 *
16 */
17
18#ifndef mISDNIF_H
19#define mISDNIF_H
20
21#include <stdarg.h>
22#include <linux/types.h>
23#include <linux/errno.h>
24#include <linux/socket.h>
25
26/*
27 * ABI Version 32 bit
28 *
29 * <8 bit> Major version
30 * - changed if any interface become backwards incompatible
31 *
32 * <8 bit> Minor version
33 * - changed if any interface is extended but backwards compatible
34 *
35 * <16 bit> Release number
36 * - should be incremented on every checkin
37 */
38#define MISDN_MAJOR_VERSION 1
39#define MISDN_MINOR_VERSION 0
40#define MISDN_RELEASE 19
41
42/* primitives for information exchange
43 * generell format
44 * <16 bit 0 >
45 * <8 bit command>
46 * BIT 8 = 1 LAYER private
47 * BIT 7 = 1 answer
48 * BIT 6 = 1 DATA
49 * <8 bit target layer mask>
50 *
51 * Layer = 00 is reserved for general commands
52 Layer = 01 L2 -> HW
53 Layer = 02 HW -> L2
54 Layer = 04 L3 -> L2
55 Layer = 08 L2 -> L3
56 * Layer = FF is reserved for broadcast commands
57 */
58
59#define MISDN_CMDMASK 0xff00
60#define MISDN_LAYERMASK 0x00ff
61
62/* generell commands */
63#define OPEN_CHANNEL 0x0100
64#define CLOSE_CHANNEL 0x0200
65#define CONTROL_CHANNEL 0x0300
66#define CHECK_DATA 0x0400
67
68/* layer 2 -> layer 1 */
69#define PH_ACTIVATE_REQ 0x0101
70#define PH_DEACTIVATE_REQ 0x0201
71#define PH_DATA_REQ 0x2001
72#define MPH_ACTIVATE_REQ 0x0501
73#define MPH_DEACTIVATE_REQ 0x0601
74#define MPH_INFORMATION_REQ 0x0701
75#define PH_CONTROL_REQ 0x0801
76
77/* layer 1 -> layer 2 */
78#define PH_ACTIVATE_IND 0x0102
79#define PH_ACTIVATE_CNF 0x4102
80#define PH_DEACTIVATE_IND 0x0202
81#define PH_DEACTIVATE_CNF 0x4202
82#define PH_DATA_IND 0x2002
83#define MPH_ACTIVATE_IND 0x0502
84#define MPH_DEACTIVATE_IND 0x0602
85#define MPH_INFORMATION_IND 0x0702
86#define PH_DATA_CNF 0x6002
87#define PH_CONTROL_IND 0x0802
88#define PH_CONTROL_CNF 0x4802
89
90/* layer 3 -> layer 2 */
91#define DL_ESTABLISH_REQ 0x1004
92#define DL_RELEASE_REQ 0x1104
93#define DL_DATA_REQ 0x3004
94#define DL_UNITDATA_REQ 0x3104
95#define DL_INFORMATION_REQ 0x0004
96
97/* layer 2 -> layer 3 */
98#define DL_ESTABLISH_IND 0x1008
99#define DL_ESTABLISH_CNF 0x5008
100#define DL_RELEASE_IND 0x1108
101#define DL_RELEASE_CNF 0x5108
102#define DL_DATA_IND 0x3008
103#define DL_UNITDATA_IND 0x3108
104#define DL_INFORMATION_IND 0x0008
105
106/* intern layer 2 managment */
107#define MDL_ASSIGN_REQ 0x1804
108#define MDL_ASSIGN_IND 0x1904
109#define MDL_REMOVE_REQ 0x1A04
110#define MDL_REMOVE_IND 0x1B04
111#define MDL_STATUS_UP_IND 0x1C04
112#define MDL_STATUS_DOWN_IND 0x1D04
113#define MDL_STATUS_UI_IND 0x1E04
114#define MDL_ERROR_IND 0x1F04
115#define MDL_ERROR_RSP 0x5F04
116
117/* DL_INFORMATION_IND types */
118#define DL_INFO_L2_CONNECT 0x0001
119#define DL_INFO_L2_REMOVED 0x0002
120
121/* PH_CONTROL types */
122/* TOUCH TONE IS 0x20XX XX "0"..."9", "A","B","C","D","*","#" */
123#define DTMF_TONE_VAL 0x2000
124#define DTMF_TONE_MASK 0x007F
125#define DTMF_TONE_START 0x2100
126#define DTMF_TONE_STOP 0x2200
127#define DTMF_HFC_COEF 0x4000
128#define DSP_CONF_JOIN 0x2403
129#define DSP_CONF_SPLIT 0x2404
130#define DSP_RECEIVE_OFF 0x2405
131#define DSP_RECEIVE_ON 0x2406
132#define DSP_ECHO_ON 0x2407
133#define DSP_ECHO_OFF 0x2408
134#define DSP_MIX_ON 0x2409
135#define DSP_MIX_OFF 0x240a
136#define DSP_DELAY 0x240b
137#define DSP_JITTER 0x240c
138#define DSP_TXDATA_ON 0x240d
139#define DSP_TXDATA_OFF 0x240e
140#define DSP_TX_DEJITTER 0x240f
141#define DSP_TX_DEJ_OFF 0x2410
142#define DSP_TONE_PATT_ON 0x2411
143#define DSP_TONE_PATT_OFF 0x2412
144#define DSP_VOL_CHANGE_TX 0x2413
145#define DSP_VOL_CHANGE_RX 0x2414
146#define DSP_BF_ENABLE_KEY 0x2415
147#define DSP_BF_DISABLE 0x2416
148#define DSP_BF_ACCEPT 0x2416
149#define DSP_BF_REJECT 0x2417
150#define DSP_PIPELINE_CFG 0x2418
151#define HFC_VOL_CHANGE_TX 0x2601
152#define HFC_VOL_CHANGE_RX 0x2602
153#define HFC_SPL_LOOP_ON 0x2603
154#define HFC_SPL_LOOP_OFF 0x2604
155
156/* DSP_TONE_PATT_ON parameter */
157#define TONE_OFF 0x0000
158#define TONE_GERMAN_DIALTONE 0x0001
159#define TONE_GERMAN_OLDDIALTONE 0x0002
160#define TONE_AMERICAN_DIALTONE 0x0003
161#define TONE_GERMAN_DIALPBX 0x0004
162#define TONE_GERMAN_OLDDIALPBX 0x0005
163#define TONE_AMERICAN_DIALPBX 0x0006
164#define TONE_GERMAN_RINGING 0x0007
165#define TONE_GERMAN_OLDRINGING 0x0008
166#define TONE_AMERICAN_RINGPBX 0x000b
167#define TONE_GERMAN_RINGPBX 0x000c
168#define TONE_GERMAN_OLDRINGPBX 0x000d
169#define TONE_AMERICAN_RINGING 0x000e
170#define TONE_GERMAN_BUSY 0x000f
171#define TONE_GERMAN_OLDBUSY 0x0010
172#define TONE_AMERICAN_BUSY 0x0011
173#define TONE_GERMAN_HANGUP 0x0012
174#define TONE_GERMAN_OLDHANGUP 0x0013
175#define TONE_AMERICAN_HANGUP 0x0014
176#define TONE_SPECIAL_INFO 0x0015
177#define TONE_GERMAN_GASSENBESETZT 0x0016
178#define TONE_GERMAN_AUFSCHALTTON 0x0016
179
180/* MPH_INFORMATION_IND */
181#define L1_SIGNAL_LOS_OFF 0x0010
182#define L1_SIGNAL_LOS_ON 0x0011
183#define L1_SIGNAL_AIS_OFF 0x0012
184#define L1_SIGNAL_AIS_ON 0x0013
185#define L1_SIGNAL_RDI_OFF 0x0014
186#define L1_SIGNAL_RDI_ON 0x0015
187#define L1_SIGNAL_SLIP_RX 0x0020
188#define L1_SIGNAL_SLIP_TX 0x0021
189
190/*
191 * protocol ids
192 * D channel 1-31
193 * B channel 33 - 63
194 */
195
196#define ISDN_P_NONE 0
197#define ISDN_P_BASE 0
198#define ISDN_P_TE_S0 0x01
199#define ISDN_P_NT_S0 0x02
200#define ISDN_P_TE_E1 0x03
201#define ISDN_P_NT_E1 0x04
202#define ISDN_P_LAPD_TE 0x10
203#define ISDN_P_LAPD_NT 0x11
204
205#define ISDN_P_B_MASK 0x1f
206#define ISDN_P_B_START 0x20
207
208#define ISDN_P_B_RAW 0x21
209#define ISDN_P_B_HDLC 0x22
210#define ISDN_P_B_X75SLP 0x23
211#define ISDN_P_B_L2DTMF 0x24
212#define ISDN_P_B_L2DSP 0x25
213#define ISDN_P_B_L2DSPHDLC 0x26
214
215#define OPTION_L2_PMX 1
216#define OPTION_L2_PTP 2
217#define OPTION_L2_FIXEDTEI 3
218#define OPTION_L2_CLEANUP 4
219
220/* should be in sync with linux/kobject.h:KOBJ_NAME_LEN */
221#define MISDN_MAX_IDLEN 20
222
223struct mISDNhead {
224 unsigned int prim;
225 unsigned int id;
226} __attribute__((packed));
227
228#define MISDN_HEADER_LEN sizeof(struct mISDNhead)
229#define MAX_DATA_SIZE 2048
230#define MAX_DATA_MEM (MAX_DATA_SIZE + MISDN_HEADER_LEN)
231#define MAX_DFRAME_LEN 260
232
233#define MISDN_ID_ADDR_MASK 0xFFFF
234#define MISDN_ID_TEI_MASK 0xFF00
235#define MISDN_ID_SAPI_MASK 0x00FF
236#define MISDN_ID_TEI_ANY 0x7F00
237
238#define MISDN_ID_ANY 0xFFFF
239#define MISDN_ID_NONE 0xFFFE
240
241#define GROUP_TEI 127
242#define TEI_SAPI 63
243#define CTRL_SAPI 0
244
245#define MISDN_MAX_CHANNEL 127
246#define MISDN_CHMAP_SIZE ((MISDN_MAX_CHANNEL + 1) >> 3)
247
248#define SOL_MISDN 0
249
250struct sockaddr_mISDN {
251 sa_family_t family;
252 unsigned char dev;
253 unsigned char channel;
254 unsigned char sapi;
255 unsigned char tei;
256};
257
258/* timer device ioctl */
259#define IMADDTIMER _IOR('I', 64, int)
260#define IMDELTIMER _IOR('I', 65, int)
261/* socket ioctls */
262#define IMGETVERSION _IOR('I', 66, int)
263#define IMGETCOUNT _IOR('I', 67, int)
264#define IMGETDEVINFO _IOR('I', 68, int)
265#define IMCTRLREQ _IOR('I', 69, int)
266#define IMCLEAR_L2 _IOR('I', 70, int)
267
268struct mISDNversion {
269 unsigned char major;
270 unsigned char minor;
271 unsigned short release;
272};
273
274struct mISDN_devinfo {
275 u_int id;
276 u_int Dprotocols;
277 u_int Bprotocols;
278 u_int protocol;
279 u_char channelmap[MISDN_CHMAP_SIZE];
280 u_int nrbchan;
281 char name[MISDN_MAX_IDLEN];
282};
283
284static inline int
285test_channelmap(u_int nr, u_char *map)
286{
287 if (nr <= MISDN_MAX_CHANNEL)
288 return map[nr >> 3] & (1 << (nr & 7));
289 else
290 return 0;
291}
292
293static inline void
294set_channelmap(u_int nr, u_char *map)
295{
296 map[nr >> 3] |= (1 << (nr & 7));
297}
298
299static inline void
300clear_channelmap(u_int nr, u_char *map)
301{
302 map[nr >> 3] &= ~(1 << (nr & 7));
303}
304
305/* CONTROL_CHANNEL parameters */
306#define MISDN_CTRL_GETOP 0x0000
307#define MISDN_CTRL_LOOP 0x0001
308#define MISDN_CTRL_CONNECT 0x0002
309#define MISDN_CTRL_DISCONNECT 0x0004
310#define MISDN_CTRL_PCMCONNECT 0x0010
311#define MISDN_CTRL_PCMDISCONNECT 0x0020
312#define MISDN_CTRL_SETPEER 0x0040
313#define MISDN_CTRL_UNSETPEER 0x0080
314#define MISDN_CTRL_RX_OFF 0x0100
315#define MISDN_CTRL_HW_FEATURES_OP 0x2000
316#define MISDN_CTRL_HW_FEATURES 0x2001
317#define MISDN_CTRL_HFC_OP 0x4000
318#define MISDN_CTRL_HFC_PCM_CONN 0x4001
319#define MISDN_CTRL_HFC_PCM_DISC 0x4002
320#define MISDN_CTRL_HFC_CONF_JOIN 0x4003
321#define MISDN_CTRL_HFC_CONF_SPLIT 0x4004
322#define MISDN_CTRL_HFC_RECEIVE_OFF 0x4005
323#define MISDN_CTRL_HFC_RECEIVE_ON 0x4006
324#define MISDN_CTRL_HFC_ECHOCAN_ON 0x4007
325#define MISDN_CTRL_HFC_ECHOCAN_OFF 0x4008
326
327
328/* socket options */
329#define MISDN_TIME_STAMP 0x0001
330
331struct mISDN_ctrl_req {
332 int op;
333 int channel;
334 int p1;
335 int p2;
336};
337
338/* muxer options */
339#define MISDN_OPT_ALL 1
340#define MISDN_OPT_TEIMGR 2
341
342#ifdef __KERNEL__
343#include <linux/list.h>
344#include <linux/skbuff.h>
345#include <linux/net.h>
346#include <net/sock.h>
347#include <linux/completion.h>
348
349#define DEBUG_CORE 0x000000ff
350#define DEBUG_CORE_FUNC 0x00000002
351#define DEBUG_SOCKET 0x00000004
352#define DEBUG_MANAGER 0x00000008
353#define DEBUG_SEND_ERR 0x00000010
354#define DEBUG_MSG_THREAD 0x00000020
355#define DEBUG_QUEUE_FUNC 0x00000040
356#define DEBUG_L1 0x0000ff00
357#define DEBUG_L1_FSM 0x00000200
358#define DEBUG_L2 0x00ff0000
359#define DEBUG_L2_FSM 0x00020000
360#define DEBUG_L2_CTRL 0x00040000
361#define DEBUG_L2_RECV 0x00080000
362#define DEBUG_L2_TEI 0x00100000
363#define DEBUG_L2_TEIFSM 0x00200000
364#define DEBUG_TIMER 0x01000000
365
366#define mISDN_HEAD_P(s) ((struct mISDNhead *)&s->cb[0])
367#define mISDN_HEAD_PRIM(s) (((struct mISDNhead *)&s->cb[0])->prim)
368#define mISDN_HEAD_ID(s) (((struct mISDNhead *)&s->cb[0])->id)
369
370/* socket states */
371#define MISDN_OPEN 1
372#define MISDN_BOUND 2
373#define MISDN_CLOSED 3
374
375struct mISDNchannel;
376struct mISDNdevice;
377struct mISDNstack;
378
379struct channel_req {
380 u_int protocol;
381 struct sockaddr_mISDN adr;
382 struct mISDNchannel *ch;
383};
384
385typedef int (ctrl_func_t)(struct mISDNchannel *, u_int, void *);
386typedef int (send_func_t)(struct mISDNchannel *, struct sk_buff *);
387typedef int (create_func_t)(struct channel_req *);
388
389struct Bprotocol {
390 struct list_head list;
391 char *name;
392 u_int Bprotocols;
393 create_func_t *create;
394};
395
396struct mISDNchannel {
397 struct list_head list;
398 u_int protocol;
399 u_int nr;
400 u_long opt;
401 u_int addr;
402 struct mISDNstack *st;
403 struct mISDNchannel *peer;
404 send_func_t *send;
405 send_func_t *recv;
406 ctrl_func_t *ctrl;
407};
408
409struct mISDN_sock_list {
410 struct hlist_head head;
411 rwlock_t lock;
412};
413
414struct mISDN_sock {
415 struct sock sk;
416 struct mISDNchannel ch;
417 u_int cmask;
418 struct mISDNdevice *dev;
419};
420
421
422
423struct mISDNdevice {
424 struct mISDNchannel D;
425 u_int id;
426 char name[MISDN_MAX_IDLEN];
427 u_int Dprotocols;
428 u_int Bprotocols;
429 u_int nrbchan;
430 u_char channelmap[MISDN_CHMAP_SIZE];
431 struct list_head bchannels;
432 struct mISDNchannel *teimgr;
433 struct device dev;
434};
435
436struct mISDNstack {
437 u_long status;
438 struct mISDNdevice *dev;
439 struct task_struct *thread;
440 struct completion *notify;
441 wait_queue_head_t workq;
442 struct sk_buff_head msgq;
443 struct list_head layer2;
444 struct mISDNchannel *layer1;
445 struct mISDNchannel own;
446 struct mutex lmutex; /* protect lists */
447 struct mISDN_sock_list l1sock;
448#ifdef MISDN_MSG_STATS
449 u_int msg_cnt;
450 u_int sleep_cnt;
451 u_int stopped_cnt;
452#endif
453};
454
455/* global alloc/queue functions */
456
457static inline struct sk_buff *
458mI_alloc_skb(unsigned int len, gfp_t gfp_mask)
459{
460 struct sk_buff *skb;
461
462 skb = alloc_skb(len + MISDN_HEADER_LEN, gfp_mask);
463 if (likely(skb))
464 skb_reserve(skb, MISDN_HEADER_LEN);
465 return skb;
466}
467
468static inline struct sk_buff *
469_alloc_mISDN_skb(u_int prim, u_int id, u_int len, void *dp, gfp_t gfp_mask)
470{
471 struct sk_buff *skb = mI_alloc_skb(len, gfp_mask);
472 struct mISDNhead *hh;
473
474 if (!skb)
475 return NULL;
476 if (len)
477 memcpy(skb_put(skb, len), dp, len);
478 hh = mISDN_HEAD_P(skb);
479 hh->prim = prim;
480 hh->id = id;
481 return skb;
482}
483
484static inline void
485_queue_data(struct mISDNchannel *ch, u_int prim,
486 u_int id, u_int len, void *dp, gfp_t gfp_mask)
487{
488 struct sk_buff *skb;
489
490 if (!ch->peer)
491 return;
492 skb = _alloc_mISDN_skb(prim, id, len, dp, gfp_mask);
493 if (!skb)
494 return;
495 if (ch->recv(ch->peer, skb))
496 dev_kfree_skb(skb);
497}
498
499/* global register/unregister functions */
500
501extern int mISDN_register_device(struct mISDNdevice *, char *name);
502extern void mISDN_unregister_device(struct mISDNdevice *);
503extern int mISDN_register_Bprotocol(struct Bprotocol *);
504extern void mISDN_unregister_Bprotocol(struct Bprotocol *);
505
506extern void set_channel_address(struct mISDNchannel *, u_int, u_int);
507
508#endif /* __KERNEL__ */
509#endif /* mISDNIF_H */
diff --git a/include/linux/magic.h b/include/linux/magic.h
index 1fa0c2ce4dec..f7f3fdddbef0 100644
--- a/include/linux/magic.h
+++ b/include/linux/magic.h
@@ -6,6 +6,10 @@
6#define AFS_SUPER_MAGIC 0x5346414F 6#define AFS_SUPER_MAGIC 0x5346414F
7#define AUTOFS_SUPER_MAGIC 0x0187 7#define AUTOFS_SUPER_MAGIC 0x0187
8#define CODA_SUPER_MAGIC 0x73757245 8#define CODA_SUPER_MAGIC 0x73757245
9#define DEBUGFS_MAGIC 0x64626720
10#define SYSFS_MAGIC 0x62656572
11#define SECURITYFS_MAGIC 0x73636673
12#define TMPFS_MAGIC 0x01021994
9#define EFS_SUPER_MAGIC 0x414A53 13#define EFS_SUPER_MAGIC 0x414A53
10#define EXT2_SUPER_MAGIC 0xEF53 14#define EXT2_SUPER_MAGIC 0xEF53
11#define EXT3_SUPER_MAGIC 0xEF53 15#define EXT3_SUPER_MAGIC 0xEF53
diff --git a/include/linux/major.h b/include/linux/major.h
index 0cb98053537a..88249452b935 100644
--- a/include/linux/major.h
+++ b/include/linux/major.h
@@ -53,7 +53,7 @@
53#define STL_SIOMEMMAJOR 28 53#define STL_SIOMEMMAJOR 28
54#define ACSI_MAJOR 28 54#define ACSI_MAJOR 28
55#define AZTECH_CDROM_MAJOR 29 55#define AZTECH_CDROM_MAJOR 29
56#define GRAPHDEV_MAJOR 29 /* SparcLinux & Linux/68k /dev/fb */ 56#define FB_MAJOR 29 /* /dev/fb* framebuffers */
57#define CM206_CDROM_MAJOR 32 57#define CM206_CDROM_MAJOR 32
58#define IDE2_MAJOR 33 58#define IDE2_MAJOR 33
59#define IDE3_MAJOR 34 59#define IDE3_MAJOR 34
@@ -170,4 +170,6 @@
170 170
171#define VIOTAPE_MAJOR 230 171#define VIOTAPE_MAJOR 230
172 172
173#define BLOCK_EXT_MAJOR 259
174
173#endif 175#endif
diff --git a/include/linux/map_to_7segment.h b/include/linux/map_to_7segment.h
new file mode 100644
index 000000000000..7df8432c4402
--- /dev/null
+++ b/include/linux/map_to_7segment.h
@@ -0,0 +1,187 @@
1/*
2 * Copyright (c) 2005 Henk Vergonet <Henk.Vergonet@gmail.com>
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of
7 * the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
19#ifndef MAP_TO_7SEGMENT_H
20#define MAP_TO_7SEGMENT_H
21
22/* This file provides translation primitives and tables for the conversion
23 * of (ASCII) characters to a 7-segments notation.
24 *
25 * The 7 segment's wikipedia notation below is used as standard.
26 * See: http://en.wikipedia.org/wiki/Seven_segment_display
27 *
28 * Notation: +-a-+
29 * f b
30 * +-g-+
31 * e c
32 * +-d-+
33 *
34 * Usage:
35 *
36 * Register a map variable, and fill it with a character set:
37 * static SEG7_DEFAULT_MAP(map_seg7);
38 *
39 *
40 * Then use for conversion:
41 * seg7 = map_to_seg7(&map_seg7, some_char);
42 * ...
43 *
44 * In device drivers it is recommended, if required, to make the char map
45 * accessible via the sysfs interface using the following scheme:
46 *
47 * static ssize_t show_map(struct device *dev, char *buf) {
48 * memcpy(buf, &map_seg7, sizeof(map_seg7));
49 * return sizeof(map_seg7);
50 * }
51 * static ssize_t store_map(struct device *dev, const char *buf, size_t cnt) {
52 * if(cnt != sizeof(map_seg7))
53 * return -EINVAL;
54 * memcpy(&map_seg7, buf, cnt);
55 * return cnt;
56 * }
57 * static DEVICE_ATTR(map_seg7, PERMS_RW, show_map, store_map);
58 *
59 * History:
60 * 2005-05-31 RFC linux-kernel@vger.kernel.org
61 */
62#include <linux/errno.h>
63
64
65#define BIT_SEG7_A 0
66#define BIT_SEG7_B 1
67#define BIT_SEG7_C 2
68#define BIT_SEG7_D 3
69#define BIT_SEG7_E 4
70#define BIT_SEG7_F 5
71#define BIT_SEG7_G 6
72#define BIT_SEG7_RESERVED 7
73
74struct seg7_conversion_map {
75 unsigned char table[128];
76};
77
78static inline int map_to_seg7(struct seg7_conversion_map *map, int c)
79{
80 return c >= 0 && c < sizeof(map->table) ? map->table[c] : -EINVAL;
81}
82
83#define SEG7_CONVERSION_MAP(_name, _map) \
84 struct seg7_conversion_map _name = { .table = { _map } }
85
86/*
87 * It is recommended to use a facility that allows user space to redefine
88 * custom character sets for LCD devices. Please use a sysfs interface
89 * as described above.
90 */
91#define MAP_TO_SEG7_SYSFS_FILE "map_seg7"
92
93/*******************************************************************************
94 * ASCII conversion table
95 ******************************************************************************/
96
97#define _SEG7(l,a,b,c,d,e,f,g) \
98 ( a<<BIT_SEG7_A | b<<BIT_SEG7_B | c<<BIT_SEG7_C | d<<BIT_SEG7_D | \
99 e<<BIT_SEG7_E | f<<BIT_SEG7_F | g<<BIT_SEG7_G )
100
101#define _MAP_0_32_ASCII_SEG7_NON_PRINTABLE \
102 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
103
104#define _MAP_33_47_ASCII_SEG7_SYMBOL \
105 _SEG7('!',0,0,0,0,1,1,0), _SEG7('"',0,1,0,0,0,1,0), _SEG7('#',0,1,1,0,1,1,0),\
106 _SEG7('$',1,0,1,1,0,1,1), _SEG7('%',0,0,1,0,0,1,0), _SEG7('&',1,0,1,1,1,1,1),\
107 _SEG7('\'',0,0,0,0,0,1,0),_SEG7('(',1,0,0,1,1,1,0), _SEG7(')',1,1,1,1,0,0,0),\
108 _SEG7('*',0,1,1,0,1,1,1), _SEG7('+',0,1,1,0,0,0,1), _SEG7(',',0,0,0,0,1,0,0),\
109 _SEG7('-',0,0,0,0,0,0,1), _SEG7('.',0,0,0,0,1,0,0), _SEG7('/',0,1,0,0,1,0,1),
110
111#define _MAP_48_57_ASCII_SEG7_NUMERIC \
112 _SEG7('0',1,1,1,1,1,1,0), _SEG7('1',0,1,1,0,0,0,0), _SEG7('2',1,1,0,1,1,0,1),\
113 _SEG7('3',1,1,1,1,0,0,1), _SEG7('4',0,1,1,0,0,1,1), _SEG7('5',1,0,1,1,0,1,1),\
114 _SEG7('6',1,0,1,1,1,1,1), _SEG7('7',1,1,1,0,0,0,0), _SEG7('8',1,1,1,1,1,1,1),\
115 _SEG7('9',1,1,1,1,0,1,1),
116
117#define _MAP_58_64_ASCII_SEG7_SYMBOL \
118 _SEG7(':',0,0,0,1,0,0,1), _SEG7(';',0,0,0,1,0,0,1), _SEG7('<',1,0,0,0,0,1,1),\
119 _SEG7('=',0,0,0,1,0,0,1), _SEG7('>',1,1,0,0,0,0,1), _SEG7('?',1,1,1,0,0,1,0),\
120 _SEG7('@',1,1,0,1,1,1,1),
121
122#define _MAP_65_90_ASCII_SEG7_ALPHA_UPPR \
123 _SEG7('A',1,1,1,0,1,1,1), _SEG7('B',1,1,1,1,1,1,1), _SEG7('C',1,0,0,1,1,1,0),\
124 _SEG7('D',1,1,1,1,1,1,0), _SEG7('E',1,0,0,1,1,1,1), _SEG7('F',1,0,0,0,1,1,1),\
125 _SEG7('G',1,1,1,1,0,1,1), _SEG7('H',0,1,1,0,1,1,1), _SEG7('I',0,1,1,0,0,0,0),\
126 _SEG7('J',0,1,1,1,0,0,0), _SEG7('K',0,1,1,0,1,1,1), _SEG7('L',0,0,0,1,1,1,0),\
127 _SEG7('M',1,1,1,0,1,1,0), _SEG7('N',1,1,1,0,1,1,0), _SEG7('O',1,1,1,1,1,1,0),\
128 _SEG7('P',1,1,0,0,1,1,1), _SEG7('Q',1,1,1,1,1,1,0), _SEG7('R',1,1,1,0,1,1,1),\
129 _SEG7('S',1,0,1,1,0,1,1), _SEG7('T',0,0,0,1,1,1,1), _SEG7('U',0,1,1,1,1,1,0),\
130 _SEG7('V',0,1,1,1,1,1,0), _SEG7('W',0,1,1,1,1,1,1), _SEG7('X',0,1,1,0,1,1,1),\
131 _SEG7('Y',0,1,1,0,0,1,1), _SEG7('Z',1,1,0,1,1,0,1),
132
133#define _MAP_91_96_ASCII_SEG7_SYMBOL \
134 _SEG7('[',1,0,0,1,1,1,0), _SEG7('\\',0,0,1,0,0,1,1),_SEG7(']',1,1,1,1,0,0,0),\
135 _SEG7('^',1,1,0,0,0,1,0), _SEG7('_',0,0,0,1,0,0,0), _SEG7('`',0,1,0,0,0,0,0),
136
137#define _MAP_97_122_ASCII_SEG7_ALPHA_LOWER \
138 _SEG7('A',1,1,1,0,1,1,1), _SEG7('b',0,0,1,1,1,1,1), _SEG7('c',0,0,0,1,1,0,1),\
139 _SEG7('d',0,1,1,1,1,0,1), _SEG7('E',1,0,0,1,1,1,1), _SEG7('F',1,0,0,0,1,1,1),\
140 _SEG7('G',1,1,1,1,0,1,1), _SEG7('h',0,0,1,0,1,1,1), _SEG7('i',0,0,1,0,0,0,0),\
141 _SEG7('j',0,0,1,1,0,0,0), _SEG7('k',0,0,1,0,1,1,1), _SEG7('L',0,0,0,1,1,1,0),\
142 _SEG7('M',1,1,1,0,1,1,0), _SEG7('n',0,0,1,0,1,0,1), _SEG7('o',0,0,1,1,1,0,1),\
143 _SEG7('P',1,1,0,0,1,1,1), _SEG7('q',1,1,1,0,0,1,1), _SEG7('r',0,0,0,0,1,0,1),\
144 _SEG7('S',1,0,1,1,0,1,1), _SEG7('T',0,0,0,1,1,1,1), _SEG7('u',0,0,1,1,1,0,0),\
145 _SEG7('v',0,0,1,1,1,0,0), _SEG7('W',0,1,1,1,1,1,1), _SEG7('X',0,1,1,0,1,1,1),\
146 _SEG7('y',0,1,1,1,0,1,1), _SEG7('Z',1,1,0,1,1,0,1),
147
148#define _MAP_123_126_ASCII_SEG7_SYMBOL \
149 _SEG7('{',1,0,0,1,1,1,0), _SEG7('|',0,0,0,0,1,1,0), _SEG7('}',1,1,1,1,0,0,0),\
150 _SEG7('~',1,0,0,0,0,0,0),
151
152/* Maps */
153
154/* This set tries to map as close as possible to the visible characteristics
155 * of the ASCII symbol, lowercase and uppercase letters may differ in
156 * presentation on the display.
157 */
158#define MAP_ASCII7SEG_ALPHANUM \
159 _MAP_0_32_ASCII_SEG7_NON_PRINTABLE \
160 _MAP_33_47_ASCII_SEG7_SYMBOL \
161 _MAP_48_57_ASCII_SEG7_NUMERIC \
162 _MAP_58_64_ASCII_SEG7_SYMBOL \
163 _MAP_65_90_ASCII_SEG7_ALPHA_UPPR \
164 _MAP_91_96_ASCII_SEG7_SYMBOL \
165 _MAP_97_122_ASCII_SEG7_ALPHA_LOWER \
166 _MAP_123_126_ASCII_SEG7_SYMBOL
167
168/* This set tries to map as close as possible to the symbolic characteristics
169 * of the ASCII character for maximum discrimination.
170 * For now this means all alpha chars are in lower case representations.
171 * (This for example facilitates the use of hex numbers with uppercase input.)
172 */
173#define MAP_ASCII7SEG_ALPHANUM_LC \
174 _MAP_0_32_ASCII_SEG7_NON_PRINTABLE \
175 _MAP_33_47_ASCII_SEG7_SYMBOL \
176 _MAP_48_57_ASCII_SEG7_NUMERIC \
177 _MAP_58_64_ASCII_SEG7_SYMBOL \
178 _MAP_97_122_ASCII_SEG7_ALPHA_LOWER \
179 _MAP_91_96_ASCII_SEG7_SYMBOL \
180 _MAP_97_122_ASCII_SEG7_ALPHA_LOWER \
181 _MAP_123_126_ASCII_SEG7_SYMBOL
182
183#define SEG7_DEFAULT_MAP(_name) \
184 SEG7_CONVERSION_MAP(_name,MAP_ASCII7SEG_ALPHANUM)
185
186#endif /* MAP_TO_7SEGMENT_H */
187
diff --git a/include/linux/maple.h b/include/linux/maple.h
index d31e36ebb436..c23d3f51ba40 100644
--- a/include/linux/maple.h
+++ b/include/linux/maple.h
@@ -2,6 +2,7 @@
2#define __LINUX_MAPLE_H 2#define __LINUX_MAPLE_H
3 3
4#include <linux/device.h> 4#include <linux/device.h>
5#include <mach/maple.h>
5 6
6extern struct bus_type maple_bus_type; 7extern struct bus_type maple_bus_type;
7 8
@@ -33,6 +34,7 @@ struct mapleq {
33 void *sendbuf, *recvbuf, *recvbufdcsp; 34 void *sendbuf, *recvbuf, *recvbufdcsp;
34 unsigned char length; 35 unsigned char length;
35 enum maple_code command; 36 enum maple_code command;
37 struct mutex mutex;
36}; 38};
37 39
38struct maple_devinfo { 40struct maple_devinfo {
@@ -49,7 +51,6 @@ struct maple_devinfo {
49struct maple_device { 51struct maple_device {
50 struct maple_driver *driver; 52 struct maple_driver *driver;
51 struct mapleq *mq; 53 struct mapleq *mq;
52 void *private_data;
53 void (*callback) (struct mapleq * mq); 54 void (*callback) (struct mapleq * mq);
54 unsigned long when, interval, function; 55 unsigned long when, interval, function;
55 struct maple_devinfo devinfo; 56 struct maple_devinfo devinfo;
@@ -61,8 +62,6 @@ struct maple_device {
61 62
62struct maple_driver { 63struct maple_driver {
63 unsigned long function; 64 unsigned long function;
64 int (*connect) (struct maple_device * dev);
65 void (*disconnect) (struct maple_device * dev);
66 struct device_driver drv; 65 struct device_driver drv;
67}; 66};
68 67
@@ -70,10 +69,17 @@ void maple_getcond_callback(struct maple_device *dev,
70 void (*callback) (struct mapleq * mq), 69 void (*callback) (struct mapleq * mq),
71 unsigned long interval, 70 unsigned long interval,
72 unsigned long function); 71 unsigned long function);
73int maple_driver_register(struct device_driver *drv); 72int maple_driver_register(struct maple_driver *);
74void maple_add_packet(struct mapleq *mq); 73void maple_driver_unregister(struct maple_driver *);
74
75int maple_add_packet_sleeps(struct maple_device *mdev, u32 function,
76 u32 command, u32 length, void *data);
77void maple_clear_dev(struct maple_device *mdev);
75 78
76#define to_maple_dev(n) container_of(n, struct maple_device, dev) 79#define to_maple_dev(n) container_of(n, struct maple_device, dev)
77#define to_maple_driver(n) container_of(n, struct maple_driver, drv) 80#define to_maple_driver(n) container_of(n, struct maple_driver, drv)
78 81
82#define maple_get_drvdata(d) dev_get_drvdata(&(d)->dev)
83#define maple_set_drvdata(d,p) dev_set_drvdata(&(d)->dev, (p))
84
79#endif /* __LINUX_MAPLE_H */ 85#endif /* __LINUX_MAPLE_H */
diff --git a/include/linux/marker.h b/include/linux/marker.h
index 1290653f9241..889196c7fbb1 100644
--- a/include/linux/marker.h
+++ b/include/linux/marker.h
@@ -160,4 +160,11 @@ extern int marker_probe_unregister_private_data(marker_probe_func *probe,
160extern void *marker_get_private_data(const char *name, marker_probe_func *probe, 160extern void *marker_get_private_data(const char *name, marker_probe_func *probe,
161 int num); 161 int num);
162 162
163/*
164 * marker_synchronize_unregister must be called between the last marker probe
165 * unregistration and the end of module exit to make sure there is no caller
166 * executing a probe when it is freed.
167 */
168#define marker_synchronize_unregister() synchronize_sched()
169
163#endif 170#endif
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index e6608776bc96..1fbe14d39521 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -27,21 +27,21 @@ struct mm_struct;
27 27
28#ifdef CONFIG_CGROUP_MEM_RES_CTLR 28#ifdef CONFIG_CGROUP_MEM_RES_CTLR
29 29
30#define page_reset_bad_cgroup(page) ((page)->page_cgroup = 0)
31
32extern struct page_cgroup *page_get_page_cgroup(struct page *page);
33extern int mem_cgroup_charge(struct page *page, struct mm_struct *mm, 30extern int mem_cgroup_charge(struct page *page, struct mm_struct *mm,
34 gfp_t gfp_mask); 31 gfp_t gfp_mask);
35extern int mem_cgroup_cache_charge(struct page *page, struct mm_struct *mm, 32extern int mem_cgroup_cache_charge(struct page *page, struct mm_struct *mm,
36 gfp_t gfp_mask); 33 gfp_t gfp_mask);
34extern void mem_cgroup_move_lists(struct page *page, enum lru_list lru);
37extern void mem_cgroup_uncharge_page(struct page *page); 35extern void mem_cgroup_uncharge_page(struct page *page);
38extern void mem_cgroup_move_lists(struct page *page, bool active); 36extern void mem_cgroup_uncharge_cache_page(struct page *page);
37extern int mem_cgroup_shrink_usage(struct mm_struct *mm, gfp_t gfp_mask);
38
39extern unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan, 39extern unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan,
40 struct list_head *dst, 40 struct list_head *dst,
41 unsigned long *scanned, int order, 41 unsigned long *scanned, int order,
42 int mode, struct zone *z, 42 int mode, struct zone *z,
43 struct mem_cgroup *mem_cont, 43 struct mem_cgroup *mem_cont,
44 int active); 44 int active, int file);
45extern void mem_cgroup_out_of_memory(struct mem_cgroup *mem, gfp_t gfp_mask); 45extern void mem_cgroup_out_of_memory(struct mem_cgroup *mem, gfp_t gfp_mask);
46int task_in_mem_cgroup(struct task_struct *task, const struct mem_cgroup *mem); 46int task_in_mem_cgroup(struct task_struct *task, const struct mem_cgroup *mem);
47 47
@@ -50,9 +50,9 @@ extern struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p);
50#define mm_match_cgroup(mm, cgroup) \ 50#define mm_match_cgroup(mm, cgroup) \
51 ((cgroup) == mem_cgroup_from_task((mm)->owner)) 51 ((cgroup) == mem_cgroup_from_task((mm)->owner))
52 52
53extern int mem_cgroup_prepare_migration(struct page *page); 53extern int
54mem_cgroup_prepare_migration(struct page *page, struct page *newpage);
54extern void mem_cgroup_end_migration(struct page *page); 55extern void mem_cgroup_end_migration(struct page *page);
55extern void mem_cgroup_page_migration(struct page *page, struct page *newpage);
56 56
57/* 57/*
58 * For memory reclaim. 58 * For memory reclaim.
@@ -66,21 +66,11 @@ extern void mem_cgroup_note_reclaim_priority(struct mem_cgroup *mem,
66extern void mem_cgroup_record_reclaim_priority(struct mem_cgroup *mem, 66extern void mem_cgroup_record_reclaim_priority(struct mem_cgroup *mem,
67 int priority); 67 int priority);
68 68
69extern long mem_cgroup_calc_reclaim_active(struct mem_cgroup *mem, 69extern long mem_cgroup_calc_reclaim(struct mem_cgroup *mem, struct zone *zone,
70 struct zone *zone, int priority); 70 int priority, enum lru_list lru);
71extern long mem_cgroup_calc_reclaim_inactive(struct mem_cgroup *mem,
72 struct zone *zone, int priority);
73
74#else /* CONFIG_CGROUP_MEM_RES_CTLR */
75static inline void page_reset_bad_cgroup(struct page *page)
76{
77}
78 71
79static inline struct page_cgroup *page_get_page_cgroup(struct page *page)
80{
81 return NULL;
82}
83 72
73#else /* CONFIG_CGROUP_MEM_RES_CTLR */
84static inline int mem_cgroup_charge(struct page *page, 74static inline int mem_cgroup_charge(struct page *page,
85 struct mm_struct *mm, gfp_t gfp_mask) 75 struct mm_struct *mm, gfp_t gfp_mask)
86{ 76{
@@ -97,6 +87,15 @@ static inline void mem_cgroup_uncharge_page(struct page *page)
97{ 87{
98} 88}
99 89
90static inline void mem_cgroup_uncharge_cache_page(struct page *page)
91{
92}
93
94static inline int mem_cgroup_shrink_usage(struct mm_struct *mm, gfp_t gfp_mask)
95{
96 return 0;
97}
98
100static inline void mem_cgroup_move_lists(struct page *page, bool active) 99static inline void mem_cgroup_move_lists(struct page *page, bool active)
101{ 100{
102} 101}
@@ -112,7 +111,8 @@ static inline int task_in_mem_cgroup(struct task_struct *task,
112 return 1; 111 return 1;
113} 112}
114 113
115static inline int mem_cgroup_prepare_migration(struct page *page) 114static inline int
115mem_cgroup_prepare_migration(struct page *page, struct page *newpage)
116{ 116{
117 return 0; 117 return 0;
118} 118}
@@ -121,11 +121,6 @@ static inline void mem_cgroup_end_migration(struct page *page)
121{ 121{
122} 122}
123 123
124static inline void
125mem_cgroup_page_migration(struct page *page, struct page *newpage)
126{
127}
128
129static inline int mem_cgroup_calc_mapped_ratio(struct mem_cgroup *mem) 124static inline int mem_cgroup_calc_mapped_ratio(struct mem_cgroup *mem)
130{ 125{
131 return 0; 126 return 0;
@@ -151,14 +146,9 @@ static inline void mem_cgroup_record_reclaim_priority(struct mem_cgroup *mem,
151{ 146{
152} 147}
153 148
154static inline long mem_cgroup_calc_reclaim_active(struct mem_cgroup *mem, 149static inline long mem_cgroup_calc_reclaim(struct mem_cgroup *mem,
155 struct zone *zone, int priority) 150 struct zone *zone, int priority,
156{ 151 enum lru_list lru)
157 return 0;
158}
159
160static inline long mem_cgroup_calc_reclaim_inactive(struct mem_cgroup *mem,
161 struct zone *zone, int priority)
162{ 152{
163 return 0; 153 return 0;
164} 154}
diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h
index ea9f5ad9ec8e..763ba81fc0f0 100644
--- a/include/linux/memory_hotplug.h
+++ b/include/linux/memory_hotplug.h
@@ -13,12 +13,12 @@ struct mem_section;
13#ifdef CONFIG_MEMORY_HOTPLUG 13#ifdef CONFIG_MEMORY_HOTPLUG
14 14
15/* 15/*
16 * Magic number for free bootmem. 16 * Types for free bootmem.
17 * The normal smallest mapcount is -1. Here is smaller value than it. 17 * The normal smallest mapcount is -1. Here is smaller value than it.
18 */ 18 */
19#define SECTION_INFO 0xfffffffe 19#define SECTION_INFO (-1 - 1)
20#define MIX_INFO 0xfffffffd 20#define MIX_SECTION_INFO (-1 - 2)
21#define NODE_INFO 0xfffffffc 21#define NODE_INFO (-1 - 3)
22 22
23/* 23/*
24 * pgdat resizing functions 24 * pgdat resizing functions
@@ -199,6 +199,18 @@ extern int walk_memory_resource(unsigned long start_pfn,
199 unsigned long nr_pages, void *arg, 199 unsigned long nr_pages, void *arg,
200 int (*func)(unsigned long, unsigned long, void *)); 200 int (*func)(unsigned long, unsigned long, void *));
201 201
202#ifdef CONFIG_MEMORY_HOTREMOVE
203
204extern int is_mem_section_removable(unsigned long pfn, unsigned long nr_pages);
205
206#else
207static inline int is_mem_section_removable(unsigned long pfn,
208 unsigned long nr_pages)
209{
210 return 0;
211}
212#endif /* CONFIG_MEMORY_HOTREMOVE */
213
202extern int add_memory(int nid, u64 start, u64 size); 214extern int add_memory(int nid, u64 start, u64 size);
203extern int arch_add_memory(int nid, u64 start, u64 size); 215extern int arch_add_memory(int nid, u64 start, u64 size);
204extern int remove_memory(u64 start, u64 size); 216extern int remove_memory(u64 start, u64 size);
diff --git a/include/linux/mempolicy.h b/include/linux/mempolicy.h
index 3a39570b81b8..085c903fe0f1 100644
--- a/include/linux/mempolicy.h
+++ b/include/linux/mempolicy.h
@@ -59,6 +59,7 @@ enum {
59#include <linux/rbtree.h> 59#include <linux/rbtree.h>
60#include <linux/spinlock.h> 60#include <linux/spinlock.h>
61#include <linux/nodemask.h> 61#include <linux/nodemask.h>
62#include <linux/pagemap.h>
62 63
63struct mm_struct; 64struct mm_struct;
64 65
@@ -220,6 +221,24 @@ extern int mpol_parse_str(char *str, struct mempolicy **mpol, int no_context);
220extern int mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol, 221extern int mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol,
221 int no_context); 222 int no_context);
222#endif 223#endif
224
225/* Check if a vma is migratable */
226static inline int vma_migratable(struct vm_area_struct *vma)
227{
228 if (vma->vm_flags & (VM_IO|VM_HUGETLB|VM_PFNMAP|VM_RESERVED))
229 return 0;
230 /*
231 * Migration allocates pages in the highest zone. If we cannot
232 * do so then migration (at least from node to node) is not
233 * possible.
234 */
235 if (vma->vm_file &&
236 gfp_zone(mapping_gfp_mask(vma->vm_file->f_mapping))
237 < policy_zone)
238 return 0;
239 return 1;
240}
241
223#else 242#else
224 243
225struct mempolicy {}; 244struct mempolicy {};
diff --git a/include/linux/memstick.h b/include/linux/memstick.h
index 37a5cdb03918..d0c37e682234 100644
--- a/include/linux/memstick.h
+++ b/include/linux/memstick.h
@@ -21,30 +21,30 @@
21struct ms_status_register { 21struct ms_status_register {
22 unsigned char reserved; 22 unsigned char reserved;
23 unsigned char interrupt; 23 unsigned char interrupt;
24#define MEMSTICK_INT_CMDNAK 0x0001 24#define MEMSTICK_INT_CMDNAK 0x01
25#define MEMSTICK_INT_IOREQ 0x0008 25#define MEMSTICK_INT_IOREQ 0x08
26#define MEMSTICK_INT_IOBREQ 0x0010 26#define MEMSTICK_INT_IOBREQ 0x10
27#define MEMSTICK_INT_BREQ 0x0020 27#define MEMSTICK_INT_BREQ 0x20
28#define MEMSTICK_INT_ERR 0x0040 28#define MEMSTICK_INT_ERR 0x40
29#define MEMSTICK_INT_CED 0x0080 29#define MEMSTICK_INT_CED 0x80
30 30
31 unsigned char status0; 31 unsigned char status0;
32#define MEMSTICK_STATUS0_WP 0x0001 32#define MEMSTICK_STATUS0_WP 0x01
33#define MEMSTICK_STATUS0_SL 0x0002 33#define MEMSTICK_STATUS0_SL 0x02
34#define MEMSTICK_STATUS0_BF 0x0010 34#define MEMSTICK_STATUS0_BF 0x10
35#define MEMSTICK_STATUS0_BE 0x0020 35#define MEMSTICK_STATUS0_BE 0x20
36#define MEMSTICK_STATUS0_FB0 0x0040 36#define MEMSTICK_STATUS0_FB0 0x40
37#define MEMSTICK_STATUS0_MB 0x0080 37#define MEMSTICK_STATUS0_MB 0x80
38 38
39 unsigned char status1; 39 unsigned char status1;
40#define MEMSTICK_STATUS1_UCFG 0x0001 40#define MEMSTICK_STATUS1_UCFG 0x01
41#define MEMSTICK_STATUS1_FGER 0x0002 41#define MEMSTICK_STATUS1_FGER 0x02
42#define MEMSTICK_STATUS1_UCEX 0x0004 42#define MEMSTICK_STATUS1_UCEX 0x04
43#define MEMSTICK_STATUS1_EXER 0x0008 43#define MEMSTICK_STATUS1_EXER 0x08
44#define MEMSTICK_STATUS1_UCDT 0x0010 44#define MEMSTICK_STATUS1_UCDT 0x10
45#define MEMSTICK_STATUS1_DTER 0x0020 45#define MEMSTICK_STATUS1_DTER 0x20
46#define MEMSTICK_STATUS1_FBI 0x0040 46#define MEMSTICK_STATUS1_FB1 0x40
47#define MEMSTICK_STATUS1_MB 0x0080 47#define MEMSTICK_STATUS1_MB 0x80
48} __attribute__((packed)); 48} __attribute__((packed));
49 49
50struct ms_id_register { 50struct ms_id_register {
@@ -56,32 +56,32 @@ struct ms_id_register {
56 56
57struct ms_param_register { 57struct ms_param_register {
58 unsigned char system; 58 unsigned char system;
59#define MEMSTICK_SYS_ATEN 0xc0
60#define MEMSTICK_SYS_BAMD 0x80
61#define MEMSTICK_SYS_PAM 0x08 59#define MEMSTICK_SYS_PAM 0x08
60#define MEMSTICK_SYS_BAMD 0x80
62 61
63 unsigned char block_address_msb; 62 unsigned char block_address_msb;
64 unsigned short block_address; 63 unsigned short block_address;
65 unsigned char cp; 64 unsigned char cp;
66#define MEMSTICK_CP_BLOCK 0x0000 65#define MEMSTICK_CP_BLOCK 0x00
67#define MEMSTICK_CP_PAGE 0x0020 66#define MEMSTICK_CP_PAGE 0x20
68#define MEMSTICK_CP_EXTRA 0x0040 67#define MEMSTICK_CP_EXTRA 0x40
69#define MEMSTICK_CP_OVERWRITE 0x0080 68#define MEMSTICK_CP_OVERWRITE 0x80
70 69
71 unsigned char page_address; 70 unsigned char page_address;
72} __attribute__((packed)); 71} __attribute__((packed));
73 72
74struct ms_extra_data_register { 73struct ms_extra_data_register {
75 unsigned char overwrite_flag; 74 unsigned char overwrite_flag;
76#define MEMSTICK_OVERWRITE_UPDATA 0x0010 75#define MEMSTICK_OVERWRITE_UDST 0x10
77#define MEMSTICK_OVERWRITE_PAGE 0x0060 76#define MEMSTICK_OVERWRITE_PGST1 0x20
78#define MEMSTICK_OVERWRITE_BLOCK 0x0080 77#define MEMSTICK_OVERWRITE_PGST0 0x40
78#define MEMSTICK_OVERWRITE_BKST 0x80
79 79
80 unsigned char management_flag; 80 unsigned char management_flag;
81#define MEMSTICK_MANAGEMENT_SYSTEM 0x0004 81#define MEMSTICK_MANAGEMENT_SYSFLG 0x04
82#define MEMSTICK_MANAGEMENT_TRANS_TABLE 0x0008 82#define MEMSTICK_MANAGEMENT_ATFLG 0x08
83#define MEMSTICK_MANAGEMENT_COPY 0x0010 83#define MEMSTICK_MANAGEMENT_SCMS1 0x10
84#define MEMSTICK_MANAGEMENT_ACCESS 0x0020 84#define MEMSTICK_MANAGEMENT_SCMS0 0x20
85 85
86 unsigned short logical_address; 86 unsigned short logical_address;
87} __attribute__((packed)); 87} __attribute__((packed));
@@ -96,9 +96,9 @@ struct ms_register {
96 96
97struct mspro_param_register { 97struct mspro_param_register {
98 unsigned char system; 98 unsigned char system;
99#define MEMSTICK_SYS_SERIAL 0x80
100#define MEMSTICK_SYS_PAR4 0x00 99#define MEMSTICK_SYS_PAR4 0x00
101#define MEMSTICK_SYS_PAR8 0x40 100#define MEMSTICK_SYS_PAR8 0x40
101#define MEMSTICK_SYS_SERIAL 0x80
102 102
103 unsigned short data_count; 103 unsigned short data_count;
104 unsigned int data_address; 104 unsigned int data_address;
@@ -147,7 +147,7 @@ struct ms_register_addr {
147 unsigned char w_length; 147 unsigned char w_length;
148} __attribute__((packed)); 148} __attribute__((packed));
149 149
150enum { 150enum memstick_tpc {
151 MS_TPC_READ_MG_STATUS = 0x01, 151 MS_TPC_READ_MG_STATUS = 0x01,
152 MS_TPC_READ_LONG_DATA = 0x02, 152 MS_TPC_READ_LONG_DATA = 0x02,
153 MS_TPC_READ_SHORT_DATA = 0x03, 153 MS_TPC_READ_SHORT_DATA = 0x03,
@@ -167,7 +167,7 @@ enum {
167 MS_TPC_SET_CMD = 0x0e 167 MS_TPC_SET_CMD = 0x0e
168}; 168};
169 169
170enum { 170enum memstick_command {
171 MS_CMD_BLOCK_END = 0x33, 171 MS_CMD_BLOCK_END = 0x33,
172 MS_CMD_RESET = 0x3c, 172 MS_CMD_RESET = 0x3c,
173 MS_CMD_BLOCK_WRITE = 0x55, 173 MS_CMD_BLOCK_WRITE = 0x55,
@@ -201,8 +201,6 @@ enum {
201 201
202/*** Driver structures and functions ***/ 202/*** Driver structures and functions ***/
203 203
204#define MEMSTICK_PART_SHIFT 3
205
206enum memstick_param { MEMSTICK_POWER = 1, MEMSTICK_INTERFACE }; 204enum memstick_param { MEMSTICK_POWER = 1, MEMSTICK_INTERFACE };
207 205
208#define MEMSTICK_POWER_OFF 0 206#define MEMSTICK_POWER_OFF 0
@@ -215,24 +213,27 @@ enum memstick_param { MEMSTICK_POWER = 1, MEMSTICK_INTERFACE };
215struct memstick_host; 213struct memstick_host;
216struct memstick_driver; 214struct memstick_driver;
217 215
216struct memstick_device_id {
217 unsigned char match_flags;
218#define MEMSTICK_MATCH_ALL 0x01 218#define MEMSTICK_MATCH_ALL 0x01
219 219
220 unsigned char type;
220#define MEMSTICK_TYPE_LEGACY 0xff 221#define MEMSTICK_TYPE_LEGACY 0xff
221#define MEMSTICK_TYPE_DUO 0x00 222#define MEMSTICK_TYPE_DUO 0x00
222#define MEMSTICK_TYPE_PRO 0x01 223#define MEMSTICK_TYPE_PRO 0x01
223 224
225 unsigned char category;
224#define MEMSTICK_CATEGORY_STORAGE 0xff 226#define MEMSTICK_CATEGORY_STORAGE 0xff
225#define MEMSTICK_CATEGORY_STORAGE_DUO 0x00 227#define MEMSTICK_CATEGORY_STORAGE_DUO 0x00
228#define MEMSTICK_CATEGORY_IO 0x01
229#define MEMSTICK_CATEGORY_IO_PRO 0x10
226 230
227#define MEMSTICK_CLASS_GENERIC 0xff
228#define MEMSTICK_CLASS_GENERIC_DUO 0x00
229
230
231struct memstick_device_id {
232 unsigned char match_flags;
233 unsigned char type;
234 unsigned char category;
235 unsigned char class; 231 unsigned char class;
232#define MEMSTICK_CLASS_FLASH 0xff
233#define MEMSTICK_CLASS_DUO 0x00
234#define MEMSTICK_CLASS_ROM 0x01
235#define MEMSTICK_CLASS_RO 0x02
236#define MEMSTICK_CLASS_WP 0x03
236}; 237};
237 238
238struct memstick_request { 239struct memstick_request {
@@ -263,6 +264,10 @@ struct memstick_dev {
263 /* Get next request from the media driver. */ 264 /* Get next request from the media driver. */
264 int (*next_request)(struct memstick_dev *card, 265 int (*next_request)(struct memstick_dev *card,
265 struct memstick_request **mrq); 266 struct memstick_request **mrq);
267 /* Tell the media driver to stop doing things */
268 void (*stop)(struct memstick_dev *card);
269 /* Allow the media driver to continue */
270 void (*start)(struct memstick_dev *card);
266 271
267 struct device dev; 272 struct device dev;
268}; 273};
@@ -284,7 +289,7 @@ struct memstick_host {
284 /* Notify the host that some requests are pending. */ 289 /* Notify the host that some requests are pending. */
285 void (*request)(struct memstick_host *host); 290 void (*request)(struct memstick_host *host);
286 /* Set host IO parameters (power, clock, etc). */ 291 /* Set host IO parameters (power, clock, etc). */
287 void (*set_param)(struct memstick_host *host, 292 int (*set_param)(struct memstick_host *host,
288 enum memstick_param param, 293 enum memstick_param param,
289 int value); 294 int value);
290 unsigned long private[0] ____cacheline_aligned; 295 unsigned long private[0] ____cacheline_aligned;
@@ -315,9 +320,9 @@ void memstick_suspend_host(struct memstick_host *host);
315void memstick_resume_host(struct memstick_host *host); 320void memstick_resume_host(struct memstick_host *host);
316 321
317void memstick_init_req_sg(struct memstick_request *mrq, unsigned char tpc, 322void memstick_init_req_sg(struct memstick_request *mrq, unsigned char tpc,
318 struct scatterlist *sg); 323 const struct scatterlist *sg);
319void memstick_init_req(struct memstick_request *mrq, unsigned char tpc, 324void memstick_init_req(struct memstick_request *mrq, unsigned char tpc,
320 void *buf, size_t length); 325 const void *buf, size_t length);
321int memstick_next_req(struct memstick_host *host, 326int memstick_next_req(struct memstick_host *host,
322 struct memstick_request **mrq); 327 struct memstick_request **mrq);
323void memstick_new_req(struct memstick_host *host); 328void memstick_new_req(struct memstick_host *host);
diff --git a/include/linux/mfd/asic3.h b/include/linux/mfd/asic3.h
index 4ab2162db13b..322cd6deb9f0 100644
--- a/include/linux/mfd/asic3.h
+++ b/include/linux/mfd/asic3.h
@@ -8,7 +8,7 @@
8 * published by the Free Software Foundation. 8 * published by the Free Software Foundation.
9 * 9 *
10 * Copyright 2001 Compaq Computer Corporation. 10 * Copyright 2001 Compaq Computer Corporation.
11 * Copyright 2007 OpendHand. 11 * Copyright 2007-2008 OpenedHand Ltd.
12 */ 12 */
13 13
14#ifndef __ASIC3_H__ 14#ifndef __ASIC3_H__
@@ -16,43 +16,22 @@
16 16
17#include <linux/types.h> 17#include <linux/types.h>
18 18
19struct asic3 {
20 void __iomem *mapping;
21 unsigned int bus_shift;
22 unsigned int irq_nr;
23 unsigned int irq_base;
24 spinlock_t lock;
25 u16 irq_bothedge[4];
26 struct device *dev;
27};
28
29struct asic3_platform_data { 19struct asic3_platform_data {
30 struct { 20 u16 *gpio_config;
31 u32 dir; 21 unsigned int gpio_config_num;
32 u32 init;
33 u32 sleep_mask;
34 u32 sleep_out;
35 u32 batt_fault_out;
36 u32 sleep_conf;
37 u32 alt_function;
38 } gpio_a, gpio_b, gpio_c, gpio_d;
39
40 unsigned int bus_shift;
41 22
42 unsigned int irq_base; 23 unsigned int irq_base;
43 24
44 struct platform_device **children; 25 unsigned int gpio_base;
45 unsigned int n_children;
46}; 26};
47 27
48int asic3_gpio_get_value(struct asic3 *asic, unsigned gpio);
49void asic3_gpio_set_value(struct asic3 *asic, unsigned gpio, int val);
50
51#define ASIC3_NUM_GPIO_BANKS 4 28#define ASIC3_NUM_GPIO_BANKS 4
52#define ASIC3_GPIOS_PER_BANK 16 29#define ASIC3_GPIOS_PER_BANK 16
53#define ASIC3_NUM_GPIOS 64 30#define ASIC3_NUM_GPIOS 64
54#define ASIC3_NR_IRQS ASIC3_NUM_GPIOS + 6 31#define ASIC3_NR_IRQS ASIC3_NUM_GPIOS + 6
55 32
33#define ASIC3_TO_GPIO(gpio) (NR_BUILTIN_GPIO + (gpio))
34
56#define ASIC3_GPIO_BANK_A 0 35#define ASIC3_GPIO_BANK_A 0
57#define ASIC3_GPIO_BANK_B 1 36#define ASIC3_GPIO_BANK_B 1
58#define ASIC3_GPIO_BANK_C 2 37#define ASIC3_GPIO_BANK_C 2
@@ -64,32 +43,89 @@ void asic3_gpio_set_value(struct asic3 *asic, unsigned gpio, int val);
64/* All offsets below are specified with this address bus shift */ 43/* All offsets below are specified with this address bus shift */
65#define ASIC3_DEFAULT_ADDR_SHIFT 2 44#define ASIC3_DEFAULT_ADDR_SHIFT 2
66 45
67#define ASIC3_OFFSET(base, reg) (ASIC3_##base##_Base + ASIC3_##base##_##reg) 46#define ASIC3_OFFSET(base, reg) (ASIC3_##base##_BASE + ASIC3_##base##_##reg)
68#define ASIC3_GPIO_OFFSET(base, reg) \ 47#define ASIC3_GPIO_OFFSET(base, reg) \
69 (ASIC3_GPIO_##base##_Base + ASIC3_GPIO_##reg) 48 (ASIC3_GPIO_##base##_BASE + ASIC3_GPIO_##reg)
70 49
71#define ASIC3_GPIO_A_Base 0x0000 50#define ASIC3_GPIO_A_BASE 0x0000
72#define ASIC3_GPIO_B_Base 0x0100 51#define ASIC3_GPIO_B_BASE 0x0100
73#define ASIC3_GPIO_C_Base 0x0200 52#define ASIC3_GPIO_C_BASE 0x0200
74#define ASIC3_GPIO_D_Base 0x0300 53#define ASIC3_GPIO_D_BASE 0x0300
75 54
76#define ASIC3_GPIO_Mask 0x00 /* R/W 0:don't mask */ 55#define ASIC3_GPIO_TO_BANK(gpio) ((gpio) >> 4)
77#define ASIC3_GPIO_Direction 0x04 /* R/W 0:input */ 56#define ASIC3_GPIO_TO_BIT(gpio) ((gpio) - \
78#define ASIC3_GPIO_Out 0x08 /* R/W 0:output low */ 57 (ASIC3_GPIOS_PER_BANK * ((gpio) >> 4)))
79#define ASIC3_GPIO_TriggerType 0x0c /* R/W 0:level */ 58#define ASIC3_GPIO_TO_MASK(gpio) (1 << ASIC3_GPIO_TO_BIT(gpio))
80#define ASIC3_GPIO_EdgeTrigger 0x10 /* R/W 0:falling */ 59#define ASIC3_GPIO_TO_BASE(gpio) (ASIC3_GPIO_A_BASE + (((gpio) >> 4) * 0x0100))
81#define ASIC3_GPIO_LevelTrigger 0x14 /* R/W 0:low level detect */ 60#define ASIC3_BANK_TO_BASE(bank) (ASIC3_GPIO_A_BASE + ((bank) * 0x100))
82#define ASIC3_GPIO_SleepMask 0x18 /* R/W 0:don't mask in sleep mode */ 61
83#define ASIC3_GPIO_SleepOut 0x1c /* R/W level 0:low in sleep mode */ 62#define ASIC3_GPIO_MASK 0x00 /* R/W 0:don't mask */
84#define ASIC3_GPIO_BattFaultOut 0x20 /* R/W level 0:low in batt_fault */ 63#define ASIC3_GPIO_DIRECTION 0x04 /* R/W 0:input */
85#define ASIC3_GPIO_IntStatus 0x24 /* R/W 0:none, 1:detect */ 64#define ASIC3_GPIO_OUT 0x08 /* R/W 0:output low */
86#define ASIC3_GPIO_AltFunction 0x28 /* R/W 1:LED register control */ 65#define ASIC3_GPIO_TRIGGER_TYPE 0x0c /* R/W 0:level */
87#define ASIC3_GPIO_SleepConf 0x2c /* 66#define ASIC3_GPIO_EDGE_TRIGGER 0x10 /* R/W 0:falling */
67#define ASIC3_GPIO_LEVEL_TRIGGER 0x14 /* R/W 0:low level detect */
68#define ASIC3_GPIO_SLEEP_MASK 0x18 /* R/W 0:don't mask in sleep mode */
69#define ASIC3_GPIO_SLEEP_OUT 0x1c /* R/W level 0:low in sleep mode */
70#define ASIC3_GPIO_BAT_FAULT_OUT 0x20 /* R/W level 0:low in batt_fault */
71#define ASIC3_GPIO_INT_STATUS 0x24 /* R/W 0:none, 1:detect */
72#define ASIC3_GPIO_ALT_FUNCTION 0x28 /* R/W 1:LED register control */
73#define ASIC3_GPIO_SLEEP_CONF 0x2c /*
88 * R/W bit 1: autosleep 74 * R/W bit 1: autosleep
89 * 0: disable gposlpout in normal mode, 75 * 0: disable gposlpout in normal mode,
90 * enable gposlpout in sleep mode. 76 * enable gposlpout in sleep mode.
91 */ 77 */
92#define ASIC3_GPIO_Status 0x30 /* R Pin status */ 78#define ASIC3_GPIO_STATUS 0x30 /* R Pin status */
79
80/*
81 * ASIC3 GPIO config
82 *
83 * Bits 0..6 gpio number
84 * Bits 7..13 Alternate function
85 * Bit 14 Direction
86 * Bit 15 Initial value
87 *
88 */
89#define ASIC3_CONFIG_GPIO_PIN(config) ((config) & 0x7f)
90#define ASIC3_CONFIG_GPIO_ALT(config) (((config) & (0x7f << 7)) >> 7)
91#define ASIC3_CONFIG_GPIO_DIR(config) ((config & (1 << 14)) >> 14)
92#define ASIC3_CONFIG_GPIO_INIT(config) ((config & (1 << 15)) >> 15)
93#define ASIC3_CONFIG_GPIO(gpio, alt, dir, init) (((gpio) & 0x7f) \
94 | (((alt) & 0x7f) << 7) | (((dir) & 0x1) << 14) \
95 | (((init) & 0x1) << 15))
96#define ASIC3_CONFIG_GPIO_DEFAULT(gpio, dir, init) \
97 ASIC3_CONFIG_GPIO((gpio), 0, (dir), (init))
98#define ASIC3_CONFIG_GPIO_DEFAULT_OUT(gpio, init) \
99 ASIC3_CONFIG_GPIO((gpio), 0, 1, (init))
100
101/*
102 * Alternate functions
103 */
104#define ASIC3_GPIOA11_PWM0 ASIC3_CONFIG_GPIO(11, 1, 1, 0)
105#define ASIC3_GPIOA12_PWM1 ASIC3_CONFIG_GPIO(12, 1, 1, 0)
106#define ASIC3_GPIOA15_CONTROL_CX ASIC3_CONFIG_GPIO(15, 1, 1, 0)
107#define ASIC3_GPIOC0_LED0 ASIC3_CONFIG_GPIO(32, 1, 1, 0)
108#define ASIC3_GPIOC1_LED1 ASIC3_CONFIG_GPIO(33, 1, 1, 0)
109#define ASIC3_GPIOC2_LED2 ASIC3_CONFIG_GPIO(34, 1, 1, 0)
110#define ASIC3_GPIOC3_SPI_RXD ASIC3_CONFIG_GPIO(35, 1, 0, 0)
111#define ASIC3_GPIOC4_CF_nCD ASIC3_CONFIG_GPIO(36, 1, 0, 0)
112#define ASIC3_GPIOC4_SPI_TXD ASIC3_CONFIG_GPIO(36, 1, 1, 0)
113#define ASIC3_GPIOC5_SPI_CLK ASIC3_CONFIG_GPIO(37, 1, 1, 0)
114#define ASIC3_GPIOC5_nCIOW ASIC3_CONFIG_GPIO(37, 1, 1, 0)
115#define ASIC3_GPIOC6_nCIOR ASIC3_CONFIG_GPIO(38, 1, 1, 0)
116#define ASIC3_GPIOC7_nPCE_1 ASIC3_CONFIG_GPIO(39, 1, 0, 0)
117#define ASIC3_GPIOC8_nPCE_2 ASIC3_CONFIG_GPIO(40, 1, 0, 0)
118#define ASIC3_GPIOC9_nPOE ASIC3_CONFIG_GPIO(41, 1, 0, 0)
119#define ASIC3_GPIOC10_nPWE ASIC3_CONFIG_GPIO(42, 1, 0, 0)
120#define ASIC3_GPIOC11_PSKTSEL ASIC3_CONFIG_GPIO(43, 1, 0, 0)
121#define ASIC3_GPIOC12_nPREG ASIC3_CONFIG_GPIO(44, 1, 0, 0)
122#define ASIC3_GPIOC13_nPWAIT ASIC3_CONFIG_GPIO(45, 1, 1, 0)
123#define ASIC3_GPIOC14_nPIOIS16 ASIC3_CONFIG_GPIO(46, 1, 1, 0)
124#define ASIC3_GPIOC15_nPIOR ASIC3_CONFIG_GPIO(47, 1, 0, 0)
125#define ASIC3_GPIOD11_nCIOIS16 ASIC3_CONFIG_GPIO(59, 1, 0, 0)
126#define ASIC3_GPIOD12_nCWAIT ASIC3_CONFIG_GPIO(60, 1, 0, 0)
127#define ASIC3_GPIOD15_nPIOW ASIC3_CONFIG_GPIO(63, 1, 0, 0)
128
93 129
94#define ASIC3_SPI_Base 0x0400 130#define ASIC3_SPI_Base 0x0400
95#define ASIC3_SPI_Control 0x0000 131#define ASIC3_SPI_Control 0x0000
@@ -128,7 +164,7 @@ void asic3_gpio_set_value(struct asic3 *asic, unsigned gpio, int val);
128#define LED_AUTOSTOP (1 << 5) /* LED ON/OFF auto stop 0:disable, 1:enable */ 164#define LED_AUTOSTOP (1 << 5) /* LED ON/OFF auto stop 0:disable, 1:enable */
129#define LED_ALWAYS (1 << 6) /* LED Interrupt Mask 0:No mask, 1:mask */ 165#define LED_ALWAYS (1 << 6) /* LED Interrupt Mask 0:No mask, 1:mask */
130 166
131#define ASIC3_CLOCK_Base 0x0A00 167#define ASIC3_CLOCK_BASE 0x0A00
132#define ASIC3_CLOCK_CDEX 0x00 168#define ASIC3_CLOCK_CDEX 0x00
133#define ASIC3_CLOCK_SEL 0x04 169#define ASIC3_CLOCK_SEL 0x04
134 170
@@ -159,12 +195,12 @@ void asic3_gpio_set_value(struct asic3 *asic, unsigned gpio, int val);
159#define CLOCK_SEL_CX (1 << 2) 195#define CLOCK_SEL_CX (1 << 2)
160 196
161 197
162#define ASIC3_INTR_Base 0x0B00 198#define ASIC3_INTR_BASE 0x0B00
163 199
164#define ASIC3_INTR_IntMask 0x00 /* Interrupt mask control */ 200#define ASIC3_INTR_INT_MASK 0x00 /* Interrupt mask control */
165#define ASIC3_INTR_PIntStat 0x04 /* Peripheral interrupt status */ 201#define ASIC3_INTR_P_INT_STAT 0x04 /* Peripheral interrupt status */
166#define ASIC3_INTR_IntCPS 0x08 /* Interrupt timer clock pre-scale */ 202#define ASIC3_INTR_INT_CPS 0x08 /* Interrupt timer clock pre-scale */
167#define ASIC3_INTR_IntTBS 0x0c /* Interrupt timer set */ 203#define ASIC3_INTR_INT_TBS 0x0c /* Interrupt timer set */
168 204
169#define ASIC3_INTMASK_GINTMASK (1 << 0) /* Global INTs mask 1:enable */ 205#define ASIC3_INTMASK_GINTMASK (1 << 0) /* Global INTs mask 1:enable */
170#define ASIC3_INTMASK_GINTEL (1 << 1) /* 1: rising edge, 0: hi level */ 206#define ASIC3_INTMASK_GINTEL (1 << 1) /* 1: rising edge, 0: hi level */
@@ -227,44 +263,12 @@ void asic3_gpio_set_value(struct asic3 *asic, unsigned gpio, int val);
227#define ASIC3_EXTCF_CF_SLEEP (1 << 15) /* CF sleep mode control */ 263#define ASIC3_EXTCF_CF_SLEEP (1 << 15) /* CF sleep mode control */
228 264
229/********************************************* 265/*********************************************
230 * The Onewire interface registers 266 * The Onewire interface (DS1WM) is handled
231 * 267 * by the ds1wm driver.
232 * OWM_CMD
233 * OWM_DAT
234 * OWM_INTR
235 * OWM_INTEN
236 * OWM_CLKDIV
237 * 268 *
238 *********************************************/ 269 *********************************************/
239 270
240#define ASIC3_OWM_Base 0xC00 271#define ASIC3_OWM_BASE 0xC00
241
242#define ASIC3_OWM_CMD 0x00
243#define ASIC3_OWM_DAT 0x04
244#define ASIC3_OWM_INTR 0x08
245#define ASIC3_OWM_INTEN 0x0C
246#define ASIC3_OWM_CLKDIV 0x10
247
248#define ASIC3_OWM_CMD_ONEWR (1 << 0)
249#define ASIC3_OWM_CMD_SRA (1 << 1)
250#define ASIC3_OWM_CMD_DQO (1 << 2)
251#define ASIC3_OWM_CMD_DQI (1 << 3)
252
253#define ASIC3_OWM_INTR_PD (1 << 0)
254#define ASIC3_OWM_INTR_PDR (1 << 1)
255#define ASIC3_OWM_INTR_TBE (1 << 2)
256#define ASIC3_OWM_INTR_TEMP (1 << 3)
257#define ASIC3_OWM_INTR_RBF (1 << 4)
258
259#define ASIC3_OWM_INTEN_EPD (1 << 0)
260#define ASIC3_OWM_INTEN_IAS (1 << 1)
261#define ASIC3_OWM_INTEN_ETBE (1 << 2)
262#define ASIC3_OWM_INTEN_ETMT (1 << 3)
263#define ASIC3_OWM_INTEN_ERBF (1 << 4)
264
265#define ASIC3_OWM_CLKDIV_PRE (3 << 0) /* two bits wide at bit 0 */
266#define ASIC3_OWM_CLKDIV_DIV (7 << 2) /* 3 bits wide at bit 2 */
267
268 272
269/***************************************************************************** 273/*****************************************************************************
270 * The SD configuration registers are at a completely different location 274 * The SD configuration registers are at a completely different location
@@ -492,6 +496,7 @@ void asic3_gpio_set_value(struct asic3 *asic, unsigned gpio, int val);
492#define ASIC3_SDIO_CTRL_LEDCtrl 0x7C 496#define ASIC3_SDIO_CTRL_LEDCtrl 0x7C
493#define ASIC3_SDIO_CTRL_SoftwareReset 0x1C0 497#define ASIC3_SDIO_CTRL_SoftwareReset 0x1C0
494 498
495#define ASIC3_MAP_SIZE 0x2000 499#define ASIC3_MAP_SIZE_32BIT 0x2000
500#define ASIC3_MAP_SIZE_16BIT 0x1000
496 501
497#endif /* __ASIC3_H__ */ 502#endif /* __ASIC3_H__ */
diff --git a/include/linux/mfd/core.h b/include/linux/mfd/core.h
new file mode 100644
index 000000000000..49ef857cdb2d
--- /dev/null
+++ b/include/linux/mfd/core.h
@@ -0,0 +1,55 @@
1/*
2 * drivers/mfd/mfd-core.h
3 *
4 * core MFD support
5 * Copyright (c) 2006 Ian Molton
6 * Copyright (c) 2007 Dmitry Baryshkov
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#ifndef MFD_CORE_H
15#define MFD_CORE_H
16
17#include <linux/platform_device.h>
18
19/*
20 * This struct describes the MFD part ("cell").
21 * After registration the copy of this structure will become the platform data
22 * of the resulting platform_device
23 */
24struct mfd_cell {
25 const char *name;
26
27 int (*enable)(struct platform_device *dev);
28 int (*disable)(struct platform_device *dev);
29 int (*suspend)(struct platform_device *dev);
30 int (*resume)(struct platform_device *dev);
31
32 /* driver-specific data for MFD-aware "cell" drivers */
33 void *driver_data;
34
35 /* platform_data can be used to either pass data to "generic"
36 driver or as a hook to mfd_cell for the "cell" drivers */
37 void *platform_data;
38 size_t data_size;
39
40 /*
41 * This resources can be specified relatievly to the parent device.
42 * For accessing device you should use resources from device
43 */
44 int num_resources;
45 const struct resource *resources;
46};
47
48extern int mfd_add_devices(struct device *parent, int id,
49 const struct mfd_cell *cells, int n_devs,
50 struct resource *mem_base,
51 int irq_base);
52
53extern void mfd_remove_devices(struct device *parent);
54
55#endif
diff --git a/include/linux/mfd/da903x.h b/include/linux/mfd/da903x.h
new file mode 100644
index 000000000000..cad314c12439
--- /dev/null
+++ b/include/linux/mfd/da903x.h
@@ -0,0 +1,201 @@
1#ifndef __LINUX_PMIC_DA903X_H
2#define __LINUX_PMIC_DA903X_H
3
4/* Unified sub device IDs for DA9030/DA9034 */
5enum {
6 DA9030_ID_LED_1,
7 DA9030_ID_LED_2,
8 DA9030_ID_LED_3,
9 DA9030_ID_LED_4,
10 DA9030_ID_LED_PC,
11 DA9030_ID_VIBRA,
12 DA9030_ID_WLED,
13 DA9030_ID_BUCK1,
14 DA9030_ID_BUCK2,
15 DA9030_ID_LDO1,
16 DA9030_ID_LDO2,
17 DA9030_ID_LDO3,
18 DA9030_ID_LDO4,
19 DA9030_ID_LDO5,
20 DA9030_ID_LDO6,
21 DA9030_ID_LDO7,
22 DA9030_ID_LDO8,
23 DA9030_ID_LDO9,
24 DA9030_ID_LDO10,
25 DA9030_ID_LDO11,
26 DA9030_ID_LDO12,
27 DA9030_ID_LDO13,
28 DA9030_ID_LDO14,
29 DA9030_ID_LDO15,
30 DA9030_ID_LDO16,
31 DA9030_ID_LDO17,
32 DA9030_ID_LDO18,
33 DA9030_ID_LDO19,
34 DA9030_ID_LDO_INT, /* LDO Internal */
35
36 DA9034_ID_LED_1,
37 DA9034_ID_LED_2,
38 DA9034_ID_VIBRA,
39 DA9034_ID_WLED,
40 DA9034_ID_TOUCH,
41
42 DA9034_ID_BUCK1,
43 DA9034_ID_BUCK2,
44 DA9034_ID_LDO1,
45 DA9034_ID_LDO2,
46 DA9034_ID_LDO3,
47 DA9034_ID_LDO4,
48 DA9034_ID_LDO5,
49 DA9034_ID_LDO6,
50 DA9034_ID_LDO7,
51 DA9034_ID_LDO8,
52 DA9034_ID_LDO9,
53 DA9034_ID_LDO10,
54 DA9034_ID_LDO11,
55 DA9034_ID_LDO12,
56 DA9034_ID_LDO13,
57 DA9034_ID_LDO14,
58 DA9034_ID_LDO15,
59};
60
61/*
62 * DA9030/DA9034 LEDs sub-devices uses generic "struct led_info"
63 * as the platform_data
64 */
65
66/* DA9030 flags for "struct led_info"
67 */
68#define DA9030_LED_RATE_ON (0 << 5)
69#define DA9030_LED_RATE_052S (1 << 5)
70#define DA9030_LED_DUTY_1_16 (0 << 3)
71#define DA9030_LED_DUTY_1_8 (1 << 3)
72#define DA9030_LED_DUTY_1_4 (2 << 3)
73#define DA9030_LED_DUTY_1_2 (3 << 3)
74
75#define DA9030_VIBRA_MODE_1P3V (0 << 1)
76#define DA9030_VIBRA_MODE_2P7V (1 << 1)
77#define DA9030_VIBRA_FREQ_1HZ (0 << 2)
78#define DA9030_VIBRA_FREQ_2HZ (1 << 2)
79#define DA9030_VIBRA_FREQ_4HZ (2 << 2)
80#define DA9030_VIBRA_FREQ_8HZ (3 << 2)
81#define DA9030_VIBRA_DUTY_ON (0 << 4)
82#define DA9030_VIBRA_DUTY_75P (1 << 4)
83#define DA9030_VIBRA_DUTY_50P (2 << 4)
84#define DA9030_VIBRA_DUTY_25P (3 << 4)
85
86/* DA9034 flags for "struct led_info" */
87#define DA9034_LED_RAMP (1 << 7)
88
89/* DA9034 touch screen platform data */
90struct da9034_touch_pdata {
91 int interval_ms; /* sampling interval while pen down */
92 int x_inverted;
93 int y_inverted;
94};
95
96struct da903x_subdev_info {
97 int id;
98 const char *name;
99 void *platform_data;
100};
101
102struct da903x_platform_data {
103 int num_subdevs;
104 struct da903x_subdev_info *subdevs;
105};
106
107/* bit definitions for DA9030 events */
108#define DA9030_EVENT_ONKEY (1 << 0)
109#define DA9030_EVENT_PWREN (1 << 1)
110#define DA9030_EVENT_EXTON (1 << 2)
111#define DA9030_EVENT_CHDET (1 << 3)
112#define DA9030_EVENT_TBAT (1 << 4)
113#define DA9030_EVENT_VBATMON (1 << 5)
114#define DA9030_EVENT_VBATMON_TXON (1 << 6)
115#define DA9030_EVENT_CHIOVER (1 << 7)
116#define DA9030_EVENT_TCTO (1 << 8)
117#define DA9030_EVENT_CCTO (1 << 9)
118#define DA9030_EVENT_ADC_READY (1 << 10)
119#define DA9030_EVENT_VBUS_4P4 (1 << 11)
120#define DA9030_EVENT_VBUS_4P0 (1 << 12)
121#define DA9030_EVENT_SESS_VALID (1 << 13)
122#define DA9030_EVENT_SRP_DETECT (1 << 14)
123#define DA9030_EVENT_WATCHDOG (1 << 15)
124#define DA9030_EVENT_LDO15 (1 << 16)
125#define DA9030_EVENT_LDO16 (1 << 17)
126#define DA9030_EVENT_LDO17 (1 << 18)
127#define DA9030_EVENT_LDO18 (1 << 19)
128#define DA9030_EVENT_LDO19 (1 << 20)
129#define DA9030_EVENT_BUCK2 (1 << 21)
130
131/* bit definitions for DA9034 events */
132#define DA9034_EVENT_ONKEY (1 << 0)
133#define DA9034_EVENT_EXTON (1 << 2)
134#define DA9034_EVENT_CHDET (1 << 3)
135#define DA9034_EVENT_TBAT (1 << 4)
136#define DA9034_EVENT_VBATMON (1 << 5)
137#define DA9034_EVENT_REV_IOVER (1 << 6)
138#define DA9034_EVENT_CH_IOVER (1 << 7)
139#define DA9034_EVENT_CH_TCTO (1 << 8)
140#define DA9034_EVENT_CH_CCTO (1 << 9)
141#define DA9034_EVENT_USB_DEV (1 << 10)
142#define DA9034_EVENT_OTGCP_IOVER (1 << 11)
143#define DA9034_EVENT_VBUS_4P55 (1 << 12)
144#define DA9034_EVENT_VBUS_3P8 (1 << 13)
145#define DA9034_EVENT_SESS_1P8 (1 << 14)
146#define DA9034_EVENT_SRP_READY (1 << 15)
147#define DA9034_EVENT_ADC_MAN (1 << 16)
148#define DA9034_EVENT_ADC_AUTO4 (1 << 17)
149#define DA9034_EVENT_ADC_AUTO5 (1 << 18)
150#define DA9034_EVENT_ADC_AUTO6 (1 << 19)
151#define DA9034_EVENT_PEN_DOWN (1 << 20)
152#define DA9034_EVENT_TSI_READY (1 << 21)
153#define DA9034_EVENT_UART_TX (1 << 22)
154#define DA9034_EVENT_UART_RX (1 << 23)
155#define DA9034_EVENT_HEADSET (1 << 25)
156#define DA9034_EVENT_HOOKSWITCH (1 << 26)
157#define DA9034_EVENT_WATCHDOG (1 << 27)
158
159extern int da903x_register_notifier(struct device *dev,
160 struct notifier_block *nb, unsigned int events);
161extern int da903x_unregister_notifier(struct device *dev,
162 struct notifier_block *nb, unsigned int events);
163
164/* Status Query Interface */
165#define DA9030_STATUS_ONKEY (1 << 0)
166#define DA9030_STATUS_PWREN1 (1 << 1)
167#define DA9030_STATUS_EXTON (1 << 2)
168#define DA9030_STATUS_CHDET (1 << 3)
169#define DA9030_STATUS_TBAT (1 << 4)
170#define DA9030_STATUS_VBATMON (1 << 5)
171#define DA9030_STATUS_VBATMON_TXON (1 << 6)
172#define DA9030_STATUS_MCLKDET (1 << 7)
173
174#define DA9034_STATUS_ONKEY (1 << 0)
175#define DA9034_STATUS_EXTON (1 << 2)
176#define DA9034_STATUS_CHDET (1 << 3)
177#define DA9034_STATUS_TBAT (1 << 4)
178#define DA9034_STATUS_VBATMON (1 << 5)
179#define DA9034_STATUS_PEN_DOWN (1 << 6)
180#define DA9034_STATUS_MCLKDET (1 << 7)
181#define DA9034_STATUS_USB_DEV (1 << 8)
182#define DA9034_STATUS_HEADSET (1 << 9)
183#define DA9034_STATUS_HOOKSWITCH (1 << 10)
184#define DA9034_STATUS_REMCON (1 << 11)
185#define DA9034_STATUS_VBUS_VALID_4P55 (1 << 12)
186#define DA9034_STATUS_VBUS_VALID_3P8 (1 << 13)
187#define DA9034_STATUS_SESS_VALID_1P8 (1 << 14)
188#define DA9034_STATUS_SRP_READY (1 << 15)
189
190extern int da903x_query_status(struct device *dev, unsigned int status);
191
192
193/* NOTE: the two functions below are not intended for use outside
194 * of the DA9034 sub-device drivers
195 */
196extern int da903x_write(struct device *dev, int reg, uint8_t val);
197extern int da903x_read(struct device *dev, int reg, uint8_t *val);
198extern int da903x_update(struct device *dev, int reg, uint8_t val, uint8_t mask);
199extern int da903x_set_bits(struct device *dev, int reg, uint8_t bit_mask);
200extern int da903x_clr_bits(struct device *dev, int reg, uint8_t bit_mask);
201#endif /* __LINUX_PMIC_DA903X_H */
diff --git a/include/linux/mfd/t7l66xb.h b/include/linux/mfd/t7l66xb.h
new file mode 100644
index 000000000000..b4629818aea5
--- /dev/null
+++ b/include/linux/mfd/t7l66xb.h
@@ -0,0 +1,34 @@
1/*
2 * This file contains the definitions for the T7L66XB
3 *
4 * (C) Copyright 2005 Ian Molton <spyro@f2s.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 version 2 as
8 * published by the Free Software Foundation.
9 *
10 */
11#ifndef MFD_T7L66XB_H
12#define MFD_T7L66XB_H
13
14#include <linux/mfd/core.h>
15#include <linux/mfd/tmio.h>
16
17struct t7l66xb_platform_data {
18 int (*enable)(struct platform_device *dev);
19 int (*disable)(struct platform_device *dev);
20 int (*suspend)(struct platform_device *dev);
21 int (*resume)(struct platform_device *dev);
22
23 int irq_base; /* The base for subdevice irqs */
24
25 struct tmio_nand_data *nand_data;
26};
27
28
29#define IRQ_T7L66XB_MMC (1)
30#define IRQ_T7L66XB_NAND (3)
31
32#define T7L66XB_NR_IRQS 8
33
34#endif
diff --git a/include/linux/mfd/tc6387xb.h b/include/linux/mfd/tc6387xb.h
new file mode 100644
index 000000000000..b4888209494a
--- /dev/null
+++ b/include/linux/mfd/tc6387xb.h
@@ -0,0 +1,20 @@
1/*
2 * This file contains the definitions for the TC6387XB
3 *
4 * (C) Copyright 2005 Ian Molton <spyro@f2s.com>
5 *
6 * May be copied or modified under the terms of the GNU General Public
7 * License. See linux/COPYING for more information.
8 *
9 */
10#ifndef MFD_TC6387XB_H
11#define MFD_TC6387XB_H
12
13struct tc6387xb_platform_data {
14 int (*enable)(struct platform_device *dev);
15 int (*disable)(struct platform_device *dev);
16 int (*suspend)(struct platform_device *dev);
17 int (*resume)(struct platform_device *dev);
18};
19
20#endif
diff --git a/include/linux/mfd/tc6393xb.h b/include/linux/mfd/tc6393xb.h
new file mode 100644
index 000000000000..626e448205c5
--- /dev/null
+++ b/include/linux/mfd/tc6393xb.h
@@ -0,0 +1,59 @@
1/*
2 * Toshiba TC6393XB SoC support
3 *
4 * Copyright(c) 2005-2006 Chris Humbert
5 * Copyright(c) 2005 Dirk Opfer
6 * Copyright(c) 2005 Ian Molton <spyro@f2s.com>
7 * Copyright(c) 2007 Dmitry Baryshkov
8 *
9 * Based on code written by Sharp/Lineo for 2.4 kernels
10 * Based on locomo.c
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
15 */
16
17#ifndef MFD_TC6393XB_H
18#define MFD_TC6393XB_H
19
20#include <linux/fb.h>
21
22/* Also one should provide the CK3P6MI clock */
23struct tc6393xb_platform_data {
24 u16 scr_pll2cr; /* PLL2 Control */
25 u16 scr_gper; /* GP Enable */
26
27 int (*enable)(struct platform_device *dev);
28 int (*disable)(struct platform_device *dev);
29 int (*suspend)(struct platform_device *dev);
30 int (*resume)(struct platform_device *dev);
31
32 int irq_base; /* base for subdevice irqs */
33 int gpio_base;
34 int (*setup)(struct platform_device *dev);
35 void (*teardown)(struct platform_device *dev);
36
37 struct tmio_nand_data *nand_data;
38 struct tmio_fb_data *fb_data;
39
40 unsigned resume_restore : 1; /* make special actions
41 to preserve the state
42 on suspend/resume */
43};
44
45extern int tc6393xb_lcd_mode(struct platform_device *fb,
46 const struct fb_videomode *mode);
47extern int tc6393xb_lcd_set_power(struct platform_device *fb, bool on);
48
49/*
50 * Relative to irq_base
51 */
52#define IRQ_TC6393_NAND 0
53#define IRQ_TC6393_MMC 1
54#define IRQ_TC6393_OHCI 2
55#define IRQ_TC6393_FB 4
56
57#define TC6393XB_NR_IRQS 8
58
59#endif
diff --git a/include/linux/mfd/tmio.h b/include/linux/mfd/tmio.h
new file mode 100644
index 000000000000..516d955ab8a1
--- /dev/null
+++ b/include/linux/mfd/tmio.h
@@ -0,0 +1,47 @@
1#ifndef MFD_TMIO_H
2#define MFD_TMIO_H
3
4#include <linux/fb.h>
5
6#define tmio_ioread8(addr) readb(addr)
7#define tmio_ioread16(addr) readw(addr)
8#define tmio_ioread16_rep(r, b, l) readsw(r, b, l)
9#define tmio_ioread32(addr) \
10 (((u32) readw((addr))) | (((u32) readw((addr) + 2)) << 16))
11
12#define tmio_iowrite8(val, addr) writeb((val), (addr))
13#define tmio_iowrite16(val, addr) writew((val), (addr))
14#define tmio_iowrite16_rep(r, b, l) writesw(r, b, l)
15#define tmio_iowrite32(val, addr) \
16 do { \
17 writew((val), (addr)); \
18 writew((val) >> 16, (addr) + 2); \
19 } while (0)
20
21/*
22 * data for the NAND controller
23 */
24struct tmio_nand_data {
25 struct nand_bbt_descr *badblock_pattern;
26 struct mtd_partition *partition;
27 unsigned int num_partitions;
28};
29
30#define FBIO_TMIO_ACC_WRITE 0x7C639300
31#define FBIO_TMIO_ACC_SYNC 0x7C639301
32
33struct tmio_fb_data {
34 int (*lcd_set_power)(struct platform_device *fb_dev,
35 bool on);
36 int (*lcd_mode)(struct platform_device *fb_dev,
37 const struct fb_videomode *mode);
38 int num_modes;
39 struct fb_videomode *modes;
40
41 /* in mm: size of screen */
42 int height;
43 int width;
44};
45
46
47#endif
diff --git a/include/linux/mfd/wm8350/audio.h b/include/linux/mfd/wm8350/audio.h
new file mode 100644
index 000000000000..217bb22ebb8e
--- /dev/null
+++ b/include/linux/mfd/wm8350/audio.h
@@ -0,0 +1,598 @@
1/*
2 * audio.h -- Audio Driver for Wolfson WM8350 PMIC
3 *
4 * Copyright 2007 Wolfson Microelectronics PLC
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 *
11 */
12
13#ifndef __LINUX_MFD_WM8350_AUDIO_H_
14#define __LINUX_MFD_WM8350_AUDIO_H_
15
16#include <linux/platform_device.h>
17
18#define WM8350_CLOCK_CONTROL_1 0x28
19#define WM8350_CLOCK_CONTROL_2 0x29
20#define WM8350_FLL_CONTROL_1 0x2A
21#define WM8350_FLL_CONTROL_2 0x2B
22#define WM8350_FLL_CONTROL_3 0x2C
23#define WM8350_FLL_CONTROL_4 0x2D
24#define WM8350_DAC_CONTROL 0x30
25#define WM8350_DAC_DIGITAL_VOLUME_L 0x32
26#define WM8350_DAC_DIGITAL_VOLUME_R 0x33
27#define WM8350_DAC_LR_RATE 0x35
28#define WM8350_DAC_CLOCK_CONTROL 0x36
29#define WM8350_DAC_MUTE 0x3A
30#define WM8350_DAC_MUTE_VOLUME 0x3B
31#define WM8350_DAC_SIDE 0x3C
32#define WM8350_ADC_CONTROL 0x40
33#define WM8350_ADC_DIGITAL_VOLUME_L 0x42
34#define WM8350_ADC_DIGITAL_VOLUME_R 0x43
35#define WM8350_ADC_DIVIDER 0x44
36#define WM8350_ADC_LR_RATE 0x46
37#define WM8350_INPUT_CONTROL 0x48
38#define WM8350_IN3_INPUT_CONTROL 0x49
39#define WM8350_MIC_BIAS_CONTROL 0x4A
40#define WM8350_OUTPUT_CONTROL 0x4C
41#define WM8350_JACK_DETECT 0x4D
42#define WM8350_ANTI_POP_CONTROL 0x4E
43#define WM8350_LEFT_INPUT_VOLUME 0x50
44#define WM8350_RIGHT_INPUT_VOLUME 0x51
45#define WM8350_LEFT_MIXER_CONTROL 0x58
46#define WM8350_RIGHT_MIXER_CONTROL 0x59
47#define WM8350_OUT3_MIXER_CONTROL 0x5C
48#define WM8350_OUT4_MIXER_CONTROL 0x5D
49#define WM8350_OUTPUT_LEFT_MIXER_VOLUME 0x60
50#define WM8350_OUTPUT_RIGHT_MIXER_VOLUME 0x61
51#define WM8350_INPUT_MIXER_VOLUME_L 0x62
52#define WM8350_INPUT_MIXER_VOLUME_R 0x63
53#define WM8350_INPUT_MIXER_VOLUME 0x64
54#define WM8350_LOUT1_VOLUME 0x68
55#define WM8350_ROUT1_VOLUME 0x69
56#define WM8350_LOUT2_VOLUME 0x6A
57#define WM8350_ROUT2_VOLUME 0x6B
58#define WM8350_BEEP_VOLUME 0x6F
59#define WM8350_AI_FORMATING 0x70
60#define WM8350_ADC_DAC_COMP 0x71
61#define WM8350_AI_ADC_CONTROL 0x72
62#define WM8350_AI_DAC_CONTROL 0x73
63#define WM8350_AIF_TEST 0x74
64#define WM8350_JACK_PIN_STATUS 0xE7
65
66/* Bit values for R08 (0x08) */
67#define WM8350_CODEC_ISEL_1_5 0 /* x1.5 */
68#define WM8350_CODEC_ISEL_1_0 1 /* x1.0 */
69#define WM8350_CODEC_ISEL_0_75 2 /* x0.75 */
70#define WM8350_CODEC_ISEL_0_5 3 /* x0.5 */
71
72#define WM8350_VMID_OFF 0
73#define WM8350_VMID_500K 1
74#define WM8350_VMID_100K 2
75#define WM8350_VMID_10K 3
76
77/*
78 * R40 (0x28) - Clock Control 1
79 */
80#define WM8350_TOCLK_RATE 0x4000
81#define WM8350_MCLK_SEL 0x0800
82#define WM8350_MCLK_DIV_MASK 0x0100
83#define WM8350_BCLK_DIV_MASK 0x00F0
84#define WM8350_OPCLK_DIV_MASK 0x0007
85
86/*
87 * R41 (0x29) - Clock Control 2
88 */
89#define WM8350_LRC_ADC_SEL 0x8000
90#define WM8350_MCLK_DIR 0x0001
91
92/*
93 * R42 (0x2A) - FLL Control 1
94 */
95#define WM8350_FLL_DITHER_WIDTH_MASK 0x3000
96#define WM8350_FLL_DITHER_HP 0x0800
97#define WM8350_FLL_OUTDIV_MASK 0x0700
98#define WM8350_FLL_RSP_RATE_MASK 0x00F0
99#define WM8350_FLL_RATE_MASK 0x0007
100
101/*
102 * R43 (0x2B) - FLL Control 2
103 */
104#define WM8350_FLL_RATIO_MASK 0xF800
105#define WM8350_FLL_N_MASK 0x03FF
106
107/*
108 * R44 (0x2C) - FLL Control 3
109 */
110#define WM8350_FLL_K_MASK 0xFFFF
111
112/*
113 * R45 (0x2D) - FLL Control 4
114 */
115#define WM8350_FLL_FRAC 0x0020
116#define WM8350_FLL_SLOW_LOCK_REF 0x0010
117#define WM8350_FLL_CLK_SRC_MASK 0x0003
118
119/*
120 * R48 (0x30) - DAC Control
121 */
122#define WM8350_DAC_MONO 0x2000
123#define WM8350_AIF_LRCLKRATE 0x1000
124#define WM8350_DEEMP_MASK 0x0030
125#define WM8350_DACL_DATINV 0x0002
126#define WM8350_DACR_DATINV 0x0001
127
128/*
129 * R50 (0x32) - DAC Digital Volume L
130 */
131#define WM8350_DAC_VU 0x0100
132#define WM8350_DACL_VOL_MASK 0x00FF
133
134/*
135 * R51 (0x33) - DAC Digital Volume R
136 */
137#define WM8350_DAC_VU 0x0100
138#define WM8350_DACR_VOL_MASK 0x00FF
139
140/*
141 * R53 (0x35) - DAC LR Rate
142 */
143#define WM8350_DACLRC_ENA 0x0800
144#define WM8350_DACLRC_RATE_MASK 0x07FF
145
146/*
147 * R54 (0x36) - DAC Clock Control
148 */
149#define WM8350_DACCLK_POL 0x0010
150#define WM8350_DAC_CLKDIV_MASK 0x0007
151
152/*
153 * R58 (0x3A) - DAC Mute
154 */
155#define WM8350_DAC_MUTE_ENA 0x4000
156
157/*
158 * R59 (0x3B) - DAC Mute Volume
159 */
160#define WM8350_DAC_MUTEMODE 0x4000
161#define WM8350_DAC_MUTERATE 0x2000
162#define WM8350_DAC_SB_FILT 0x1000
163
164/*
165 * R60 (0x3C) - DAC Side
166 */
167#define WM8350_ADC_TO_DACL_MASK 0x3000
168#define WM8350_ADC_TO_DACR_MASK 0x0C00
169
170/*
171 * R64 (0x40) - ADC Control
172 */
173#define WM8350_ADC_HPF_CUT_MASK 0x0300
174#define WM8350_ADCL_DATINV 0x0002
175#define WM8350_ADCR_DATINV 0x0001
176
177/*
178 * R66 (0x42) - ADC Digital Volume L
179 */
180#define WM8350_ADC_VU 0x0100
181#define WM8350_ADCL_VOL_MASK 0x00FF
182
183/*
184 * R67 (0x43) - ADC Digital Volume R
185 */
186#define WM8350_ADC_VU 0x0100
187#define WM8350_ADCR_VOL_MASK 0x00FF
188
189/*
190 * R68 (0x44) - ADC Divider
191 */
192#define WM8350_ADCL_DAC_SVOL_MASK 0x0F00
193#define WM8350_ADCR_DAC_SVOL_MASK 0x00F0
194#define WM8350_ADCCLK_POL 0x0008
195#define WM8350_ADC_CLKDIV_MASK 0x0007
196
197/*
198 * R70 (0x46) - ADC LR Rate
199 */
200#define WM8350_ADCLRC_ENA 0x0800
201#define WM8350_ADCLRC_RATE_MASK 0x07FF
202
203/*
204 * R72 (0x48) - Input Control
205 */
206#define WM8350_IN2R_ENA 0x0400
207#define WM8350_IN1RN_ENA 0x0200
208#define WM8350_IN1RP_ENA 0x0100
209#define WM8350_IN2L_ENA 0x0004
210#define WM8350_IN1LN_ENA 0x0002
211#define WM8350_IN1LP_ENA 0x0001
212
213/*
214 * R73 (0x49) - IN3 Input Control
215 */
216#define WM8350_IN3R_SHORT 0x4000
217#define WM8350_IN3L_SHORT 0x0040
218
219/*
220 * R74 (0x4A) - Mic Bias Control
221 */
222#define WM8350_MICBSEL 0x4000
223#define WM8350_MCDTHR_MASK 0x001C
224#define WM8350_MCDSCTHR_MASK 0x0003
225
226/*
227 * R76 (0x4C) - Output Control
228 */
229#define WM8350_OUT4_VROI 0x0800
230#define WM8350_OUT3_VROI 0x0400
231#define WM8350_OUT2_VROI 0x0200
232#define WM8350_OUT1_VROI 0x0100
233#define WM8350_OUT2_FB 0x0004
234#define WM8350_OUT1_FB 0x0001
235
236/*
237 * R77 (0x4D) - Jack Detect
238 */
239#define WM8350_JDL_ENA 0x8000
240#define WM8350_JDR_ENA 0x4000
241
242/*
243 * R78 (0x4E) - Anti Pop Control
244 */
245#define WM8350_ANTI_POP_MASK 0x0300
246#define WM8350_DIS_OP_LN4_MASK 0x00C0
247#define WM8350_DIS_OP_LN3_MASK 0x0030
248#define WM8350_DIS_OP_OUT2_MASK 0x000C
249#define WM8350_DIS_OP_OUT1_MASK 0x0003
250
251/*
252 * R80 (0x50) - Left Input Volume
253 */
254#define WM8350_INL_MUTE 0x4000
255#define WM8350_INL_ZC 0x2000
256#define WM8350_IN_VU 0x0100
257#define WM8350_INL_VOL_MASK 0x00FC
258
259/*
260 * R81 (0x51) - Right Input Volume
261 */
262#define WM8350_INR_MUTE 0x4000
263#define WM8350_INR_ZC 0x2000
264#define WM8350_IN_VU 0x0100
265#define WM8350_INR_VOL_MASK 0x00FC
266
267/*
268 * R88 (0x58) - Left Mixer Control
269 */
270#define WM8350_DACR_TO_MIXOUTL 0x1000
271#define WM8350_DACL_TO_MIXOUTL 0x0800
272#define WM8350_IN3L_TO_MIXOUTL 0x0004
273#define WM8350_INR_TO_MIXOUTL 0x0002
274#define WM8350_INL_TO_MIXOUTL 0x0001
275
276/*
277 * R89 (0x59) - Right Mixer Control
278 */
279#define WM8350_DACR_TO_MIXOUTR 0x1000
280#define WM8350_DACL_TO_MIXOUTR 0x0800
281#define WM8350_IN3R_TO_MIXOUTR 0x0008
282#define WM8350_INR_TO_MIXOUTR 0x0002
283#define WM8350_INL_TO_MIXOUTR 0x0001
284
285/*
286 * R92 (0x5C) - OUT3 Mixer Control
287 */
288#define WM8350_DACL_TO_OUT3 0x0800
289#define WM8350_MIXINL_TO_OUT3 0x0100
290#define WM8350_OUT4_TO_OUT3 0x0008
291#define WM8350_MIXOUTL_TO_OUT3 0x0001
292
293/*
294 * R93 (0x5D) - OUT4 Mixer Control
295 */
296#define WM8350_DACR_TO_OUT4 0x1000
297#define WM8350_DACL_TO_OUT4 0x0800
298#define WM8350_OUT4_ATTN 0x0400
299#define WM8350_MIXINR_TO_OUT4 0x0200
300#define WM8350_OUT3_TO_OUT4 0x0004
301#define WM8350_MIXOUTR_TO_OUT4 0x0002
302#define WM8350_MIXOUTL_TO_OUT4 0x0001
303
304/*
305 * R96 (0x60) - Output Left Mixer Volume
306 */
307#define WM8350_IN3L_MIXOUTL_VOL_MASK 0x0E00
308#define WM8350_IN3L_MIXOUTL_VOL_SHIFT 9
309#define WM8350_INR_MIXOUTL_VOL_MASK 0x00E0
310#define WM8350_INR_MIXOUTL_VOL_SHIFT 5
311#define WM8350_INL_MIXOUTL_VOL_MASK 0x000E
312#define WM8350_INL_MIXOUTL_VOL_SHIFT 1
313
314/* Bit values for R96 (0x60) */
315#define WM8350_IN3L_MIXOUTL_VOL_OFF 0
316#define WM8350_IN3L_MIXOUTL_VOL_M12DB 1
317#define WM8350_IN3L_MIXOUTL_VOL_M9DB 2
318#define WM8350_IN3L_MIXOUTL_VOL_M6DB 3
319#define WM8350_IN3L_MIXOUTL_VOL_M3DB 4
320#define WM8350_IN3L_MIXOUTL_VOL_0DB 5
321#define WM8350_IN3L_MIXOUTL_VOL_3DB 6
322#define WM8350_IN3L_MIXOUTL_VOL_6DB 7
323
324#define WM8350_INR_MIXOUTL_VOL_OFF 0
325#define WM8350_INR_MIXOUTL_VOL_M12DB 1
326#define WM8350_INR_MIXOUTL_VOL_M9DB 2
327#define WM8350_INR_MIXOUTL_VOL_M6DB 3
328#define WM8350_INR_MIXOUTL_VOL_M3DB 4
329#define WM8350_INR_MIXOUTL_VOL_0DB 5
330#define WM8350_INR_MIXOUTL_VOL_3DB 6
331#define WM8350_INR_MIXOUTL_VOL_6DB 7
332
333#define WM8350_INL_MIXOUTL_VOL_OFF 0
334#define WM8350_INL_MIXOUTL_VOL_M12DB 1
335#define WM8350_INL_MIXOUTL_VOL_M9DB 2
336#define WM8350_INL_MIXOUTL_VOL_M6DB 3
337#define WM8350_INL_MIXOUTL_VOL_M3DB 4
338#define WM8350_INL_MIXOUTL_VOL_0DB 5
339#define WM8350_INL_MIXOUTL_VOL_3DB 6
340#define WM8350_INL_MIXOUTL_VOL_6DB 7
341
342/*
343 * R97 (0x61) - Output Right Mixer Volume
344 */
345#define WM8350_IN3R_MIXOUTR_VOL_MASK 0xE000
346#define WM8350_IN3R_MIXOUTR_VOL_SHIFT 13
347#define WM8350_INR_MIXOUTR_VOL_MASK 0x00E0
348#define WM8350_INR_MIXOUTR_VOL_SHIFT 5
349#define WM8350_INL_MIXOUTR_VOL_MASK 0x000E
350#define WM8350_INL_MIXOUTR_VOL_SHIFT 1
351
352/* Bit values for R96 (0x60) */
353#define WM8350_IN3R_MIXOUTR_VOL_OFF 0
354#define WM8350_IN3R_MIXOUTR_VOL_M12DB 1
355#define WM8350_IN3R_MIXOUTR_VOL_M9DB 2
356#define WM8350_IN3R_MIXOUTR_VOL_M6DB 3
357#define WM8350_IN3R_MIXOUTR_VOL_M3DB 4
358#define WM8350_IN3R_MIXOUTR_VOL_0DB 5
359#define WM8350_IN3R_MIXOUTR_VOL_3DB 6
360#define WM8350_IN3R_MIXOUTR_VOL_6DB 7
361
362#define WM8350_INR_MIXOUTR_VOL_OFF 0
363#define WM8350_INR_MIXOUTR_VOL_M12DB 1
364#define WM8350_INR_MIXOUTR_VOL_M9DB 2
365#define WM8350_INR_MIXOUTR_VOL_M6DB 3
366#define WM8350_INR_MIXOUTR_VOL_M3DB 4
367#define WM8350_INR_MIXOUTR_VOL_0DB 5
368#define WM8350_INR_MIXOUTR_VOL_3DB 6
369#define WM8350_INR_MIXOUTR_VOL_6DB 7
370
371#define WM8350_INL_MIXOUTR_VOL_OFF 0
372#define WM8350_INL_MIXOUTR_VOL_M12DB 1
373#define WM8350_INL_MIXOUTR_VOL_M9DB 2
374#define WM8350_INL_MIXOUTR_VOL_M6DB 3
375#define WM8350_INL_MIXOUTR_VOL_M3DB 4
376#define WM8350_INL_MIXOUTR_VOL_0DB 5
377#define WM8350_INL_MIXOUTR_VOL_3DB 6
378#define WM8350_INL_MIXOUTR_VOL_6DB 7
379
380/*
381 * R98 (0x62) - Input Mixer Volume L
382 */
383#define WM8350_IN3L_MIXINL_VOL_MASK 0x0E00
384#define WM8350_IN2L_MIXINL_VOL_MASK 0x000E
385#define WM8350_INL_MIXINL_VOL 0x0001
386
387/*
388 * R99 (0x63) - Input Mixer Volume R
389 */
390#define WM8350_IN3R_MIXINR_VOL_MASK 0xE000
391#define WM8350_IN2R_MIXINR_VOL_MASK 0x00E0
392#define WM8350_INR_MIXINR_VOL 0x0001
393
394/*
395 * R100 (0x64) - Input Mixer Volume
396 */
397#define WM8350_OUT4_MIXIN_DST 0x8000
398#define WM8350_OUT4_MIXIN_VOL_MASK 0x000E
399
400/*
401 * R104 (0x68) - LOUT1 Volume
402 */
403#define WM8350_OUT1L_MUTE 0x4000
404#define WM8350_OUT1L_ZC 0x2000
405#define WM8350_OUT1_VU 0x0100
406#define WM8350_OUT1L_VOL_MASK 0x00FC
407#define WM8350_OUT1L_VOL_SHIFT 2
408
409/*
410 * R105 (0x69) - ROUT1 Volume
411 */
412#define WM8350_OUT1R_MUTE 0x4000
413#define WM8350_OUT1R_ZC 0x2000
414#define WM8350_OUT1_VU 0x0100
415#define WM8350_OUT1R_VOL_MASK 0x00FC
416#define WM8350_OUT1R_VOL_SHIFT 2
417
418/*
419 * R106 (0x6A) - LOUT2 Volume
420 */
421#define WM8350_OUT2L_MUTE 0x4000
422#define WM8350_OUT2L_ZC 0x2000
423#define WM8350_OUT2_VU 0x0100
424#define WM8350_OUT2L_VOL_MASK 0x00FC
425
426/*
427 * R107 (0x6B) - ROUT2 Volume
428 */
429#define WM8350_OUT2R_MUTE 0x4000
430#define WM8350_OUT2R_ZC 0x2000
431#define WM8350_OUT2R_INV 0x0400
432#define WM8350_OUT2R_INV_MUTE 0x0200
433#define WM8350_OUT2_VU 0x0100
434#define WM8350_OUT2R_VOL_MASK 0x00FC
435
436/*
437 * R111 (0x6F) - BEEP Volume
438 */
439#define WM8350_IN3R_OUT2R_VOL_MASK 0x00E0
440
441/*
442 * R112 (0x70) - AI Formating
443 */
444#define WM8350_AIF_BCLK_INV 0x8000
445#define WM8350_AIF_TRI 0x2000
446#define WM8350_AIF_LRCLK_INV 0x1000
447#define WM8350_AIF_WL_MASK 0x0C00
448#define WM8350_AIF_FMT_MASK 0x0300
449
450/*
451 * R113 (0x71) - ADC DAC COMP
452 */
453#define WM8350_DAC_COMP 0x0080
454#define WM8350_DAC_COMPMODE 0x0040
455#define WM8350_ADC_COMP 0x0020
456#define WM8350_ADC_COMPMODE 0x0010
457#define WM8350_LOOPBACK 0x0001
458
459/*
460 * R114 (0x72) - AI ADC Control
461 */
462#define WM8350_AIFADC_PD 0x0080
463#define WM8350_AIFADCL_SRC 0x0040
464#define WM8350_AIFADCR_SRC 0x0020
465#define WM8350_AIFADC_TDM_CHAN 0x0010
466#define WM8350_AIFADC_TDM 0x0008
467
468/*
469 * R115 (0x73) - AI DAC Control
470 */
471#define WM8350_BCLK_MSTR 0x4000
472#define WM8350_AIFDAC_PD 0x0080
473#define WM8350_DACL_SRC 0x0040
474#define WM8350_DACR_SRC 0x0020
475#define WM8350_AIFDAC_TDM_CHAN 0x0010
476#define WM8350_AIFDAC_TDM 0x0008
477#define WM8350_DAC_BOOST_MASK 0x0003
478
479/*
480 * R116 (0x74) - AIF Test
481 */
482#define WM8350_CODEC_BYP 0x4000
483#define WM8350_AIFADC_WR_TST 0x2000
484#define WM8350_AIFADC_RD_TST 0x1000
485#define WM8350_AIFDAC_WR_TST 0x0800
486#define WM8350_AIFDAC_RD_TST 0x0400
487#define WM8350_AIFADC_ASYN 0x0020
488#define WM8350_AIFDAC_ASYN 0x0010
489
490/*
491 * R231 (0xE7) - Jack Status
492 */
493#define WM8350_JACK_R_LVL 0x0400
494
495/*
496 * WM8350 Platform setup
497 */
498#define WM8350_S_CURVE_NONE 0x0
499#define WM8350_S_CURVE_FAST 0x1
500#define WM8350_S_CURVE_MEDIUM 0x2
501#define WM8350_S_CURVE_SLOW 0x3
502
503#define WM8350_DISCHARGE_OFF 0x0
504#define WM8350_DISCHARGE_FAST 0x1
505#define WM8350_DISCHARGE_MEDIUM 0x2
506#define WM8350_DISCHARGE_SLOW 0x3
507
508#define WM8350_TIE_OFF_500R 0x0
509#define WM8350_TIE_OFF_30K 0x1
510
511/*
512 * Clock sources & directions
513 */
514#define WM8350_SYSCLK 0
515
516#define WM8350_MCLK_SEL_PLL_MCLK 0
517#define WM8350_MCLK_SEL_PLL_DAC 1
518#define WM8350_MCLK_SEL_PLL_ADC 2
519#define WM8350_MCLK_SEL_PLL_32K 3
520#define WM8350_MCLK_SEL_MCLK 5
521
522#define WM8350_MCLK_DIR_OUT 0
523#define WM8350_MCLK_DIR_IN 1
524
525/* clock divider id's */
526#define WM8350_ADC_CLKDIV 0
527#define WM8350_DAC_CLKDIV 1
528#define WM8350_BCLK_CLKDIV 2
529#define WM8350_OPCLK_CLKDIV 3
530#define WM8350_TO_CLKDIV 4
531#define WM8350_SYS_CLKDIV 5
532#define WM8350_DACLR_CLKDIV 6
533#define WM8350_ADCLR_CLKDIV 7
534
535/* ADC clock dividers */
536#define WM8350_ADCDIV_1 0x0
537#define WM8350_ADCDIV_1_5 0x1
538#define WM8350_ADCDIV_2 0x2
539#define WM8350_ADCDIV_3 0x3
540#define WM8350_ADCDIV_4 0x4
541#define WM8350_ADCDIV_5_5 0x5
542#define WM8350_ADCDIV_6 0x6
543
544/* ADC clock dividers */
545#define WM8350_DACDIV_1 0x0
546#define WM8350_DACDIV_1_5 0x1
547#define WM8350_DACDIV_2 0x2
548#define WM8350_DACDIV_3 0x3
549#define WM8350_DACDIV_4 0x4
550#define WM8350_DACDIV_5_5 0x5
551#define WM8350_DACDIV_6 0x6
552
553/* BCLK clock dividers */
554#define WM8350_BCLK_DIV_1 (0x0 << 4)
555#define WM8350_BCLK_DIV_1_5 (0x1 << 4)
556#define WM8350_BCLK_DIV_2 (0x2 << 4)
557#define WM8350_BCLK_DIV_3 (0x3 << 4)
558#define WM8350_BCLK_DIV_4 (0x4 << 4)
559#define WM8350_BCLK_DIV_5_5 (0x5 << 4)
560#define WM8350_BCLK_DIV_6 (0x6 << 4)
561#define WM8350_BCLK_DIV_8 (0x7 << 4)
562#define WM8350_BCLK_DIV_11 (0x8 << 4)
563#define WM8350_BCLK_DIV_12 (0x9 << 4)
564#define WM8350_BCLK_DIV_16 (0xa << 4)
565#define WM8350_BCLK_DIV_22 (0xb << 4)
566#define WM8350_BCLK_DIV_24 (0xc << 4)
567#define WM8350_BCLK_DIV_32 (0xd << 4)
568#define WM8350_BCLK_DIV_44 (0xe << 4)
569#define WM8350_BCLK_DIV_48 (0xf << 4)
570
571/* Sys (MCLK) clock dividers */
572#define WM8350_MCLK_DIV_1 (0x0 << 8)
573#define WM8350_MCLK_DIV_2 (0x1 << 8)
574
575/* OP clock dividers */
576#define WM8350_OPCLK_DIV_1 0x0
577#define WM8350_OPCLK_DIV_2 0x1
578#define WM8350_OPCLK_DIV_3 0x2
579#define WM8350_OPCLK_DIV_4 0x3
580#define WM8350_OPCLK_DIV_5_5 0x4
581#define WM8350_OPCLK_DIV_6 0x5
582
583/* DAI ID */
584#define WM8350_HIFI_DAI 0
585
586/*
587 * Audio interrupts.
588 */
589#define WM8350_IRQ_CODEC_JCK_DET_L 39
590#define WM8350_IRQ_CODEC_JCK_DET_R 40
591#define WM8350_IRQ_CODEC_MICSCD 41
592#define WM8350_IRQ_CODEC_MICD 42
593
594struct wm8350_codec {
595 struct platform_device *pdev;
596};
597
598#endif
diff --git a/include/linux/mfd/wm8350/comparator.h b/include/linux/mfd/wm8350/comparator.h
new file mode 100644
index 000000000000..053788649452
--- /dev/null
+++ b/include/linux/mfd/wm8350/comparator.h
@@ -0,0 +1,167 @@
1/*
2 * comparator.h -- Comparator Aux ADC for Wolfson WM8350 PMIC
3 *
4 * Copyright 2007 Wolfson Microelectronics PLC
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 */
11
12#ifndef __LINUX_MFD_WM8350_COMPARATOR_H_
13#define __LINUX_MFD_WM8350_COMPARATOR_H_
14
15/*
16 * Registers
17 */
18
19#define WM8350_DIGITISER_CONTROL_1 0x90
20#define WM8350_DIGITISER_CONTROL_2 0x91
21#define WM8350_AUX1_READBACK 0x98
22#define WM8350_AUX2_READBACK 0x99
23#define WM8350_AUX3_READBACK 0x9A
24#define WM8350_AUX4_READBACK 0x9B
25#define WM8350_CHIP_TEMP_READBACK 0x9F
26#define WM8350_GENERIC_COMPARATOR_CONTROL 0xA3
27#define WM8350_GENERIC_COMPARATOR_1 0xA4
28#define WM8350_GENERIC_COMPARATOR_2 0xA5
29#define WM8350_GENERIC_COMPARATOR_3 0xA6
30#define WM8350_GENERIC_COMPARATOR_4 0xA7
31
32/*
33 * R144 (0x90) - Digitiser Control (1)
34 */
35#define WM8350_AUXADC_CTC 0x4000
36#define WM8350_AUXADC_POLL 0x2000
37#define WM8350_AUXADC_HIB_MODE 0x1000
38#define WM8350_AUXADC_SEL8 0x0080
39#define WM8350_AUXADC_SEL7 0x0040
40#define WM8350_AUXADC_SEL6 0x0020
41#define WM8350_AUXADC_SEL5 0x0010
42#define WM8350_AUXADC_SEL4 0x0008
43#define WM8350_AUXADC_SEL3 0x0004
44#define WM8350_AUXADC_SEL2 0x0002
45#define WM8350_AUXADC_SEL1 0x0001
46
47/*
48 * R145 (0x91) - Digitiser Control (2)
49 */
50#define WM8350_AUXADC_MASKMODE_MASK 0x3000
51#define WM8350_AUXADC_CRATE_MASK 0x0700
52#define WM8350_AUXADC_CAL 0x0004
53#define WM8350_AUX_RBMODE 0x0002
54#define WM8350_AUXADC_WAIT 0x0001
55
56/*
57 * R152 (0x98) - AUX1 Readback
58 */
59#define WM8350_AUXADC_SCALE1_MASK 0x6000
60#define WM8350_AUXADC_REF1 0x1000
61#define WM8350_AUXADC_DATA1_MASK 0x0FFF
62
63/*
64 * R153 (0x99) - AUX2 Readback
65 */
66#define WM8350_AUXADC_SCALE2_MASK 0x6000
67#define WM8350_AUXADC_REF2 0x1000
68#define WM8350_AUXADC_DATA2_MASK 0x0FFF
69
70/*
71 * R154 (0x9A) - AUX3 Readback
72 */
73#define WM8350_AUXADC_SCALE3_MASK 0x6000
74#define WM8350_AUXADC_REF3 0x1000
75#define WM8350_AUXADC_DATA3_MASK 0x0FFF
76
77/*
78 * R155 (0x9B) - AUX4 Readback
79 */
80#define WM8350_AUXADC_SCALE4_MASK 0x6000
81#define WM8350_AUXADC_REF4 0x1000
82#define WM8350_AUXADC_DATA4_MASK 0x0FFF
83
84/*
85 * R156 (0x9C) - USB Voltage Readback
86 */
87#define WM8350_AUXADC_DATA_USB_MASK 0x0FFF
88
89/*
90 * R157 (0x9D) - LINE Voltage Readback
91 */
92#define WM8350_AUXADC_DATA_LINE_MASK 0x0FFF
93
94/*
95 * R158 (0x9E) - BATT Voltage Readback
96 */
97#define WM8350_AUXADC_DATA_BATT_MASK 0x0FFF
98
99/*
100 * R159 (0x9F) - Chip Temp Readback
101 */
102#define WM8350_AUXADC_DATA_CHIPTEMP_MASK 0x0FFF
103
104/*
105 * R163 (0xA3) - Generic Comparator Control
106 */
107#define WM8350_DCMP4_ENA 0x0008
108#define WM8350_DCMP3_ENA 0x0004
109#define WM8350_DCMP2_ENA 0x0002
110#define WM8350_DCMP1_ENA 0x0001
111
112/*
113 * R164 (0xA4) - Generic comparator 1
114 */
115#define WM8350_DCMP1_SRCSEL_MASK 0xE000
116#define WM8350_DCMP1_GT 0x1000
117#define WM8350_DCMP1_THR_MASK 0x0FFF
118
119/*
120 * R165 (0xA5) - Generic comparator 2
121 */
122#define WM8350_DCMP2_SRCSEL_MASK 0xE000
123#define WM8350_DCMP2_GT 0x1000
124#define WM8350_DCMP2_THR_MASK 0x0FFF
125
126/*
127 * R166 (0xA6) - Generic comparator 3
128 */
129#define WM8350_DCMP3_SRCSEL_MASK 0xE000
130#define WM8350_DCMP3_GT 0x1000
131#define WM8350_DCMP3_THR_MASK 0x0FFF
132
133/*
134 * R167 (0xA7) - Generic comparator 4
135 */
136#define WM8350_DCMP4_SRCSEL_MASK 0xE000
137#define WM8350_DCMP4_GT 0x1000
138#define WM8350_DCMP4_THR_MASK 0x0FFF
139
140/*
141 * Interrupts.
142 */
143#define WM8350_IRQ_AUXADC_DATARDY 16
144#define WM8350_IRQ_AUXADC_DCOMP4 17
145#define WM8350_IRQ_AUXADC_DCOMP3 18
146#define WM8350_IRQ_AUXADC_DCOMP2 19
147#define WM8350_IRQ_AUXADC_DCOMP1 20
148#define WM8350_IRQ_SYS_HYST_COMP_FAIL 21
149#define WM8350_IRQ_SYS_CHIP_GT115 22
150#define WM8350_IRQ_SYS_CHIP_GT140 23
151
152/*
153 * USB/2, LINE & BATT = ((VRTC * 2) / 4095)) * 10e6 uV
154 * Where VRTC = 2.7 V
155 */
156#define WM8350_AUX_COEFF 1319
157
158#define WM8350_AUXADC_AUX1 0
159#define WM8350_AUXADC_AUX2 1
160#define WM8350_AUXADC_AUX3 2
161#define WM8350_AUXADC_AUX4 3
162#define WM8350_AUXADC_USB 4
163#define WM8350_AUXADC_LINE 5
164#define WM8350_AUXADC_BATT 6
165#define WM8350_AUXADC_TEMP 7
166
167#endif
diff --git a/include/linux/mfd/wm8350/core.h b/include/linux/mfd/wm8350/core.h
new file mode 100644
index 000000000000..6ebf97f2a475
--- /dev/null
+++ b/include/linux/mfd/wm8350/core.h
@@ -0,0 +1,631 @@
1/*
2 * core.h -- Core Driver for Wolfson WM8350 PMIC
3 *
4 * Copyright 2007 Wolfson Microelectronics PLC
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 *
11 */
12
13#ifndef __LINUX_MFD_WM8350_CORE_H_
14#define __LINUX_MFD_WM8350_CORE_H_
15
16#include <linux/kernel.h>
17#include <linux/mutex.h>
18#include <linux/workqueue.h>
19
20#include <linux/mfd/wm8350/audio.h>
21#include <linux/mfd/wm8350/gpio.h>
22#include <linux/mfd/wm8350/pmic.h>
23#include <linux/mfd/wm8350/rtc.h>
24#include <linux/mfd/wm8350/supply.h>
25#include <linux/mfd/wm8350/wdt.h>
26
27/*
28 * Register values.
29 */
30#define WM8350_RESET_ID 0x00
31#define WM8350_ID 0x01
32#define WM8350_SYSTEM_CONTROL_1 0x03
33#define WM8350_SYSTEM_CONTROL_2 0x04
34#define WM8350_SYSTEM_HIBERNATE 0x05
35#define WM8350_INTERFACE_CONTROL 0x06
36#define WM8350_POWER_MGMT_1 0x08
37#define WM8350_POWER_MGMT_2 0x09
38#define WM8350_POWER_MGMT_3 0x0A
39#define WM8350_POWER_MGMT_4 0x0B
40#define WM8350_POWER_MGMT_5 0x0C
41#define WM8350_POWER_MGMT_6 0x0D
42#define WM8350_POWER_MGMT_7 0x0E
43
44#define WM8350_SYSTEM_INTERRUPTS 0x18
45#define WM8350_INT_STATUS_1 0x19
46#define WM8350_INT_STATUS_2 0x1A
47#define WM8350_POWER_UP_INT_STATUS 0x1B
48#define WM8350_UNDER_VOLTAGE_INT_STATUS 0x1C
49#define WM8350_OVER_CURRENT_INT_STATUS 0x1D
50#define WM8350_GPIO_INT_STATUS 0x1E
51#define WM8350_COMPARATOR_INT_STATUS 0x1F
52#define WM8350_SYSTEM_INTERRUPTS_MASK 0x20
53#define WM8350_INT_STATUS_1_MASK 0x21
54#define WM8350_INT_STATUS_2_MASK 0x22
55#define WM8350_POWER_UP_INT_STATUS_MASK 0x23
56#define WM8350_UNDER_VOLTAGE_INT_STATUS_MASK 0x24
57#define WM8350_OVER_CURRENT_INT_STATUS_MASK 0x25
58#define WM8350_GPIO_INT_STATUS_MASK 0x26
59#define WM8350_COMPARATOR_INT_STATUS_MASK 0x27
60
61#define WM8350_MAX_REGISTER 0xFF
62
63/*
64 * Field Definitions.
65 */
66
67/*
68 * R0 (0x00) - Reset/ID
69 */
70#define WM8350_SW_RESET_CHIP_ID_MASK 0xFFFF
71
72/*
73 * R1 (0x01) - ID
74 */
75#define WM8350_CHIP_REV_MASK 0x7000
76#define WM8350_CONF_STS_MASK 0x0C00
77#define WM8350_CUST_ID_MASK 0x00FF
78
79/*
80 * R3 (0x03) - System Control 1
81 */
82#define WM8350_CHIP_ON 0x8000
83#define WM8350_POWERCYCLE 0x2000
84#define WM8350_VCC_FAULT_OV 0x1000
85#define WM8350_REG_RSTB_TIME_MASK 0x0C00
86#define WM8350_BG_SLEEP 0x0200
87#define WM8350_MEM_VALID 0x0020
88#define WM8350_CHIP_SET_UP 0x0010
89#define WM8350_ON_DEB_T 0x0008
90#define WM8350_ON_POL 0x0002
91#define WM8350_IRQ_POL 0x0001
92
93/*
94 * R4 (0x04) - System Control 2
95 */
96#define WM8350_USB_SUSPEND_8MA 0x8000
97#define WM8350_USB_SUSPEND 0x4000
98#define WM8350_USB_MSTR 0x2000
99#define WM8350_USB_MSTR_SRC 0x1000
100#define WM8350_USB_500MA 0x0800
101#define WM8350_USB_NOLIM 0x0400
102
103/*
104 * R5 (0x05) - System Hibernate
105 */
106#define WM8350_HIBERNATE 0x8000
107#define WM8350_WDOG_HIB_MODE 0x0080
108#define WM8350_REG_HIB_STARTUP_SEQ 0x0040
109#define WM8350_REG_RESET_HIB_MODE 0x0020
110#define WM8350_RST_HIB_MODE 0x0010
111#define WM8350_IRQ_HIB_MODE 0x0008
112#define WM8350_MEMRST_HIB_MODE 0x0004
113#define WM8350_PCCOMP_HIB_MODE 0x0002
114#define WM8350_TEMPMON_HIB_MODE 0x0001
115
116/*
117 * R6 (0x06) - Interface Control
118 */
119#define WM8350_USE_DEV_PINS 0x8000
120#define WM8350_USE_DEV_PINS_MASK 0x8000
121#define WM8350_USE_DEV_PINS_SHIFT 15
122#define WM8350_DEV_ADDR_MASK 0x6000
123#define WM8350_DEV_ADDR_SHIFT 13
124#define WM8350_CONFIG_DONE 0x1000
125#define WM8350_CONFIG_DONE_MASK 0x1000
126#define WM8350_CONFIG_DONE_SHIFT 12
127#define WM8350_RECONFIG_AT_ON 0x0800
128#define WM8350_RECONFIG_AT_ON_MASK 0x0800
129#define WM8350_RECONFIG_AT_ON_SHIFT 11
130#define WM8350_AUTOINC 0x0200
131#define WM8350_AUTOINC_MASK 0x0200
132#define WM8350_AUTOINC_SHIFT 9
133#define WM8350_ARA 0x0100
134#define WM8350_ARA_MASK 0x0100
135#define WM8350_ARA_SHIFT 8
136#define WM8350_SPI_CFG 0x0008
137#define WM8350_SPI_CFG_MASK 0x0008
138#define WM8350_SPI_CFG_SHIFT 3
139#define WM8350_SPI_4WIRE 0x0004
140#define WM8350_SPI_4WIRE_MASK 0x0004
141#define WM8350_SPI_4WIRE_SHIFT 2
142#define WM8350_SPI_3WIRE 0x0002
143#define WM8350_SPI_3WIRE_MASK 0x0002
144#define WM8350_SPI_3WIRE_SHIFT 1
145
146/* Bit values for R06 (0x06) */
147#define WM8350_USE_DEV_PINS_PRIMARY 0
148#define WM8350_USE_DEV_PINS_DEV 1
149
150#define WM8350_DEV_ADDR_34 0
151#define WM8350_DEV_ADDR_36 1
152#define WM8350_DEV_ADDR_3C 2
153#define WM8350_DEV_ADDR_3E 3
154
155#define WM8350_CONFIG_DONE_OFF 0
156#define WM8350_CONFIG_DONE_DONE 1
157
158#define WM8350_RECONFIG_AT_ON_OFF 0
159#define WM8350_RECONFIG_AT_ON_ON 1
160
161#define WM8350_AUTOINC_OFF 0
162#define WM8350_AUTOINC_ON 1
163
164#define WM8350_ARA_OFF 0
165#define WM8350_ARA_ON 1
166
167#define WM8350_SPI_CFG_CMOS 0
168#define WM8350_SPI_CFG_OD 1
169
170#define WM8350_SPI_4WIRE_3WIRE 0
171#define WM8350_SPI_4WIRE_4WIRE 1
172
173#define WM8350_SPI_3WIRE_I2C 0
174#define WM8350_SPI_3WIRE_SPI 1
175
176/*
177 * R8 (0x08) - Power mgmt (1)
178 */
179#define WM8350_CODEC_ISEL_MASK 0xC000
180#define WM8350_VBUFEN 0x2000
181#define WM8350_OUTPUT_DRAIN_EN 0x0400
182#define WM8350_MIC_DET_ENA 0x0100
183#define WM8350_BIASEN 0x0020
184#define WM8350_MICBEN 0x0010
185#define WM8350_VMIDEN 0x0004
186#define WM8350_VMID_MASK 0x0003
187#define WM8350_VMID_SHIFT 0
188
189/*
190 * R9 (0x09) - Power mgmt (2)
191 */
192#define WM8350_IN3R_ENA 0x0800
193#define WM8350_IN3L_ENA 0x0400
194#define WM8350_INR_ENA 0x0200
195#define WM8350_INL_ENA 0x0100
196#define WM8350_MIXINR_ENA 0x0080
197#define WM8350_MIXINL_ENA 0x0040
198#define WM8350_OUT4_ENA 0x0020
199#define WM8350_OUT3_ENA 0x0010
200#define WM8350_MIXOUTR_ENA 0x0002
201#define WM8350_MIXOUTL_ENA 0x0001
202
203/*
204 * R10 (0x0A) - Power mgmt (3)
205 */
206#define WM8350_IN3R_TO_OUT2R 0x0080
207#define WM8350_OUT2R_ENA 0x0008
208#define WM8350_OUT2L_ENA 0x0004
209#define WM8350_OUT1R_ENA 0x0002
210#define WM8350_OUT1L_ENA 0x0001
211
212/*
213 * R11 (0x0B) - Power mgmt (4)
214 */
215#define WM8350_SYSCLK_ENA 0x4000
216#define WM8350_ADC_HPF_ENA 0x2000
217#define WM8350_FLL_ENA 0x0800
218#define WM8350_FLL_OSC_ENA 0x0400
219#define WM8350_TOCLK_ENA 0x0100
220#define WM8350_DACR_ENA 0x0020
221#define WM8350_DACL_ENA 0x0010
222#define WM8350_ADCR_ENA 0x0008
223#define WM8350_ADCL_ENA 0x0004
224
225/*
226 * R12 (0x0C) - Power mgmt (5)
227 */
228#define WM8350_CODEC_ENA 0x1000
229#define WM8350_RTC_TICK_ENA 0x0800
230#define WM8350_OSC32K_ENA 0x0400
231#define WM8350_CHG_ENA 0x0200
232#define WM8350_ACC_DET_ENA 0x0100
233#define WM8350_AUXADC_ENA 0x0080
234#define WM8350_DCMP4_ENA 0x0008
235#define WM8350_DCMP3_ENA 0x0004
236#define WM8350_DCMP2_ENA 0x0002
237#define WM8350_DCMP1_ENA 0x0001
238
239/*
240 * R13 (0x0D) - Power mgmt (6)
241 */
242#define WM8350_LS_ENA 0x8000
243#define WM8350_LDO4_ENA 0x0800
244#define WM8350_LDO3_ENA 0x0400
245#define WM8350_LDO2_ENA 0x0200
246#define WM8350_LDO1_ENA 0x0100
247#define WM8350_DC6_ENA 0x0020
248#define WM8350_DC5_ENA 0x0010
249#define WM8350_DC4_ENA 0x0008
250#define WM8350_DC3_ENA 0x0004
251#define WM8350_DC2_ENA 0x0002
252#define WM8350_DC1_ENA 0x0001
253
254/*
255 * R14 (0x0E) - Power mgmt (7)
256 */
257#define WM8350_CS2_ENA 0x0002
258#define WM8350_CS1_ENA 0x0001
259
260/*
261 * R24 (0x18) - System Interrupts
262 */
263#define WM8350_OC_INT 0x2000
264#define WM8350_UV_INT 0x1000
265#define WM8350_PUTO_INT 0x0800
266#define WM8350_CS_INT 0x0200
267#define WM8350_EXT_INT 0x0100
268#define WM8350_CODEC_INT 0x0080
269#define WM8350_GP_INT 0x0040
270#define WM8350_AUXADC_INT 0x0020
271#define WM8350_RTC_INT 0x0010
272#define WM8350_SYS_INT 0x0008
273#define WM8350_CHG_INT 0x0004
274#define WM8350_USB_INT 0x0002
275#define WM8350_WKUP_INT 0x0001
276
277/*
278 * R25 (0x19) - Interrupt Status 1
279 */
280#define WM8350_CHG_BAT_HOT_EINT 0x8000
281#define WM8350_CHG_BAT_COLD_EINT 0x4000
282#define WM8350_CHG_BAT_FAIL_EINT 0x2000
283#define WM8350_CHG_TO_EINT 0x1000
284#define WM8350_CHG_END_EINT 0x0800
285#define WM8350_CHG_START_EINT 0x0400
286#define WM8350_CHG_FAST_RDY_EINT 0x0200
287#define WM8350_RTC_PER_EINT 0x0080
288#define WM8350_RTC_SEC_EINT 0x0040
289#define WM8350_RTC_ALM_EINT 0x0020
290#define WM8350_CHG_VBATT_LT_3P9_EINT 0x0004
291#define WM8350_CHG_VBATT_LT_3P1_EINT 0x0002
292#define WM8350_CHG_VBATT_LT_2P85_EINT 0x0001
293
294/*
295 * R26 (0x1A) - Interrupt Status 2
296 */
297#define WM8350_CS1_EINT 0x2000
298#define WM8350_CS2_EINT 0x1000
299#define WM8350_USB_LIMIT_EINT 0x0400
300#define WM8350_AUXADC_DATARDY_EINT 0x0100
301#define WM8350_AUXADC_DCOMP4_EINT 0x0080
302#define WM8350_AUXADC_DCOMP3_EINT 0x0040
303#define WM8350_AUXADC_DCOMP2_EINT 0x0020
304#define WM8350_AUXADC_DCOMP1_EINT 0x0010
305#define WM8350_SYS_HYST_COMP_FAIL_EINT 0x0008
306#define WM8350_SYS_CHIP_GT115_EINT 0x0004
307#define WM8350_SYS_CHIP_GT140_EINT 0x0002
308#define WM8350_SYS_WDOG_TO_EINT 0x0001
309
310/*
311 * R27 (0x1B) - Power Up Interrupt Status
312 */
313#define WM8350_PUTO_LDO4_EINT 0x0800
314#define WM8350_PUTO_LDO3_EINT 0x0400
315#define WM8350_PUTO_LDO2_EINT 0x0200
316#define WM8350_PUTO_LDO1_EINT 0x0100
317#define WM8350_PUTO_DC6_EINT 0x0020
318#define WM8350_PUTO_DC5_EINT 0x0010
319#define WM8350_PUTO_DC4_EINT 0x0008
320#define WM8350_PUTO_DC3_EINT 0x0004
321#define WM8350_PUTO_DC2_EINT 0x0002
322#define WM8350_PUTO_DC1_EINT 0x0001
323
324/*
325 * R28 (0x1C) - Under Voltage Interrupt status
326 */
327#define WM8350_UV_LDO4_EINT 0x0800
328#define WM8350_UV_LDO3_EINT 0x0400
329#define WM8350_UV_LDO2_EINT 0x0200
330#define WM8350_UV_LDO1_EINT 0x0100
331#define WM8350_UV_DC6_EINT 0x0020
332#define WM8350_UV_DC5_EINT 0x0010
333#define WM8350_UV_DC4_EINT 0x0008
334#define WM8350_UV_DC3_EINT 0x0004
335#define WM8350_UV_DC2_EINT 0x0002
336#define WM8350_UV_DC1_EINT 0x0001
337
338/*
339 * R29 (0x1D) - Over Current Interrupt status
340 */
341#define WM8350_OC_LS_EINT 0x8000
342
343/*
344 * R30 (0x1E) - GPIO Interrupt Status
345 */
346#define WM8350_GP12_EINT 0x1000
347#define WM8350_GP11_EINT 0x0800
348#define WM8350_GP10_EINT 0x0400
349#define WM8350_GP9_EINT 0x0200
350#define WM8350_GP8_EINT 0x0100
351#define WM8350_GP7_EINT 0x0080
352#define WM8350_GP6_EINT 0x0040
353#define WM8350_GP5_EINT 0x0020
354#define WM8350_GP4_EINT 0x0010
355#define WM8350_GP3_EINT 0x0008
356#define WM8350_GP2_EINT 0x0004
357#define WM8350_GP1_EINT 0x0002
358#define WM8350_GP0_EINT 0x0001
359
360/*
361 * R31 (0x1F) - Comparator Interrupt Status
362 */
363#define WM8350_EXT_USB_FB_EINT 0x8000
364#define WM8350_EXT_WALL_FB_EINT 0x4000
365#define WM8350_EXT_BAT_FB_EINT 0x2000
366#define WM8350_CODEC_JCK_DET_L_EINT 0x0800
367#define WM8350_CODEC_JCK_DET_R_EINT 0x0400
368#define WM8350_CODEC_MICSCD_EINT 0x0200
369#define WM8350_CODEC_MICD_EINT 0x0100
370#define WM8350_WKUP_OFF_STATE_EINT 0x0040
371#define WM8350_WKUP_HIB_STATE_EINT 0x0020
372#define WM8350_WKUP_CONV_FAULT_EINT 0x0010
373#define WM8350_WKUP_WDOG_RST_EINT 0x0008
374#define WM8350_WKUP_GP_PWR_ON_EINT 0x0004
375#define WM8350_WKUP_ONKEY_EINT 0x0002
376#define WM8350_WKUP_GP_WAKEUP_EINT 0x0001
377
378/*
379 * R32 (0x20) - System Interrupts Mask
380 */
381#define WM8350_IM_OC_INT 0x2000
382#define WM8350_IM_UV_INT 0x1000
383#define WM8350_IM_PUTO_INT 0x0800
384#define WM8350_IM_SPARE_INT 0x0400
385#define WM8350_IM_CS_INT 0x0200
386#define WM8350_IM_EXT_INT 0x0100
387#define WM8350_IM_CODEC_INT 0x0080
388#define WM8350_IM_GP_INT 0x0040
389#define WM8350_IM_AUXADC_INT 0x0020
390#define WM8350_IM_RTC_INT 0x0010
391#define WM8350_IM_SYS_INT 0x0008
392#define WM8350_IM_CHG_INT 0x0004
393#define WM8350_IM_USB_INT 0x0002
394#define WM8350_IM_WKUP_INT 0x0001
395
396/*
397 * R33 (0x21) - Interrupt Status 1 Mask
398 */
399#define WM8350_IM_CHG_BAT_HOT_EINT 0x8000
400#define WM8350_IM_CHG_BAT_COLD_EINT 0x4000
401#define WM8350_IM_CHG_BAT_FAIL_EINT 0x2000
402#define WM8350_IM_CHG_TO_EINT 0x1000
403#define WM8350_IM_CHG_END_EINT 0x0800
404#define WM8350_IM_CHG_START_EINT 0x0400
405#define WM8350_IM_CHG_FAST_RDY_EINT 0x0200
406#define WM8350_IM_RTC_PER_EINT 0x0080
407#define WM8350_IM_RTC_SEC_EINT 0x0040
408#define WM8350_IM_RTC_ALM_EINT 0x0020
409#define WM8350_IM_CHG_VBATT_LT_3P9_EINT 0x0004
410#define WM8350_IM_CHG_VBATT_LT_3P1_EINT 0x0002
411#define WM8350_IM_CHG_VBATT_LT_2P85_EINT 0x0001
412
413/*
414 * R34 (0x22) - Interrupt Status 2 Mask
415 */
416#define WM8350_IM_SPARE2_EINT 0x8000
417#define WM8350_IM_SPARE1_EINT 0x4000
418#define WM8350_IM_CS1_EINT 0x2000
419#define WM8350_IM_CS2_EINT 0x1000
420#define WM8350_IM_USB_LIMIT_EINT 0x0400
421#define WM8350_IM_AUXADC_DATARDY_EINT 0x0100
422#define WM8350_IM_AUXADC_DCOMP4_EINT 0x0080
423#define WM8350_IM_AUXADC_DCOMP3_EINT 0x0040
424#define WM8350_IM_AUXADC_DCOMP2_EINT 0x0020
425#define WM8350_IM_AUXADC_DCOMP1_EINT 0x0010
426#define WM8350_IM_SYS_HYST_COMP_FAIL_EINT 0x0008
427#define WM8350_IM_SYS_CHIP_GT115_EINT 0x0004
428#define WM8350_IM_SYS_CHIP_GT140_EINT 0x0002
429#define WM8350_IM_SYS_WDOG_TO_EINT 0x0001
430
431/*
432 * R35 (0x23) - Power Up Interrupt Status Mask
433 */
434#define WM8350_IM_PUTO_LDO4_EINT 0x0800
435#define WM8350_IM_PUTO_LDO3_EINT 0x0400
436#define WM8350_IM_PUTO_LDO2_EINT 0x0200
437#define WM8350_IM_PUTO_LDO1_EINT 0x0100
438#define WM8350_IM_PUTO_DC6_EINT 0x0020
439#define WM8350_IM_PUTO_DC5_EINT 0x0010
440#define WM8350_IM_PUTO_DC4_EINT 0x0008
441#define WM8350_IM_PUTO_DC3_EINT 0x0004
442#define WM8350_IM_PUTO_DC2_EINT 0x0002
443#define WM8350_IM_PUTO_DC1_EINT 0x0001
444
445/*
446 * R36 (0x24) - Under Voltage Interrupt status Mask
447 */
448#define WM8350_IM_UV_LDO4_EINT 0x0800
449#define WM8350_IM_UV_LDO3_EINT 0x0400
450#define WM8350_IM_UV_LDO2_EINT 0x0200
451#define WM8350_IM_UV_LDO1_EINT 0x0100
452#define WM8350_IM_UV_DC6_EINT 0x0020
453#define WM8350_IM_UV_DC5_EINT 0x0010
454#define WM8350_IM_UV_DC4_EINT 0x0008
455#define WM8350_IM_UV_DC3_EINT 0x0004
456#define WM8350_IM_UV_DC2_EINT 0x0002
457#define WM8350_IM_UV_DC1_EINT 0x0001
458
459/*
460 * R37 (0x25) - Over Current Interrupt status Mask
461 */
462#define WM8350_IM_OC_LS_EINT 0x8000
463
464/*
465 * R38 (0x26) - GPIO Interrupt Status Mask
466 */
467#define WM8350_IM_GP12_EINT 0x1000
468#define WM8350_IM_GP11_EINT 0x0800
469#define WM8350_IM_GP10_EINT 0x0400
470#define WM8350_IM_GP9_EINT 0x0200
471#define WM8350_IM_GP8_EINT 0x0100
472#define WM8350_IM_GP7_EINT 0x0080
473#define WM8350_IM_GP6_EINT 0x0040
474#define WM8350_IM_GP5_EINT 0x0020
475#define WM8350_IM_GP4_EINT 0x0010
476#define WM8350_IM_GP3_EINT 0x0008
477#define WM8350_IM_GP2_EINT 0x0004
478#define WM8350_IM_GP1_EINT 0x0002
479#define WM8350_IM_GP0_EINT 0x0001
480
481/*
482 * R39 (0x27) - Comparator Interrupt Status Mask
483 */
484#define WM8350_IM_EXT_USB_FB_EINT 0x8000
485#define WM8350_IM_EXT_WALL_FB_EINT 0x4000
486#define WM8350_IM_EXT_BAT_FB_EINT 0x2000
487#define WM8350_IM_CODEC_JCK_DET_L_EINT 0x0800
488#define WM8350_IM_CODEC_JCK_DET_R_EINT 0x0400
489#define WM8350_IM_CODEC_MICSCD_EINT 0x0200
490#define WM8350_IM_CODEC_MICD_EINT 0x0100
491#define WM8350_IM_WKUP_OFF_STATE_EINT 0x0040
492#define WM8350_IM_WKUP_HIB_STATE_EINT 0x0020
493#define WM8350_IM_WKUP_CONV_FAULT_EINT 0x0010
494#define WM8350_IM_WKUP_WDOG_RST_EINT 0x0008
495#define WM8350_IM_WKUP_GP_PWR_ON_EINT 0x0004
496#define WM8350_IM_WKUP_ONKEY_EINT 0x0002
497#define WM8350_IM_WKUP_GP_WAKEUP_EINT 0x0001
498
499/*
500 * R220 (0xDC) - RAM BIST 1
501 */
502#define WM8350_READ_STATUS 0x0800
503#define WM8350_TSTRAM_CLK 0x0100
504#define WM8350_TSTRAM_CLK_ENA 0x0080
505#define WM8350_STARTSEQ 0x0040
506#define WM8350_READ_SRC 0x0020
507#define WM8350_COUNT_DIR 0x0010
508#define WM8350_TSTRAM_MODE_MASK 0x000E
509#define WM8350_TSTRAM_ENA 0x0001
510
511/*
512 * R225 (0xE1) - DCDC/LDO status
513 */
514#define WM8350_LS_STS 0x8000
515#define WM8350_LDO4_STS 0x0800
516#define WM8350_LDO3_STS 0x0400
517#define WM8350_LDO2_STS 0x0200
518#define WM8350_LDO1_STS 0x0100
519#define WM8350_DC6_STS 0x0020
520#define WM8350_DC5_STS 0x0010
521#define WM8350_DC4_STS 0x0008
522#define WM8350_DC3_STS 0x0004
523#define WM8350_DC2_STS 0x0002
524#define WM8350_DC1_STS 0x0001
525
526/* WM8350 wake up conditions */
527#define WM8350_IRQ_WKUP_OFF_STATE 43
528#define WM8350_IRQ_WKUP_HIB_STATE 44
529#define WM8350_IRQ_WKUP_CONV_FAULT 45
530#define WM8350_IRQ_WKUP_WDOG_RST 46
531#define WM8350_IRQ_WKUP_GP_PWR_ON 47
532#define WM8350_IRQ_WKUP_ONKEY 48
533#define WM8350_IRQ_WKUP_GP_WAKEUP 49
534
535/* wm8350 chip revisions */
536#define WM8350_REV_E 0x4
537#define WM8350_REV_F 0x5
538#define WM8350_REV_G 0x6
539
540#define WM8350_NUM_IRQ 63
541
542struct wm8350_reg_access {
543 u16 readable; /* Mask of readable bits */
544 u16 writable; /* Mask of writable bits */
545 u16 vol; /* Mask of volatile bits */
546};
547extern const struct wm8350_reg_access wm8350_reg_io_map[];
548extern const u16 wm8350_mode0_defaults[];
549extern const u16 wm8350_mode1_defaults[];
550extern const u16 wm8350_mode2_defaults[];
551extern const u16 wm8350_mode3_defaults[];
552
553struct wm8350;
554
555struct wm8350_irq {
556 void (*handler) (struct wm8350 *, int, void *);
557 void *data;
558};
559
560struct wm8350 {
561 int rev; /* chip revision */
562
563 struct device *dev;
564
565 /* device IO */
566 union {
567 struct i2c_client *i2c_client;
568 struct spi_device *spi_device;
569 };
570 int (*read_dev)(struct wm8350 *wm8350, char reg, int size, void *dest);
571 int (*write_dev)(struct wm8350 *wm8350, char reg, int size,
572 void *src);
573 u16 *reg_cache;
574
575 /* Interrupt handling */
576 struct work_struct irq_work;
577 struct mutex irq_mutex; /* IRQ table mutex */
578 struct wm8350_irq irq[WM8350_NUM_IRQ];
579 int chip_irq;
580
581 /* Client devices */
582 struct wm8350_codec codec;
583 struct wm8350_gpio gpio;
584 struct wm8350_pmic pmic;
585 struct wm8350_power power;
586 struct wm8350_rtc rtc;
587 struct wm8350_wdt wdt;
588};
589
590/**
591 * Data to be supplied by the platform to initialise the WM8350.
592 *
593 * @init: Function called during driver initialisation. Should be
594 * used by the platform to configure GPIO functions and similar.
595 */
596struct wm8350_platform_data {
597 int (*init)(struct wm8350 *wm8350);
598};
599
600
601/*
602 * WM8350 device initialisation and exit.
603 */
604int wm8350_device_init(struct wm8350 *wm8350, int irq,
605 struct wm8350_platform_data *pdata);
606void wm8350_device_exit(struct wm8350 *wm8350);
607
608/*
609 * WM8350 device IO
610 */
611int wm8350_clear_bits(struct wm8350 *wm8350, u16 reg, u16 mask);
612int wm8350_set_bits(struct wm8350 *wm8350, u16 reg, u16 mask);
613u16 wm8350_reg_read(struct wm8350 *wm8350, int reg);
614int wm8350_reg_write(struct wm8350 *wm8350, int reg, u16 val);
615int wm8350_reg_lock(struct wm8350 *wm8350);
616int wm8350_reg_unlock(struct wm8350 *wm8350);
617int wm8350_block_read(struct wm8350 *wm8350, int reg, int size, u16 *dest);
618int wm8350_block_write(struct wm8350 *wm8350, int reg, int size, u16 *src);
619
620/*
621 * WM8350 internal interrupts
622 */
623int wm8350_register_irq(struct wm8350 *wm8350, int irq,
624 void (*handler) (struct wm8350 *, int, void *),
625 void *data);
626int wm8350_free_irq(struct wm8350 *wm8350, int irq);
627int wm8350_mask_irq(struct wm8350 *wm8350, int irq);
628int wm8350_unmask_irq(struct wm8350 *wm8350, int irq);
629
630
631#endif
diff --git a/include/linux/mfd/wm8350/gpio.h b/include/linux/mfd/wm8350/gpio.h
new file mode 100644
index 000000000000..ed91e8f5d298
--- /dev/null
+++ b/include/linux/mfd/wm8350/gpio.h
@@ -0,0 +1,342 @@
1/*
2 * gpio.h -- GPIO Driver for Wolfson WM8350 PMIC
3 *
4 * Copyright 2007 Wolfson Microelectronics PLC
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 *
11 */
12
13#ifndef __LINUX_MFD_WM8350_GPIO_H_
14#define __LINUX_MFD_WM8350_GPIO_H_
15
16#include <linux/platform_device.h>
17
18/*
19 * GPIO Registers.
20 */
21#define WM8350_GPIO_DEBOUNCE 0x80
22#define WM8350_GPIO_PIN_PULL_UP_CONTROL 0x81
23#define WM8350_GPIO_PULL_DOWN_CONTROL 0x82
24#define WM8350_GPIO_INT_MODE 0x83
25#define WM8350_GPIO_CONTROL 0x85
26#define WM8350_GPIO_CONFIGURATION_I_O 0x86
27#define WM8350_GPIO_PIN_POLARITY_TYPE 0x87
28#define WM8350_GPIO_FUNCTION_SELECT_1 0x8C
29#define WM8350_GPIO_FUNCTION_SELECT_2 0x8D
30#define WM8350_GPIO_FUNCTION_SELECT_3 0x8E
31#define WM8350_GPIO_FUNCTION_SELECT_4 0x8F
32
33/*
34 * GPIO Functions
35 */
36#define WM8350_GPIO0_GPIO_IN 0x0
37#define WM8350_GPIO0_GPIO_OUT 0x0
38#define WM8350_GPIO0_PWR_ON_IN 0x1
39#define WM8350_GPIO0_PWR_ON_OUT 0x1
40#define WM8350_GPIO0_LDO_EN_IN 0x2
41#define WM8350_GPIO0_VRTC_OUT 0x2
42#define WM8350_GPIO0_LPWR1_IN 0x3
43#define WM8350_GPIO0_POR_B_OUT 0x3
44
45#define WM8350_GPIO1_GPIO_IN 0x0
46#define WM8350_GPIO1_GPIO_OUT 0x0
47#define WM8350_GPIO1_PWR_ON_IN 0x1
48#define WM8350_GPIO1_DO_CONF_OUT 0x1
49#define WM8350_GPIO1_LDO_EN_IN 0x2
50#define WM8350_GPIO1_RESET_OUT 0x2
51#define WM8350_GPIO1_LPWR2_IN 0x3
52#define WM8350_GPIO1_MEMRST_OUT 0x3
53
54#define WM8350_GPIO2_GPIO_IN 0x0
55#define WM8350_GPIO2_GPIO_OUT 0x0
56#define WM8350_GPIO2_PWR_ON_IN 0x1
57#define WM8350_GPIO2_PWR_ON_OUT 0x1
58#define WM8350_GPIO2_WAKE_UP_IN 0x2
59#define WM8350_GPIO2_VRTC_OUT 0x2
60#define WM8350_GPIO2_32KHZ_IN 0x3
61#define WM8350_GPIO2_32KHZ_OUT 0x3
62
63#define WM8350_GPIO3_GPIO_IN 0x0
64#define WM8350_GPIO3_GPIO_OUT 0x0
65#define WM8350_GPIO3_PWR_ON_IN 0x1
66#define WM8350_GPIO3_P_CLK_OUT 0x1
67#define WM8350_GPIO3_LDO_EN_IN 0x2
68#define WM8350_GPIO3_VRTC_OUT 0x2
69#define WM8350_GPIO3_PWR_OFF_IN 0x3
70#define WM8350_GPIO3_32KHZ_OUT 0x3
71
72#define WM8350_GPIO4_GPIO_IN 0x0
73#define WM8350_GPIO4_GPIO_OUT 0x0
74#define WM8350_GPIO4_MR_IN 0x1
75#define WM8350_GPIO4_MEM_RST_OUT 0x1
76#define WM8350_GPIO4_FLASH_IN 0x2
77#define WM8350_GPIO4_ADA_OUT 0x2
78#define WM8350_GPIO4_HIBERNATE_IN 0x3
79#define WM8350_GPIO4_FLASH_OUT 0x3
80#define WM8350_GPIO4_MICDET_OUT 0x4
81#define WM8350_GPIO4_MICSHT_OUT 0x5
82
83#define WM8350_GPIO5_GPIO_IN 0x0
84#define WM8350_GPIO5_GPIO_OUT 0x0
85#define WM8350_GPIO5_LPWR1_IN 0x1
86#define WM8350_GPIO5_P_CLK_OUT 0x1
87#define WM8350_GPIO5_ADCLRCLK_IN 0x2
88#define WM8350_GPIO5_ADCLRCLK_OUT 0x2
89#define WM8350_GPIO5_HIBERNATE_IN 0x3
90#define WM8350_GPIO5_32KHZ_OUT 0x3
91#define WM8350_GPIO5_MICDET_OUT 0x4
92#define WM8350_GPIO5_MICSHT_OUT 0x5
93#define WM8350_GPIO5_ADA_OUT 0x6
94#define WM8350_GPIO5_OPCLK_OUT 0x7
95
96#define WM8350_GPIO6_GPIO_IN 0x0
97#define WM8350_GPIO6_GPIO_OUT 0x0
98#define WM8350_GPIO6_LPWR2_IN 0x1
99#define WM8350_GPIO6_MEMRST_OUT 0x1
100#define WM8350_GPIO6_FLASH_IN 0x2
101#define WM8350_GPIO6_ADA_OUT 0x2
102#define WM8350_GPIO6_HIBERNATE_IN 0x3
103#define WM8350_GPIO6_RTC_OUT 0x3
104#define WM8350_GPIO6_MICDET_OUT 0x4
105#define WM8350_GPIO6_MICSHT_OUT 0x5
106#define WM8350_GPIO6_ADCLRCLKB_OUT 0x6
107#define WM8350_GPIO6_SDOUT_OUT 0x7
108
109#define WM8350_GPIO7_GPIO_IN 0x0
110#define WM8350_GPIO7_GPIO_OUT 0x0
111#define WM8350_GPIO7_LPWR3_IN 0x1
112#define WM8350_GPIO7_P_CLK_OUT 0x1
113#define WM8350_GPIO7_MASK_IN 0x2
114#define WM8350_GPIO7_VCC_FAULT_OUT 0x2
115#define WM8350_GPIO7_HIBERNATE_IN 0x3
116#define WM8350_GPIO7_BATT_FAULT_OUT 0x3
117#define WM8350_GPIO7_MICDET_OUT 0x4
118#define WM8350_GPIO7_MICSHT_OUT 0x5
119#define WM8350_GPIO7_ADA_OUT 0x6
120#define WM8350_GPIO7_CSB_IN 0x7
121
122#define WM8350_GPIO8_GPIO_IN 0x0
123#define WM8350_GPIO8_GPIO_OUT 0x0
124#define WM8350_GPIO8_MR_IN 0x1
125#define WM8350_GPIO8_VCC_FAULT_OUT 0x1
126#define WM8350_GPIO8_ADCBCLK_IN 0x2
127#define WM8350_GPIO8_ADCBCLK_OUT 0x2
128#define WM8350_GPIO8_PWR_OFF_IN 0x3
129#define WM8350_GPIO8_BATT_FAULT_OUT 0x3
130#define WM8350_GPIO8_ALTSCL_IN 0xf
131
132#define WM8350_GPIO9_GPIO_IN 0x0
133#define WM8350_GPIO9_GPIO_OUT 0x0
134#define WM8350_GPIO9_HEARTBEAT_IN 0x1
135#define WM8350_GPIO9_VCC_FAULT_OUT 0x1
136#define WM8350_GPIO9_MASK_IN 0x2
137#define WM8350_GPIO9_LINE_GT_BATT_OUT 0x2
138#define WM8350_GPIO9_PWR_OFF_IN 0x3
139#define WM8350_GPIO9_BATT_FAULT_OUT 0x3
140#define WM8350_GPIO9_ALTSDA_OUT 0xf
141
142#define WM8350_GPIO10_GPIO_IN 0x0
143#define WM8350_GPIO10_GPIO_OUT 0x0
144#define WM8350_GPIO10_ISINKC_OUT 0x1
145#define WM8350_GPIO10_PWR_OFF_IN 0x2
146#define WM8350_GPIO10_LINE_GT_BATT_OUT 0x2
147#define WM8350_GPIO10_CHD_IND_IN 0x3
148
149#define WM8350_GPIO11_GPIO_IN 0x0
150#define WM8350_GPIO11_GPIO_OUT 0x0
151#define WM8350_GPIO11_ISINKD_OUT 0x1
152#define WM8350_GPIO11_WAKEUP_IN 0x2
153#define WM8350_GPIO11_LINE_GT_BATT_OUT 0x2
154#define WM8350_GPIO11_CHD_IND_IN 0x3
155
156#define WM8350_GPIO12_GPIO_IN 0x0
157#define WM8350_GPIO12_GPIO_OUT 0x0
158#define WM8350_GPIO12_ISINKE_OUT 0x1
159#define WM8350_GPIO12_LINE_GT_BATT_OUT 0x2
160#define WM8350_GPIO12_LINE_EN_OUT 0x3
161#define WM8350_GPIO12_32KHZ_OUT 0x4
162
163#define WM8350_GPIO_DIR_IN 0
164#define WM8350_GPIO_DIR_OUT 1
165#define WM8350_GPIO_ACTIVE_LOW 0
166#define WM8350_GPIO_ACTIVE_HIGH 1
167#define WM8350_GPIO_PULL_NONE 0
168#define WM8350_GPIO_PULL_UP 1
169#define WM8350_GPIO_PULL_DOWN 2
170#define WM8350_GPIO_INVERT_OFF 0
171#define WM8350_GPIO_INVERT_ON 1
172#define WM8350_GPIO_DEBOUNCE_OFF 0
173#define WM8350_GPIO_DEBOUNCE_ON 1
174
175/*
176 * R128 (0x80) - GPIO Debounce
177 */
178#define WM8350_GP12_DB 0x1000
179#define WM8350_GP11_DB 0x0800
180#define WM8350_GP10_DB 0x0400
181#define WM8350_GP9_DB 0x0200
182#define WM8350_GP8_DB 0x0100
183#define WM8350_GP7_DB 0x0080
184#define WM8350_GP6_DB 0x0040
185#define WM8350_GP5_DB 0x0020
186#define WM8350_GP4_DB 0x0010
187#define WM8350_GP3_DB 0x0008
188#define WM8350_GP2_DB 0x0004
189#define WM8350_GP1_DB 0x0002
190#define WM8350_GP0_DB 0x0001
191
192/*
193 * R129 (0x81) - GPIO Pin pull up Control
194 */
195#define WM8350_GP12_PU 0x1000
196#define WM8350_GP11_PU 0x0800
197#define WM8350_GP10_PU 0x0400
198#define WM8350_GP9_PU 0x0200
199#define WM8350_GP8_PU 0x0100
200#define WM8350_GP7_PU 0x0080
201#define WM8350_GP6_PU 0x0040
202#define WM8350_GP5_PU 0x0020
203#define WM8350_GP4_PU 0x0010
204#define WM8350_GP3_PU 0x0008
205#define WM8350_GP2_PU 0x0004
206#define WM8350_GP1_PU 0x0002
207#define WM8350_GP0_PU 0x0001
208
209/*
210 * R130 (0x82) - GPIO Pull down Control
211 */
212#define WM8350_GP12_PD 0x1000
213#define WM8350_GP11_PD 0x0800
214#define WM8350_GP10_PD 0x0400
215#define WM8350_GP9_PD 0x0200
216#define WM8350_GP8_PD 0x0100
217#define WM8350_GP7_PD 0x0080
218#define WM8350_GP6_PD 0x0040
219#define WM8350_GP5_PD 0x0020
220#define WM8350_GP4_PD 0x0010
221#define WM8350_GP3_PD 0x0008
222#define WM8350_GP2_PD 0x0004
223#define WM8350_GP1_PD 0x0002
224#define WM8350_GP0_PD 0x0001
225
226/*
227 * R131 (0x83) - GPIO Interrupt Mode
228 */
229#define WM8350_GP12_INTMODE 0x1000
230#define WM8350_GP11_INTMODE 0x0800
231#define WM8350_GP10_INTMODE 0x0400
232#define WM8350_GP9_INTMODE 0x0200
233#define WM8350_GP8_INTMODE 0x0100
234#define WM8350_GP7_INTMODE 0x0080
235#define WM8350_GP6_INTMODE 0x0040
236#define WM8350_GP5_INTMODE 0x0020
237#define WM8350_GP4_INTMODE 0x0010
238#define WM8350_GP3_INTMODE 0x0008
239#define WM8350_GP2_INTMODE 0x0004
240#define WM8350_GP1_INTMODE 0x0002
241#define WM8350_GP0_INTMODE 0x0001
242
243/*
244 * R133 (0x85) - GPIO Control
245 */
246#define WM8350_GP_DBTIME_MASK 0x00C0
247
248/*
249 * R134 (0x86) - GPIO Configuration (i/o)
250 */
251#define WM8350_GP12_DIR 0x1000
252#define WM8350_GP11_DIR 0x0800
253#define WM8350_GP10_DIR 0x0400
254#define WM8350_GP9_DIR 0x0200
255#define WM8350_GP8_DIR 0x0100
256#define WM8350_GP7_DIR 0x0080
257#define WM8350_GP6_DIR 0x0040
258#define WM8350_GP5_DIR 0x0020
259#define WM8350_GP4_DIR 0x0010
260#define WM8350_GP3_DIR 0x0008
261#define WM8350_GP2_DIR 0x0004
262#define WM8350_GP1_DIR 0x0002
263#define WM8350_GP0_DIR 0x0001
264
265/*
266 * R135 (0x87) - GPIO Pin Polarity / Type
267 */
268#define WM8350_GP12_CFG 0x1000
269#define WM8350_GP11_CFG 0x0800
270#define WM8350_GP10_CFG 0x0400
271#define WM8350_GP9_CFG 0x0200
272#define WM8350_GP8_CFG 0x0100
273#define WM8350_GP7_CFG 0x0080
274#define WM8350_GP6_CFG 0x0040
275#define WM8350_GP5_CFG 0x0020
276#define WM8350_GP4_CFG 0x0010
277#define WM8350_GP3_CFG 0x0008
278#define WM8350_GP2_CFG 0x0004
279#define WM8350_GP1_CFG 0x0002
280#define WM8350_GP0_CFG 0x0001
281
282/*
283 * R140 (0x8C) - GPIO Function Select 1
284 */
285#define WM8350_GP3_FN_MASK 0xF000
286#define WM8350_GP2_FN_MASK 0x0F00
287#define WM8350_GP1_FN_MASK 0x00F0
288#define WM8350_GP0_FN_MASK 0x000F
289
290/*
291 * R141 (0x8D) - GPIO Function Select 2
292 */
293#define WM8350_GP7_FN_MASK 0xF000
294#define WM8350_GP6_FN_MASK 0x0F00
295#define WM8350_GP5_FN_MASK 0x00F0
296#define WM8350_GP4_FN_MASK 0x000F
297
298/*
299 * R142 (0x8E) - GPIO Function Select 3
300 */
301#define WM8350_GP11_FN_MASK 0xF000
302#define WM8350_GP10_FN_MASK 0x0F00
303#define WM8350_GP9_FN_MASK 0x00F0
304#define WM8350_GP8_FN_MASK 0x000F
305
306/*
307 * R143 (0x8F) - GPIO Function Select 4
308 */
309#define WM8350_GP12_FN_MASK 0x000F
310
311/*
312 * R230 (0xE6) - GPIO Pin Status
313 */
314#define WM8350_GP12_LVL 0x1000
315#define WM8350_GP11_LVL 0x0800
316#define WM8350_GP10_LVL 0x0400
317#define WM8350_GP9_LVL 0x0200
318#define WM8350_GP8_LVL 0x0100
319#define WM8350_GP7_LVL 0x0080
320#define WM8350_GP6_LVL 0x0040
321#define WM8350_GP5_LVL 0x0020
322#define WM8350_GP4_LVL 0x0010
323#define WM8350_GP3_LVL 0x0008
324#define WM8350_GP2_LVL 0x0004
325#define WM8350_GP1_LVL 0x0002
326#define WM8350_GP0_LVL 0x0001
327
328struct wm8350;
329
330int wm8350_gpio_config(struct wm8350 *wm8350, int gpio, int dir, int func,
331 int pol, int pull, int invert, int debounce);
332
333struct wm8350_gpio {
334 struct platform_device *pdev;
335};
336
337/*
338 * GPIO Interrupts
339 */
340#define WM8350_IRQ_GPIO(x) (50 + x)
341
342#endif
diff --git a/include/linux/mfd/wm8350/pmic.h b/include/linux/mfd/wm8350/pmic.h
new file mode 100644
index 000000000000..69b69e07f62f
--- /dev/null
+++ b/include/linux/mfd/wm8350/pmic.h
@@ -0,0 +1,741 @@
1/*
2 * pmic.h -- Power Managment Driver for Wolfson WM8350 PMIC
3 *
4 * Copyright 2007 Wolfson Microelectronics PLC
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 *
11 */
12
13#ifndef __LINUX_MFD_WM8350_PMIC_H
14#define __LINUX_MFD_WM8350_PMIC_H
15
16/*
17 * Register values.
18 */
19
20#define WM8350_CURRENT_SINK_DRIVER_A 0xAC
21#define WM8350_CSA_FLASH_CONTROL 0xAD
22#define WM8350_CURRENT_SINK_DRIVER_B 0xAE
23#define WM8350_CSB_FLASH_CONTROL 0xAF
24#define WM8350_DCDC_LDO_REQUESTED 0xB0
25#define WM8350_DCDC_ACTIVE_OPTIONS 0xB1
26#define WM8350_DCDC_SLEEP_OPTIONS 0xB2
27#define WM8350_POWER_CHECK_COMPARATOR 0xB3
28#define WM8350_DCDC1_CONTROL 0xB4
29#define WM8350_DCDC1_TIMEOUTS 0xB5
30#define WM8350_DCDC1_LOW_POWER 0xB6
31#define WM8350_DCDC2_CONTROL 0xB7
32#define WM8350_DCDC2_TIMEOUTS 0xB8
33#define WM8350_DCDC3_CONTROL 0xBA
34#define WM8350_DCDC3_TIMEOUTS 0xBB
35#define WM8350_DCDC3_LOW_POWER 0xBC
36#define WM8350_DCDC4_CONTROL 0xBD
37#define WM8350_DCDC4_TIMEOUTS 0xBE
38#define WM8350_DCDC4_LOW_POWER 0xBF
39#define WM8350_DCDC5_CONTROL 0xC0
40#define WM8350_DCDC5_TIMEOUTS 0xC1
41#define WM8350_DCDC6_CONTROL 0xC3
42#define WM8350_DCDC6_TIMEOUTS 0xC4
43#define WM8350_DCDC6_LOW_POWER 0xC5
44#define WM8350_LIMIT_SWITCH_CONTROL 0xC7
45#define WM8350_LDO1_CONTROL 0xC8
46#define WM8350_LDO1_TIMEOUTS 0xC9
47#define WM8350_LDO1_LOW_POWER 0xCA
48#define WM8350_LDO2_CONTROL 0xCB
49#define WM8350_LDO2_TIMEOUTS 0xCC
50#define WM8350_LDO2_LOW_POWER 0xCD
51#define WM8350_LDO3_CONTROL 0xCE
52#define WM8350_LDO3_TIMEOUTS 0xCF
53#define WM8350_LDO3_LOW_POWER 0xD0
54#define WM8350_LDO4_CONTROL 0xD1
55#define WM8350_LDO4_TIMEOUTS 0xD2
56#define WM8350_LDO4_LOW_POWER 0xD3
57#define WM8350_VCC_FAULT_MASKS 0xD7
58#define WM8350_MAIN_BANDGAP_CONTROL 0xD8
59#define WM8350_OSC_CONTROL 0xD9
60#define WM8350_RTC_TICK_CONTROL 0xDA
61#define WM8350_SECURITY 0xDB
62#define WM8350_RAM_BIST_1 0xDC
63#define WM8350_DCDC_LDO_STATUS 0xE1
64#define WM8350_GPIO_PIN_STATUS 0xE6
65
66#define WM8350_DCDC1_FORCE_PWM 0xF8
67#define WM8350_DCDC3_FORCE_PWM 0xFA
68#define WM8350_DCDC4_FORCE_PWM 0xFB
69#define WM8350_DCDC6_FORCE_PWM 0xFD
70
71/*
72 * R172 (0xAC) - Current Sink Driver A
73 */
74#define WM8350_CS1_HIB_MODE 0x1000
75#define WM8350_CS1_HIB_MODE_MASK 0x1000
76#define WM8350_CS1_HIB_MODE_SHIFT 12
77#define WM8350_CS1_ISEL_MASK 0x003F
78#define WM8350_CS1_ISEL_SHIFT 0
79
80/* Bit values for R172 (0xAC) */
81#define WM8350_CS1_HIB_MODE_DISABLE 0
82#define WM8350_CS1_HIB_MODE_LEAVE 1
83
84#define WM8350_CS1_ISEL_220M 0x3F
85
86/*
87 * R173 (0xAD) - CSA Flash control
88 */
89#define WM8350_CS1_FLASH_MODE 0x8000
90#define WM8350_CS1_TRIGSRC 0x4000
91#define WM8350_CS1_DRIVE 0x2000
92#define WM8350_CS1_FLASH_DUR_MASK 0x0300
93#define WM8350_CS1_OFF_RAMP_MASK 0x0030
94#define WM8350_CS1_ON_RAMP_MASK 0x0003
95
96/*
97 * R174 (0xAE) - Current Sink Driver B
98 */
99#define WM8350_CS2_HIB_MODE 0x1000
100#define WM8350_CS2_ISEL_MASK 0x003F
101
102/*
103 * R175 (0xAF) - CSB Flash control
104 */
105#define WM8350_CS2_FLASH_MODE 0x8000
106#define WM8350_CS2_TRIGSRC 0x4000
107#define WM8350_CS2_DRIVE 0x2000
108#define WM8350_CS2_FLASH_DUR_MASK 0x0300
109#define WM8350_CS2_OFF_RAMP_MASK 0x0030
110#define WM8350_CS2_ON_RAMP_MASK 0x0003
111
112/*
113 * R176 (0xB0) - DCDC/LDO requested
114 */
115#define WM8350_LS_ENA 0x8000
116#define WM8350_LDO4_ENA 0x0800
117#define WM8350_LDO3_ENA 0x0400
118#define WM8350_LDO2_ENA 0x0200
119#define WM8350_LDO1_ENA 0x0100
120#define WM8350_DC6_ENA 0x0020
121#define WM8350_DC5_ENA 0x0010
122#define WM8350_DC4_ENA 0x0008
123#define WM8350_DC3_ENA 0x0004
124#define WM8350_DC2_ENA 0x0002
125#define WM8350_DC1_ENA 0x0001
126
127/*
128 * R177 (0xB1) - DCDC Active options
129 */
130#define WM8350_PUTO_MASK 0x3000
131#define WM8350_PWRUP_DELAY_MASK 0x0300
132#define WM8350_DC6_ACTIVE 0x0020
133#define WM8350_DC4_ACTIVE 0x0008
134#define WM8350_DC3_ACTIVE 0x0004
135#define WM8350_DC1_ACTIVE 0x0001
136
137/*
138 * R178 (0xB2) - DCDC Sleep options
139 */
140#define WM8350_DC6_SLEEP 0x0020
141#define WM8350_DC4_SLEEP 0x0008
142#define WM8350_DC3_SLEEP 0x0004
143#define WM8350_DC1_SLEEP 0x0001
144
145/*
146 * R179 (0xB3) - Power-check comparator
147 */
148#define WM8350_PCCMP_ERRACT 0x4000
149#define WM8350_PCCMP_RAIL 0x0100
150#define WM8350_PCCMP_OFF_THR_MASK 0x0070
151#define WM8350_PCCMP_ON_THR_MASK 0x0007
152
153/*
154 * R180 (0xB4) - DCDC1 Control
155 */
156#define WM8350_DC1_OPFLT 0x0400
157#define WM8350_DC1_VSEL_MASK 0x007F
158#define WM8350_DC1_VSEL_SHIFT 0
159
160/*
161 * R181 (0xB5) - DCDC1 Timeouts
162 */
163#define WM8350_DC1_ERRACT_MASK 0xC000
164#define WM8350_DC1_ERRACT_SHIFT 14
165#define WM8350_DC1_ENSLOT_MASK 0x3C00
166#define WM8350_DC1_ENSLOT_SHIFT 10
167#define WM8350_DC1_SDSLOT_MASK 0x03C0
168#define WM8350_DC1_UVTO_MASK 0x0030
169#define WM8350_DC1_SDSLOT_SHIFT 6
170
171/* Bit values for R181 (0xB5) */
172#define WM8350_DC1_ERRACT_NONE 0
173#define WM8350_DC1_ERRACT_SHUTDOWN_CONV 1
174#define WM8350_DC1_ERRACT_SHUTDOWN_SYS 2
175
176/*
177 * R182 (0xB6) - DCDC1 Low Power
178 */
179#define WM8350_DC1_HIB_MODE_MASK 0x7000
180#define WM8350_DC1_HIB_TRIG_MASK 0x0300
181#define WM8350_DC1_VIMG_MASK 0x007F
182
183/*
184 * R183 (0xB7) - DCDC2 Control
185 */
186#define WM8350_DC2_MODE 0x4000
187#define WM8350_DC2_MODE_MASK 0x4000
188#define WM8350_DC2_MODE_SHIFT 14
189#define WM8350_DC2_HIB_MODE 0x1000
190#define WM8350_DC2_HIB_MODE_MASK 0x1000
191#define WM8350_DC2_HIB_MODE_SHIFT 12
192#define WM8350_DC2_HIB_TRIG_MASK 0x0300
193#define WM8350_DC2_HIB_TRIG_SHIFT 8
194#define WM8350_DC2_ILIM 0x0040
195#define WM8350_DC2_ILIM_MASK 0x0040
196#define WM8350_DC2_ILIM_SHIFT 6
197#define WM8350_DC2_RMP_MASK 0x0018
198#define WM8350_DC2_RMP_SHIFT 3
199#define WM8350_DC2_FBSRC_MASK 0x0003
200#define WM8350_DC2_FBSRC_SHIFT 0
201
202/* Bit values for R183 (0xB7) */
203#define WM8350_DC2_MODE_BOOST 0
204#define WM8350_DC2_MODE_SWITCH 1
205
206#define WM8350_DC2_HIB_MODE_ACTIVE 1
207#define WM8350_DC2_HIB_MODE_DISABLE 0
208
209#define WM8350_DC2_HIB_TRIG_NONE 0
210#define WM8350_DC2_HIB_TRIG_LPWR1 1
211#define WM8350_DC2_HIB_TRIG_LPWR2 2
212#define WM8350_DC2_HIB_TRIG_LPWR3 3
213
214#define WM8350_DC2_ILIM_HIGH 0
215#define WM8350_DC2_ILIM_LOW 1
216
217#define WM8350_DC2_RMP_30V 0
218#define WM8350_DC2_RMP_20V 1
219#define WM8350_DC2_RMP_10V 2
220#define WM8350_DC2_RMP_5V 3
221
222#define WM8350_DC2_FBSRC_FB2 0
223#define WM8350_DC2_FBSRC_ISINKA 1
224#define WM8350_DC2_FBSRC_ISINKB 2
225#define WM8350_DC2_FBSRC_USB 3
226
227/*
228 * R184 (0xB8) - DCDC2 Timeouts
229 */
230#define WM8350_DC2_ERRACT_MASK 0xC000
231#define WM8350_DC2_ERRACT_SHIFT 14
232#define WM8350_DC2_ENSLOT_MASK 0x3C00
233#define WM8350_DC2_ENSLOT_SHIFT 10
234#define WM8350_DC2_SDSLOT_MASK 0x03C0
235#define WM8350_DC2_UVTO_MASK 0x0030
236
237/* Bit values for R184 (0xB8) */
238#define WM8350_DC2_ERRACT_NONE 0
239#define WM8350_DC2_ERRACT_SHUTDOWN_CONV 1
240#define WM8350_DC2_ERRACT_SHUTDOWN_SYS 2
241
242/*
243 * R186 (0xBA) - DCDC3 Control
244 */
245#define WM8350_DC3_OPFLT 0x0400
246#define WM8350_DC3_VSEL_MASK 0x007F
247#define WM8350_DC3_VSEL_SHIFT 0
248
249/*
250 * R187 (0xBB) - DCDC3 Timeouts
251 */
252#define WM8350_DC3_ERRACT_MASK 0xC000
253#define WM8350_DC3_ERRACT_SHIFT 14
254#define WM8350_DC3_ENSLOT_MASK 0x3C00
255#define WM8350_DC3_ENSLOT_SHIFT 10
256#define WM8350_DC3_SDSLOT_MASK 0x03C0
257#define WM8350_DC3_UVTO_MASK 0x0030
258#define WM8350_DC3_SDSLOT_SHIFT 6
259
260/* Bit values for R187 (0xBB) */
261#define WM8350_DC3_ERRACT_NONE 0
262#define WM8350_DC3_ERRACT_SHUTDOWN_CONV 1
263#define WM8350_DC3_ERRACT_SHUTDOWN_SYS 2
264/*
265 * R188 (0xBC) - DCDC3 Low Power
266 */
267#define WM8350_DC3_HIB_MODE_MASK 0x7000
268#define WM8350_DC3_HIB_TRIG_MASK 0x0300
269#define WM8350_DC3_VIMG_MASK 0x007F
270
271/*
272 * R189 (0xBD) - DCDC4 Control
273 */
274#define WM8350_DC4_OPFLT 0x0400
275#define WM8350_DC4_VSEL_MASK 0x007F
276#define WM8350_DC4_VSEL_SHIFT 0
277
278/*
279 * R190 (0xBE) - DCDC4 Timeouts
280 */
281#define WM8350_DC4_ERRACT_MASK 0xC000
282#define WM8350_DC4_ERRACT_SHIFT 14
283#define WM8350_DC4_ENSLOT_MASK 0x3C00
284#define WM8350_DC4_ENSLOT_SHIFT 10
285#define WM8350_DC4_SDSLOT_MASK 0x03C0
286#define WM8350_DC4_UVTO_MASK 0x0030
287#define WM8350_DC4_SDSLOT_SHIFT 6
288
289/* Bit values for R190 (0xBE) */
290#define WM8350_DC4_ERRACT_NONE 0
291#define WM8350_DC4_ERRACT_SHUTDOWN_CONV 1
292#define WM8350_DC4_ERRACT_SHUTDOWN_SYS 2
293
294/*
295 * R191 (0xBF) - DCDC4 Low Power
296 */
297#define WM8350_DC4_HIB_MODE_MASK 0x7000
298#define WM8350_DC4_HIB_TRIG_MASK 0x0300
299#define WM8350_DC4_VIMG_MASK 0x007F
300
301/*
302 * R192 (0xC0) - DCDC5 Control
303 */
304#define WM8350_DC5_MODE 0x4000
305#define WM8350_DC5_MODE_MASK 0x4000
306#define WM8350_DC5_MODE_SHIFT 14
307#define WM8350_DC5_HIB_MODE 0x1000
308#define WM8350_DC5_HIB_MODE_MASK 0x1000
309#define WM8350_DC5_HIB_MODE_SHIFT 12
310#define WM8350_DC5_HIB_TRIG_MASK 0x0300
311#define WM8350_DC5_HIB_TRIG_SHIFT 8
312#define WM8350_DC5_ILIM 0x0040
313#define WM8350_DC5_ILIM_MASK 0x0040
314#define WM8350_DC5_ILIM_SHIFT 6
315#define WM8350_DC5_RMP_MASK 0x0018
316#define WM8350_DC5_RMP_SHIFT 3
317#define WM8350_DC5_FBSRC_MASK 0x0003
318#define WM8350_DC5_FBSRC_SHIFT 0
319
320/* Bit values for R192 (0xC0) */
321#define WM8350_DC5_MODE_BOOST 0
322#define WM8350_DC5_MODE_SWITCH 1
323
324#define WM8350_DC5_HIB_MODE_ACTIVE 1
325#define WM8350_DC5_HIB_MODE_DISABLE 0
326
327#define WM8350_DC5_HIB_TRIG_NONE 0
328#define WM8350_DC5_HIB_TRIG_LPWR1 1
329#define WM8350_DC5_HIB_TRIG_LPWR2 2
330#define WM8350_DC5_HIB_TRIG_LPWR3 3
331
332#define WM8350_DC5_ILIM_HIGH 0
333#define WM8350_DC5_ILIM_LOW 1
334
335#define WM8350_DC5_RMP_30V 0
336#define WM8350_DC5_RMP_20V 1
337#define WM8350_DC5_RMP_10V 2
338#define WM8350_DC5_RMP_5V 3
339
340#define WM8350_DC5_FBSRC_FB2 0
341#define WM8350_DC5_FBSRC_ISINKA 1
342#define WM8350_DC5_FBSRC_ISINKB 2
343#define WM8350_DC5_FBSRC_USB 3
344
345/*
346 * R193 (0xC1) - DCDC5 Timeouts
347 */
348#define WM8350_DC5_ERRACT_MASK 0xC000
349#define WM8350_DC5_ERRACT_SHIFT 14
350#define WM8350_DC5_ENSLOT_MASK 0x3C00
351#define WM8350_DC5_ENSLOT_SHIFT 10
352#define WM8350_DC5_SDSLOT_MASK 0x03C0
353#define WM8350_DC5_UVTO_MASK 0x0030
354#define WM8350_DC5_SDSLOT_SHIFT 6
355
356/* Bit values for R193 (0xC1) */
357#define WM8350_DC5_ERRACT_NONE 0
358#define WM8350_DC5_ERRACT_SHUTDOWN_CONV 1
359#define WM8350_DC5_ERRACT_SHUTDOWN_SYS 2
360
361/*
362 * R195 (0xC3) - DCDC6 Control
363 */
364#define WM8350_DC6_OPFLT 0x0400
365#define WM8350_DC6_VSEL_MASK 0x007F
366#define WM8350_DC6_VSEL_SHIFT 0
367
368/*
369 * R196 (0xC4) - DCDC6 Timeouts
370 */
371#define WM8350_DC6_ERRACT_MASK 0xC000
372#define WM8350_DC6_ERRACT_SHIFT 14
373#define WM8350_DC6_ENSLOT_MASK 0x3C00
374#define WM8350_DC6_ENSLOT_SHIFT 10
375#define WM8350_DC6_SDSLOT_MASK 0x03C0
376#define WM8350_DC6_UVTO_MASK 0x0030
377#define WM8350_DC6_SDSLOT_SHIFT 6
378
379/* Bit values for R196 (0xC4) */
380#define WM8350_DC6_ERRACT_NONE 0
381#define WM8350_DC6_ERRACT_SHUTDOWN_CONV 1
382#define WM8350_DC6_ERRACT_SHUTDOWN_SYS 2
383
384/*
385 * R197 (0xC5) - DCDC6 Low Power
386 */
387#define WM8350_DC6_HIB_MODE_MASK 0x7000
388#define WM8350_DC6_HIB_TRIG_MASK 0x0300
389#define WM8350_DC6_VIMG_MASK 0x007F
390
391/*
392 * R199 (0xC7) - Limit Switch Control
393 */
394#define WM8350_LS_ERRACT_MASK 0xC000
395#define WM8350_LS_ERRACT_SHIFT 14
396#define WM8350_LS_ENSLOT_MASK 0x3C00
397#define WM8350_LS_ENSLOT_SHIFT 10
398#define WM8350_LS_SDSLOT_MASK 0x03C0
399#define WM8350_LS_SDSLOT_SHIFT 6
400#define WM8350_LS_HIB_MODE 0x0010
401#define WM8350_LS_HIB_MODE_MASK 0x0010
402#define WM8350_LS_HIB_MODE_SHIFT 4
403#define WM8350_LS_HIB_PROT 0x0002
404#define WM8350_LS_HIB_PROT_MASK 0x0002
405#define WM8350_LS_HIB_PROT_SHIFT 1
406#define WM8350_LS_PROT 0x0001
407#define WM8350_LS_PROT_MASK 0x0001
408#define WM8350_LS_PROT_SHIFT 0
409
410/* Bit values for R199 (0xC7) */
411#define WM8350_LS_ERRACT_NONE 0
412#define WM8350_LS_ERRACT_SHUTDOWN_CONV 1
413#define WM8350_LS_ERRACT_SHUTDOWN_SYS 2
414
415/*
416 * R200 (0xC8) - LDO1 Control
417 */
418#define WM8350_LDO1_SWI 0x4000
419#define WM8350_LDO1_OPFLT 0x0400
420#define WM8350_LDO1_VSEL_MASK 0x001F
421#define WM8350_LDO1_VSEL_SHIFT 0
422
423/*
424 * R201 (0xC9) - LDO1 Timeouts
425 */
426#define WM8350_LDO1_ERRACT_MASK 0xC000
427#define WM8350_LDO1_ERRACT_SHIFT 14
428#define WM8350_LDO1_ENSLOT_MASK 0x3C00
429#define WM8350_LDO1_ENSLOT_SHIFT 10
430#define WM8350_LDO1_SDSLOT_MASK 0x03C0
431#define WM8350_LDO1_UVTO_MASK 0x0030
432#define WM8350_LDO1_SDSLOT_SHIFT 6
433
434/* Bit values for R201 (0xC9) */
435#define WM8350_LDO1_ERRACT_NONE 0
436#define WM8350_LDO1_ERRACT_SHUTDOWN_CONV 1
437#define WM8350_LDO1_ERRACT_SHUTDOWN_SYS 2
438
439/*
440 * R202 (0xCA) - LDO1 Low Power
441 */
442#define WM8350_LDO1_HIB_MODE_MASK 0x3000
443#define WM8350_LDO1_HIB_TRIG_MASK 0x0300
444#define WM8350_LDO1_VIMG_MASK 0x001F
445#define WM8350_LDO1_HIB_MODE_DIS (0x1 << 12)
446
447
448/*
449 * R203 (0xCB) - LDO2 Control
450 */
451#define WM8350_LDO2_SWI 0x4000
452#define WM8350_LDO2_OPFLT 0x0400
453#define WM8350_LDO2_VSEL_MASK 0x001F
454#define WM8350_LDO2_VSEL_SHIFT 0
455
456/*
457 * R204 (0xCC) - LDO2 Timeouts
458 */
459#define WM8350_LDO2_ERRACT_MASK 0xC000
460#define WM8350_LDO2_ERRACT_SHIFT 14
461#define WM8350_LDO2_ENSLOT_MASK 0x3C00
462#define WM8350_LDO2_ENSLOT_SHIFT 10
463#define WM8350_LDO2_SDSLOT_MASK 0x03C0
464#define WM8350_LDO2_SDSLOT_SHIFT 6
465
466/* Bit values for R204 (0xCC) */
467#define WM8350_LDO2_ERRACT_NONE 0
468#define WM8350_LDO2_ERRACT_SHUTDOWN_CONV 1
469#define WM8350_LDO2_ERRACT_SHUTDOWN_SYS 2
470
471/*
472 * R205 (0xCD) - LDO2 Low Power
473 */
474#define WM8350_LDO2_HIB_MODE_MASK 0x3000
475#define WM8350_LDO2_HIB_TRIG_MASK 0x0300
476#define WM8350_LDO2_VIMG_MASK 0x001F
477
478/*
479 * R206 (0xCE) - LDO3 Control
480 */
481#define WM8350_LDO3_SWI 0x4000
482#define WM8350_LDO3_OPFLT 0x0400
483#define WM8350_LDO3_VSEL_MASK 0x001F
484#define WM8350_LDO3_VSEL_SHIFT 0
485
486/*
487 * R207 (0xCF) - LDO3 Timeouts
488 */
489#define WM8350_LDO3_ERRACT_MASK 0xC000
490#define WM8350_LDO3_ERRACT_SHIFT 14
491#define WM8350_LDO3_ENSLOT_MASK 0x3C00
492#define WM8350_LDO3_ENSLOT_SHIFT 10
493#define WM8350_LDO3_SDSLOT_MASK 0x03C0
494#define WM8350_LDO3_UVTO_MASK 0x0030
495#define WM8350_LDO3_SDSLOT_SHIFT 6
496
497/* Bit values for R207 (0xCF) */
498#define WM8350_LDO3_ERRACT_NONE 0
499#define WM8350_LDO3_ERRACT_SHUTDOWN_CONV 1
500#define WM8350_LDO3_ERRACT_SHUTDOWN_SYS 2
501
502/*
503 * R208 (0xD0) - LDO3 Low Power
504 */
505#define WM8350_LDO3_HIB_MODE_MASK 0x3000
506#define WM8350_LDO3_HIB_TRIG_MASK 0x0300
507#define WM8350_LDO3_VIMG_MASK 0x001F
508
509/*
510 * R209 (0xD1) - LDO4 Control
511 */
512#define WM8350_LDO4_SWI 0x4000
513#define WM8350_LDO4_OPFLT 0x0400
514#define WM8350_LDO4_VSEL_MASK 0x001F
515#define WM8350_LDO4_VSEL_SHIFT 0
516
517/*
518 * R210 (0xD2) - LDO4 Timeouts
519 */
520#define WM8350_LDO4_ERRACT_MASK 0xC000
521#define WM8350_LDO4_ERRACT_SHIFT 14
522#define WM8350_LDO4_ENSLOT_MASK 0x3C00
523#define WM8350_LDO4_ENSLOT_SHIFT 10
524#define WM8350_LDO4_SDSLOT_MASK 0x03C0
525#define WM8350_LDO4_UVTO_MASK 0x0030
526#define WM8350_LDO4_SDSLOT_SHIFT 6
527
528/* Bit values for R210 (0xD2) */
529#define WM8350_LDO4_ERRACT_NONE 0
530#define WM8350_LDO4_ERRACT_SHUTDOWN_CONV 1
531#define WM8350_LDO4_ERRACT_SHUTDOWN_SYS 2
532
533/*
534 * R211 (0xD3) - LDO4 Low Power
535 */
536#define WM8350_LDO4_HIB_MODE_MASK 0x3000
537#define WM8350_LDO4_HIB_TRIG_MASK 0x0300
538#define WM8350_LDO4_VIMG_MASK 0x001F
539
540/*
541 * R215 (0xD7) - VCC_FAULT Masks
542 */
543#define WM8350_LS_FAULT 0x8000
544#define WM8350_LDO4_FAULT 0x0800
545#define WM8350_LDO3_FAULT 0x0400
546#define WM8350_LDO2_FAULT 0x0200
547#define WM8350_LDO1_FAULT 0x0100
548#define WM8350_DC6_FAULT 0x0020
549#define WM8350_DC5_FAULT 0x0010
550#define WM8350_DC4_FAULT 0x0008
551#define WM8350_DC3_FAULT 0x0004
552#define WM8350_DC2_FAULT 0x0002
553#define WM8350_DC1_FAULT 0x0001
554
555/*
556 * R216 (0xD8) - Main Bandgap Control
557 */
558#define WM8350_MBG_LOAD_FUSES 0x8000
559#define WM8350_MBG_FUSE_WPREP 0x4000
560#define WM8350_MBG_FUSE_WRITE 0x2000
561#define WM8350_MBG_FUSE_TRIM_MASK 0x1F00
562#define WM8350_MBG_TRIM_SRC 0x0020
563#define WM8350_MBG_USER_TRIM_MASK 0x001F
564
565/*
566 * R217 (0xD9) - OSC Control
567 */
568#define WM8350_OSC_LOAD_FUSES 0x8000
569#define WM8350_OSC_FUSE_WPREP 0x4000
570#define WM8350_OSC_FUSE_WRITE 0x2000
571#define WM8350_OSC_FUSE_TRIM_MASK 0x0F00
572#define WM8350_OSC_TRIM_SRC 0x0020
573#define WM8350_OSC_USER_TRIM_MASK 0x000F
574
575/*
576 * R248 (0xF8) - DCDC1 Force PWM
577 */
578#define WM8350_DCDC1_FORCE_PWM_ENA 0x0010
579
580/*
581 * R250 (0xFA) - DCDC3 Force PWM
582 */
583#define WM8350_DCDC3_FORCE_PWM_ENA 0x0010
584
585/*
586 * R251 (0xFB) - DCDC4 Force PWM
587 */
588#define WM8350_DCDC4_FORCE_PWM_ENA 0x0010
589
590/*
591 * R253 (0xFD) - DCDC1 Force PWM
592 */
593#define WM8350_DCDC6_FORCE_PWM_ENA 0x0010
594
595/*
596 * DCDC's
597 */
598#define WM8350_DCDC_1 0
599#define WM8350_DCDC_2 1
600#define WM8350_DCDC_3 2
601#define WM8350_DCDC_4 3
602#define WM8350_DCDC_5 4
603#define WM8350_DCDC_6 5
604
605/* DCDC modes */
606#define WM8350_DCDC_ACTIVE_STANDBY 0
607#define WM8350_DCDC_ACTIVE_PULSE 1
608#define WM8350_DCDC_SLEEP_NORMAL 0
609#define WM8350_DCDC_SLEEP_LOW 1
610
611/* DCDC Low power (Hibernate) mode */
612#define WM8350_DCDC_HIB_MODE_CUR (0 << 12)
613#define WM8350_DCDC_HIB_MODE_IMAGE (1 << 12)
614#define WM8350_DCDC_HIB_MODE_STANDBY (2 << 12)
615#define WM8350_DCDC_HIB_MODE_LDO (4 << 12)
616#define WM8350_DCDC_HIB_MODE_LDO_IM (5 << 12)
617#define WM8350_DCDC_HIB_MODE_DIS (7 << 12)
618#define WM8350_DCDC_HIB_MODE_MASK (7 << 12)
619
620/* DCDC Low Power (Hibernate) signal */
621#define WM8350_DCDC_HIB_SIG_REG (0 << 8)
622#define WM8350_DCDC_HIB_SIG_LPWR1 (1 << 8)
623#define WM8350_DCDC_HIB_SIG_LPWR2 (2 << 8)
624#define WM8350_DCDC_HIB_SIG_LPWR3 (3 << 8)
625
626/* LDO Low power (Hibernate) mode */
627#define WM8350_LDO_HIB_MODE_IMAGE (0 << 0)
628#define WM8350_LDO_HIB_MODE_DIS (1 << 0)
629
630/* LDO Low Power (Hibernate) signal */
631#define WM8350_LDO_HIB_SIG_REG (0 << 8)
632#define WM8350_LDO_HIB_SIG_LPWR1 (1 << 8)
633#define WM8350_LDO_HIB_SIG_LPWR2 (2 << 8)
634#define WM8350_LDO_HIB_SIG_LPWR3 (3 << 8)
635
636/*
637 * LDOs
638 */
639#define WM8350_LDO_1 6
640#define WM8350_LDO_2 7
641#define WM8350_LDO_3 8
642#define WM8350_LDO_4 9
643
644/*
645 * ISINKs
646 */
647#define WM8350_ISINK_A 10
648#define WM8350_ISINK_B 11
649
650#define WM8350_ISINK_MODE_BOOST 0
651#define WM8350_ISINK_MODE_SWITCH 1
652#define WM8350_ISINK_ILIM_NORMAL 0
653#define WM8350_ISINK_ILIM_LOW 1
654
655#define WM8350_ISINK_FLASH_DISABLE 0
656#define WM8350_ISINK_FLASH_ENABLE 1
657#define WM8350_ISINK_FLASH_TRIG_BIT 0
658#define WM8350_ISINK_FLASH_TRIG_GPIO 1
659#define WM8350_ISINK_FLASH_MODE_EN (1 << 13)
660#define WM8350_ISINK_FLASH_MODE_DIS (0 << 13)
661#define WM8350_ISINK_FLASH_DUR_32MS (0 << 8)
662#define WM8350_ISINK_FLASH_DUR_64MS (1 << 8)
663#define WM8350_ISINK_FLASH_DUR_96MS (2 << 8)
664#define WM8350_ISINK_FLASH_DUR_1024MS (3 << 8)
665#define WM8350_ISINK_FLASH_ON_INSTANT (0 << 4)
666#define WM8350_ISINK_FLASH_ON_0_25S (1 << 4)
667#define WM8350_ISINK_FLASH_ON_0_50S (2 << 4)
668#define WM8350_ISINK_FLASH_ON_1_00S (3 << 4)
669#define WM8350_ISINK_FLASH_ON_1_95S (1 << 4)
670#define WM8350_ISINK_FLASH_ON_3_91S (2 << 4)
671#define WM8350_ISINK_FLASH_ON_7_80S (3 << 4)
672#define WM8350_ISINK_FLASH_OFF_INSTANT (0 << 0)
673#define WM8350_ISINK_FLASH_OFF_0_25S (1 << 0)
674#define WM8350_ISINK_FLASH_OFF_0_50S (2 << 0)
675#define WM8350_ISINK_FLASH_OFF_1_00S (3 << 0)
676#define WM8350_ISINK_FLASH_OFF_1_95S (1 << 0)
677#define WM8350_ISINK_FLASH_OFF_3_91S (2 << 0)
678#define WM8350_ISINK_FLASH_OFF_7_80S (3 << 0)
679
680/*
681 * Regulator Interrupts.
682 */
683#define WM8350_IRQ_CS1 13
684#define WM8350_IRQ_CS2 14
685#define WM8350_IRQ_UV_LDO4 25
686#define WM8350_IRQ_UV_LDO3 26
687#define WM8350_IRQ_UV_LDO2 27
688#define WM8350_IRQ_UV_LDO1 28
689#define WM8350_IRQ_UV_DC6 29
690#define WM8350_IRQ_UV_DC5 30
691#define WM8350_IRQ_UV_DC4 31
692#define WM8350_IRQ_UV_DC3 32
693#define WM8350_IRQ_UV_DC2 33
694#define WM8350_IRQ_UV_DC1 34
695#define WM8350_IRQ_OC_LS 35
696
697#define NUM_WM8350_REGULATORS 12
698
699struct wm8350;
700struct platform_device;
701struct regulator_init_data;
702
703struct wm8350_pmic {
704 /* ISINK to DCDC mapping */
705 int isink_A_dcdc;
706 int isink_B_dcdc;
707
708 /* hibernate configs */
709 u16 dcdc1_hib_mode;
710 u16 dcdc3_hib_mode;
711 u16 dcdc4_hib_mode;
712 u16 dcdc6_hib_mode;
713
714 /* regulator devices */
715 struct platform_device *pdev[NUM_WM8350_REGULATORS];
716};
717
718int wm8350_register_regulator(struct wm8350 *wm8350, int reg,
719 struct regulator_init_data *initdata);
720
721/*
722 * Additional DCDC control not supported via regulator API
723 */
724int wm8350_dcdc_set_slot(struct wm8350 *wm8350, int dcdc, u16 start,
725 u16 stop, u16 fault);
726int wm8350_dcdc25_set_mode(struct wm8350 *wm8350, int dcdc, u16 mode,
727 u16 ilim, u16 ramp, u16 feedback);
728
729/*
730 * Additional LDO control not supported via regulator API
731 */
732int wm8350_ldo_set_slot(struct wm8350 *wm8350, int ldo, u16 start, u16 stop);
733
734/*
735 * Additional ISINK control not supported via regulator API
736 */
737int wm8350_isink_set_flash(struct wm8350 *wm8350, int isink, u16 mode,
738 u16 trigger, u16 duration, u16 on_ramp,
739 u16 off_ramp, u16 drive);
740
741#endif
diff --git a/include/linux/mfd/wm8350/rtc.h b/include/linux/mfd/wm8350/rtc.h
new file mode 100644
index 000000000000..dfda69e9f440
--- /dev/null
+++ b/include/linux/mfd/wm8350/rtc.h
@@ -0,0 +1,266 @@
1/*
2 * rtc.h -- RTC driver for Wolfson WM8350 PMIC
3 *
4 * Copyright 2007 Wolfson Microelectronics PLC
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 */
11
12#ifndef __LINUX_MFD_WM8350_RTC_H
13#define __LINUX_MFD_WM8350_RTC_H
14
15#include <linux/platform_device.h>
16
17/*
18 * Register values.
19 */
20#define WM8350_RTC_SECONDS_MINUTES 0x10
21#define WM8350_RTC_HOURS_DAY 0x11
22#define WM8350_RTC_DATE_MONTH 0x12
23#define WM8350_RTC_YEAR 0x13
24#define WM8350_ALARM_SECONDS_MINUTES 0x14
25#define WM8350_ALARM_HOURS_DAY 0x15
26#define WM8350_ALARM_DATE_MONTH 0x16
27#define WM8350_RTC_TIME_CONTROL 0x17
28
29/*
30 * R16 (0x10) - RTC Seconds/Minutes
31 */
32#define WM8350_RTC_MINS_MASK 0x7F00
33#define WM8350_RTC_MINS_SHIFT 8
34#define WM8350_RTC_SECS_MASK 0x007F
35#define WM8350_RTC_SECS_SHIFT 0
36
37/*
38 * R17 (0x11) - RTC Hours/Day
39 */
40#define WM8350_RTC_DAY_MASK 0x0700
41#define WM8350_RTC_DAY_SHIFT 8
42#define WM8350_RTC_HPM_MASK 0x0020
43#define WM8350_RTC_HPM_SHIFT 5
44#define WM8350_RTC_HRS_MASK 0x001F
45#define WM8350_RTC_HRS_SHIFT 0
46
47/* Bit values for R21 (0x15) */
48#define WM8350_RTC_DAY_SUN 1
49#define WM8350_RTC_DAY_MON 2
50#define WM8350_RTC_DAY_TUE 3
51#define WM8350_RTC_DAY_WED 4
52#define WM8350_RTC_DAY_THU 5
53#define WM8350_RTC_DAY_FRI 6
54#define WM8350_RTC_DAY_SAT 7
55
56#define WM8350_RTC_HPM_AM 0
57#define WM8350_RTC_HPM_PM 1
58
59/*
60 * R18 (0x12) - RTC Date/Month
61 */
62#define WM8350_RTC_MTH_MASK 0x1F00
63#define WM8350_RTC_MTH_SHIFT 8
64#define WM8350_RTC_DATE_MASK 0x003F
65#define WM8350_RTC_DATE_SHIFT 0
66
67/* Bit values for R22 (0x16) */
68#define WM8350_RTC_MTH_JAN 1
69#define WM8350_RTC_MTH_FEB 2
70#define WM8350_RTC_MTH_MAR 3
71#define WM8350_RTC_MTH_APR 4
72#define WM8350_RTC_MTH_MAY 5
73#define WM8350_RTC_MTH_JUN 6
74#define WM8350_RTC_MTH_JUL 7
75#define WM8350_RTC_MTH_AUG 8
76#define WM8350_RTC_MTH_SEP 9
77#define WM8350_RTC_MTH_OCT 10
78#define WM8350_RTC_MTH_NOV 11
79#define WM8350_RTC_MTH_DEC 12
80#define WM8350_RTC_MTH_JAN_BCD 0x01
81#define WM8350_RTC_MTH_FEB_BCD 0x02
82#define WM8350_RTC_MTH_MAR_BCD 0x03
83#define WM8350_RTC_MTH_APR_BCD 0x04
84#define WM8350_RTC_MTH_MAY_BCD 0x05
85#define WM8350_RTC_MTH_JUN_BCD 0x06
86#define WM8350_RTC_MTH_JUL_BCD 0x07
87#define WM8350_RTC_MTH_AUG_BCD 0x08
88#define WM8350_RTC_MTH_SEP_BCD 0x09
89#define WM8350_RTC_MTH_OCT_BCD 0x10
90#define WM8350_RTC_MTH_NOV_BCD 0x11
91#define WM8350_RTC_MTH_DEC_BCD 0x12
92
93/*
94 * R19 (0x13) - RTC Year
95 */
96#define WM8350_RTC_YHUNDREDS_MASK 0x3F00
97#define WM8350_RTC_YHUNDREDS_SHIFT 8
98#define WM8350_RTC_YUNITS_MASK 0x00FF
99#define WM8350_RTC_YUNITS_SHIFT 0
100
101/*
102 * R20 (0x14) - Alarm Seconds/Minutes
103 */
104#define WM8350_RTC_ALMMINS_MASK 0x7F00
105#define WM8350_RTC_ALMMINS_SHIFT 8
106#define WM8350_RTC_ALMSECS_MASK 0x007F
107#define WM8350_RTC_ALMSECS_SHIFT 0
108
109/* Bit values for R20 (0x14) */
110#define WM8350_RTC_ALMMINS_DONT_CARE -1
111#define WM8350_RTC_ALMSECS_DONT_CARE -1
112
113/*
114 * R21 (0x15) - Alarm Hours/Day
115 */
116#define WM8350_RTC_ALMDAY_MASK 0x0F00
117#define WM8350_RTC_ALMDAY_SHIFT 8
118#define WM8350_RTC_ALMHPM_MASK 0x0020
119#define WM8350_RTC_ALMHPM_SHIFT 5
120#define WM8350_RTC_ALMHRS_MASK 0x001F
121#define WM8350_RTC_ALMHRS_SHIFT 0
122
123/* Bit values for R21 (0x15) */
124#define WM8350_RTC_ALMDAY_DONT_CARE -1
125#define WM8350_RTC_ALMDAY_SUN 1
126#define WM8350_RTC_ALMDAY_MON 2
127#define WM8350_RTC_ALMDAY_TUE 3
128#define WM8350_RTC_ALMDAY_WED 4
129#define WM8350_RTC_ALMDAY_THU 5
130#define WM8350_RTC_ALMDAY_FRI 6
131#define WM8350_RTC_ALMDAY_SAT 7
132
133#define WM8350_RTC_ALMHPM_AM 0
134#define WM8350_RTC_ALMHPM_PM 1
135
136#define WM8350_RTC_ALMHRS_DONT_CARE -1
137
138/*
139 * R22 (0x16) - Alarm Date/Month
140 */
141#define WM8350_RTC_ALMMTH_MASK 0x1F00
142#define WM8350_RTC_ALMMTH_SHIFT 8
143#define WM8350_RTC_ALMDATE_MASK 0x003F
144#define WM8350_RTC_ALMDATE_SHIFT 0
145
146/* Bit values for R22 (0x16) */
147#define WM8350_RTC_ALMDATE_DONT_CARE -1
148
149#define WM8350_RTC_ALMMTH_DONT_CARE -1
150#define WM8350_RTC_ALMMTH_JAN 1
151#define WM8350_RTC_ALMMTH_FEB 2
152#define WM8350_RTC_ALMMTH_MAR 3
153#define WM8350_RTC_ALMMTH_APR 4
154#define WM8350_RTC_ALMMTH_MAY 5
155#define WM8350_RTC_ALMMTH_JUN 6
156#define WM8350_RTC_ALMMTH_JUL 7
157#define WM8350_RTC_ALMMTH_AUG 8
158#define WM8350_RTC_ALMMTH_SEP 9
159#define WM8350_RTC_ALMMTH_OCT 10
160#define WM8350_RTC_ALMMTH_NOV 11
161#define WM8350_RTC_ALMMTH_DEC 12
162#define WM8350_RTC_ALMMTH_JAN_BCD 0x01
163#define WM8350_RTC_ALMMTH_FEB_BCD 0x02
164#define WM8350_RTC_ALMMTH_MAR_BCD 0x03
165#define WM8350_RTC_ALMMTH_APR_BCD 0x04
166#define WM8350_RTC_ALMMTH_MAY_BCD 0x05
167#define WM8350_RTC_ALMMTH_JUN_BCD 0x06
168#define WM8350_RTC_ALMMTH_JUL_BCD 0x07
169#define WM8350_RTC_ALMMTH_AUG_BCD 0x08
170#define WM8350_RTC_ALMMTH_SEP_BCD 0x09
171#define WM8350_RTC_ALMMTH_OCT_BCD 0x10
172#define WM8350_RTC_ALMMTH_NOV_BCD 0x11
173#define WM8350_RTC_ALMMTH_DEC_BCD 0x12
174
175/*
176 * R23 (0x17) - RTC Time Control
177 */
178#define WM8350_RTC_BCD 0x8000
179#define WM8350_RTC_BCD_MASK 0x8000
180#define WM8350_RTC_BCD_SHIFT 15
181#define WM8350_RTC_12HR 0x4000
182#define WM8350_RTC_12HR_MASK 0x4000
183#define WM8350_RTC_12HR_SHIFT 14
184#define WM8350_RTC_DST 0x2000
185#define WM8350_RTC_DST_MASK 0x2000
186#define WM8350_RTC_DST_SHIFT 13
187#define WM8350_RTC_SET 0x0800
188#define WM8350_RTC_SET_MASK 0x0800
189#define WM8350_RTC_SET_SHIFT 11
190#define WM8350_RTC_STS 0x0400
191#define WM8350_RTC_STS_MASK 0x0400
192#define WM8350_RTC_STS_SHIFT 10
193#define WM8350_RTC_ALMSET 0x0200
194#define WM8350_RTC_ALMSET_MASK 0x0200
195#define WM8350_RTC_ALMSET_SHIFT 9
196#define WM8350_RTC_ALMSTS 0x0100
197#define WM8350_RTC_ALMSTS_MASK 0x0100
198#define WM8350_RTC_ALMSTS_SHIFT 8
199#define WM8350_RTC_PINT 0x0070
200#define WM8350_RTC_PINT_MASK 0x0070
201#define WM8350_RTC_PINT_SHIFT 4
202#define WM8350_RTC_DSW 0x000F
203#define WM8350_RTC_DSW_MASK 0x000F
204#define WM8350_RTC_DSW_SHIFT 0
205
206/* Bit values for R23 (0x17) */
207#define WM8350_RTC_BCD_BINARY 0
208#define WM8350_RTC_BCD_BCD 1
209
210#define WM8350_RTC_12HR_24HR 0
211#define WM8350_RTC_12HR_12HR 1
212
213#define WM8350_RTC_DST_DISABLED 0
214#define WM8350_RTC_DST_ENABLED 1
215
216#define WM8350_RTC_SET_RUN 0
217#define WM8350_RTC_SET_SET 1
218
219#define WM8350_RTC_STS_RUNNING 0
220#define WM8350_RTC_STS_STOPPED 1
221
222#define WM8350_RTC_ALMSET_RUN 0
223#define WM8350_RTC_ALMSET_SET 1
224
225#define WM8350_RTC_ALMSTS_RUNNING 0
226#define WM8350_RTC_ALMSTS_STOPPED 1
227
228#define WM8350_RTC_PINT_DISABLED 0
229#define WM8350_RTC_PINT_SECS 1
230#define WM8350_RTC_PINT_MINS 2
231#define WM8350_RTC_PINT_HRS 3
232#define WM8350_RTC_PINT_DAYS 4
233#define WM8350_RTC_PINT_MTHS 5
234
235#define WM8350_RTC_DSW_DISABLED 0
236#define WM8350_RTC_DSW_1HZ 1
237#define WM8350_RTC_DSW_2HZ 2
238#define WM8350_RTC_DSW_4HZ 3
239#define WM8350_RTC_DSW_8HZ 4
240#define WM8350_RTC_DSW_16HZ 5
241#define WM8350_RTC_DSW_32HZ 6
242#define WM8350_RTC_DSW_64HZ 7
243#define WM8350_RTC_DSW_128HZ 8
244#define WM8350_RTC_DSW_256HZ 9
245#define WM8350_RTC_DSW_512HZ 10
246#define WM8350_RTC_DSW_1024HZ 11
247
248/*
249 * R218 (0xDA) - RTC Tick Control
250 */
251#define WM8350_RTC_TICKSTS 0x4000
252#define WM8350_RTC_CLKSRC 0x2000
253#define WM8350_RTC_TRIM_MASK 0x03FF
254
255/*
256 * RTC Interrupts.
257 */
258#define WM8350_IRQ_RTC_PER 7
259#define WM8350_IRQ_RTC_SEC 8
260#define WM8350_IRQ_RTC_ALM 9
261
262struct wm8350_rtc {
263 struct platform_device *pdev;
264};
265
266#endif
diff --git a/include/linux/mfd/wm8350/supply.h b/include/linux/mfd/wm8350/supply.h
new file mode 100644
index 000000000000..1c8f3cde79b0
--- /dev/null
+++ b/include/linux/mfd/wm8350/supply.h
@@ -0,0 +1,111 @@
1/*
2 * supply.h -- Power Supply Driver for Wolfson WM8350 PMIC
3 *
4 * Copyright 2007 Wolfson Microelectronics PLC
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 *
11 */
12
13#ifndef __LINUX_MFD_WM8350_SUPPLY_H_
14#define __LINUX_MFD_WM8350_SUPPLY_H_
15
16#include <linux/platform_device.h>
17
18/*
19 * Charger registers
20 */
21#define WM8350_BATTERY_CHARGER_CONTROL_1 0xA8
22#define WM8350_BATTERY_CHARGER_CONTROL_2 0xA9
23#define WM8350_BATTERY_CHARGER_CONTROL_3 0xAA
24
25/*
26 * R168 (0xA8) - Battery Charger Control 1
27 */
28#define WM8350_CHG_ENA_R168 0x8000
29#define WM8350_CHG_THR 0x2000
30#define WM8350_CHG_EOC_SEL_MASK 0x1C00
31#define WM8350_CHG_TRICKLE_TEMP_CHOKE 0x0200
32#define WM8350_CHG_TRICKLE_USB_CHOKE 0x0100
33#define WM8350_CHG_RECOVER_T 0x0080
34#define WM8350_CHG_END_ACT 0x0040
35#define WM8350_CHG_FAST 0x0020
36#define WM8350_CHG_FAST_USB_THROTTLE 0x0010
37#define WM8350_CHG_NTC_MON 0x0008
38#define WM8350_CHG_BATT_HOT_MON 0x0004
39#define WM8350_CHG_BATT_COLD_MON 0x0002
40#define WM8350_CHG_CHIP_TEMP_MON 0x0001
41
42/*
43 * R169 (0xA9) - Battery Charger Control 2
44 */
45#define WM8350_CHG_ACTIVE 0x8000
46#define WM8350_CHG_PAUSE 0x4000
47#define WM8350_CHG_STS_MASK 0x3000
48#define WM8350_CHG_TIME_MASK 0x0F00
49#define WM8350_CHG_MASK_WALL_FB 0x0080
50#define WM8350_CHG_TRICKLE_SEL 0x0040
51#define WM8350_CHG_VSEL_MASK 0x0030
52#define WM8350_CHG_ISEL_MASK 0x000F
53#define WM8350_CHG_STS_OFF 0x0000
54#define WM8350_CHG_STS_TRICKLE 0x1000
55#define WM8350_CHG_STS_FAST 0x2000
56
57/*
58 * R170 (0xAA) - Battery Charger Control 3
59 */
60#define WM8350_CHG_THROTTLE_T_MASK 0x0060
61#define WM8350_CHG_SMART 0x0010
62#define WM8350_CHG_TIMER_ADJT_MASK 0x000F
63
64/*
65 * Charger Interrupts
66 */
67#define WM8350_IRQ_CHG_BAT_HOT 0
68#define WM8350_IRQ_CHG_BAT_COLD 1
69#define WM8350_IRQ_CHG_BAT_FAIL 2
70#define WM8350_IRQ_CHG_TO 3
71#define WM8350_IRQ_CHG_END 4
72#define WM8350_IRQ_CHG_START 5
73#define WM8350_IRQ_CHG_FAST_RDY 6
74#define WM8350_IRQ_CHG_VBATT_LT_3P9 10
75#define WM8350_IRQ_CHG_VBATT_LT_3P1 11
76#define WM8350_IRQ_CHG_VBATT_LT_2P85 12
77
78/*
79 * Charger Policy
80 */
81#define WM8350_CHG_TRICKLE_50mA (0 << 6)
82#define WM8350_CHG_TRICKLE_100mA (1 << 6)
83#define WM8350_CHG_4_05V (0 << 4)
84#define WM8350_CHG_4_10V (1 << 4)
85#define WM8350_CHG_4_15V (2 << 4)
86#define WM8350_CHG_4_20V (3 << 4)
87#define WM8350_CHG_FAST_LIMIT_mA(x) ((x / 50) & 0xf)
88#define WM8350_CHG_EOC_mA(x) (((x - 10) & 0x7) << 10)
89#define WM8350_CHG_TRICKLE_3_1V (0 << 13)
90#define WM8350_CHG_TRICKLE_3_9V (1 << 13)
91
92/*
93 * Supply Registers.
94 */
95#define WM8350_USB_VOLTAGE_READBACK 0x9C
96#define WM8350_LINE_VOLTAGE_READBACK 0x9D
97#define WM8350_BATT_VOLTAGE_READBACK 0x9E
98
99/*
100 * Supply Interrupts.
101 */
102#define WM8350_IRQ_USB_LIMIT 15
103#define WM8350_IRQ_EXT_USB_FB 36
104#define WM8350_IRQ_EXT_WALL_FB 37
105#define WM8350_IRQ_EXT_BAT_FB 38
106
107struct wm8350_power {
108 struct platform_device *pdev;
109};
110
111#endif
diff --git a/include/linux/mfd/wm8350/wdt.h b/include/linux/mfd/wm8350/wdt.h
new file mode 100644
index 000000000000..f6135b5e5ef4
--- /dev/null
+++ b/include/linux/mfd/wm8350/wdt.h
@@ -0,0 +1,28 @@
1/*
2 * wdt.h -- Watchdog Driver for Wolfson WM8350 PMIC
3 *
4 * Copyright 2007, 2008 Wolfson Microelectronics PLC
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 */
11
12#ifndef __LINUX_MFD_WM8350_WDT_H_
13#define __LINUX_MFD_WM8350_WDT_H_
14
15#include <linux/platform_device.h>
16
17#define WM8350_WDOG_HIB_MODE 0x0080
18#define WM8350_WDOG_DEBUG 0x0040
19#define WM8350_WDOG_MODE_MASK 0x0030
20#define WM8350_WDOG_TO_MASK 0x0007
21
22#define WM8350_IRQ_SYS_WDOG_TO 24
23
24struct wm8350_wdt {
25 struct platform_device *pdev;
26};
27
28#endif
diff --git a/include/linux/mfd/wm8400-audio.h b/include/linux/mfd/wm8400-audio.h
new file mode 100644
index 000000000000..b6640e018046
--- /dev/null
+++ b/include/linux/mfd/wm8400-audio.h
@@ -0,0 +1,1186 @@
1/*
2 * wm8400 private definitions for audio
3 *
4 * Copyright 2008 Wolfson Microelectronics plc
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
21#ifndef __LINUX_MFD_WM8400_AUDIO_H
22#define __LINUX_MFD_WM8400_AUDIO_H
23
24#include <linux/mfd/wm8400-audio.h>
25
26/*
27 * R2 (0x02) - Power Management (1)
28 */
29#define WM8400_CODEC_ENA 0x8000 /* CODEC_ENA */
30#define WM8400_CODEC_ENA_MASK 0x8000 /* CODEC_ENA */
31#define WM8400_CODEC_ENA_SHIFT 15 /* CODEC_ENA */
32#define WM8400_CODEC_ENA_WIDTH 1 /* CODEC_ENA */
33#define WM8400_SYSCLK_ENA 0x4000 /* SYSCLK_ENA */
34#define WM8400_SYSCLK_ENA_MASK 0x4000 /* SYSCLK_ENA */
35#define WM8400_SYSCLK_ENA_SHIFT 14 /* SYSCLK_ENA */
36#define WM8400_SYSCLK_ENA_WIDTH 1 /* SYSCLK_ENA */
37#define WM8400_SPK_MIX_ENA 0x2000 /* SPK_MIX_ENA */
38#define WM8400_SPK_MIX_ENA_MASK 0x2000 /* SPK_MIX_ENA */
39#define WM8400_SPK_MIX_ENA_SHIFT 13 /* SPK_MIX_ENA */
40#define WM8400_SPK_MIX_ENA_WIDTH 1 /* SPK_MIX_ENA */
41#define WM8400_SPK_ENA 0x1000 /* SPK_ENA */
42#define WM8400_SPK_ENA_MASK 0x1000 /* SPK_ENA */
43#define WM8400_SPK_ENA_SHIFT 12 /* SPK_ENA */
44#define WM8400_SPK_ENA_WIDTH 1 /* SPK_ENA */
45#define WM8400_OUT3_ENA 0x0800 /* OUT3_ENA */
46#define WM8400_OUT3_ENA_MASK 0x0800 /* OUT3_ENA */
47#define WM8400_OUT3_ENA_SHIFT 11 /* OUT3_ENA */
48#define WM8400_OUT3_ENA_WIDTH 1 /* OUT3_ENA */
49#define WM8400_OUT4_ENA 0x0400 /* OUT4_ENA */
50#define WM8400_OUT4_ENA_MASK 0x0400 /* OUT4_ENA */
51#define WM8400_OUT4_ENA_SHIFT 10 /* OUT4_ENA */
52#define WM8400_OUT4_ENA_WIDTH 1 /* OUT4_ENA */
53#define WM8400_LOUT_ENA 0x0200 /* LOUT_ENA */
54#define WM8400_LOUT_ENA_MASK 0x0200 /* LOUT_ENA */
55#define WM8400_LOUT_ENA_SHIFT 9 /* LOUT_ENA */
56#define WM8400_LOUT_ENA_WIDTH 1 /* LOUT_ENA */
57#define WM8400_ROUT_ENA 0x0100 /* ROUT_ENA */
58#define WM8400_ROUT_ENA_MASK 0x0100 /* ROUT_ENA */
59#define WM8400_ROUT_ENA_SHIFT 8 /* ROUT_ENA */
60#define WM8400_ROUT_ENA_WIDTH 1 /* ROUT_ENA */
61#define WM8400_MIC1BIAS_ENA 0x0010 /* MIC1BIAS_ENA */
62#define WM8400_MIC1BIAS_ENA_MASK 0x0010 /* MIC1BIAS_ENA */
63#define WM8400_MIC1BIAS_ENA_SHIFT 4 /* MIC1BIAS_ENA */
64#define WM8400_MIC1BIAS_ENA_WIDTH 1 /* MIC1BIAS_ENA */
65#define WM8400_VMID_MODE_MASK 0x0006 /* VMID_MODE - [2:1] */
66#define WM8400_VMID_MODE_SHIFT 1 /* VMID_MODE - [2:1] */
67#define WM8400_VMID_MODE_WIDTH 2 /* VMID_MODE - [2:1] */
68#define WM8400_VREF_ENA 0x0001 /* VREF_ENA */
69#define WM8400_VREF_ENA_MASK 0x0001 /* VREF_ENA */
70#define WM8400_VREF_ENA_SHIFT 0 /* VREF_ENA */
71#define WM8400_VREF_ENA_WIDTH 1 /* VREF_ENA */
72
73/*
74 * R3 (0x03) - Power Management (2)
75 */
76#define WM8400_FLL_ENA 0x8000 /* FLL_ENA */
77#define WM8400_FLL_ENA_MASK 0x8000 /* FLL_ENA */
78#define WM8400_FLL_ENA_SHIFT 15 /* FLL_ENA */
79#define WM8400_FLL_ENA_WIDTH 1 /* FLL_ENA */
80#define WM8400_TSHUT_ENA 0x4000 /* TSHUT_ENA */
81#define WM8400_TSHUT_ENA_MASK 0x4000 /* TSHUT_ENA */
82#define WM8400_TSHUT_ENA_SHIFT 14 /* TSHUT_ENA */
83#define WM8400_TSHUT_ENA_WIDTH 1 /* TSHUT_ENA */
84#define WM8400_TSHUT_OPDIS 0x2000 /* TSHUT_OPDIS */
85#define WM8400_TSHUT_OPDIS_MASK 0x2000 /* TSHUT_OPDIS */
86#define WM8400_TSHUT_OPDIS_SHIFT 13 /* TSHUT_OPDIS */
87#define WM8400_TSHUT_OPDIS_WIDTH 1 /* TSHUT_OPDIS */
88#define WM8400_OPCLK_ENA 0x0800 /* OPCLK_ENA */
89#define WM8400_OPCLK_ENA_MASK 0x0800 /* OPCLK_ENA */
90#define WM8400_OPCLK_ENA_SHIFT 11 /* OPCLK_ENA */
91#define WM8400_OPCLK_ENA_WIDTH 1 /* OPCLK_ENA */
92#define WM8400_AINL_ENA 0x0200 /* AINL_ENA */
93#define WM8400_AINL_ENA_MASK 0x0200 /* AINL_ENA */
94#define WM8400_AINL_ENA_SHIFT 9 /* AINL_ENA */
95#define WM8400_AINL_ENA_WIDTH 1 /* AINL_ENA */
96#define WM8400_AINR_ENA 0x0100 /* AINR_ENA */
97#define WM8400_AINR_ENA_MASK 0x0100 /* AINR_ENA */
98#define WM8400_AINR_ENA_SHIFT 8 /* AINR_ENA */
99#define WM8400_AINR_ENA_WIDTH 1 /* AINR_ENA */
100#define WM8400_LIN34_ENA 0x0080 /* LIN34_ENA */
101#define WM8400_LIN34_ENA_MASK 0x0080 /* LIN34_ENA */
102#define WM8400_LIN34_ENA_SHIFT 7 /* LIN34_ENA */
103#define WM8400_LIN34_ENA_WIDTH 1 /* LIN34_ENA */
104#define WM8400_LIN12_ENA 0x0040 /* LIN12_ENA */
105#define WM8400_LIN12_ENA_MASK 0x0040 /* LIN12_ENA */
106#define WM8400_LIN12_ENA_SHIFT 6 /* LIN12_ENA */
107#define WM8400_LIN12_ENA_WIDTH 1 /* LIN12_ENA */
108#define WM8400_RIN34_ENA 0x0020 /* RIN34_ENA */
109#define WM8400_RIN34_ENA_MASK 0x0020 /* RIN34_ENA */
110#define WM8400_RIN34_ENA_SHIFT 5 /* RIN34_ENA */
111#define WM8400_RIN34_ENA_WIDTH 1 /* RIN34_ENA */
112#define WM8400_RIN12_ENA 0x0010 /* RIN12_ENA */
113#define WM8400_RIN12_ENA_MASK 0x0010 /* RIN12_ENA */
114#define WM8400_RIN12_ENA_SHIFT 4 /* RIN12_ENA */
115#define WM8400_RIN12_ENA_WIDTH 1 /* RIN12_ENA */
116#define WM8400_ADCL_ENA 0x0002 /* ADCL_ENA */
117#define WM8400_ADCL_ENA_MASK 0x0002 /* ADCL_ENA */
118#define WM8400_ADCL_ENA_SHIFT 1 /* ADCL_ENA */
119#define WM8400_ADCL_ENA_WIDTH 1 /* ADCL_ENA */
120#define WM8400_ADCR_ENA 0x0001 /* ADCR_ENA */
121#define WM8400_ADCR_ENA_MASK 0x0001 /* ADCR_ENA */
122#define WM8400_ADCR_ENA_SHIFT 0 /* ADCR_ENA */
123#define WM8400_ADCR_ENA_WIDTH 1 /* ADCR_ENA */
124
125/*
126 * R4 (0x04) - Power Management (3)
127 */
128#define WM8400_LON_ENA 0x2000 /* LON_ENA */
129#define WM8400_LON_ENA_MASK 0x2000 /* LON_ENA */
130#define WM8400_LON_ENA_SHIFT 13 /* LON_ENA */
131#define WM8400_LON_ENA_WIDTH 1 /* LON_ENA */
132#define WM8400_LOP_ENA 0x1000 /* LOP_ENA */
133#define WM8400_LOP_ENA_MASK 0x1000 /* LOP_ENA */
134#define WM8400_LOP_ENA_SHIFT 12 /* LOP_ENA */
135#define WM8400_LOP_ENA_WIDTH 1 /* LOP_ENA */
136#define WM8400_RON_ENA 0x0800 /* RON_ENA */
137#define WM8400_RON_ENA_MASK 0x0800 /* RON_ENA */
138#define WM8400_RON_ENA_SHIFT 11 /* RON_ENA */
139#define WM8400_RON_ENA_WIDTH 1 /* RON_ENA */
140#define WM8400_ROP_ENA 0x0400 /* ROP_ENA */
141#define WM8400_ROP_ENA_MASK 0x0400 /* ROP_ENA */
142#define WM8400_ROP_ENA_SHIFT 10 /* ROP_ENA */
143#define WM8400_ROP_ENA_WIDTH 1 /* ROP_ENA */
144#define WM8400_LOPGA_ENA 0x0080 /* LOPGA_ENA */
145#define WM8400_LOPGA_ENA_MASK 0x0080 /* LOPGA_ENA */
146#define WM8400_LOPGA_ENA_SHIFT 7 /* LOPGA_ENA */
147#define WM8400_LOPGA_ENA_WIDTH 1 /* LOPGA_ENA */
148#define WM8400_ROPGA_ENA 0x0040 /* ROPGA_ENA */
149#define WM8400_ROPGA_ENA_MASK 0x0040 /* ROPGA_ENA */
150#define WM8400_ROPGA_ENA_SHIFT 6 /* ROPGA_ENA */
151#define WM8400_ROPGA_ENA_WIDTH 1 /* ROPGA_ENA */
152#define WM8400_LOMIX_ENA 0x0020 /* LOMIX_ENA */
153#define WM8400_LOMIX_ENA_MASK 0x0020 /* LOMIX_ENA */
154#define WM8400_LOMIX_ENA_SHIFT 5 /* LOMIX_ENA */
155#define WM8400_LOMIX_ENA_WIDTH 1 /* LOMIX_ENA */
156#define WM8400_ROMIX_ENA 0x0010 /* ROMIX_ENA */
157#define WM8400_ROMIX_ENA_MASK 0x0010 /* ROMIX_ENA */
158#define WM8400_ROMIX_ENA_SHIFT 4 /* ROMIX_ENA */
159#define WM8400_ROMIX_ENA_WIDTH 1 /* ROMIX_ENA */
160#define WM8400_DACL_ENA 0x0002 /* DACL_ENA */
161#define WM8400_DACL_ENA_MASK 0x0002 /* DACL_ENA */
162#define WM8400_DACL_ENA_SHIFT 1 /* DACL_ENA */
163#define WM8400_DACL_ENA_WIDTH 1 /* DACL_ENA */
164#define WM8400_DACR_ENA 0x0001 /* DACR_ENA */
165#define WM8400_DACR_ENA_MASK 0x0001 /* DACR_ENA */
166#define WM8400_DACR_ENA_SHIFT 0 /* DACR_ENA */
167#define WM8400_DACR_ENA_WIDTH 1 /* DACR_ENA */
168
169/*
170 * R5 (0x05) - Audio Interface (1)
171 */
172#define WM8400_AIFADCL_SRC 0x8000 /* AIFADCL_SRC */
173#define WM8400_AIFADCL_SRC_MASK 0x8000 /* AIFADCL_SRC */
174#define WM8400_AIFADCL_SRC_SHIFT 15 /* AIFADCL_SRC */
175#define WM8400_AIFADCL_SRC_WIDTH 1 /* AIFADCL_SRC */
176#define WM8400_AIFADCR_SRC 0x4000 /* AIFADCR_SRC */
177#define WM8400_AIFADCR_SRC_MASK 0x4000 /* AIFADCR_SRC */
178#define WM8400_AIFADCR_SRC_SHIFT 14 /* AIFADCR_SRC */
179#define WM8400_AIFADCR_SRC_WIDTH 1 /* AIFADCR_SRC */
180#define WM8400_AIFADC_TDM 0x2000 /* AIFADC_TDM */
181#define WM8400_AIFADC_TDM_MASK 0x2000 /* AIFADC_TDM */
182#define WM8400_AIFADC_TDM_SHIFT 13 /* AIFADC_TDM */
183#define WM8400_AIFADC_TDM_WIDTH 1 /* AIFADC_TDM */
184#define WM8400_AIFADC_TDM_CHAN 0x1000 /* AIFADC_TDM_CHAN */
185#define WM8400_AIFADC_TDM_CHAN_MASK 0x1000 /* AIFADC_TDM_CHAN */
186#define WM8400_AIFADC_TDM_CHAN_SHIFT 12 /* AIFADC_TDM_CHAN */
187#define WM8400_AIFADC_TDM_CHAN_WIDTH 1 /* AIFADC_TDM_CHAN */
188#define WM8400_AIF_BCLK_INV 0x0100 /* AIF_BCLK_INV */
189#define WM8400_AIF_BCLK_INV_MASK 0x0100 /* AIF_BCLK_INV */
190#define WM8400_AIF_BCLK_INV_SHIFT 8 /* AIF_BCLK_INV */
191#define WM8400_AIF_BCLK_INV_WIDTH 1 /* AIF_BCLK_INV */
192#define WM8400_AIF_LRCLK_INV 0x0080 /* AIF_LRCLK_INV */
193#define WM8400_AIF_LRCLK_INV_MASK 0x0080 /* AIF_LRCLK_INV */
194#define WM8400_AIF_LRCLK_INV_SHIFT 7 /* AIF_LRCLK_INV */
195#define WM8400_AIF_LRCLK_INV_WIDTH 1 /* AIF_LRCLK_INV */
196#define WM8400_AIF_WL_MASK 0x0060 /* AIF_WL - [6:5] */
197#define WM8400_AIF_WL_SHIFT 5 /* AIF_WL - [6:5] */
198#define WM8400_AIF_WL_WIDTH 2 /* AIF_WL - [6:5] */
199#define WM8400_AIF_WL_16BITS (0 << 5)
200#define WM8400_AIF_WL_20BITS (1 << 5)
201#define WM8400_AIF_WL_24BITS (2 << 5)
202#define WM8400_AIF_WL_32BITS (3 << 5)
203#define WM8400_AIF_FMT_MASK 0x0018 /* AIF_FMT - [4:3] */
204#define WM8400_AIF_FMT_SHIFT 3 /* AIF_FMT - [4:3] */
205#define WM8400_AIF_FMT_WIDTH 2 /* AIF_FMT - [4:3] */
206#define WM8400_AIF_FMT_RIGHTJ (0 << 3)
207#define WM8400_AIF_FMT_LEFTJ (1 << 3)
208#define WM8400_AIF_FMT_I2S (2 << 3)
209#define WM8400_AIF_FMT_DSP (3 << 3)
210
211/*
212 * R6 (0x06) - Audio Interface (2)
213 */
214#define WM8400_DACL_SRC 0x8000 /* DACL_SRC */
215#define WM8400_DACL_SRC_MASK 0x8000 /* DACL_SRC */
216#define WM8400_DACL_SRC_SHIFT 15 /* DACL_SRC */
217#define WM8400_DACL_SRC_WIDTH 1 /* DACL_SRC */
218#define WM8400_DACR_SRC 0x4000 /* DACR_SRC */
219#define WM8400_DACR_SRC_MASK 0x4000 /* DACR_SRC */
220#define WM8400_DACR_SRC_SHIFT 14 /* DACR_SRC */
221#define WM8400_DACR_SRC_WIDTH 1 /* DACR_SRC */
222#define WM8400_AIFDAC_TDM 0x2000 /* AIFDAC_TDM */
223#define WM8400_AIFDAC_TDM_MASK 0x2000 /* AIFDAC_TDM */
224#define WM8400_AIFDAC_TDM_SHIFT 13 /* AIFDAC_TDM */
225#define WM8400_AIFDAC_TDM_WIDTH 1 /* AIFDAC_TDM */
226#define WM8400_AIFDAC_TDM_CHAN 0x1000 /* AIFDAC_TDM_CHAN */
227#define WM8400_AIFDAC_TDM_CHAN_MASK 0x1000 /* AIFDAC_TDM_CHAN */
228#define WM8400_AIFDAC_TDM_CHAN_SHIFT 12 /* AIFDAC_TDM_CHAN */
229#define WM8400_AIFDAC_TDM_CHAN_WIDTH 1 /* AIFDAC_TDM_CHAN */
230#define WM8400_DAC_BOOST_MASK 0x0C00 /* DAC_BOOST - [11:10] */
231#define WM8400_DAC_BOOST_SHIFT 10 /* DAC_BOOST - [11:10] */
232#define WM8400_DAC_BOOST_WIDTH 2 /* DAC_BOOST - [11:10] */
233#define WM8400_DAC_COMP 0x0010 /* DAC_COMP */
234#define WM8400_DAC_COMP_MASK 0x0010 /* DAC_COMP */
235#define WM8400_DAC_COMP_SHIFT 4 /* DAC_COMP */
236#define WM8400_DAC_COMP_WIDTH 1 /* DAC_COMP */
237#define WM8400_DAC_COMPMODE 0x0008 /* DAC_COMPMODE */
238#define WM8400_DAC_COMPMODE_MASK 0x0008 /* DAC_COMPMODE */
239#define WM8400_DAC_COMPMODE_SHIFT 3 /* DAC_COMPMODE */
240#define WM8400_DAC_COMPMODE_WIDTH 1 /* DAC_COMPMODE */
241#define WM8400_ADC_COMP 0x0004 /* ADC_COMP */
242#define WM8400_ADC_COMP_MASK 0x0004 /* ADC_COMP */
243#define WM8400_ADC_COMP_SHIFT 2 /* ADC_COMP */
244#define WM8400_ADC_COMP_WIDTH 1 /* ADC_COMP */
245#define WM8400_ADC_COMPMODE 0x0002 /* ADC_COMPMODE */
246#define WM8400_ADC_COMPMODE_MASK 0x0002 /* ADC_COMPMODE */
247#define WM8400_ADC_COMPMODE_SHIFT 1 /* ADC_COMPMODE */
248#define WM8400_ADC_COMPMODE_WIDTH 1 /* ADC_COMPMODE */
249#define WM8400_LOOPBACK 0x0001 /* LOOPBACK */
250#define WM8400_LOOPBACK_MASK 0x0001 /* LOOPBACK */
251#define WM8400_LOOPBACK_SHIFT 0 /* LOOPBACK */
252#define WM8400_LOOPBACK_WIDTH 1 /* LOOPBACK */
253
254/*
255 * R7 (0x07) - Clocking (1)
256 */
257#define WM8400_TOCLK_RATE 0x8000 /* TOCLK_RATE */
258#define WM8400_TOCLK_RATE_MASK 0x8000 /* TOCLK_RATE */
259#define WM8400_TOCLK_RATE_SHIFT 15 /* TOCLK_RATE */
260#define WM8400_TOCLK_RATE_WIDTH 1 /* TOCLK_RATE */
261#define WM8400_TOCLK_ENA 0x4000 /* TOCLK_ENA */
262#define WM8400_TOCLK_ENA_MASK 0x4000 /* TOCLK_ENA */
263#define WM8400_TOCLK_ENA_SHIFT 14 /* TOCLK_ENA */
264#define WM8400_TOCLK_ENA_WIDTH 1 /* TOCLK_ENA */
265#define WM8400_OPCLKDIV_MASK 0x1E00 /* OPCLKDIV - [12:9] */
266#define WM8400_OPCLKDIV_SHIFT 9 /* OPCLKDIV - [12:9] */
267#define WM8400_OPCLKDIV_WIDTH 4 /* OPCLKDIV - [12:9] */
268#define WM8400_DCLKDIV_MASK 0x01C0 /* DCLKDIV - [8:6] */
269#define WM8400_DCLKDIV_SHIFT 6 /* DCLKDIV - [8:6] */
270#define WM8400_DCLKDIV_WIDTH 3 /* DCLKDIV - [8:6] */
271#define WM8400_BCLK_DIV_MASK 0x001E /* BCLK_DIV - [4:1] */
272#define WM8400_BCLK_DIV_SHIFT 1 /* BCLK_DIV - [4:1] */
273#define WM8400_BCLK_DIV_WIDTH 4 /* BCLK_DIV - [4:1] */
274
275/*
276 * R8 (0x08) - Clocking (2)
277 */
278#define WM8400_MCLK_SRC 0x8000 /* MCLK_SRC */
279#define WM8400_MCLK_SRC_MASK 0x8000 /* MCLK_SRC */
280#define WM8400_MCLK_SRC_SHIFT 15 /* MCLK_SRC */
281#define WM8400_MCLK_SRC_WIDTH 1 /* MCLK_SRC */
282#define WM8400_SYSCLK_SRC 0x4000 /* SYSCLK_SRC */
283#define WM8400_SYSCLK_SRC_MASK 0x4000 /* SYSCLK_SRC */
284#define WM8400_SYSCLK_SRC_SHIFT 14 /* SYSCLK_SRC */
285#define WM8400_SYSCLK_SRC_WIDTH 1 /* SYSCLK_SRC */
286#define WM8400_CLK_FORCE 0x2000 /* CLK_FORCE */
287#define WM8400_CLK_FORCE_MASK 0x2000 /* CLK_FORCE */
288#define WM8400_CLK_FORCE_SHIFT 13 /* CLK_FORCE */
289#define WM8400_CLK_FORCE_WIDTH 1 /* CLK_FORCE */
290#define WM8400_MCLK_DIV_MASK 0x1800 /* MCLK_DIV - [12:11] */
291#define WM8400_MCLK_DIV_SHIFT 11 /* MCLK_DIV - [12:11] */
292#define WM8400_MCLK_DIV_WIDTH 2 /* MCLK_DIV - [12:11] */
293#define WM8400_MCLK_INV 0x0400 /* MCLK_INV */
294#define WM8400_MCLK_INV_MASK 0x0400 /* MCLK_INV */
295#define WM8400_MCLK_INV_SHIFT 10 /* MCLK_INV */
296#define WM8400_MCLK_INV_WIDTH 1 /* MCLK_INV */
297#define WM8400_ADC_CLKDIV_MASK 0x00E0 /* ADC_CLKDIV - [7:5] */
298#define WM8400_ADC_CLKDIV_SHIFT 5 /* ADC_CLKDIV - [7:5] */
299#define WM8400_ADC_CLKDIV_WIDTH 3 /* ADC_CLKDIV - [7:5] */
300#define WM8400_DAC_CLKDIV_MASK 0x001C /* DAC_CLKDIV - [4:2] */
301#define WM8400_DAC_CLKDIV_SHIFT 2 /* DAC_CLKDIV - [4:2] */
302#define WM8400_DAC_CLKDIV_WIDTH 3 /* DAC_CLKDIV - [4:2] */
303
304/*
305 * R9 (0x09) - Audio Interface (3)
306 */
307#define WM8400_AIF_MSTR1 0x8000 /* AIF_MSTR1 */
308#define WM8400_AIF_MSTR1_MASK 0x8000 /* AIF_MSTR1 */
309#define WM8400_AIF_MSTR1_SHIFT 15 /* AIF_MSTR1 */
310#define WM8400_AIF_MSTR1_WIDTH 1 /* AIF_MSTR1 */
311#define WM8400_AIF_MSTR2 0x4000 /* AIF_MSTR2 */
312#define WM8400_AIF_MSTR2_MASK 0x4000 /* AIF_MSTR2 */
313#define WM8400_AIF_MSTR2_SHIFT 14 /* AIF_MSTR2 */
314#define WM8400_AIF_MSTR2_WIDTH 1 /* AIF_MSTR2 */
315#define WM8400_AIF_SEL 0x2000 /* AIF_SEL */
316#define WM8400_AIF_SEL_MASK 0x2000 /* AIF_SEL */
317#define WM8400_AIF_SEL_SHIFT 13 /* AIF_SEL */
318#define WM8400_AIF_SEL_WIDTH 1 /* AIF_SEL */
319#define WM8400_ADCLRC_DIR 0x0800 /* ADCLRC_DIR */
320#define WM8400_ADCLRC_DIR_MASK 0x0800 /* ADCLRC_DIR */
321#define WM8400_ADCLRC_DIR_SHIFT 11 /* ADCLRC_DIR */
322#define WM8400_ADCLRC_DIR_WIDTH 1 /* ADCLRC_DIR */
323#define WM8400_ADCLRC_RATE_MASK 0x07FF /* ADCLRC_RATE - [10:0] */
324#define WM8400_ADCLRC_RATE_SHIFT 0 /* ADCLRC_RATE - [10:0] */
325#define WM8400_ADCLRC_RATE_WIDTH 11 /* ADCLRC_RATE - [10:0] */
326
327/*
328 * R10 (0x0A) - Audio Interface (4)
329 */
330#define WM8400_ALRCGPIO1 0x8000 /* ALRCGPIO1 */
331#define WM8400_ALRCGPIO1_MASK 0x8000 /* ALRCGPIO1 */
332#define WM8400_ALRCGPIO1_SHIFT 15 /* ALRCGPIO1 */
333#define WM8400_ALRCGPIO1_WIDTH 1 /* ALRCGPIO1 */
334#define WM8400_ALRCBGPIO6 0x4000 /* ALRCBGPIO6 */
335#define WM8400_ALRCBGPIO6_MASK 0x4000 /* ALRCBGPIO6 */
336#define WM8400_ALRCBGPIO6_SHIFT 14 /* ALRCBGPIO6 */
337#define WM8400_ALRCBGPIO6_WIDTH 1 /* ALRCBGPIO6 */
338#define WM8400_AIF_TRIS 0x2000 /* AIF_TRIS */
339#define WM8400_AIF_TRIS_MASK 0x2000 /* AIF_TRIS */
340#define WM8400_AIF_TRIS_SHIFT 13 /* AIF_TRIS */
341#define WM8400_AIF_TRIS_WIDTH 1 /* AIF_TRIS */
342#define WM8400_DACLRC_DIR 0x0800 /* DACLRC_DIR */
343#define WM8400_DACLRC_DIR_MASK 0x0800 /* DACLRC_DIR */
344#define WM8400_DACLRC_DIR_SHIFT 11 /* DACLRC_DIR */
345#define WM8400_DACLRC_DIR_WIDTH 1 /* DACLRC_DIR */
346#define WM8400_DACLRC_RATE_MASK 0x07FF /* DACLRC_RATE - [10:0] */
347#define WM8400_DACLRC_RATE_SHIFT 0 /* DACLRC_RATE - [10:0] */
348#define WM8400_DACLRC_RATE_WIDTH 11 /* DACLRC_RATE - [10:0] */
349
350/*
351 * R11 (0x0B) - DAC CTRL
352 */
353#define WM8400_DAC_SDMCLK_RATE 0x2000 /* DAC_SDMCLK_RATE */
354#define WM8400_DAC_SDMCLK_RATE_MASK 0x2000 /* DAC_SDMCLK_RATE */
355#define WM8400_DAC_SDMCLK_RATE_SHIFT 13 /* DAC_SDMCLK_RATE */
356#define WM8400_DAC_SDMCLK_RATE_WIDTH 1 /* DAC_SDMCLK_RATE */
357#define WM8400_AIF_LRCLKRATE 0x0400 /* AIF_LRCLKRATE */
358#define WM8400_AIF_LRCLKRATE_MASK 0x0400 /* AIF_LRCLKRATE */
359#define WM8400_AIF_LRCLKRATE_SHIFT 10 /* AIF_LRCLKRATE */
360#define WM8400_AIF_LRCLKRATE_WIDTH 1 /* AIF_LRCLKRATE */
361#define WM8400_DAC_MONO 0x0200 /* DAC_MONO */
362#define WM8400_DAC_MONO_MASK 0x0200 /* DAC_MONO */
363#define WM8400_DAC_MONO_SHIFT 9 /* DAC_MONO */
364#define WM8400_DAC_MONO_WIDTH 1 /* DAC_MONO */
365#define WM8400_DAC_SB_FILT 0x0100 /* DAC_SB_FILT */
366#define WM8400_DAC_SB_FILT_MASK 0x0100 /* DAC_SB_FILT */
367#define WM8400_DAC_SB_FILT_SHIFT 8 /* DAC_SB_FILT */
368#define WM8400_DAC_SB_FILT_WIDTH 1 /* DAC_SB_FILT */
369#define WM8400_DAC_MUTERATE 0x0080 /* DAC_MUTERATE */
370#define WM8400_DAC_MUTERATE_MASK 0x0080 /* DAC_MUTERATE */
371#define WM8400_DAC_MUTERATE_SHIFT 7 /* DAC_MUTERATE */
372#define WM8400_DAC_MUTERATE_WIDTH 1 /* DAC_MUTERATE */
373#define WM8400_DAC_MUTEMODE 0x0040 /* DAC_MUTEMODE */
374#define WM8400_DAC_MUTEMODE_MASK 0x0040 /* DAC_MUTEMODE */
375#define WM8400_DAC_MUTEMODE_SHIFT 6 /* DAC_MUTEMODE */
376#define WM8400_DAC_MUTEMODE_WIDTH 1 /* DAC_MUTEMODE */
377#define WM8400_DEEMP_MASK 0x0030 /* DEEMP - [5:4] */
378#define WM8400_DEEMP_SHIFT 4 /* DEEMP - [5:4] */
379#define WM8400_DEEMP_WIDTH 2 /* DEEMP - [5:4] */
380#define WM8400_DAC_MUTE 0x0004 /* DAC_MUTE */
381#define WM8400_DAC_MUTE_MASK 0x0004 /* DAC_MUTE */
382#define WM8400_DAC_MUTE_SHIFT 2 /* DAC_MUTE */
383#define WM8400_DAC_MUTE_WIDTH 1 /* DAC_MUTE */
384#define WM8400_DACL_DATINV 0x0002 /* DACL_DATINV */
385#define WM8400_DACL_DATINV_MASK 0x0002 /* DACL_DATINV */
386#define WM8400_DACL_DATINV_SHIFT 1 /* DACL_DATINV */
387#define WM8400_DACL_DATINV_WIDTH 1 /* DACL_DATINV */
388#define WM8400_DACR_DATINV 0x0001 /* DACR_DATINV */
389#define WM8400_DACR_DATINV_MASK 0x0001 /* DACR_DATINV */
390#define WM8400_DACR_DATINV_SHIFT 0 /* DACR_DATINV */
391#define WM8400_DACR_DATINV_WIDTH 1 /* DACR_DATINV */
392
393/*
394 * R12 (0x0C) - Left DAC Digital Volume
395 */
396#define WM8400_DAC_VU 0x0100 /* DAC_VU */
397#define WM8400_DAC_VU_MASK 0x0100 /* DAC_VU */
398#define WM8400_DAC_VU_SHIFT 8 /* DAC_VU */
399#define WM8400_DAC_VU_WIDTH 1 /* DAC_VU */
400#define WM8400_DACL_VOL_MASK 0x00FF /* DACL_VOL - [7:0] */
401#define WM8400_DACL_VOL_SHIFT 0 /* DACL_VOL - [7:0] */
402#define WM8400_DACL_VOL_WIDTH 8 /* DACL_VOL - [7:0] */
403
404/*
405 * R13 (0x0D) - Right DAC Digital Volume
406 */
407#define WM8400_DAC_VU 0x0100 /* DAC_VU */
408#define WM8400_DAC_VU_MASK 0x0100 /* DAC_VU */
409#define WM8400_DAC_VU_SHIFT 8 /* DAC_VU */
410#define WM8400_DAC_VU_WIDTH 1 /* DAC_VU */
411#define WM8400_DACR_VOL_MASK 0x00FF /* DACR_VOL - [7:0] */
412#define WM8400_DACR_VOL_SHIFT 0 /* DACR_VOL - [7:0] */
413#define WM8400_DACR_VOL_WIDTH 8 /* DACR_VOL - [7:0] */
414
415/*
416 * R14 (0x0E) - Digital Side Tone
417 */
418#define WM8400_ADCL_DAC_SVOL_MASK 0x1E00 /* ADCL_DAC_SVOL - [12:9] */
419#define WM8400_ADCL_DAC_SVOL_SHIFT 9 /* ADCL_DAC_SVOL - [12:9] */
420#define WM8400_ADCL_DAC_SVOL_WIDTH 4 /* ADCL_DAC_SVOL - [12:9] */
421#define WM8400_ADCR_DAC_SVOL_MASK 0x01E0 /* ADCR_DAC_SVOL - [8:5] */
422#define WM8400_ADCR_DAC_SVOL_SHIFT 5 /* ADCR_DAC_SVOL - [8:5] */
423#define WM8400_ADCR_DAC_SVOL_WIDTH 4 /* ADCR_DAC_SVOL - [8:5] */
424#define WM8400_ADC_TO_DACL_MASK 0x000C /* ADC_TO_DACL - [3:2] */
425#define WM8400_ADC_TO_DACL_SHIFT 2 /* ADC_TO_DACL - [3:2] */
426#define WM8400_ADC_TO_DACL_WIDTH 2 /* ADC_TO_DACL - [3:2] */
427#define WM8400_ADC_TO_DACR_MASK 0x0003 /* ADC_TO_DACR - [1:0] */
428#define WM8400_ADC_TO_DACR_SHIFT 0 /* ADC_TO_DACR - [1:0] */
429#define WM8400_ADC_TO_DACR_WIDTH 2 /* ADC_TO_DACR - [1:0] */
430
431/*
432 * R15 (0x0F) - ADC CTRL
433 */
434#define WM8400_ADC_HPF_ENA 0x0100 /* ADC_HPF_ENA */
435#define WM8400_ADC_HPF_ENA_MASK 0x0100 /* ADC_HPF_ENA */
436#define WM8400_ADC_HPF_ENA_SHIFT 8 /* ADC_HPF_ENA */
437#define WM8400_ADC_HPF_ENA_WIDTH 1 /* ADC_HPF_ENA */
438#define WM8400_ADC_HPF_CUT_MASK 0x0060 /* ADC_HPF_CUT - [6:5] */
439#define WM8400_ADC_HPF_CUT_SHIFT 5 /* ADC_HPF_CUT - [6:5] */
440#define WM8400_ADC_HPF_CUT_WIDTH 2 /* ADC_HPF_CUT - [6:5] */
441#define WM8400_ADCL_DATINV 0x0002 /* ADCL_DATINV */
442#define WM8400_ADCL_DATINV_MASK 0x0002 /* ADCL_DATINV */
443#define WM8400_ADCL_DATINV_SHIFT 1 /* ADCL_DATINV */
444#define WM8400_ADCL_DATINV_WIDTH 1 /* ADCL_DATINV */
445#define WM8400_ADCR_DATINV 0x0001 /* ADCR_DATINV */
446#define WM8400_ADCR_DATINV_MASK 0x0001 /* ADCR_DATINV */
447#define WM8400_ADCR_DATINV_SHIFT 0 /* ADCR_DATINV */
448#define WM8400_ADCR_DATINV_WIDTH 1 /* ADCR_DATINV */
449
450/*
451 * R16 (0x10) - Left ADC Digital Volume
452 */
453#define WM8400_ADC_VU 0x0100 /* ADC_VU */
454#define WM8400_ADC_VU_MASK 0x0100 /* ADC_VU */
455#define WM8400_ADC_VU_SHIFT 8 /* ADC_VU */
456#define WM8400_ADC_VU_WIDTH 1 /* ADC_VU */
457#define WM8400_ADCL_VOL_MASK 0x00FF /* ADCL_VOL - [7:0] */
458#define WM8400_ADCL_VOL_SHIFT 0 /* ADCL_VOL - [7:0] */
459#define WM8400_ADCL_VOL_WIDTH 8 /* ADCL_VOL - [7:0] */
460
461/*
462 * R17 (0x11) - Right ADC Digital Volume
463 */
464#define WM8400_ADC_VU 0x0100 /* ADC_VU */
465#define WM8400_ADC_VU_MASK 0x0100 /* ADC_VU */
466#define WM8400_ADC_VU_SHIFT 8 /* ADC_VU */
467#define WM8400_ADC_VU_WIDTH 1 /* ADC_VU */
468#define WM8400_ADCR_VOL_MASK 0x00FF /* ADCR_VOL - [7:0] */
469#define WM8400_ADCR_VOL_SHIFT 0 /* ADCR_VOL - [7:0] */
470#define WM8400_ADCR_VOL_WIDTH 8 /* ADCR_VOL - [7:0] */
471
472/*
473 * R24 (0x18) - Left Line Input 1&2 Volume
474 */
475#define WM8400_IPVU 0x0100 /* IPVU */
476#define WM8400_IPVU_MASK 0x0100 /* IPVU */
477#define WM8400_IPVU_SHIFT 8 /* IPVU */
478#define WM8400_IPVU_WIDTH 1 /* IPVU */
479#define WM8400_LI12MUTE 0x0080 /* LI12MUTE */
480#define WM8400_LI12MUTE_MASK 0x0080 /* LI12MUTE */
481#define WM8400_LI12MUTE_SHIFT 7 /* LI12MUTE */
482#define WM8400_LI12MUTE_WIDTH 1 /* LI12MUTE */
483#define WM8400_LI12ZC 0x0040 /* LI12ZC */
484#define WM8400_LI12ZC_MASK 0x0040 /* LI12ZC */
485#define WM8400_LI12ZC_SHIFT 6 /* LI12ZC */
486#define WM8400_LI12ZC_WIDTH 1 /* LI12ZC */
487#define WM8400_LIN12VOL_MASK 0x001F /* LIN12VOL - [4:0] */
488#define WM8400_LIN12VOL_SHIFT 0 /* LIN12VOL - [4:0] */
489#define WM8400_LIN12VOL_WIDTH 5 /* LIN12VOL - [4:0] */
490
491/*
492 * R25 (0x19) - Left Line Input 3&4 Volume
493 */
494#define WM8400_IPVU 0x0100 /* IPVU */
495#define WM8400_IPVU_MASK 0x0100 /* IPVU */
496#define WM8400_IPVU_SHIFT 8 /* IPVU */
497#define WM8400_IPVU_WIDTH 1 /* IPVU */
498#define WM8400_LI34MUTE 0x0080 /* LI34MUTE */
499#define WM8400_LI34MUTE_MASK 0x0080 /* LI34MUTE */
500#define WM8400_LI34MUTE_SHIFT 7 /* LI34MUTE */
501#define WM8400_LI34MUTE_WIDTH 1 /* LI34MUTE */
502#define WM8400_LI34ZC 0x0040 /* LI34ZC */
503#define WM8400_LI34ZC_MASK 0x0040 /* LI34ZC */
504#define WM8400_LI34ZC_SHIFT 6 /* LI34ZC */
505#define WM8400_LI34ZC_WIDTH 1 /* LI34ZC */
506#define WM8400_LIN34VOL_MASK 0x001F /* LIN34VOL - [4:0] */
507#define WM8400_LIN34VOL_SHIFT 0 /* LIN34VOL - [4:0] */
508#define WM8400_LIN34VOL_WIDTH 5 /* LIN34VOL - [4:0] */
509
510/*
511 * R26 (0x1A) - Right Line Input 1&2 Volume
512 */
513#define WM8400_IPVU 0x0100 /* IPVU */
514#define WM8400_IPVU_MASK 0x0100 /* IPVU */
515#define WM8400_IPVU_SHIFT 8 /* IPVU */
516#define WM8400_IPVU_WIDTH 1 /* IPVU */
517#define WM8400_RI12MUTE 0x0080 /* RI12MUTE */
518#define WM8400_RI12MUTE_MASK 0x0080 /* RI12MUTE */
519#define WM8400_RI12MUTE_SHIFT 7 /* RI12MUTE */
520#define WM8400_RI12MUTE_WIDTH 1 /* RI12MUTE */
521#define WM8400_RI12ZC 0x0040 /* RI12ZC */
522#define WM8400_RI12ZC_MASK 0x0040 /* RI12ZC */
523#define WM8400_RI12ZC_SHIFT 6 /* RI12ZC */
524#define WM8400_RI12ZC_WIDTH 1 /* RI12ZC */
525#define WM8400_RIN12VOL_MASK 0x001F /* RIN12VOL - [4:0] */
526#define WM8400_RIN12VOL_SHIFT 0 /* RIN12VOL - [4:0] */
527#define WM8400_RIN12VOL_WIDTH 5 /* RIN12VOL - [4:0] */
528
529/*
530 * R27 (0x1B) - Right Line Input 3&4 Volume
531 */
532#define WM8400_IPVU 0x0100 /* IPVU */
533#define WM8400_IPVU_MASK 0x0100 /* IPVU */
534#define WM8400_IPVU_SHIFT 8 /* IPVU */
535#define WM8400_IPVU_WIDTH 1 /* IPVU */
536#define WM8400_RI34MUTE 0x0080 /* RI34MUTE */
537#define WM8400_RI34MUTE_MASK 0x0080 /* RI34MUTE */
538#define WM8400_RI34MUTE_SHIFT 7 /* RI34MUTE */
539#define WM8400_RI34MUTE_WIDTH 1 /* RI34MUTE */
540#define WM8400_RI34ZC 0x0040 /* RI34ZC */
541#define WM8400_RI34ZC_MASK 0x0040 /* RI34ZC */
542#define WM8400_RI34ZC_SHIFT 6 /* RI34ZC */
543#define WM8400_RI34ZC_WIDTH 1 /* RI34ZC */
544#define WM8400_RIN34VOL_MASK 0x001F /* RIN34VOL - [4:0] */
545#define WM8400_RIN34VOL_SHIFT 0 /* RIN34VOL - [4:0] */
546#define WM8400_RIN34VOL_WIDTH 5 /* RIN34VOL - [4:0] */
547
548/*
549 * R28 (0x1C) - Left Output Volume
550 */
551#define WM8400_OPVU 0x0100 /* OPVU */
552#define WM8400_OPVU_MASK 0x0100 /* OPVU */
553#define WM8400_OPVU_SHIFT 8 /* OPVU */
554#define WM8400_OPVU_WIDTH 1 /* OPVU */
555#define WM8400_LOZC 0x0080 /* LOZC */
556#define WM8400_LOZC_MASK 0x0080 /* LOZC */
557#define WM8400_LOZC_SHIFT 7 /* LOZC */
558#define WM8400_LOZC_WIDTH 1 /* LOZC */
559#define WM8400_LOUTVOL_MASK 0x007F /* LOUTVOL - [6:0] */
560#define WM8400_LOUTVOL_SHIFT 0 /* LOUTVOL - [6:0] */
561#define WM8400_LOUTVOL_WIDTH 7 /* LOUTVOL - [6:0] */
562
563/*
564 * R29 (0x1D) - Right Output Volume
565 */
566#define WM8400_OPVU 0x0100 /* OPVU */
567#define WM8400_OPVU_MASK 0x0100 /* OPVU */
568#define WM8400_OPVU_SHIFT 8 /* OPVU */
569#define WM8400_OPVU_WIDTH 1 /* OPVU */
570#define WM8400_ROZC 0x0080 /* ROZC */
571#define WM8400_ROZC_MASK 0x0080 /* ROZC */
572#define WM8400_ROZC_SHIFT 7 /* ROZC */
573#define WM8400_ROZC_WIDTH 1 /* ROZC */
574#define WM8400_ROUTVOL_MASK 0x007F /* ROUTVOL - [6:0] */
575#define WM8400_ROUTVOL_SHIFT 0 /* ROUTVOL - [6:0] */
576#define WM8400_ROUTVOL_WIDTH 7 /* ROUTVOL - [6:0] */
577
578/*
579 * R30 (0x1E) - Line Outputs Volume
580 */
581#define WM8400_LONMUTE 0x0040 /* LONMUTE */
582#define WM8400_LONMUTE_MASK 0x0040 /* LONMUTE */
583#define WM8400_LONMUTE_SHIFT 6 /* LONMUTE */
584#define WM8400_LONMUTE_WIDTH 1 /* LONMUTE */
585#define WM8400_LOPMUTE 0x0020 /* LOPMUTE */
586#define WM8400_LOPMUTE_MASK 0x0020 /* LOPMUTE */
587#define WM8400_LOPMUTE_SHIFT 5 /* LOPMUTE */
588#define WM8400_LOPMUTE_WIDTH 1 /* LOPMUTE */
589#define WM8400_LOATTN 0x0010 /* LOATTN */
590#define WM8400_LOATTN_MASK 0x0010 /* LOATTN */
591#define WM8400_LOATTN_SHIFT 4 /* LOATTN */
592#define WM8400_LOATTN_WIDTH 1 /* LOATTN */
593#define WM8400_RONMUTE 0x0004 /* RONMUTE */
594#define WM8400_RONMUTE_MASK 0x0004 /* RONMUTE */
595#define WM8400_RONMUTE_SHIFT 2 /* RONMUTE */
596#define WM8400_RONMUTE_WIDTH 1 /* RONMUTE */
597#define WM8400_ROPMUTE 0x0002 /* ROPMUTE */
598#define WM8400_ROPMUTE_MASK 0x0002 /* ROPMUTE */
599#define WM8400_ROPMUTE_SHIFT 1 /* ROPMUTE */
600#define WM8400_ROPMUTE_WIDTH 1 /* ROPMUTE */
601#define WM8400_ROATTN 0x0001 /* ROATTN */
602#define WM8400_ROATTN_MASK 0x0001 /* ROATTN */
603#define WM8400_ROATTN_SHIFT 0 /* ROATTN */
604#define WM8400_ROATTN_WIDTH 1 /* ROATTN */
605
606/*
607 * R31 (0x1F) - Out3/4 Volume
608 */
609#define WM8400_OUT3MUTE 0x0020 /* OUT3MUTE */
610#define WM8400_OUT3MUTE_MASK 0x0020 /* OUT3MUTE */
611#define WM8400_OUT3MUTE_SHIFT 5 /* OUT3MUTE */
612#define WM8400_OUT3MUTE_WIDTH 1 /* OUT3MUTE */
613#define WM8400_OUT3ATTN 0x0010 /* OUT3ATTN */
614#define WM8400_OUT3ATTN_MASK 0x0010 /* OUT3ATTN */
615#define WM8400_OUT3ATTN_SHIFT 4 /* OUT3ATTN */
616#define WM8400_OUT3ATTN_WIDTH 1 /* OUT3ATTN */
617#define WM8400_OUT4MUTE 0x0002 /* OUT4MUTE */
618#define WM8400_OUT4MUTE_MASK 0x0002 /* OUT4MUTE */
619#define WM8400_OUT4MUTE_SHIFT 1 /* OUT4MUTE */
620#define WM8400_OUT4MUTE_WIDTH 1 /* OUT4MUTE */
621#define WM8400_OUT4ATTN 0x0001 /* OUT4ATTN */
622#define WM8400_OUT4ATTN_MASK 0x0001 /* OUT4ATTN */
623#define WM8400_OUT4ATTN_SHIFT 0 /* OUT4ATTN */
624#define WM8400_OUT4ATTN_WIDTH 1 /* OUT4ATTN */
625
626/*
627 * R32 (0x20) - Left OPGA Volume
628 */
629#define WM8400_OPVU 0x0100 /* OPVU */
630#define WM8400_OPVU_MASK 0x0100 /* OPVU */
631#define WM8400_OPVU_SHIFT 8 /* OPVU */
632#define WM8400_OPVU_WIDTH 1 /* OPVU */
633#define WM8400_LOPGAZC 0x0080 /* LOPGAZC */
634#define WM8400_LOPGAZC_MASK 0x0080 /* LOPGAZC */
635#define WM8400_LOPGAZC_SHIFT 7 /* LOPGAZC */
636#define WM8400_LOPGAZC_WIDTH 1 /* LOPGAZC */
637#define WM8400_LOPGAVOL_MASK 0x007F /* LOPGAVOL - [6:0] */
638#define WM8400_LOPGAVOL_SHIFT 0 /* LOPGAVOL - [6:0] */
639#define WM8400_LOPGAVOL_WIDTH 7 /* LOPGAVOL - [6:0] */
640
641/*
642 * R33 (0x21) - Right OPGA Volume
643 */
644#define WM8400_OPVU 0x0100 /* OPVU */
645#define WM8400_OPVU_MASK 0x0100 /* OPVU */
646#define WM8400_OPVU_SHIFT 8 /* OPVU */
647#define WM8400_OPVU_WIDTH 1 /* OPVU */
648#define WM8400_ROPGAZC 0x0080 /* ROPGAZC */
649#define WM8400_ROPGAZC_MASK 0x0080 /* ROPGAZC */
650#define WM8400_ROPGAZC_SHIFT 7 /* ROPGAZC */
651#define WM8400_ROPGAZC_WIDTH 1 /* ROPGAZC */
652#define WM8400_ROPGAVOL_MASK 0x007F /* ROPGAVOL - [6:0] */
653#define WM8400_ROPGAVOL_SHIFT 0 /* ROPGAVOL - [6:0] */
654#define WM8400_ROPGAVOL_WIDTH 7 /* ROPGAVOL - [6:0] */
655
656/*
657 * R34 (0x22) - Speaker Volume
658 */
659#define WM8400_SPKATTN_MASK 0x0003 /* SPKATTN - [1:0] */
660#define WM8400_SPKATTN_SHIFT 0 /* SPKATTN - [1:0] */
661#define WM8400_SPKATTN_WIDTH 2 /* SPKATTN - [1:0] */
662
663/*
664 * R35 (0x23) - ClassD1
665 */
666#define WM8400_CDMODE 0x0100 /* CDMODE */
667#define WM8400_CDMODE_MASK 0x0100 /* CDMODE */
668#define WM8400_CDMODE_SHIFT 8 /* CDMODE */
669#define WM8400_CDMODE_WIDTH 1 /* CDMODE */
670#define WM8400_CLASSD_CLK_SEL 0x0080 /* CLASSD_CLK_SEL */
671#define WM8400_CLASSD_CLK_SEL_MASK 0x0080 /* CLASSD_CLK_SEL */
672#define WM8400_CLASSD_CLK_SEL_SHIFT 7 /* CLASSD_CLK_SEL */
673#define WM8400_CLASSD_CLK_SEL_WIDTH 1 /* CLASSD_CLK_SEL */
674#define WM8400_CD_SRCTRL 0x0040 /* CD_SRCTRL */
675#define WM8400_CD_SRCTRL_MASK 0x0040 /* CD_SRCTRL */
676#define WM8400_CD_SRCTRL_SHIFT 6 /* CD_SRCTRL */
677#define WM8400_CD_SRCTRL_WIDTH 1 /* CD_SRCTRL */
678#define WM8400_SPKNOPOP 0x0020 /* SPKNOPOP */
679#define WM8400_SPKNOPOP_MASK 0x0020 /* SPKNOPOP */
680#define WM8400_SPKNOPOP_SHIFT 5 /* SPKNOPOP */
681#define WM8400_SPKNOPOP_WIDTH 1 /* SPKNOPOP */
682#define WM8400_DBLERATE 0x0010 /* DBLERATE */
683#define WM8400_DBLERATE_MASK 0x0010 /* DBLERATE */
684#define WM8400_DBLERATE_SHIFT 4 /* DBLERATE */
685#define WM8400_DBLERATE_WIDTH 1 /* DBLERATE */
686#define WM8400_LOOPTEST 0x0008 /* LOOPTEST */
687#define WM8400_LOOPTEST_MASK 0x0008 /* LOOPTEST */
688#define WM8400_LOOPTEST_SHIFT 3 /* LOOPTEST */
689#define WM8400_LOOPTEST_WIDTH 1 /* LOOPTEST */
690#define WM8400_HALFABBIAS 0x0004 /* HALFABBIAS */
691#define WM8400_HALFABBIAS_MASK 0x0004 /* HALFABBIAS */
692#define WM8400_HALFABBIAS_SHIFT 2 /* HALFABBIAS */
693#define WM8400_HALFABBIAS_WIDTH 1 /* HALFABBIAS */
694#define WM8400_TRIDEL_MASK 0x0003 /* TRIDEL - [1:0] */
695#define WM8400_TRIDEL_SHIFT 0 /* TRIDEL - [1:0] */
696#define WM8400_TRIDEL_WIDTH 2 /* TRIDEL - [1:0] */
697
698/*
699 * R37 (0x25) - ClassD3
700 */
701#define WM8400_DCGAIN_MASK 0x0038 /* DCGAIN - [5:3] */
702#define WM8400_DCGAIN_SHIFT 3 /* DCGAIN - [5:3] */
703#define WM8400_DCGAIN_WIDTH 3 /* DCGAIN - [5:3] */
704#define WM8400_ACGAIN_MASK 0x0007 /* ACGAIN - [2:0] */
705#define WM8400_ACGAIN_SHIFT 0 /* ACGAIN - [2:0] */
706#define WM8400_ACGAIN_WIDTH 3 /* ACGAIN - [2:0] */
707
708/*
709 * R39 (0x27) - Input Mixer1
710 */
711#define WM8400_AINLMODE_MASK 0x000C /* AINLMODE - [3:2] */
712#define WM8400_AINLMODE_SHIFT 2 /* AINLMODE - [3:2] */
713#define WM8400_AINLMODE_WIDTH 2 /* AINLMODE - [3:2] */
714#define WM8400_AINRMODE_MASK 0x0003 /* AINRMODE - [1:0] */
715#define WM8400_AINRMODE_SHIFT 0 /* AINRMODE - [1:0] */
716#define WM8400_AINRMODE_WIDTH 2 /* AINRMODE - [1:0] */
717
718/*
719 * R40 (0x28) - Input Mixer2
720 */
721#define WM8400_LMP4 0x0080 /* LMP4 */
722#define WM8400_LMP4_MASK 0x0080 /* LMP4 */
723#define WM8400_LMP4_SHIFT 7 /* LMP4 */
724#define WM8400_LMP4_WIDTH 1 /* LMP4 */
725#define WM8400_LMN3 0x0040 /* LMN3 */
726#define WM8400_LMN3_MASK 0x0040 /* LMN3 */
727#define WM8400_LMN3_SHIFT 6 /* LMN3 */
728#define WM8400_LMN3_WIDTH 1 /* LMN3 */
729#define WM8400_LMP2 0x0020 /* LMP2 */
730#define WM8400_LMP2_MASK 0x0020 /* LMP2 */
731#define WM8400_LMP2_SHIFT 5 /* LMP2 */
732#define WM8400_LMP2_WIDTH 1 /* LMP2 */
733#define WM8400_LMN1 0x0010 /* LMN1 */
734#define WM8400_LMN1_MASK 0x0010 /* LMN1 */
735#define WM8400_LMN1_SHIFT 4 /* LMN1 */
736#define WM8400_LMN1_WIDTH 1 /* LMN1 */
737#define WM8400_RMP4 0x0008 /* RMP4 */
738#define WM8400_RMP4_MASK 0x0008 /* RMP4 */
739#define WM8400_RMP4_SHIFT 3 /* RMP4 */
740#define WM8400_RMP4_WIDTH 1 /* RMP4 */
741#define WM8400_RMN3 0x0004 /* RMN3 */
742#define WM8400_RMN3_MASK 0x0004 /* RMN3 */
743#define WM8400_RMN3_SHIFT 2 /* RMN3 */
744#define WM8400_RMN3_WIDTH 1 /* RMN3 */
745#define WM8400_RMP2 0x0002 /* RMP2 */
746#define WM8400_RMP2_MASK 0x0002 /* RMP2 */
747#define WM8400_RMP2_SHIFT 1 /* RMP2 */
748#define WM8400_RMP2_WIDTH 1 /* RMP2 */
749#define WM8400_RMN1 0x0001 /* RMN1 */
750#define WM8400_RMN1_MASK 0x0001 /* RMN1 */
751#define WM8400_RMN1_SHIFT 0 /* RMN1 */
752#define WM8400_RMN1_WIDTH 1 /* RMN1 */
753
754/*
755 * R41 (0x29) - Input Mixer3
756 */
757#define WM8400_L34MNB 0x0100 /* L34MNB */
758#define WM8400_L34MNB_MASK 0x0100 /* L34MNB */
759#define WM8400_L34MNB_SHIFT 8 /* L34MNB */
760#define WM8400_L34MNB_WIDTH 1 /* L34MNB */
761#define WM8400_L34MNBST 0x0080 /* L34MNBST */
762#define WM8400_L34MNBST_MASK 0x0080 /* L34MNBST */
763#define WM8400_L34MNBST_SHIFT 7 /* L34MNBST */
764#define WM8400_L34MNBST_WIDTH 1 /* L34MNBST */
765#define WM8400_L12MNB 0x0020 /* L12MNB */
766#define WM8400_L12MNB_MASK 0x0020 /* L12MNB */
767#define WM8400_L12MNB_SHIFT 5 /* L12MNB */
768#define WM8400_L12MNB_WIDTH 1 /* L12MNB */
769#define WM8400_L12MNBST 0x0010 /* L12MNBST */
770#define WM8400_L12MNBST_MASK 0x0010 /* L12MNBST */
771#define WM8400_L12MNBST_SHIFT 4 /* L12MNBST */
772#define WM8400_L12MNBST_WIDTH 1 /* L12MNBST */
773#define WM8400_LDBVOL_MASK 0x0007 /* LDBVOL - [2:0] */
774#define WM8400_LDBVOL_SHIFT 0 /* LDBVOL - [2:0] */
775#define WM8400_LDBVOL_WIDTH 3 /* LDBVOL - [2:0] */
776
777/*
778 * R42 (0x2A) - Input Mixer4
779 */
780#define WM8400_R34MNB 0x0100 /* R34MNB */
781#define WM8400_R34MNB_MASK 0x0100 /* R34MNB */
782#define WM8400_R34MNB_SHIFT 8 /* R34MNB */
783#define WM8400_R34MNB_WIDTH 1 /* R34MNB */
784#define WM8400_R34MNBST 0x0080 /* R34MNBST */
785#define WM8400_R34MNBST_MASK 0x0080 /* R34MNBST */
786#define WM8400_R34MNBST_SHIFT 7 /* R34MNBST */
787#define WM8400_R34MNBST_WIDTH 1 /* R34MNBST */
788#define WM8400_R12MNB 0x0020 /* R12MNB */
789#define WM8400_R12MNB_MASK 0x0020 /* R12MNB */
790#define WM8400_R12MNB_SHIFT 5 /* R12MNB */
791#define WM8400_R12MNB_WIDTH 1 /* R12MNB */
792#define WM8400_R12MNBST 0x0010 /* R12MNBST */
793#define WM8400_R12MNBST_MASK 0x0010 /* R12MNBST */
794#define WM8400_R12MNBST_SHIFT 4 /* R12MNBST */
795#define WM8400_R12MNBST_WIDTH 1 /* R12MNBST */
796#define WM8400_RDBVOL_MASK 0x0007 /* RDBVOL - [2:0] */
797#define WM8400_RDBVOL_SHIFT 0 /* RDBVOL - [2:0] */
798#define WM8400_RDBVOL_WIDTH 3 /* RDBVOL - [2:0] */
799
800/*
801 * R43 (0x2B) - Input Mixer5
802 */
803#define WM8400_LI2BVOL_MASK 0x01C0 /* LI2BVOL - [8:6] */
804#define WM8400_LI2BVOL_SHIFT 6 /* LI2BVOL - [8:6] */
805#define WM8400_LI2BVOL_WIDTH 3 /* LI2BVOL - [8:6] */
806#define WM8400_LR4BVOL_MASK 0x0038 /* LR4BVOL - [5:3] */
807#define WM8400_LR4BVOL_SHIFT 3 /* LR4BVOL - [5:3] */
808#define WM8400_LR4BVOL_WIDTH 3 /* LR4BVOL - [5:3] */
809#define WM8400_LL4BVOL_MASK 0x0007 /* LL4BVOL - [2:0] */
810#define WM8400_LL4BVOL_SHIFT 0 /* LL4BVOL - [2:0] */
811#define WM8400_LL4BVOL_WIDTH 3 /* LL4BVOL - [2:0] */
812
813/*
814 * R44 (0x2C) - Input Mixer6
815 */
816#define WM8400_RI2BVOL_MASK 0x01C0 /* RI2BVOL - [8:6] */
817#define WM8400_RI2BVOL_SHIFT 6 /* RI2BVOL - [8:6] */
818#define WM8400_RI2BVOL_WIDTH 3 /* RI2BVOL - [8:6] */
819#define WM8400_RL4BVOL_MASK 0x0038 /* RL4BVOL - [5:3] */
820#define WM8400_RL4BVOL_SHIFT 3 /* RL4BVOL - [5:3] */
821#define WM8400_RL4BVOL_WIDTH 3 /* RL4BVOL - [5:3] */
822#define WM8400_RR4BVOL_MASK 0x0007 /* RR4BVOL - [2:0] */
823#define WM8400_RR4BVOL_SHIFT 0 /* RR4BVOL - [2:0] */
824#define WM8400_RR4BVOL_WIDTH 3 /* RR4BVOL - [2:0] */
825
826/*
827 * R45 (0x2D) - Output Mixer1
828 */
829#define WM8400_LRBLO 0x0080 /* LRBLO */
830#define WM8400_LRBLO_MASK 0x0080 /* LRBLO */
831#define WM8400_LRBLO_SHIFT 7 /* LRBLO */
832#define WM8400_LRBLO_WIDTH 1 /* LRBLO */
833#define WM8400_LLBLO 0x0040 /* LLBLO */
834#define WM8400_LLBLO_MASK 0x0040 /* LLBLO */
835#define WM8400_LLBLO_SHIFT 6 /* LLBLO */
836#define WM8400_LLBLO_WIDTH 1 /* LLBLO */
837#define WM8400_LRI3LO 0x0020 /* LRI3LO */
838#define WM8400_LRI3LO_MASK 0x0020 /* LRI3LO */
839#define WM8400_LRI3LO_SHIFT 5 /* LRI3LO */
840#define WM8400_LRI3LO_WIDTH 1 /* LRI3LO */
841#define WM8400_LLI3LO 0x0010 /* LLI3LO */
842#define WM8400_LLI3LO_MASK 0x0010 /* LLI3LO */
843#define WM8400_LLI3LO_SHIFT 4 /* LLI3LO */
844#define WM8400_LLI3LO_WIDTH 1 /* LLI3LO */
845#define WM8400_LR12LO 0x0008 /* LR12LO */
846#define WM8400_LR12LO_MASK 0x0008 /* LR12LO */
847#define WM8400_LR12LO_SHIFT 3 /* LR12LO */
848#define WM8400_LR12LO_WIDTH 1 /* LR12LO */
849#define WM8400_LL12LO 0x0004 /* LL12LO */
850#define WM8400_LL12LO_MASK 0x0004 /* LL12LO */
851#define WM8400_LL12LO_SHIFT 2 /* LL12LO */
852#define WM8400_LL12LO_WIDTH 1 /* LL12LO */
853#define WM8400_LDLO 0x0001 /* LDLO */
854#define WM8400_LDLO_MASK 0x0001 /* LDLO */
855#define WM8400_LDLO_SHIFT 0 /* LDLO */
856#define WM8400_LDLO_WIDTH 1 /* LDLO */
857
858/*
859 * R46 (0x2E) - Output Mixer2
860 */
861#define WM8400_RLBRO 0x0080 /* RLBRO */
862#define WM8400_RLBRO_MASK 0x0080 /* RLBRO */
863#define WM8400_RLBRO_SHIFT 7 /* RLBRO */
864#define WM8400_RLBRO_WIDTH 1 /* RLBRO */
865#define WM8400_RRBRO 0x0040 /* RRBRO */
866#define WM8400_RRBRO_MASK 0x0040 /* RRBRO */
867#define WM8400_RRBRO_SHIFT 6 /* RRBRO */
868#define WM8400_RRBRO_WIDTH 1 /* RRBRO */
869#define WM8400_RLI3RO 0x0020 /* RLI3RO */
870#define WM8400_RLI3RO_MASK 0x0020 /* RLI3RO */
871#define WM8400_RLI3RO_SHIFT 5 /* RLI3RO */
872#define WM8400_RLI3RO_WIDTH 1 /* RLI3RO */
873#define WM8400_RRI3RO 0x0010 /* RRI3RO */
874#define WM8400_RRI3RO_MASK 0x0010 /* RRI3RO */
875#define WM8400_RRI3RO_SHIFT 4 /* RRI3RO */
876#define WM8400_RRI3RO_WIDTH 1 /* RRI3RO */
877#define WM8400_RL12RO 0x0008 /* RL12RO */
878#define WM8400_RL12RO_MASK 0x0008 /* RL12RO */
879#define WM8400_RL12RO_SHIFT 3 /* RL12RO */
880#define WM8400_RL12RO_WIDTH 1 /* RL12RO */
881#define WM8400_RR12RO 0x0004 /* RR12RO */
882#define WM8400_RR12RO_MASK 0x0004 /* RR12RO */
883#define WM8400_RR12RO_SHIFT 2 /* RR12RO */
884#define WM8400_RR12RO_WIDTH 1 /* RR12RO */
885#define WM8400_RDRO 0x0001 /* RDRO */
886#define WM8400_RDRO_MASK 0x0001 /* RDRO */
887#define WM8400_RDRO_SHIFT 0 /* RDRO */
888#define WM8400_RDRO_WIDTH 1 /* RDRO */
889
890/*
891 * R47 (0x2F) - Output Mixer3
892 */
893#define WM8400_LLI3LOVOL_MASK 0x01C0 /* LLI3LOVOL - [8:6] */
894#define WM8400_LLI3LOVOL_SHIFT 6 /* LLI3LOVOL - [8:6] */
895#define WM8400_LLI3LOVOL_WIDTH 3 /* LLI3LOVOL - [8:6] */
896#define WM8400_LR12LOVOL_MASK 0x0038 /* LR12LOVOL - [5:3] */
897#define WM8400_LR12LOVOL_SHIFT 3 /* LR12LOVOL - [5:3] */
898#define WM8400_LR12LOVOL_WIDTH 3 /* LR12LOVOL - [5:3] */
899#define WM8400_LL12LOVOL_MASK 0x0007 /* LL12LOVOL - [2:0] */
900#define WM8400_LL12LOVOL_SHIFT 0 /* LL12LOVOL - [2:0] */
901#define WM8400_LL12LOVOL_WIDTH 3 /* LL12LOVOL - [2:0] */
902
903/*
904 * R48 (0x30) - Output Mixer4
905 */
906#define WM8400_RRI3ROVOL_MASK 0x01C0 /* RRI3ROVOL - [8:6] */
907#define WM8400_RRI3ROVOL_SHIFT 6 /* RRI3ROVOL - [8:6] */
908#define WM8400_RRI3ROVOL_WIDTH 3 /* RRI3ROVOL - [8:6] */
909#define WM8400_RL12ROVOL_MASK 0x0038 /* RL12ROVOL - [5:3] */
910#define WM8400_RL12ROVOL_SHIFT 3 /* RL12ROVOL - [5:3] */
911#define WM8400_RL12ROVOL_WIDTH 3 /* RL12ROVOL - [5:3] */
912#define WM8400_RR12ROVOL_MASK 0x0007 /* RR12ROVOL - [2:0] */
913#define WM8400_RR12ROVOL_SHIFT 0 /* RR12ROVOL - [2:0] */
914#define WM8400_RR12ROVOL_WIDTH 3 /* RR12ROVOL - [2:0] */
915
916/*
917 * R49 (0x31) - Output Mixer5
918 */
919#define WM8400_LRI3LOVOL_MASK 0x01C0 /* LRI3LOVOL - [8:6] */
920#define WM8400_LRI3LOVOL_SHIFT 6 /* LRI3LOVOL - [8:6] */
921#define WM8400_LRI3LOVOL_WIDTH 3 /* LRI3LOVOL - [8:6] */
922#define WM8400_LRBLOVOL_MASK 0x0038 /* LRBLOVOL - [5:3] */
923#define WM8400_LRBLOVOL_SHIFT 3 /* LRBLOVOL - [5:3] */
924#define WM8400_LRBLOVOL_WIDTH 3 /* LRBLOVOL - [5:3] */
925#define WM8400_LLBLOVOL_MASK 0x0007 /* LLBLOVOL - [2:0] */
926#define WM8400_LLBLOVOL_SHIFT 0 /* LLBLOVOL - [2:0] */
927#define WM8400_LLBLOVOL_WIDTH 3 /* LLBLOVOL - [2:0] */
928
929/*
930 * R50 (0x32) - Output Mixer6
931 */
932#define WM8400_RLI3ROVOL_MASK 0x01C0 /* RLI3ROVOL - [8:6] */
933#define WM8400_RLI3ROVOL_SHIFT 6 /* RLI3ROVOL - [8:6] */
934#define WM8400_RLI3ROVOL_WIDTH 3 /* RLI3ROVOL - [8:6] */
935#define WM8400_RLBROVOL_MASK 0x0038 /* RLBROVOL - [5:3] */
936#define WM8400_RLBROVOL_SHIFT 3 /* RLBROVOL - [5:3] */
937#define WM8400_RLBROVOL_WIDTH 3 /* RLBROVOL - [5:3] */
938#define WM8400_RRBROVOL_MASK 0x0007 /* RRBROVOL - [2:0] */
939#define WM8400_RRBROVOL_SHIFT 0 /* RRBROVOL - [2:0] */
940#define WM8400_RRBROVOL_WIDTH 3 /* RRBROVOL - [2:0] */
941
942/*
943 * R51 (0x33) - Out3/4 Mixer
944 */
945#define WM8400_VSEL_MASK 0x0180 /* VSEL - [8:7] */
946#define WM8400_VSEL_SHIFT 7 /* VSEL - [8:7] */
947#define WM8400_VSEL_WIDTH 2 /* VSEL - [8:7] */
948#define WM8400_LI4O3 0x0020 /* LI4O3 */
949#define WM8400_LI4O3_MASK 0x0020 /* LI4O3 */
950#define WM8400_LI4O3_SHIFT 5 /* LI4O3 */
951#define WM8400_LI4O3_WIDTH 1 /* LI4O3 */
952#define WM8400_LPGAO3 0x0010 /* LPGAO3 */
953#define WM8400_LPGAO3_MASK 0x0010 /* LPGAO3 */
954#define WM8400_LPGAO3_SHIFT 4 /* LPGAO3 */
955#define WM8400_LPGAO3_WIDTH 1 /* LPGAO3 */
956#define WM8400_RI4O4 0x0002 /* RI4O4 */
957#define WM8400_RI4O4_MASK 0x0002 /* RI4O4 */
958#define WM8400_RI4O4_SHIFT 1 /* RI4O4 */
959#define WM8400_RI4O4_WIDTH 1 /* RI4O4 */
960#define WM8400_RPGAO4 0x0001 /* RPGAO4 */
961#define WM8400_RPGAO4_MASK 0x0001 /* RPGAO4 */
962#define WM8400_RPGAO4_SHIFT 0 /* RPGAO4 */
963#define WM8400_RPGAO4_WIDTH 1 /* RPGAO4 */
964
965/*
966 * R52 (0x34) - Line Mixer1
967 */
968#define WM8400_LLOPGALON 0x0040 /* LLOPGALON */
969#define WM8400_LLOPGALON_MASK 0x0040 /* LLOPGALON */
970#define WM8400_LLOPGALON_SHIFT 6 /* LLOPGALON */
971#define WM8400_LLOPGALON_WIDTH 1 /* LLOPGALON */
972#define WM8400_LROPGALON 0x0020 /* LROPGALON */
973#define WM8400_LROPGALON_MASK 0x0020 /* LROPGALON */
974#define WM8400_LROPGALON_SHIFT 5 /* LROPGALON */
975#define WM8400_LROPGALON_WIDTH 1 /* LROPGALON */
976#define WM8400_LOPLON 0x0010 /* LOPLON */
977#define WM8400_LOPLON_MASK 0x0010 /* LOPLON */
978#define WM8400_LOPLON_SHIFT 4 /* LOPLON */
979#define WM8400_LOPLON_WIDTH 1 /* LOPLON */
980#define WM8400_LR12LOP 0x0004 /* LR12LOP */
981#define WM8400_LR12LOP_MASK 0x0004 /* LR12LOP */
982#define WM8400_LR12LOP_SHIFT 2 /* LR12LOP */
983#define WM8400_LR12LOP_WIDTH 1 /* LR12LOP */
984#define WM8400_LL12LOP 0x0002 /* LL12LOP */
985#define WM8400_LL12LOP_MASK 0x0002 /* LL12LOP */
986#define WM8400_LL12LOP_SHIFT 1 /* LL12LOP */
987#define WM8400_LL12LOP_WIDTH 1 /* LL12LOP */
988#define WM8400_LLOPGALOP 0x0001 /* LLOPGALOP */
989#define WM8400_LLOPGALOP_MASK 0x0001 /* LLOPGALOP */
990#define WM8400_LLOPGALOP_SHIFT 0 /* LLOPGALOP */
991#define WM8400_LLOPGALOP_WIDTH 1 /* LLOPGALOP */
992
993/*
994 * R53 (0x35) - Line Mixer2
995 */
996#define WM8400_RROPGARON 0x0040 /* RROPGARON */
997#define WM8400_RROPGARON_MASK 0x0040 /* RROPGARON */
998#define WM8400_RROPGARON_SHIFT 6 /* RROPGARON */
999#define WM8400_RROPGARON_WIDTH 1 /* RROPGARON */
1000#define WM8400_RLOPGARON 0x0020 /* RLOPGARON */
1001#define WM8400_RLOPGARON_MASK 0x0020 /* RLOPGARON */
1002#define WM8400_RLOPGARON_SHIFT 5 /* RLOPGARON */
1003#define WM8400_RLOPGARON_WIDTH 1 /* RLOPGARON */
1004#define WM8400_ROPRON 0x0010 /* ROPRON */
1005#define WM8400_ROPRON_MASK 0x0010 /* ROPRON */
1006#define WM8400_ROPRON_SHIFT 4 /* ROPRON */
1007#define WM8400_ROPRON_WIDTH 1 /* ROPRON */
1008#define WM8400_RL12ROP 0x0004 /* RL12ROP */
1009#define WM8400_RL12ROP_MASK 0x0004 /* RL12ROP */
1010#define WM8400_RL12ROP_SHIFT 2 /* RL12ROP */
1011#define WM8400_RL12ROP_WIDTH 1 /* RL12ROP */
1012#define WM8400_RR12ROP 0x0002 /* RR12ROP */
1013#define WM8400_RR12ROP_MASK 0x0002 /* RR12ROP */
1014#define WM8400_RR12ROP_SHIFT 1 /* RR12ROP */
1015#define WM8400_RR12ROP_WIDTH 1 /* RR12ROP */
1016#define WM8400_RROPGAROP 0x0001 /* RROPGAROP */
1017#define WM8400_RROPGAROP_MASK 0x0001 /* RROPGAROP */
1018#define WM8400_RROPGAROP_SHIFT 0 /* RROPGAROP */
1019#define WM8400_RROPGAROP_WIDTH 1 /* RROPGAROP */
1020
1021/*
1022 * R54 (0x36) - Speaker Mixer
1023 */
1024#define WM8400_LB2SPK 0x0080 /* LB2SPK */
1025#define WM8400_LB2SPK_MASK 0x0080 /* LB2SPK */
1026#define WM8400_LB2SPK_SHIFT 7 /* LB2SPK */
1027#define WM8400_LB2SPK_WIDTH 1 /* LB2SPK */
1028#define WM8400_RB2SPK 0x0040 /* RB2SPK */
1029#define WM8400_RB2SPK_MASK 0x0040 /* RB2SPK */
1030#define WM8400_RB2SPK_SHIFT 6 /* RB2SPK */
1031#define WM8400_RB2SPK_WIDTH 1 /* RB2SPK */
1032#define WM8400_LI2SPK 0x0020 /* LI2SPK */
1033#define WM8400_LI2SPK_MASK 0x0020 /* LI2SPK */
1034#define WM8400_LI2SPK_SHIFT 5 /* LI2SPK */
1035#define WM8400_LI2SPK_WIDTH 1 /* LI2SPK */
1036#define WM8400_RI2SPK 0x0010 /* RI2SPK */
1037#define WM8400_RI2SPK_MASK 0x0010 /* RI2SPK */
1038#define WM8400_RI2SPK_SHIFT 4 /* RI2SPK */
1039#define WM8400_RI2SPK_WIDTH 1 /* RI2SPK */
1040#define WM8400_LOPGASPK 0x0008 /* LOPGASPK */
1041#define WM8400_LOPGASPK_MASK 0x0008 /* LOPGASPK */
1042#define WM8400_LOPGASPK_SHIFT 3 /* LOPGASPK */
1043#define WM8400_LOPGASPK_WIDTH 1 /* LOPGASPK */
1044#define WM8400_ROPGASPK 0x0004 /* ROPGASPK */
1045#define WM8400_ROPGASPK_MASK 0x0004 /* ROPGASPK */
1046#define WM8400_ROPGASPK_SHIFT 2 /* ROPGASPK */
1047#define WM8400_ROPGASPK_WIDTH 1 /* ROPGASPK */
1048#define WM8400_LDSPK 0x0002 /* LDSPK */
1049#define WM8400_LDSPK_MASK 0x0002 /* LDSPK */
1050#define WM8400_LDSPK_SHIFT 1 /* LDSPK */
1051#define WM8400_LDSPK_WIDTH 1 /* LDSPK */
1052#define WM8400_RDSPK 0x0001 /* RDSPK */
1053#define WM8400_RDSPK_MASK 0x0001 /* RDSPK */
1054#define WM8400_RDSPK_SHIFT 0 /* RDSPK */
1055#define WM8400_RDSPK_WIDTH 1 /* RDSPK */
1056
1057/*
1058 * R55 (0x37) - Additional Control
1059 */
1060#define WM8400_VROI 0x0001 /* VROI */
1061#define WM8400_VROI_MASK 0x0001 /* VROI */
1062#define WM8400_VROI_SHIFT 0 /* VROI */
1063#define WM8400_VROI_WIDTH 1 /* VROI */
1064
1065/*
1066 * R56 (0x38) - AntiPOP1
1067 */
1068#define WM8400_DIS_LLINE 0x0020 /* DIS_LLINE */
1069#define WM8400_DIS_LLINE_MASK 0x0020 /* DIS_LLINE */
1070#define WM8400_DIS_LLINE_SHIFT 5 /* DIS_LLINE */
1071#define WM8400_DIS_LLINE_WIDTH 1 /* DIS_LLINE */
1072#define WM8400_DIS_RLINE 0x0010 /* DIS_RLINE */
1073#define WM8400_DIS_RLINE_MASK 0x0010 /* DIS_RLINE */
1074#define WM8400_DIS_RLINE_SHIFT 4 /* DIS_RLINE */
1075#define WM8400_DIS_RLINE_WIDTH 1 /* DIS_RLINE */
1076#define WM8400_DIS_OUT3 0x0008 /* DIS_OUT3 */
1077#define WM8400_DIS_OUT3_MASK 0x0008 /* DIS_OUT3 */
1078#define WM8400_DIS_OUT3_SHIFT 3 /* DIS_OUT3 */
1079#define WM8400_DIS_OUT3_WIDTH 1 /* DIS_OUT3 */
1080#define WM8400_DIS_OUT4 0x0004 /* DIS_OUT4 */
1081#define WM8400_DIS_OUT4_MASK 0x0004 /* DIS_OUT4 */
1082#define WM8400_DIS_OUT4_SHIFT 2 /* DIS_OUT4 */
1083#define WM8400_DIS_OUT4_WIDTH 1 /* DIS_OUT4 */
1084#define WM8400_DIS_LOUT 0x0002 /* DIS_LOUT */
1085#define WM8400_DIS_LOUT_MASK 0x0002 /* DIS_LOUT */
1086#define WM8400_DIS_LOUT_SHIFT 1 /* DIS_LOUT */
1087#define WM8400_DIS_LOUT_WIDTH 1 /* DIS_LOUT */
1088#define WM8400_DIS_ROUT 0x0001 /* DIS_ROUT */
1089#define WM8400_DIS_ROUT_MASK 0x0001 /* DIS_ROUT */
1090#define WM8400_DIS_ROUT_SHIFT 0 /* DIS_ROUT */
1091#define WM8400_DIS_ROUT_WIDTH 1 /* DIS_ROUT */
1092
1093/*
1094 * R57 (0x39) - AntiPOP2
1095 */
1096#define WM8400_SOFTST 0x0040 /* SOFTST */
1097#define WM8400_SOFTST_MASK 0x0040 /* SOFTST */
1098#define WM8400_SOFTST_SHIFT 6 /* SOFTST */
1099#define WM8400_SOFTST_WIDTH 1 /* SOFTST */
1100#define WM8400_BUFIOEN 0x0008 /* BUFIOEN */
1101#define WM8400_BUFIOEN_MASK 0x0008 /* BUFIOEN */
1102#define WM8400_BUFIOEN_SHIFT 3 /* BUFIOEN */
1103#define WM8400_BUFIOEN_WIDTH 1 /* BUFIOEN */
1104#define WM8400_BUFDCOPEN 0x0004 /* BUFDCOPEN */
1105#define WM8400_BUFDCOPEN_MASK 0x0004 /* BUFDCOPEN */
1106#define WM8400_BUFDCOPEN_SHIFT 2 /* BUFDCOPEN */
1107#define WM8400_BUFDCOPEN_WIDTH 1 /* BUFDCOPEN */
1108#define WM8400_POBCTRL 0x0002 /* POBCTRL */
1109#define WM8400_POBCTRL_MASK 0x0002 /* POBCTRL */
1110#define WM8400_POBCTRL_SHIFT 1 /* POBCTRL */
1111#define WM8400_POBCTRL_WIDTH 1 /* POBCTRL */
1112#define WM8400_VMIDTOG 0x0001 /* VMIDTOG */
1113#define WM8400_VMIDTOG_MASK 0x0001 /* VMIDTOG */
1114#define WM8400_VMIDTOG_SHIFT 0 /* VMIDTOG */
1115#define WM8400_VMIDTOG_WIDTH 1 /* VMIDTOG */
1116
1117/*
1118 * R58 (0x3A) - MICBIAS
1119 */
1120#define WM8400_MCDSCTH_MASK 0x00C0 /* MCDSCTH - [7:6] */
1121#define WM8400_MCDSCTH_SHIFT 6 /* MCDSCTH - [7:6] */
1122#define WM8400_MCDSCTH_WIDTH 2 /* MCDSCTH - [7:6] */
1123#define WM8400_MCDTHR_MASK 0x0038 /* MCDTHR - [5:3] */
1124#define WM8400_MCDTHR_SHIFT 3 /* MCDTHR - [5:3] */
1125#define WM8400_MCDTHR_WIDTH 3 /* MCDTHR - [5:3] */
1126#define WM8400_MCD 0x0004 /* MCD */
1127#define WM8400_MCD_MASK 0x0004 /* MCD */
1128#define WM8400_MCD_SHIFT 2 /* MCD */
1129#define WM8400_MCD_WIDTH 1 /* MCD */
1130#define WM8400_MBSEL 0x0001 /* MBSEL */
1131#define WM8400_MBSEL_MASK 0x0001 /* MBSEL */
1132#define WM8400_MBSEL_SHIFT 0 /* MBSEL */
1133#define WM8400_MBSEL_WIDTH 1 /* MBSEL */
1134
1135/*
1136 * R60 (0x3C) - FLL Control 1
1137 */
1138#define WM8400_FLL_REF_FREQ 0x1000 /* FLL_REF_FREQ */
1139#define WM8400_FLL_REF_FREQ_MASK 0x1000 /* FLL_REF_FREQ */
1140#define WM8400_FLL_REF_FREQ_SHIFT 12 /* FLL_REF_FREQ */
1141#define WM8400_FLL_REF_FREQ_WIDTH 1 /* FLL_REF_FREQ */
1142#define WM8400_FLL_CLK_SRC_MASK 0x0C00 /* FLL_CLK_SRC - [11:10] */
1143#define WM8400_FLL_CLK_SRC_SHIFT 10 /* FLL_CLK_SRC - [11:10] */
1144#define WM8400_FLL_CLK_SRC_WIDTH 2 /* FLL_CLK_SRC - [11:10] */
1145#define WM8400_FLL_FRAC 0x0200 /* FLL_FRAC */
1146#define WM8400_FLL_FRAC_MASK 0x0200 /* FLL_FRAC */
1147#define WM8400_FLL_FRAC_SHIFT 9 /* FLL_FRAC */
1148#define WM8400_FLL_FRAC_WIDTH 1 /* FLL_FRAC */
1149#define WM8400_FLL_OSC_ENA 0x0100 /* FLL_OSC_ENA */
1150#define WM8400_FLL_OSC_ENA_MASK 0x0100 /* FLL_OSC_ENA */
1151#define WM8400_FLL_OSC_ENA_SHIFT 8 /* FLL_OSC_ENA */
1152#define WM8400_FLL_OSC_ENA_WIDTH 1 /* FLL_OSC_ENA */
1153#define WM8400_FLL_CTRL_RATE_MASK 0x00E0 /* FLL_CTRL_RATE - [7:5] */
1154#define WM8400_FLL_CTRL_RATE_SHIFT 5 /* FLL_CTRL_RATE - [7:5] */
1155#define WM8400_FLL_CTRL_RATE_WIDTH 3 /* FLL_CTRL_RATE - [7:5] */
1156#define WM8400_FLL_FRATIO_MASK 0x001F /* FLL_FRATIO - [4:0] */
1157#define WM8400_FLL_FRATIO_SHIFT 0 /* FLL_FRATIO - [4:0] */
1158#define WM8400_FLL_FRATIO_WIDTH 5 /* FLL_FRATIO - [4:0] */
1159
1160/*
1161 * R61 (0x3D) - FLL Control 2
1162 */
1163#define WM8400_FLL_K_MASK 0xFFFF /* FLL_K - [15:0] */
1164#define WM8400_FLL_K_SHIFT 0 /* FLL_K - [15:0] */
1165#define WM8400_FLL_K_WIDTH 16 /* FLL_K - [15:0] */
1166
1167/*
1168 * R62 (0x3E) - FLL Control 3
1169 */
1170#define WM8400_FLL_N_MASK 0x03FF /* FLL_N - [9:0] */
1171#define WM8400_FLL_N_SHIFT 0 /* FLL_N - [9:0] */
1172#define WM8400_FLL_N_WIDTH 10 /* FLL_N - [9:0] */
1173
1174/*
1175 * R63 (0x3F) - FLL Control 4
1176 */
1177#define WM8400_FLL_TRK_GAIN_MASK 0x0078 /* FLL_TRK_GAIN - [6:3] */
1178#define WM8400_FLL_TRK_GAIN_SHIFT 3 /* FLL_TRK_GAIN - [6:3] */
1179#define WM8400_FLL_TRK_GAIN_WIDTH 4 /* FLL_TRK_GAIN - [6:3] */
1180#define WM8400_FLL_OUTDIV_MASK 0x0007 /* FLL_OUTDIV - [2:0] */
1181#define WM8400_FLL_OUTDIV_SHIFT 0 /* FLL_OUTDIV - [2:0] */
1182#define WM8400_FLL_OUTDIV_WIDTH 3 /* FLL_OUTDIV - [2:0] */
1183
1184void wm8400_reset_codec_reg_cache(struct wm8400 *wm8400);
1185
1186#endif
diff --git a/include/linux/mfd/wm8400-private.h b/include/linux/mfd/wm8400-private.h
new file mode 100644
index 000000000000..2aab4e93a5c9
--- /dev/null
+++ b/include/linux/mfd/wm8400-private.h
@@ -0,0 +1,936 @@
1/*
2 * wm8400 private definitions.
3 *
4 * Copyright 2008 Wolfson Microelectronics plc
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
21#ifndef __LINUX_MFD_WM8400_PRIV_H
22#define __LINUX_MFD_WM8400_PRIV_H
23
24#include <linux/mfd/wm8400.h>
25#include <linux/mutex.h>
26#include <linux/platform_device.h>
27
28#define WM8400_REGISTER_COUNT 0x55
29
30struct wm8400 {
31 struct device *dev;
32
33 int (*read_dev)(void *data, char reg, int count, u16 *dst);
34 int (*write_dev)(void *data, char reg, int count, const u16 *src);
35
36 struct mutex io_lock;
37 void *io_data;
38
39 u16 reg_cache[WM8400_REGISTER_COUNT];
40
41 struct platform_device regulators[6];
42};
43
44/*
45 * Register values.
46 */
47#define WM8400_RESET_ID 0x00
48#define WM8400_ID 0x01
49#define WM8400_POWER_MANAGEMENT_1 0x02
50#define WM8400_POWER_MANAGEMENT_2 0x03
51#define WM8400_POWER_MANAGEMENT_3 0x04
52#define WM8400_AUDIO_INTERFACE_1 0x05
53#define WM8400_AUDIO_INTERFACE_2 0x06
54#define WM8400_CLOCKING_1 0x07
55#define WM8400_CLOCKING_2 0x08
56#define WM8400_AUDIO_INTERFACE_3 0x09
57#define WM8400_AUDIO_INTERFACE_4 0x0A
58#define WM8400_DAC_CTRL 0x0B
59#define WM8400_LEFT_DAC_DIGITAL_VOLUME 0x0C
60#define WM8400_RIGHT_DAC_DIGITAL_VOLUME 0x0D
61#define WM8400_DIGITAL_SIDE_TONE 0x0E
62#define WM8400_ADC_CTRL 0x0F
63#define WM8400_LEFT_ADC_DIGITAL_VOLUME 0x10
64#define WM8400_RIGHT_ADC_DIGITAL_VOLUME 0x11
65#define WM8400_GPIO_CTRL_1 0x12
66#define WM8400_GPIO1_GPIO2 0x13
67#define WM8400_GPIO3_GPIO4 0x14
68#define WM8400_GPIO5_GPIO6 0x15
69#define WM8400_GPIOCTRL_2 0x16
70#define WM8400_GPIO_POL 0x17
71#define WM8400_LEFT_LINE_INPUT_1_2_VOLUME 0x18
72#define WM8400_LEFT_LINE_INPUT_3_4_VOLUME 0x19
73#define WM8400_RIGHT_LINE_INPUT_1_2_VOLUME 0x1A
74#define WM8400_RIGHT_LINE_INPUT_3_4_VOLUME 0x1B
75#define WM8400_LEFT_OUTPUT_VOLUME 0x1C
76#define WM8400_RIGHT_OUTPUT_VOLUME 0x1D
77#define WM8400_LINE_OUTPUTS_VOLUME 0x1E
78#define WM8400_OUT3_4_VOLUME 0x1F
79#define WM8400_LEFT_OPGA_VOLUME 0x20
80#define WM8400_RIGHT_OPGA_VOLUME 0x21
81#define WM8400_SPEAKER_VOLUME 0x22
82#define WM8400_CLASSD1 0x23
83#define WM8400_CLASSD3 0x25
84#define WM8400_INPUT_MIXER1 0x27
85#define WM8400_INPUT_MIXER2 0x28
86#define WM8400_INPUT_MIXER3 0x29
87#define WM8400_INPUT_MIXER4 0x2A
88#define WM8400_INPUT_MIXER5 0x2B
89#define WM8400_INPUT_MIXER6 0x2C
90#define WM8400_OUTPUT_MIXER1 0x2D
91#define WM8400_OUTPUT_MIXER2 0x2E
92#define WM8400_OUTPUT_MIXER3 0x2F
93#define WM8400_OUTPUT_MIXER4 0x30
94#define WM8400_OUTPUT_MIXER5 0x31
95#define WM8400_OUTPUT_MIXER6 0x32
96#define WM8400_OUT3_4_MIXER 0x33
97#define WM8400_LINE_MIXER1 0x34
98#define WM8400_LINE_MIXER2 0x35
99#define WM8400_SPEAKER_MIXER 0x36
100#define WM8400_ADDITIONAL_CONTROL 0x37
101#define WM8400_ANTIPOP1 0x38
102#define WM8400_ANTIPOP2 0x39
103#define WM8400_MICBIAS 0x3A
104#define WM8400_FLL_CONTROL_1 0x3C
105#define WM8400_FLL_CONTROL_2 0x3D
106#define WM8400_FLL_CONTROL_3 0x3E
107#define WM8400_FLL_CONTROL_4 0x3F
108#define WM8400_LDO1_CONTROL 0x41
109#define WM8400_LDO2_CONTROL 0x42
110#define WM8400_LDO3_CONTROL 0x43
111#define WM8400_LDO4_CONTROL 0x44
112#define WM8400_DCDC1_CONTROL_1 0x46
113#define WM8400_DCDC1_CONTROL_2 0x47
114#define WM8400_DCDC2_CONTROL_1 0x48
115#define WM8400_DCDC2_CONTROL_2 0x49
116#define WM8400_INTERFACE 0x4B
117#define WM8400_PM_GENERAL 0x4C
118#define WM8400_PM_SHUTDOWN_CONTROL 0x4E
119#define WM8400_INTERRUPT_STATUS_1 0x4F
120#define WM8400_INTERRUPT_STATUS_1_MASK 0x50
121#define WM8400_INTERRUPT_LEVELS 0x51
122#define WM8400_SHUTDOWN_REASON 0x52
123#define WM8400_LINE_CIRCUITS 0x54
124
125/*
126 * Field Definitions.
127 */
128
129/*
130 * R0 (0x00) - Reset/ID
131 */
132#define WM8400_SW_RESET_CHIP_ID_MASK 0xFFFF /* SW_RESET/CHIP_ID - [15:0] */
133#define WM8400_SW_RESET_CHIP_ID_SHIFT 0 /* SW_RESET/CHIP_ID - [15:0] */
134#define WM8400_SW_RESET_CHIP_ID_WIDTH 16 /* SW_RESET/CHIP_ID - [15:0] */
135
136/*
137 * R1 (0x01) - ID
138 */
139#define WM8400_CHIP_REV_MASK 0x7000 /* CHIP_REV - [14:12] */
140#define WM8400_CHIP_REV_SHIFT 12 /* CHIP_REV - [14:12] */
141#define WM8400_CHIP_REV_WIDTH 3 /* CHIP_REV - [14:12] */
142
143/*
144 * R18 (0x12) - GPIO CTRL 1
145 */
146#define WM8400_IRQ 0x1000 /* IRQ */
147#define WM8400_IRQ_MASK 0x1000 /* IRQ */
148#define WM8400_IRQ_SHIFT 12 /* IRQ */
149#define WM8400_IRQ_WIDTH 1 /* IRQ */
150#define WM8400_TEMPOK 0x0800 /* TEMPOK */
151#define WM8400_TEMPOK_MASK 0x0800 /* TEMPOK */
152#define WM8400_TEMPOK_SHIFT 11 /* TEMPOK */
153#define WM8400_TEMPOK_WIDTH 1 /* TEMPOK */
154#define WM8400_MIC1SHRT 0x0400 /* MIC1SHRT */
155#define WM8400_MIC1SHRT_MASK 0x0400 /* MIC1SHRT */
156#define WM8400_MIC1SHRT_SHIFT 10 /* MIC1SHRT */
157#define WM8400_MIC1SHRT_WIDTH 1 /* MIC1SHRT */
158#define WM8400_MIC1DET 0x0200 /* MIC1DET */
159#define WM8400_MIC1DET_MASK 0x0200 /* MIC1DET */
160#define WM8400_MIC1DET_SHIFT 9 /* MIC1DET */
161#define WM8400_MIC1DET_WIDTH 1 /* MIC1DET */
162#define WM8400_FLL_LCK 0x0100 /* FLL_LCK */
163#define WM8400_FLL_LCK_MASK 0x0100 /* FLL_LCK */
164#define WM8400_FLL_LCK_SHIFT 8 /* FLL_LCK */
165#define WM8400_FLL_LCK_WIDTH 1 /* FLL_LCK */
166#define WM8400_GPIO_STATUS_MASK 0x00FF /* GPIO_STATUS - [7:0] */
167#define WM8400_GPIO_STATUS_SHIFT 0 /* GPIO_STATUS - [7:0] */
168#define WM8400_GPIO_STATUS_WIDTH 8 /* GPIO_STATUS - [7:0] */
169
170/*
171 * R19 (0x13) - GPIO1 & GPIO2
172 */
173#define WM8400_GPIO2_DEB_ENA 0x8000 /* GPIO2_DEB_ENA */
174#define WM8400_GPIO2_DEB_ENA_MASK 0x8000 /* GPIO2_DEB_ENA */
175#define WM8400_GPIO2_DEB_ENA_SHIFT 15 /* GPIO2_DEB_ENA */
176#define WM8400_GPIO2_DEB_ENA_WIDTH 1 /* GPIO2_DEB_ENA */
177#define WM8400_GPIO2_IRQ_ENA 0x4000 /* GPIO2_IRQ_ENA */
178#define WM8400_GPIO2_IRQ_ENA_MASK 0x4000 /* GPIO2_IRQ_ENA */
179#define WM8400_GPIO2_IRQ_ENA_SHIFT 14 /* GPIO2_IRQ_ENA */
180#define WM8400_GPIO2_IRQ_ENA_WIDTH 1 /* GPIO2_IRQ_ENA */
181#define WM8400_GPIO2_PU 0x2000 /* GPIO2_PU */
182#define WM8400_GPIO2_PU_MASK 0x2000 /* GPIO2_PU */
183#define WM8400_GPIO2_PU_SHIFT 13 /* GPIO2_PU */
184#define WM8400_GPIO2_PU_WIDTH 1 /* GPIO2_PU */
185#define WM8400_GPIO2_PD 0x1000 /* GPIO2_PD */
186#define WM8400_GPIO2_PD_MASK 0x1000 /* GPIO2_PD */
187#define WM8400_GPIO2_PD_SHIFT 12 /* GPIO2_PD */
188#define WM8400_GPIO2_PD_WIDTH 1 /* GPIO2_PD */
189#define WM8400_GPIO2_SEL_MASK 0x0F00 /* GPIO2_SEL - [11:8] */
190#define WM8400_GPIO2_SEL_SHIFT 8 /* GPIO2_SEL - [11:8] */
191#define WM8400_GPIO2_SEL_WIDTH 4 /* GPIO2_SEL - [11:8] */
192#define WM8400_GPIO1_DEB_ENA 0x0080 /* GPIO1_DEB_ENA */
193#define WM8400_GPIO1_DEB_ENA_MASK 0x0080 /* GPIO1_DEB_ENA */
194#define WM8400_GPIO1_DEB_ENA_SHIFT 7 /* GPIO1_DEB_ENA */
195#define WM8400_GPIO1_DEB_ENA_WIDTH 1 /* GPIO1_DEB_ENA */
196#define WM8400_GPIO1_IRQ_ENA 0x0040 /* GPIO1_IRQ_ENA */
197#define WM8400_GPIO1_IRQ_ENA_MASK 0x0040 /* GPIO1_IRQ_ENA */
198#define WM8400_GPIO1_IRQ_ENA_SHIFT 6 /* GPIO1_IRQ_ENA */
199#define WM8400_GPIO1_IRQ_ENA_WIDTH 1 /* GPIO1_IRQ_ENA */
200#define WM8400_GPIO1_PU 0x0020 /* GPIO1_PU */
201#define WM8400_GPIO1_PU_MASK 0x0020 /* GPIO1_PU */
202#define WM8400_GPIO1_PU_SHIFT 5 /* GPIO1_PU */
203#define WM8400_GPIO1_PU_WIDTH 1 /* GPIO1_PU */
204#define WM8400_GPIO1_PD 0x0010 /* GPIO1_PD */
205#define WM8400_GPIO1_PD_MASK 0x0010 /* GPIO1_PD */
206#define WM8400_GPIO1_PD_SHIFT 4 /* GPIO1_PD */
207#define WM8400_GPIO1_PD_WIDTH 1 /* GPIO1_PD */
208#define WM8400_GPIO1_SEL_MASK 0x000F /* GPIO1_SEL - [3:0] */
209#define WM8400_GPIO1_SEL_SHIFT 0 /* GPIO1_SEL - [3:0] */
210#define WM8400_GPIO1_SEL_WIDTH 4 /* GPIO1_SEL - [3:0] */
211
212/*
213 * R20 (0x14) - GPIO3 & GPIO4
214 */
215#define WM8400_GPIO4_DEB_ENA 0x8000 /* GPIO4_DEB_ENA */
216#define WM8400_GPIO4_DEB_ENA_MASK 0x8000 /* GPIO4_DEB_ENA */
217#define WM8400_GPIO4_DEB_ENA_SHIFT 15 /* GPIO4_DEB_ENA */
218#define WM8400_GPIO4_DEB_ENA_WIDTH 1 /* GPIO4_DEB_ENA */
219#define WM8400_GPIO4_IRQ_ENA 0x4000 /* GPIO4_IRQ_ENA */
220#define WM8400_GPIO4_IRQ_ENA_MASK 0x4000 /* GPIO4_IRQ_ENA */
221#define WM8400_GPIO4_IRQ_ENA_SHIFT 14 /* GPIO4_IRQ_ENA */
222#define WM8400_GPIO4_IRQ_ENA_WIDTH 1 /* GPIO4_IRQ_ENA */
223#define WM8400_GPIO4_PU 0x2000 /* GPIO4_PU */
224#define WM8400_GPIO4_PU_MASK 0x2000 /* GPIO4_PU */
225#define WM8400_GPIO4_PU_SHIFT 13 /* GPIO4_PU */
226#define WM8400_GPIO4_PU_WIDTH 1 /* GPIO4_PU */
227#define WM8400_GPIO4_PD 0x1000 /* GPIO4_PD */
228#define WM8400_GPIO4_PD_MASK 0x1000 /* GPIO4_PD */
229#define WM8400_GPIO4_PD_SHIFT 12 /* GPIO4_PD */
230#define WM8400_GPIO4_PD_WIDTH 1 /* GPIO4_PD */
231#define WM8400_GPIO4_SEL_MASK 0x0F00 /* GPIO4_SEL - [11:8] */
232#define WM8400_GPIO4_SEL_SHIFT 8 /* GPIO4_SEL - [11:8] */
233#define WM8400_GPIO4_SEL_WIDTH 4 /* GPIO4_SEL - [11:8] */
234#define WM8400_GPIO3_DEB_ENA 0x0080 /* GPIO3_DEB_ENA */
235#define WM8400_GPIO3_DEB_ENA_MASK 0x0080 /* GPIO3_DEB_ENA */
236#define WM8400_GPIO3_DEB_ENA_SHIFT 7 /* GPIO3_DEB_ENA */
237#define WM8400_GPIO3_DEB_ENA_WIDTH 1 /* GPIO3_DEB_ENA */
238#define WM8400_GPIO3_IRQ_ENA 0x0040 /* GPIO3_IRQ_ENA */
239#define WM8400_GPIO3_IRQ_ENA_MASK 0x0040 /* GPIO3_IRQ_ENA */
240#define WM8400_GPIO3_IRQ_ENA_SHIFT 6 /* GPIO3_IRQ_ENA */
241#define WM8400_GPIO3_IRQ_ENA_WIDTH 1 /* GPIO3_IRQ_ENA */
242#define WM8400_GPIO3_PU 0x0020 /* GPIO3_PU */
243#define WM8400_GPIO3_PU_MASK 0x0020 /* GPIO3_PU */
244#define WM8400_GPIO3_PU_SHIFT 5 /* GPIO3_PU */
245#define WM8400_GPIO3_PU_WIDTH 1 /* GPIO3_PU */
246#define WM8400_GPIO3_PD 0x0010 /* GPIO3_PD */
247#define WM8400_GPIO3_PD_MASK 0x0010 /* GPIO3_PD */
248#define WM8400_GPIO3_PD_SHIFT 4 /* GPIO3_PD */
249#define WM8400_GPIO3_PD_WIDTH 1 /* GPIO3_PD */
250#define WM8400_GPIO3_SEL_MASK 0x000F /* GPIO3_SEL - [3:0] */
251#define WM8400_GPIO3_SEL_SHIFT 0 /* GPIO3_SEL - [3:0] */
252#define WM8400_GPIO3_SEL_WIDTH 4 /* GPIO3_SEL - [3:0] */
253
254/*
255 * R21 (0x15) - GPIO5 & GPIO6
256 */
257#define WM8400_GPIO6_DEB_ENA 0x8000 /* GPIO6_DEB_ENA */
258#define WM8400_GPIO6_DEB_ENA_MASK 0x8000 /* GPIO6_DEB_ENA */
259#define WM8400_GPIO6_DEB_ENA_SHIFT 15 /* GPIO6_DEB_ENA */
260#define WM8400_GPIO6_DEB_ENA_WIDTH 1 /* GPIO6_DEB_ENA */
261#define WM8400_GPIO6_IRQ_ENA 0x4000 /* GPIO6_IRQ_ENA */
262#define WM8400_GPIO6_IRQ_ENA_MASK 0x4000 /* GPIO6_IRQ_ENA */
263#define WM8400_GPIO6_IRQ_ENA_SHIFT 14 /* GPIO6_IRQ_ENA */
264#define WM8400_GPIO6_IRQ_ENA_WIDTH 1 /* GPIO6_IRQ_ENA */
265#define WM8400_GPIO6_PU 0x2000 /* GPIO6_PU */
266#define WM8400_GPIO6_PU_MASK 0x2000 /* GPIO6_PU */
267#define WM8400_GPIO6_PU_SHIFT 13 /* GPIO6_PU */
268#define WM8400_GPIO6_PU_WIDTH 1 /* GPIO6_PU */
269#define WM8400_GPIO6_PD 0x1000 /* GPIO6_PD */
270#define WM8400_GPIO6_PD_MASK 0x1000 /* GPIO6_PD */
271#define WM8400_GPIO6_PD_SHIFT 12 /* GPIO6_PD */
272#define WM8400_GPIO6_PD_WIDTH 1 /* GPIO6_PD */
273#define WM8400_GPIO6_SEL_MASK 0x0F00 /* GPIO6_SEL - [11:8] */
274#define WM8400_GPIO6_SEL_SHIFT 8 /* GPIO6_SEL - [11:8] */
275#define WM8400_GPIO6_SEL_WIDTH 4 /* GPIO6_SEL - [11:8] */
276#define WM8400_GPIO5_DEB_ENA 0x0080 /* GPIO5_DEB_ENA */
277#define WM8400_GPIO5_DEB_ENA_MASK 0x0080 /* GPIO5_DEB_ENA */
278#define WM8400_GPIO5_DEB_ENA_SHIFT 7 /* GPIO5_DEB_ENA */
279#define WM8400_GPIO5_DEB_ENA_WIDTH 1 /* GPIO5_DEB_ENA */
280#define WM8400_GPIO5_IRQ_ENA 0x0040 /* GPIO5_IRQ_ENA */
281#define WM8400_GPIO5_IRQ_ENA_MASK 0x0040 /* GPIO5_IRQ_ENA */
282#define WM8400_GPIO5_IRQ_ENA_SHIFT 6 /* GPIO5_IRQ_ENA */
283#define WM8400_GPIO5_IRQ_ENA_WIDTH 1 /* GPIO5_IRQ_ENA */
284#define WM8400_GPIO5_PU 0x0020 /* GPIO5_PU */
285#define WM8400_GPIO5_PU_MASK 0x0020 /* GPIO5_PU */
286#define WM8400_GPIO5_PU_SHIFT 5 /* GPIO5_PU */
287#define WM8400_GPIO5_PU_WIDTH 1 /* GPIO5_PU */
288#define WM8400_GPIO5_PD 0x0010 /* GPIO5_PD */
289#define WM8400_GPIO5_PD_MASK 0x0010 /* GPIO5_PD */
290#define WM8400_GPIO5_PD_SHIFT 4 /* GPIO5_PD */
291#define WM8400_GPIO5_PD_WIDTH 1 /* GPIO5_PD */
292#define WM8400_GPIO5_SEL_MASK 0x000F /* GPIO5_SEL - [3:0] */
293#define WM8400_GPIO5_SEL_SHIFT 0 /* GPIO5_SEL - [3:0] */
294#define WM8400_GPIO5_SEL_WIDTH 4 /* GPIO5_SEL - [3:0] */
295
296/*
297 * R22 (0x16) - GPIOCTRL 2
298 */
299#define WM8400_TEMPOK_IRQ_ENA 0x0800 /* TEMPOK_IRQ_ENA */
300#define WM8400_TEMPOK_IRQ_ENA_MASK 0x0800 /* TEMPOK_IRQ_ENA */
301#define WM8400_TEMPOK_IRQ_ENA_SHIFT 11 /* TEMPOK_IRQ_ENA */
302#define WM8400_TEMPOK_IRQ_ENA_WIDTH 1 /* TEMPOK_IRQ_ENA */
303#define WM8400_MIC1SHRT_IRQ_ENA 0x0400 /* MIC1SHRT_IRQ_ENA */
304#define WM8400_MIC1SHRT_IRQ_ENA_MASK 0x0400 /* MIC1SHRT_IRQ_ENA */
305#define WM8400_MIC1SHRT_IRQ_ENA_SHIFT 10 /* MIC1SHRT_IRQ_ENA */
306#define WM8400_MIC1SHRT_IRQ_ENA_WIDTH 1 /* MIC1SHRT_IRQ_ENA */
307#define WM8400_MIC1DET_IRQ_ENA 0x0200 /* MIC1DET_IRQ_ENA */
308#define WM8400_MIC1DET_IRQ_ENA_MASK 0x0200 /* MIC1DET_IRQ_ENA */
309#define WM8400_MIC1DET_IRQ_ENA_SHIFT 9 /* MIC1DET_IRQ_ENA */
310#define WM8400_MIC1DET_IRQ_ENA_WIDTH 1 /* MIC1DET_IRQ_ENA */
311#define WM8400_FLL_LCK_IRQ_ENA 0x0100 /* FLL_LCK_IRQ_ENA */
312#define WM8400_FLL_LCK_IRQ_ENA_MASK 0x0100 /* FLL_LCK_IRQ_ENA */
313#define WM8400_FLL_LCK_IRQ_ENA_SHIFT 8 /* FLL_LCK_IRQ_ENA */
314#define WM8400_FLL_LCK_IRQ_ENA_WIDTH 1 /* FLL_LCK_IRQ_ENA */
315#define WM8400_GPI8_DEB_ENA 0x0080 /* GPI8_DEB_ENA */
316#define WM8400_GPI8_DEB_ENA_MASK 0x0080 /* GPI8_DEB_ENA */
317#define WM8400_GPI8_DEB_ENA_SHIFT 7 /* GPI8_DEB_ENA */
318#define WM8400_GPI8_DEB_ENA_WIDTH 1 /* GPI8_DEB_ENA */
319#define WM8400_GPI8_IRQ_ENA 0x0040 /* GPI8_IRQ_ENA */
320#define WM8400_GPI8_IRQ_ENA_MASK 0x0040 /* GPI8_IRQ_ENA */
321#define WM8400_GPI8_IRQ_ENA_SHIFT 6 /* GPI8_IRQ_ENA */
322#define WM8400_GPI8_IRQ_ENA_WIDTH 1 /* GPI8_IRQ_ENA */
323#define WM8400_GPI8_ENA 0x0010 /* GPI8_ENA */
324#define WM8400_GPI8_ENA_MASK 0x0010 /* GPI8_ENA */
325#define WM8400_GPI8_ENA_SHIFT 4 /* GPI8_ENA */
326#define WM8400_GPI8_ENA_WIDTH 1 /* GPI8_ENA */
327#define WM8400_GPI7_DEB_ENA 0x0008 /* GPI7_DEB_ENA */
328#define WM8400_GPI7_DEB_ENA_MASK 0x0008 /* GPI7_DEB_ENA */
329#define WM8400_GPI7_DEB_ENA_SHIFT 3 /* GPI7_DEB_ENA */
330#define WM8400_GPI7_DEB_ENA_WIDTH 1 /* GPI7_DEB_ENA */
331#define WM8400_GPI7_IRQ_ENA 0x0004 /* GPI7_IRQ_ENA */
332#define WM8400_GPI7_IRQ_ENA_MASK 0x0004 /* GPI7_IRQ_ENA */
333#define WM8400_GPI7_IRQ_ENA_SHIFT 2 /* GPI7_IRQ_ENA */
334#define WM8400_GPI7_IRQ_ENA_WIDTH 1 /* GPI7_IRQ_ENA */
335#define WM8400_GPI7_ENA 0x0001 /* GPI7_ENA */
336#define WM8400_GPI7_ENA_MASK 0x0001 /* GPI7_ENA */
337#define WM8400_GPI7_ENA_SHIFT 0 /* GPI7_ENA */
338#define WM8400_GPI7_ENA_WIDTH 1 /* GPI7_ENA */
339
340/*
341 * R23 (0x17) - GPIO_POL
342 */
343#define WM8400_IRQ_INV 0x1000 /* IRQ_INV */
344#define WM8400_IRQ_INV_MASK 0x1000 /* IRQ_INV */
345#define WM8400_IRQ_INV_SHIFT 12 /* IRQ_INV */
346#define WM8400_IRQ_INV_WIDTH 1 /* IRQ_INV */
347#define WM8400_TEMPOK_POL 0x0800 /* TEMPOK_POL */
348#define WM8400_TEMPOK_POL_MASK 0x0800 /* TEMPOK_POL */
349#define WM8400_TEMPOK_POL_SHIFT 11 /* TEMPOK_POL */
350#define WM8400_TEMPOK_POL_WIDTH 1 /* TEMPOK_POL */
351#define WM8400_MIC1SHRT_POL 0x0400 /* MIC1SHRT_POL */
352#define WM8400_MIC1SHRT_POL_MASK 0x0400 /* MIC1SHRT_POL */
353#define WM8400_MIC1SHRT_POL_SHIFT 10 /* MIC1SHRT_POL */
354#define WM8400_MIC1SHRT_POL_WIDTH 1 /* MIC1SHRT_POL */
355#define WM8400_MIC1DET_POL 0x0200 /* MIC1DET_POL */
356#define WM8400_MIC1DET_POL_MASK 0x0200 /* MIC1DET_POL */
357#define WM8400_MIC1DET_POL_SHIFT 9 /* MIC1DET_POL */
358#define WM8400_MIC1DET_POL_WIDTH 1 /* MIC1DET_POL */
359#define WM8400_FLL_LCK_POL 0x0100 /* FLL_LCK_POL */
360#define WM8400_FLL_LCK_POL_MASK 0x0100 /* FLL_LCK_POL */
361#define WM8400_FLL_LCK_POL_SHIFT 8 /* FLL_LCK_POL */
362#define WM8400_FLL_LCK_POL_WIDTH 1 /* FLL_LCK_POL */
363#define WM8400_GPIO_POL_MASK 0x00FF /* GPIO_POL - [7:0] */
364#define WM8400_GPIO_POL_SHIFT 0 /* GPIO_POL - [7:0] */
365#define WM8400_GPIO_POL_WIDTH 8 /* GPIO_POL - [7:0] */
366
367/*
368 * R65 (0x41) - LDO 1 Control
369 */
370#define WM8400_LDO1_ENA 0x8000 /* LDO1_ENA */
371#define WM8400_LDO1_ENA_MASK 0x8000 /* LDO1_ENA */
372#define WM8400_LDO1_ENA_SHIFT 15 /* LDO1_ENA */
373#define WM8400_LDO1_ENA_WIDTH 1 /* LDO1_ENA */
374#define WM8400_LDO1_SWI 0x4000 /* LDO1_SWI */
375#define WM8400_LDO1_SWI_MASK 0x4000 /* LDO1_SWI */
376#define WM8400_LDO1_SWI_SHIFT 14 /* LDO1_SWI */
377#define WM8400_LDO1_SWI_WIDTH 1 /* LDO1_SWI */
378#define WM8400_LDO1_OPFLT 0x1000 /* LDO1_OPFLT */
379#define WM8400_LDO1_OPFLT_MASK 0x1000 /* LDO1_OPFLT */
380#define WM8400_LDO1_OPFLT_SHIFT 12 /* LDO1_OPFLT */
381#define WM8400_LDO1_OPFLT_WIDTH 1 /* LDO1_OPFLT */
382#define WM8400_LDO1_ERRACT 0x0800 /* LDO1_ERRACT */
383#define WM8400_LDO1_ERRACT_MASK 0x0800 /* LDO1_ERRACT */
384#define WM8400_LDO1_ERRACT_SHIFT 11 /* LDO1_ERRACT */
385#define WM8400_LDO1_ERRACT_WIDTH 1 /* LDO1_ERRACT */
386#define WM8400_LDO1_HIB_MODE 0x0400 /* LDO1_HIB_MODE */
387#define WM8400_LDO1_HIB_MODE_MASK 0x0400 /* LDO1_HIB_MODE */
388#define WM8400_LDO1_HIB_MODE_SHIFT 10 /* LDO1_HIB_MODE */
389#define WM8400_LDO1_HIB_MODE_WIDTH 1 /* LDO1_HIB_MODE */
390#define WM8400_LDO1_VIMG_MASK 0x03E0 /* LDO1_VIMG - [9:5] */
391#define WM8400_LDO1_VIMG_SHIFT 5 /* LDO1_VIMG - [9:5] */
392#define WM8400_LDO1_VIMG_WIDTH 5 /* LDO1_VIMG - [9:5] */
393#define WM8400_LDO1_VSEL_MASK 0x001F /* LDO1_VSEL - [4:0] */
394#define WM8400_LDO1_VSEL_SHIFT 0 /* LDO1_VSEL - [4:0] */
395#define WM8400_LDO1_VSEL_WIDTH 5 /* LDO1_VSEL - [4:0] */
396
397/*
398 * R66 (0x42) - LDO 2 Control
399 */
400#define WM8400_LDO2_ENA 0x8000 /* LDO2_ENA */
401#define WM8400_LDO2_ENA_MASK 0x8000 /* LDO2_ENA */
402#define WM8400_LDO2_ENA_SHIFT 15 /* LDO2_ENA */
403#define WM8400_LDO2_ENA_WIDTH 1 /* LDO2_ENA */
404#define WM8400_LDO2_SWI 0x4000 /* LDO2_SWI */
405#define WM8400_LDO2_SWI_MASK 0x4000 /* LDO2_SWI */
406#define WM8400_LDO2_SWI_SHIFT 14 /* LDO2_SWI */
407#define WM8400_LDO2_SWI_WIDTH 1 /* LDO2_SWI */
408#define WM8400_LDO2_OPFLT 0x1000 /* LDO2_OPFLT */
409#define WM8400_LDO2_OPFLT_MASK 0x1000 /* LDO2_OPFLT */
410#define WM8400_LDO2_OPFLT_SHIFT 12 /* LDO2_OPFLT */
411#define WM8400_LDO2_OPFLT_WIDTH 1 /* LDO2_OPFLT */
412#define WM8400_LDO2_ERRACT 0x0800 /* LDO2_ERRACT */
413#define WM8400_LDO2_ERRACT_MASK 0x0800 /* LDO2_ERRACT */
414#define WM8400_LDO2_ERRACT_SHIFT 11 /* LDO2_ERRACT */
415#define WM8400_LDO2_ERRACT_WIDTH 1 /* LDO2_ERRACT */
416#define WM8400_LDO2_HIB_MODE 0x0400 /* LDO2_HIB_MODE */
417#define WM8400_LDO2_HIB_MODE_MASK 0x0400 /* LDO2_HIB_MODE */
418#define WM8400_LDO2_HIB_MODE_SHIFT 10 /* LDO2_HIB_MODE */
419#define WM8400_LDO2_HIB_MODE_WIDTH 1 /* LDO2_HIB_MODE */
420#define WM8400_LDO2_VIMG_MASK 0x03E0 /* LDO2_VIMG - [9:5] */
421#define WM8400_LDO2_VIMG_SHIFT 5 /* LDO2_VIMG - [9:5] */
422#define WM8400_LDO2_VIMG_WIDTH 5 /* LDO2_VIMG - [9:5] */
423#define WM8400_LDO2_VSEL_MASK 0x001F /* LDO2_VSEL - [4:0] */
424#define WM8400_LDO2_VSEL_SHIFT 0 /* LDO2_VSEL - [4:0] */
425#define WM8400_LDO2_VSEL_WIDTH 5 /* LDO2_VSEL - [4:0] */
426
427/*
428 * R67 (0x43) - LDO 3 Control
429 */
430#define WM8400_LDO3_ENA 0x8000 /* LDO3_ENA */
431#define WM8400_LDO3_ENA_MASK 0x8000 /* LDO3_ENA */
432#define WM8400_LDO3_ENA_SHIFT 15 /* LDO3_ENA */
433#define WM8400_LDO3_ENA_WIDTH 1 /* LDO3_ENA */
434#define WM8400_LDO3_SWI 0x4000 /* LDO3_SWI */
435#define WM8400_LDO3_SWI_MASK 0x4000 /* LDO3_SWI */
436#define WM8400_LDO3_SWI_SHIFT 14 /* LDO3_SWI */
437#define WM8400_LDO3_SWI_WIDTH 1 /* LDO3_SWI */
438#define WM8400_LDO3_OPFLT 0x1000 /* LDO3_OPFLT */
439#define WM8400_LDO3_OPFLT_MASK 0x1000 /* LDO3_OPFLT */
440#define WM8400_LDO3_OPFLT_SHIFT 12 /* LDO3_OPFLT */
441#define WM8400_LDO3_OPFLT_WIDTH 1 /* LDO3_OPFLT */
442#define WM8400_LDO3_ERRACT 0x0800 /* LDO3_ERRACT */
443#define WM8400_LDO3_ERRACT_MASK 0x0800 /* LDO3_ERRACT */
444#define WM8400_LDO3_ERRACT_SHIFT 11 /* LDO3_ERRACT */
445#define WM8400_LDO3_ERRACT_WIDTH 1 /* LDO3_ERRACT */
446#define WM8400_LDO3_HIB_MODE 0x0400 /* LDO3_HIB_MODE */
447#define WM8400_LDO3_HIB_MODE_MASK 0x0400 /* LDO3_HIB_MODE */
448#define WM8400_LDO3_HIB_MODE_SHIFT 10 /* LDO3_HIB_MODE */
449#define WM8400_LDO3_HIB_MODE_WIDTH 1 /* LDO3_HIB_MODE */
450#define WM8400_LDO3_VIMG_MASK 0x03E0 /* LDO3_VIMG - [9:5] */
451#define WM8400_LDO3_VIMG_SHIFT 5 /* LDO3_VIMG - [9:5] */
452#define WM8400_LDO3_VIMG_WIDTH 5 /* LDO3_VIMG - [9:5] */
453#define WM8400_LDO3_VSEL_MASK 0x001F /* LDO3_VSEL - [4:0] */
454#define WM8400_LDO3_VSEL_SHIFT 0 /* LDO3_VSEL - [4:0] */
455#define WM8400_LDO3_VSEL_WIDTH 5 /* LDO3_VSEL - [4:0] */
456
457/*
458 * R68 (0x44) - LDO 4 Control
459 */
460#define WM8400_LDO4_ENA 0x8000 /* LDO4_ENA */
461#define WM8400_LDO4_ENA_MASK 0x8000 /* LDO4_ENA */
462#define WM8400_LDO4_ENA_SHIFT 15 /* LDO4_ENA */
463#define WM8400_LDO4_ENA_WIDTH 1 /* LDO4_ENA */
464#define WM8400_LDO4_SWI 0x4000 /* LDO4_SWI */
465#define WM8400_LDO4_SWI_MASK 0x4000 /* LDO4_SWI */
466#define WM8400_LDO4_SWI_SHIFT 14 /* LDO4_SWI */
467#define WM8400_LDO4_SWI_WIDTH 1 /* LDO4_SWI */
468#define WM8400_LDO4_OPFLT 0x1000 /* LDO4_OPFLT */
469#define WM8400_LDO4_OPFLT_MASK 0x1000 /* LDO4_OPFLT */
470#define WM8400_LDO4_OPFLT_SHIFT 12 /* LDO4_OPFLT */
471#define WM8400_LDO4_OPFLT_WIDTH 1 /* LDO4_OPFLT */
472#define WM8400_LDO4_ERRACT 0x0800 /* LDO4_ERRACT */
473#define WM8400_LDO4_ERRACT_MASK 0x0800 /* LDO4_ERRACT */
474#define WM8400_LDO4_ERRACT_SHIFT 11 /* LDO4_ERRACT */
475#define WM8400_LDO4_ERRACT_WIDTH 1 /* LDO4_ERRACT */
476#define WM8400_LDO4_HIB_MODE 0x0400 /* LDO4_HIB_MODE */
477#define WM8400_LDO4_HIB_MODE_MASK 0x0400 /* LDO4_HIB_MODE */
478#define WM8400_LDO4_HIB_MODE_SHIFT 10 /* LDO4_HIB_MODE */
479#define WM8400_LDO4_HIB_MODE_WIDTH 1 /* LDO4_HIB_MODE */
480#define WM8400_LDO4_VIMG_MASK 0x03E0 /* LDO4_VIMG - [9:5] */
481#define WM8400_LDO4_VIMG_SHIFT 5 /* LDO4_VIMG - [9:5] */
482#define WM8400_LDO4_VIMG_WIDTH 5 /* LDO4_VIMG - [9:5] */
483#define WM8400_LDO4_VSEL_MASK 0x001F /* LDO4_VSEL - [4:0] */
484#define WM8400_LDO4_VSEL_SHIFT 0 /* LDO4_VSEL - [4:0] */
485#define WM8400_LDO4_VSEL_WIDTH 5 /* LDO4_VSEL - [4:0] */
486
487/*
488 * R70 (0x46) - DCDC1 Control 1
489 */
490#define WM8400_DC1_ENA 0x8000 /* DC1_ENA */
491#define WM8400_DC1_ENA_MASK 0x8000 /* DC1_ENA */
492#define WM8400_DC1_ENA_SHIFT 15 /* DC1_ENA */
493#define WM8400_DC1_ENA_WIDTH 1 /* DC1_ENA */
494#define WM8400_DC1_ACTIVE 0x4000 /* DC1_ACTIVE */
495#define WM8400_DC1_ACTIVE_MASK 0x4000 /* DC1_ACTIVE */
496#define WM8400_DC1_ACTIVE_SHIFT 14 /* DC1_ACTIVE */
497#define WM8400_DC1_ACTIVE_WIDTH 1 /* DC1_ACTIVE */
498#define WM8400_DC1_SLEEP 0x2000 /* DC1_SLEEP */
499#define WM8400_DC1_SLEEP_MASK 0x2000 /* DC1_SLEEP */
500#define WM8400_DC1_SLEEP_SHIFT 13 /* DC1_SLEEP */
501#define WM8400_DC1_SLEEP_WIDTH 1 /* DC1_SLEEP */
502#define WM8400_DC1_OPFLT 0x1000 /* DC1_OPFLT */
503#define WM8400_DC1_OPFLT_MASK 0x1000 /* DC1_OPFLT */
504#define WM8400_DC1_OPFLT_SHIFT 12 /* DC1_OPFLT */
505#define WM8400_DC1_OPFLT_WIDTH 1 /* DC1_OPFLT */
506#define WM8400_DC1_ERRACT 0x0800 /* DC1_ERRACT */
507#define WM8400_DC1_ERRACT_MASK 0x0800 /* DC1_ERRACT */
508#define WM8400_DC1_ERRACT_SHIFT 11 /* DC1_ERRACT */
509#define WM8400_DC1_ERRACT_WIDTH 1 /* DC1_ERRACT */
510#define WM8400_DC1_HIB_MODE 0x0400 /* DC1_HIB_MODE */
511#define WM8400_DC1_HIB_MODE_MASK 0x0400 /* DC1_HIB_MODE */
512#define WM8400_DC1_HIB_MODE_SHIFT 10 /* DC1_HIB_MODE */
513#define WM8400_DC1_HIB_MODE_WIDTH 1 /* DC1_HIB_MODE */
514#define WM8400_DC1_SOFTST_MASK 0x0300 /* DC1_SOFTST - [9:8] */
515#define WM8400_DC1_SOFTST_SHIFT 8 /* DC1_SOFTST - [9:8] */
516#define WM8400_DC1_SOFTST_WIDTH 2 /* DC1_SOFTST - [9:8] */
517#define WM8400_DC1_OV_PROT 0x0080 /* DC1_OV_PROT */
518#define WM8400_DC1_OV_PROT_MASK 0x0080 /* DC1_OV_PROT */
519#define WM8400_DC1_OV_PROT_SHIFT 7 /* DC1_OV_PROT */
520#define WM8400_DC1_OV_PROT_WIDTH 1 /* DC1_OV_PROT */
521#define WM8400_DC1_VSEL_MASK 0x007F /* DC1_VSEL - [6:0] */
522#define WM8400_DC1_VSEL_SHIFT 0 /* DC1_VSEL - [6:0] */
523#define WM8400_DC1_VSEL_WIDTH 7 /* DC1_VSEL - [6:0] */
524
525/*
526 * R71 (0x47) - DCDC1 Control 2
527 */
528#define WM8400_DC1_FRC_PWM 0x2000 /* DC1_FRC_PWM */
529#define WM8400_DC1_FRC_PWM_MASK 0x2000 /* DC1_FRC_PWM */
530#define WM8400_DC1_FRC_PWM_SHIFT 13 /* DC1_FRC_PWM */
531#define WM8400_DC1_FRC_PWM_WIDTH 1 /* DC1_FRC_PWM */
532#define WM8400_DC1_STBY_LIM_MASK 0x0300 /* DC1_STBY_LIM - [9:8] */
533#define WM8400_DC1_STBY_LIM_SHIFT 8 /* DC1_STBY_LIM - [9:8] */
534#define WM8400_DC1_STBY_LIM_WIDTH 2 /* DC1_STBY_LIM - [9:8] */
535#define WM8400_DC1_ACT_LIM 0x0080 /* DC1_ACT_LIM */
536#define WM8400_DC1_ACT_LIM_MASK 0x0080 /* DC1_ACT_LIM */
537#define WM8400_DC1_ACT_LIM_SHIFT 7 /* DC1_ACT_LIM */
538#define WM8400_DC1_ACT_LIM_WIDTH 1 /* DC1_ACT_LIM */
539#define WM8400_DC1_VIMG_MASK 0x007F /* DC1_VIMG - [6:0] */
540#define WM8400_DC1_VIMG_SHIFT 0 /* DC1_VIMG - [6:0] */
541#define WM8400_DC1_VIMG_WIDTH 7 /* DC1_VIMG - [6:0] */
542
543/*
544 * R72 (0x48) - DCDC2 Control 1
545 */
546#define WM8400_DC2_ENA 0x8000 /* DC2_ENA */
547#define WM8400_DC2_ENA_MASK 0x8000 /* DC2_ENA */
548#define WM8400_DC2_ENA_SHIFT 15 /* DC2_ENA */
549#define WM8400_DC2_ENA_WIDTH 1 /* DC2_ENA */
550#define WM8400_DC2_ACTIVE 0x4000 /* DC2_ACTIVE */
551#define WM8400_DC2_ACTIVE_MASK 0x4000 /* DC2_ACTIVE */
552#define WM8400_DC2_ACTIVE_SHIFT 14 /* DC2_ACTIVE */
553#define WM8400_DC2_ACTIVE_WIDTH 1 /* DC2_ACTIVE */
554#define WM8400_DC2_SLEEP 0x2000 /* DC2_SLEEP */
555#define WM8400_DC2_SLEEP_MASK 0x2000 /* DC2_SLEEP */
556#define WM8400_DC2_SLEEP_SHIFT 13 /* DC2_SLEEP */
557#define WM8400_DC2_SLEEP_WIDTH 1 /* DC2_SLEEP */
558#define WM8400_DC2_OPFLT 0x1000 /* DC2_OPFLT */
559#define WM8400_DC2_OPFLT_MASK 0x1000 /* DC2_OPFLT */
560#define WM8400_DC2_OPFLT_SHIFT 12 /* DC2_OPFLT */
561#define WM8400_DC2_OPFLT_WIDTH 1 /* DC2_OPFLT */
562#define WM8400_DC2_ERRACT 0x0800 /* DC2_ERRACT */
563#define WM8400_DC2_ERRACT_MASK 0x0800 /* DC2_ERRACT */
564#define WM8400_DC2_ERRACT_SHIFT 11 /* DC2_ERRACT */
565#define WM8400_DC2_ERRACT_WIDTH 1 /* DC2_ERRACT */
566#define WM8400_DC2_HIB_MODE 0x0400 /* DC2_HIB_MODE */
567#define WM8400_DC2_HIB_MODE_MASK 0x0400 /* DC2_HIB_MODE */
568#define WM8400_DC2_HIB_MODE_SHIFT 10 /* DC2_HIB_MODE */
569#define WM8400_DC2_HIB_MODE_WIDTH 1 /* DC2_HIB_MODE */
570#define WM8400_DC2_SOFTST_MASK 0x0300 /* DC2_SOFTST - [9:8] */
571#define WM8400_DC2_SOFTST_SHIFT 8 /* DC2_SOFTST - [9:8] */
572#define WM8400_DC2_SOFTST_WIDTH 2 /* DC2_SOFTST - [9:8] */
573#define WM8400_DC2_OV_PROT 0x0080 /* DC2_OV_PROT */
574#define WM8400_DC2_OV_PROT_MASK 0x0080 /* DC2_OV_PROT */
575#define WM8400_DC2_OV_PROT_SHIFT 7 /* DC2_OV_PROT */
576#define WM8400_DC2_OV_PROT_WIDTH 1 /* DC2_OV_PROT */
577#define WM8400_DC2_VSEL_MASK 0x007F /* DC2_VSEL - [6:0] */
578#define WM8400_DC2_VSEL_SHIFT 0 /* DC2_VSEL - [6:0] */
579#define WM8400_DC2_VSEL_WIDTH 7 /* DC2_VSEL - [6:0] */
580
581/*
582 * R73 (0x49) - DCDC2 Control 2
583 */
584#define WM8400_DC2_FRC_PWM 0x2000 /* DC2_FRC_PWM */
585#define WM8400_DC2_FRC_PWM_MASK 0x2000 /* DC2_FRC_PWM */
586#define WM8400_DC2_FRC_PWM_SHIFT 13 /* DC2_FRC_PWM */
587#define WM8400_DC2_FRC_PWM_WIDTH 1 /* DC2_FRC_PWM */
588#define WM8400_DC2_STBY_LIM_MASK 0x0300 /* DC2_STBY_LIM - [9:8] */
589#define WM8400_DC2_STBY_LIM_SHIFT 8 /* DC2_STBY_LIM - [9:8] */
590#define WM8400_DC2_STBY_LIM_WIDTH 2 /* DC2_STBY_LIM - [9:8] */
591#define WM8400_DC2_ACT_LIM 0x0080 /* DC2_ACT_LIM */
592#define WM8400_DC2_ACT_LIM_MASK 0x0080 /* DC2_ACT_LIM */
593#define WM8400_DC2_ACT_LIM_SHIFT 7 /* DC2_ACT_LIM */
594#define WM8400_DC2_ACT_LIM_WIDTH 1 /* DC2_ACT_LIM */
595#define WM8400_DC2_VIMG_MASK 0x007F /* DC2_VIMG - [6:0] */
596#define WM8400_DC2_VIMG_SHIFT 0 /* DC2_VIMG - [6:0] */
597#define WM8400_DC2_VIMG_WIDTH 7 /* DC2_VIMG - [6:0] */
598
599/*
600 * R75 (0x4B) - Interface
601 */
602#define WM8400_AUTOINC 0x0008 /* AUTOINC */
603#define WM8400_AUTOINC_MASK 0x0008 /* AUTOINC */
604#define WM8400_AUTOINC_SHIFT 3 /* AUTOINC */
605#define WM8400_AUTOINC_WIDTH 1 /* AUTOINC */
606#define WM8400_ARA_ENA 0x0004 /* ARA_ENA */
607#define WM8400_ARA_ENA_MASK 0x0004 /* ARA_ENA */
608#define WM8400_ARA_ENA_SHIFT 2 /* ARA_ENA */
609#define WM8400_ARA_ENA_WIDTH 1 /* ARA_ENA */
610#define WM8400_SPI_CFG 0x0002 /* SPI_CFG */
611#define WM8400_SPI_CFG_MASK 0x0002 /* SPI_CFG */
612#define WM8400_SPI_CFG_SHIFT 1 /* SPI_CFG */
613#define WM8400_SPI_CFG_WIDTH 1 /* SPI_CFG */
614
615/*
616 * R76 (0x4C) - PM GENERAL
617 */
618#define WM8400_CODEC_SOFTST 0x8000 /* CODEC_SOFTST */
619#define WM8400_CODEC_SOFTST_MASK 0x8000 /* CODEC_SOFTST */
620#define WM8400_CODEC_SOFTST_SHIFT 15 /* CODEC_SOFTST */
621#define WM8400_CODEC_SOFTST_WIDTH 1 /* CODEC_SOFTST */
622#define WM8400_CODEC_SOFTSD 0x4000 /* CODEC_SOFTSD */
623#define WM8400_CODEC_SOFTSD_MASK 0x4000 /* CODEC_SOFTSD */
624#define WM8400_CODEC_SOFTSD_SHIFT 14 /* CODEC_SOFTSD */
625#define WM8400_CODEC_SOFTSD_WIDTH 1 /* CODEC_SOFTSD */
626#define WM8400_CHIP_SOFTSD 0x2000 /* CHIP_SOFTSD */
627#define WM8400_CHIP_SOFTSD_MASK 0x2000 /* CHIP_SOFTSD */
628#define WM8400_CHIP_SOFTSD_SHIFT 13 /* CHIP_SOFTSD */
629#define WM8400_CHIP_SOFTSD_WIDTH 1 /* CHIP_SOFTSD */
630#define WM8400_DSLEEP1_POL 0x0008 /* DSLEEP1_POL */
631#define WM8400_DSLEEP1_POL_MASK 0x0008 /* DSLEEP1_POL */
632#define WM8400_DSLEEP1_POL_SHIFT 3 /* DSLEEP1_POL */
633#define WM8400_DSLEEP1_POL_WIDTH 1 /* DSLEEP1_POL */
634#define WM8400_DSLEEP2_POL 0x0004 /* DSLEEP2_POL */
635#define WM8400_DSLEEP2_POL_MASK 0x0004 /* DSLEEP2_POL */
636#define WM8400_DSLEEP2_POL_SHIFT 2 /* DSLEEP2_POL */
637#define WM8400_DSLEEP2_POL_WIDTH 1 /* DSLEEP2_POL */
638#define WM8400_PWR_STATE_MASK 0x0003 /* PWR_STATE - [1:0] */
639#define WM8400_PWR_STATE_SHIFT 0 /* PWR_STATE - [1:0] */
640#define WM8400_PWR_STATE_WIDTH 2 /* PWR_STATE - [1:0] */
641
642/*
643 * R78 (0x4E) - PM Shutdown Control
644 */
645#define WM8400_CHIP_GT150_ERRACT 0x0200 /* CHIP_GT150_ERRACT */
646#define WM8400_CHIP_GT150_ERRACT_MASK 0x0200 /* CHIP_GT150_ERRACT */
647#define WM8400_CHIP_GT150_ERRACT_SHIFT 9 /* CHIP_GT150_ERRACT */
648#define WM8400_CHIP_GT150_ERRACT_WIDTH 1 /* CHIP_GT150_ERRACT */
649#define WM8400_CHIP_GT115_ERRACT 0x0100 /* CHIP_GT115_ERRACT */
650#define WM8400_CHIP_GT115_ERRACT_MASK 0x0100 /* CHIP_GT115_ERRACT */
651#define WM8400_CHIP_GT115_ERRACT_SHIFT 8 /* CHIP_GT115_ERRACT */
652#define WM8400_CHIP_GT115_ERRACT_WIDTH 1 /* CHIP_GT115_ERRACT */
653#define WM8400_LINE_CMP_ERRACT 0x0080 /* LINE_CMP_ERRACT */
654#define WM8400_LINE_CMP_ERRACT_MASK 0x0080 /* LINE_CMP_ERRACT */
655#define WM8400_LINE_CMP_ERRACT_SHIFT 7 /* LINE_CMP_ERRACT */
656#define WM8400_LINE_CMP_ERRACT_WIDTH 1 /* LINE_CMP_ERRACT */
657#define WM8400_UVLO_ERRACT 0x0040 /* UVLO_ERRACT */
658#define WM8400_UVLO_ERRACT_MASK 0x0040 /* UVLO_ERRACT */
659#define WM8400_UVLO_ERRACT_SHIFT 6 /* UVLO_ERRACT */
660#define WM8400_UVLO_ERRACT_WIDTH 1 /* UVLO_ERRACT */
661
662/*
663 * R79 (0x4F) - Interrupt Status 1
664 */
665#define WM8400_MICD_CINT 0x8000 /* MICD_CINT */
666#define WM8400_MICD_CINT_MASK 0x8000 /* MICD_CINT */
667#define WM8400_MICD_CINT_SHIFT 15 /* MICD_CINT */
668#define WM8400_MICD_CINT_WIDTH 1 /* MICD_CINT */
669#define WM8400_MICSCD_CINT 0x4000 /* MICSCD_CINT */
670#define WM8400_MICSCD_CINT_MASK 0x4000 /* MICSCD_CINT */
671#define WM8400_MICSCD_CINT_SHIFT 14 /* MICSCD_CINT */
672#define WM8400_MICSCD_CINT_WIDTH 1 /* MICSCD_CINT */
673#define WM8400_JDL_CINT 0x2000 /* JDL_CINT */
674#define WM8400_JDL_CINT_MASK 0x2000 /* JDL_CINT */
675#define WM8400_JDL_CINT_SHIFT 13 /* JDL_CINT */
676#define WM8400_JDL_CINT_WIDTH 1 /* JDL_CINT */
677#define WM8400_JDR_CINT 0x1000 /* JDR_CINT */
678#define WM8400_JDR_CINT_MASK 0x1000 /* JDR_CINT */
679#define WM8400_JDR_CINT_SHIFT 12 /* JDR_CINT */
680#define WM8400_JDR_CINT_WIDTH 1 /* JDR_CINT */
681#define WM8400_CODEC_SEQ_END_EINT 0x0800 /* CODEC_SEQ_END_EINT */
682#define WM8400_CODEC_SEQ_END_EINT_MASK 0x0800 /* CODEC_SEQ_END_EINT */
683#define WM8400_CODEC_SEQ_END_EINT_SHIFT 11 /* CODEC_SEQ_END_EINT */
684#define WM8400_CODEC_SEQ_END_EINT_WIDTH 1 /* CODEC_SEQ_END_EINT */
685#define WM8400_CDEL_TO_EINT 0x0400 /* CDEL_TO_EINT */
686#define WM8400_CDEL_TO_EINT_MASK 0x0400 /* CDEL_TO_EINT */
687#define WM8400_CDEL_TO_EINT_SHIFT 10 /* CDEL_TO_EINT */
688#define WM8400_CDEL_TO_EINT_WIDTH 1 /* CDEL_TO_EINT */
689#define WM8400_CHIP_GT150_EINT 0x0200 /* CHIP_GT150_EINT */
690#define WM8400_CHIP_GT150_EINT_MASK 0x0200 /* CHIP_GT150_EINT */
691#define WM8400_CHIP_GT150_EINT_SHIFT 9 /* CHIP_GT150_EINT */
692#define WM8400_CHIP_GT150_EINT_WIDTH 1 /* CHIP_GT150_EINT */
693#define WM8400_CHIP_GT115_EINT 0x0100 /* CHIP_GT115_EINT */
694#define WM8400_CHIP_GT115_EINT_MASK 0x0100 /* CHIP_GT115_EINT */
695#define WM8400_CHIP_GT115_EINT_SHIFT 8 /* CHIP_GT115_EINT */
696#define WM8400_CHIP_GT115_EINT_WIDTH 1 /* CHIP_GT115_EINT */
697#define WM8400_LINE_CMP_EINT 0x0080 /* LINE_CMP_EINT */
698#define WM8400_LINE_CMP_EINT_MASK 0x0080 /* LINE_CMP_EINT */
699#define WM8400_LINE_CMP_EINT_SHIFT 7 /* LINE_CMP_EINT */
700#define WM8400_LINE_CMP_EINT_WIDTH 1 /* LINE_CMP_EINT */
701#define WM8400_UVLO_EINT 0x0040 /* UVLO_EINT */
702#define WM8400_UVLO_EINT_MASK 0x0040 /* UVLO_EINT */
703#define WM8400_UVLO_EINT_SHIFT 6 /* UVLO_EINT */
704#define WM8400_UVLO_EINT_WIDTH 1 /* UVLO_EINT */
705#define WM8400_DC2_UV_EINT 0x0020 /* DC2_UV_EINT */
706#define WM8400_DC2_UV_EINT_MASK 0x0020 /* DC2_UV_EINT */
707#define WM8400_DC2_UV_EINT_SHIFT 5 /* DC2_UV_EINT */
708#define WM8400_DC2_UV_EINT_WIDTH 1 /* DC2_UV_EINT */
709#define WM8400_DC1_UV_EINT 0x0010 /* DC1_UV_EINT */
710#define WM8400_DC1_UV_EINT_MASK 0x0010 /* DC1_UV_EINT */
711#define WM8400_DC1_UV_EINT_SHIFT 4 /* DC1_UV_EINT */
712#define WM8400_DC1_UV_EINT_WIDTH 1 /* DC1_UV_EINT */
713#define WM8400_LDO4_UV_EINT 0x0008 /* LDO4_UV_EINT */
714#define WM8400_LDO4_UV_EINT_MASK 0x0008 /* LDO4_UV_EINT */
715#define WM8400_LDO4_UV_EINT_SHIFT 3 /* LDO4_UV_EINT */
716#define WM8400_LDO4_UV_EINT_WIDTH 1 /* LDO4_UV_EINT */
717#define WM8400_LDO3_UV_EINT 0x0004 /* LDO3_UV_EINT */
718#define WM8400_LDO3_UV_EINT_MASK 0x0004 /* LDO3_UV_EINT */
719#define WM8400_LDO3_UV_EINT_SHIFT 2 /* LDO3_UV_EINT */
720#define WM8400_LDO3_UV_EINT_WIDTH 1 /* LDO3_UV_EINT */
721#define WM8400_LDO2_UV_EINT 0x0002 /* LDO2_UV_EINT */
722#define WM8400_LDO2_UV_EINT_MASK 0x0002 /* LDO2_UV_EINT */
723#define WM8400_LDO2_UV_EINT_SHIFT 1 /* LDO2_UV_EINT */
724#define WM8400_LDO2_UV_EINT_WIDTH 1 /* LDO2_UV_EINT */
725#define WM8400_LDO1_UV_EINT 0x0001 /* LDO1_UV_EINT */
726#define WM8400_LDO1_UV_EINT_MASK 0x0001 /* LDO1_UV_EINT */
727#define WM8400_LDO1_UV_EINT_SHIFT 0 /* LDO1_UV_EINT */
728#define WM8400_LDO1_UV_EINT_WIDTH 1 /* LDO1_UV_EINT */
729
730/*
731 * R80 (0x50) - Interrupt Status 1 Mask
732 */
733#define WM8400_IM_MICD_CINT 0x8000 /* IM_MICD_CINT */
734#define WM8400_IM_MICD_CINT_MASK 0x8000 /* IM_MICD_CINT */
735#define WM8400_IM_MICD_CINT_SHIFT 15 /* IM_MICD_CINT */
736#define WM8400_IM_MICD_CINT_WIDTH 1 /* IM_MICD_CINT */
737#define WM8400_IM_MICSCD_CINT 0x4000 /* IM_MICSCD_CINT */
738#define WM8400_IM_MICSCD_CINT_MASK 0x4000 /* IM_MICSCD_CINT */
739#define WM8400_IM_MICSCD_CINT_SHIFT 14 /* IM_MICSCD_CINT */
740#define WM8400_IM_MICSCD_CINT_WIDTH 1 /* IM_MICSCD_CINT */
741#define WM8400_IM_JDL_CINT 0x2000 /* IM_JDL_CINT */
742#define WM8400_IM_JDL_CINT_MASK 0x2000 /* IM_JDL_CINT */
743#define WM8400_IM_JDL_CINT_SHIFT 13 /* IM_JDL_CINT */
744#define WM8400_IM_JDL_CINT_WIDTH 1 /* IM_JDL_CINT */
745#define WM8400_IM_JDR_CINT 0x1000 /* IM_JDR_CINT */
746#define WM8400_IM_JDR_CINT_MASK 0x1000 /* IM_JDR_CINT */
747#define WM8400_IM_JDR_CINT_SHIFT 12 /* IM_JDR_CINT */
748#define WM8400_IM_JDR_CINT_WIDTH 1 /* IM_JDR_CINT */
749#define WM8400_IM_CODEC_SEQ_END_EINT 0x0800 /* IM_CODEC_SEQ_END_EINT */
750#define WM8400_IM_CODEC_SEQ_END_EINT_MASK 0x0800 /* IM_CODEC_SEQ_END_EINT */
751#define WM8400_IM_CODEC_SEQ_END_EINT_SHIFT 11 /* IM_CODEC_SEQ_END_EINT */
752#define WM8400_IM_CODEC_SEQ_END_EINT_WIDTH 1 /* IM_CODEC_SEQ_END_EINT */
753#define WM8400_IM_CDEL_TO_EINT 0x0400 /* IM_CDEL_TO_EINT */
754#define WM8400_IM_CDEL_TO_EINT_MASK 0x0400 /* IM_CDEL_TO_EINT */
755#define WM8400_IM_CDEL_TO_EINT_SHIFT 10 /* IM_CDEL_TO_EINT */
756#define WM8400_IM_CDEL_TO_EINT_WIDTH 1 /* IM_CDEL_TO_EINT */
757#define WM8400_IM_CHIP_GT150_EINT 0x0200 /* IM_CHIP_GT150_EINT */
758#define WM8400_IM_CHIP_GT150_EINT_MASK 0x0200 /* IM_CHIP_GT150_EINT */
759#define WM8400_IM_CHIP_GT150_EINT_SHIFT 9 /* IM_CHIP_GT150_EINT */
760#define WM8400_IM_CHIP_GT150_EINT_WIDTH 1 /* IM_CHIP_GT150_EINT */
761#define WM8400_IM_CHIP_GT115_EINT 0x0100 /* IM_CHIP_GT115_EINT */
762#define WM8400_IM_CHIP_GT115_EINT_MASK 0x0100 /* IM_CHIP_GT115_EINT */
763#define WM8400_IM_CHIP_GT115_EINT_SHIFT 8 /* IM_CHIP_GT115_EINT */
764#define WM8400_IM_CHIP_GT115_EINT_WIDTH 1 /* IM_CHIP_GT115_EINT */
765#define WM8400_IM_LINE_CMP_EINT 0x0080 /* IM_LINE_CMP_EINT */
766#define WM8400_IM_LINE_CMP_EINT_MASK 0x0080 /* IM_LINE_CMP_EINT */
767#define WM8400_IM_LINE_CMP_EINT_SHIFT 7 /* IM_LINE_CMP_EINT */
768#define WM8400_IM_LINE_CMP_EINT_WIDTH 1 /* IM_LINE_CMP_EINT */
769#define WM8400_IM_UVLO_EINT 0x0040 /* IM_UVLO_EINT */
770#define WM8400_IM_UVLO_EINT_MASK 0x0040 /* IM_UVLO_EINT */
771#define WM8400_IM_UVLO_EINT_SHIFT 6 /* IM_UVLO_EINT */
772#define WM8400_IM_UVLO_EINT_WIDTH 1 /* IM_UVLO_EINT */
773#define WM8400_IM_DC2_UV_EINT 0x0020 /* IM_DC2_UV_EINT */
774#define WM8400_IM_DC2_UV_EINT_MASK 0x0020 /* IM_DC2_UV_EINT */
775#define WM8400_IM_DC2_UV_EINT_SHIFT 5 /* IM_DC2_UV_EINT */
776#define WM8400_IM_DC2_UV_EINT_WIDTH 1 /* IM_DC2_UV_EINT */
777#define WM8400_IM_DC1_UV_EINT 0x0010 /* IM_DC1_UV_EINT */
778#define WM8400_IM_DC1_UV_EINT_MASK 0x0010 /* IM_DC1_UV_EINT */
779#define WM8400_IM_DC1_UV_EINT_SHIFT 4 /* IM_DC1_UV_EINT */
780#define WM8400_IM_DC1_UV_EINT_WIDTH 1 /* IM_DC1_UV_EINT */
781#define WM8400_IM_LDO4_UV_EINT 0x0008 /* IM_LDO4_UV_EINT */
782#define WM8400_IM_LDO4_UV_EINT_MASK 0x0008 /* IM_LDO4_UV_EINT */
783#define WM8400_IM_LDO4_UV_EINT_SHIFT 3 /* IM_LDO4_UV_EINT */
784#define WM8400_IM_LDO4_UV_EINT_WIDTH 1 /* IM_LDO4_UV_EINT */
785#define WM8400_IM_LDO3_UV_EINT 0x0004 /* IM_LDO3_UV_EINT */
786#define WM8400_IM_LDO3_UV_EINT_MASK 0x0004 /* IM_LDO3_UV_EINT */
787#define WM8400_IM_LDO3_UV_EINT_SHIFT 2 /* IM_LDO3_UV_EINT */
788#define WM8400_IM_LDO3_UV_EINT_WIDTH 1 /* IM_LDO3_UV_EINT */
789#define WM8400_IM_LDO2_UV_EINT 0x0002 /* IM_LDO2_UV_EINT */
790#define WM8400_IM_LDO2_UV_EINT_MASK 0x0002 /* IM_LDO2_UV_EINT */
791#define WM8400_IM_LDO2_UV_EINT_SHIFT 1 /* IM_LDO2_UV_EINT */
792#define WM8400_IM_LDO2_UV_EINT_WIDTH 1 /* IM_LDO2_UV_EINT */
793#define WM8400_IM_LDO1_UV_EINT 0x0001 /* IM_LDO1_UV_EINT */
794#define WM8400_IM_LDO1_UV_EINT_MASK 0x0001 /* IM_LDO1_UV_EINT */
795#define WM8400_IM_LDO1_UV_EINT_SHIFT 0 /* IM_LDO1_UV_EINT */
796#define WM8400_IM_LDO1_UV_EINT_WIDTH 1 /* IM_LDO1_UV_EINT */
797
798/*
799 * R81 (0x51) - Interrupt Levels
800 */
801#define WM8400_MICD_LVL 0x8000 /* MICD_LVL */
802#define WM8400_MICD_LVL_MASK 0x8000 /* MICD_LVL */
803#define WM8400_MICD_LVL_SHIFT 15 /* MICD_LVL */
804#define WM8400_MICD_LVL_WIDTH 1 /* MICD_LVL */
805#define WM8400_MICSCD_LVL 0x4000 /* MICSCD_LVL */
806#define WM8400_MICSCD_LVL_MASK 0x4000 /* MICSCD_LVL */
807#define WM8400_MICSCD_LVL_SHIFT 14 /* MICSCD_LVL */
808#define WM8400_MICSCD_LVL_WIDTH 1 /* MICSCD_LVL */
809#define WM8400_JDL_LVL 0x2000 /* JDL_LVL */
810#define WM8400_JDL_LVL_MASK 0x2000 /* JDL_LVL */
811#define WM8400_JDL_LVL_SHIFT 13 /* JDL_LVL */
812#define WM8400_JDL_LVL_WIDTH 1 /* JDL_LVL */
813#define WM8400_JDR_LVL 0x1000 /* JDR_LVL */
814#define WM8400_JDR_LVL_MASK 0x1000 /* JDR_LVL */
815#define WM8400_JDR_LVL_SHIFT 12 /* JDR_LVL */
816#define WM8400_JDR_LVL_WIDTH 1 /* JDR_LVL */
817#define WM8400_CODEC_SEQ_END_LVL 0x0800 /* CODEC_SEQ_END_LVL */
818#define WM8400_CODEC_SEQ_END_LVL_MASK 0x0800 /* CODEC_SEQ_END_LVL */
819#define WM8400_CODEC_SEQ_END_LVL_SHIFT 11 /* CODEC_SEQ_END_LVL */
820#define WM8400_CODEC_SEQ_END_LVL_WIDTH 1 /* CODEC_SEQ_END_LVL */
821#define WM8400_CDEL_TO_LVL 0x0400 /* CDEL_TO_LVL */
822#define WM8400_CDEL_TO_LVL_MASK 0x0400 /* CDEL_TO_LVL */
823#define WM8400_CDEL_TO_LVL_SHIFT 10 /* CDEL_TO_LVL */
824#define WM8400_CDEL_TO_LVL_WIDTH 1 /* CDEL_TO_LVL */
825#define WM8400_CHIP_GT150_LVL 0x0200 /* CHIP_GT150_LVL */
826#define WM8400_CHIP_GT150_LVL_MASK 0x0200 /* CHIP_GT150_LVL */
827#define WM8400_CHIP_GT150_LVL_SHIFT 9 /* CHIP_GT150_LVL */
828#define WM8400_CHIP_GT150_LVL_WIDTH 1 /* CHIP_GT150_LVL */
829#define WM8400_CHIP_GT115_LVL 0x0100 /* CHIP_GT115_LVL */
830#define WM8400_CHIP_GT115_LVL_MASK 0x0100 /* CHIP_GT115_LVL */
831#define WM8400_CHIP_GT115_LVL_SHIFT 8 /* CHIP_GT115_LVL */
832#define WM8400_CHIP_GT115_LVL_WIDTH 1 /* CHIP_GT115_LVL */
833#define WM8400_LINE_CMP_LVL 0x0080 /* LINE_CMP_LVL */
834#define WM8400_LINE_CMP_LVL_MASK 0x0080 /* LINE_CMP_LVL */
835#define WM8400_LINE_CMP_LVL_SHIFT 7 /* LINE_CMP_LVL */
836#define WM8400_LINE_CMP_LVL_WIDTH 1 /* LINE_CMP_LVL */
837#define WM8400_UVLO_LVL 0x0040 /* UVLO_LVL */
838#define WM8400_UVLO_LVL_MASK 0x0040 /* UVLO_LVL */
839#define WM8400_UVLO_LVL_SHIFT 6 /* UVLO_LVL */
840#define WM8400_UVLO_LVL_WIDTH 1 /* UVLO_LVL */
841#define WM8400_DC2_UV_LVL 0x0020 /* DC2_UV_LVL */
842#define WM8400_DC2_UV_LVL_MASK 0x0020 /* DC2_UV_LVL */
843#define WM8400_DC2_UV_LVL_SHIFT 5 /* DC2_UV_LVL */
844#define WM8400_DC2_UV_LVL_WIDTH 1 /* DC2_UV_LVL */
845#define WM8400_DC1_UV_LVL 0x0010 /* DC1_UV_LVL */
846#define WM8400_DC1_UV_LVL_MASK 0x0010 /* DC1_UV_LVL */
847#define WM8400_DC1_UV_LVL_SHIFT 4 /* DC1_UV_LVL */
848#define WM8400_DC1_UV_LVL_WIDTH 1 /* DC1_UV_LVL */
849#define WM8400_LDO4_UV_LVL 0x0008 /* LDO4_UV_LVL */
850#define WM8400_LDO4_UV_LVL_MASK 0x0008 /* LDO4_UV_LVL */
851#define WM8400_LDO4_UV_LVL_SHIFT 3 /* LDO4_UV_LVL */
852#define WM8400_LDO4_UV_LVL_WIDTH 1 /* LDO4_UV_LVL */
853#define WM8400_LDO3_UV_LVL 0x0004 /* LDO3_UV_LVL */
854#define WM8400_LDO3_UV_LVL_MASK 0x0004 /* LDO3_UV_LVL */
855#define WM8400_LDO3_UV_LVL_SHIFT 2 /* LDO3_UV_LVL */
856#define WM8400_LDO3_UV_LVL_WIDTH 1 /* LDO3_UV_LVL */
857#define WM8400_LDO2_UV_LVL 0x0002 /* LDO2_UV_LVL */
858#define WM8400_LDO2_UV_LVL_MASK 0x0002 /* LDO2_UV_LVL */
859#define WM8400_LDO2_UV_LVL_SHIFT 1 /* LDO2_UV_LVL */
860#define WM8400_LDO2_UV_LVL_WIDTH 1 /* LDO2_UV_LVL */
861#define WM8400_LDO1_UV_LVL 0x0001 /* LDO1_UV_LVL */
862#define WM8400_LDO1_UV_LVL_MASK 0x0001 /* LDO1_UV_LVL */
863#define WM8400_LDO1_UV_LVL_SHIFT 0 /* LDO1_UV_LVL */
864#define WM8400_LDO1_UV_LVL_WIDTH 1 /* LDO1_UV_LVL */
865
866/*
867 * R82 (0x52) - Shutdown Reason
868 */
869#define WM8400_SDR_CHIP_SOFTSD 0x2000 /* SDR_CHIP_SOFTSD */
870#define WM8400_SDR_CHIP_SOFTSD_MASK 0x2000 /* SDR_CHIP_SOFTSD */
871#define WM8400_SDR_CHIP_SOFTSD_SHIFT 13 /* SDR_CHIP_SOFTSD */
872#define WM8400_SDR_CHIP_SOFTSD_WIDTH 1 /* SDR_CHIP_SOFTSD */
873#define WM8400_SDR_NPDN 0x0800 /* SDR_NPDN */
874#define WM8400_SDR_NPDN_MASK 0x0800 /* SDR_NPDN */
875#define WM8400_SDR_NPDN_SHIFT 11 /* SDR_NPDN */
876#define WM8400_SDR_NPDN_WIDTH 1 /* SDR_NPDN */
877#define WM8400_SDR_CHIP_GT150 0x0200 /* SDR_CHIP_GT150 */
878#define WM8400_SDR_CHIP_GT150_MASK 0x0200 /* SDR_CHIP_GT150 */
879#define WM8400_SDR_CHIP_GT150_SHIFT 9 /* SDR_CHIP_GT150 */
880#define WM8400_SDR_CHIP_GT150_WIDTH 1 /* SDR_CHIP_GT150 */
881#define WM8400_SDR_CHIP_GT115 0x0100 /* SDR_CHIP_GT115 */
882#define WM8400_SDR_CHIP_GT115_MASK 0x0100 /* SDR_CHIP_GT115 */
883#define WM8400_SDR_CHIP_GT115_SHIFT 8 /* SDR_CHIP_GT115 */
884#define WM8400_SDR_CHIP_GT115_WIDTH 1 /* SDR_CHIP_GT115 */
885#define WM8400_SDR_LINE_CMP 0x0080 /* SDR_LINE_CMP */
886#define WM8400_SDR_LINE_CMP_MASK 0x0080 /* SDR_LINE_CMP */
887#define WM8400_SDR_LINE_CMP_SHIFT 7 /* SDR_LINE_CMP */
888#define WM8400_SDR_LINE_CMP_WIDTH 1 /* SDR_LINE_CMP */
889#define WM8400_SDR_UVLO 0x0040 /* SDR_UVLO */
890#define WM8400_SDR_UVLO_MASK 0x0040 /* SDR_UVLO */
891#define WM8400_SDR_UVLO_SHIFT 6 /* SDR_UVLO */
892#define WM8400_SDR_UVLO_WIDTH 1 /* SDR_UVLO */
893#define WM8400_SDR_DC2_UV 0x0020 /* SDR_DC2_UV */
894#define WM8400_SDR_DC2_UV_MASK 0x0020 /* SDR_DC2_UV */
895#define WM8400_SDR_DC2_UV_SHIFT 5 /* SDR_DC2_UV */
896#define WM8400_SDR_DC2_UV_WIDTH 1 /* SDR_DC2_UV */
897#define WM8400_SDR_DC1_UV 0x0010 /* SDR_DC1_UV */
898#define WM8400_SDR_DC1_UV_MASK 0x0010 /* SDR_DC1_UV */
899#define WM8400_SDR_DC1_UV_SHIFT 4 /* SDR_DC1_UV */
900#define WM8400_SDR_DC1_UV_WIDTH 1 /* SDR_DC1_UV */
901#define WM8400_SDR_LDO4_UV 0x0008 /* SDR_LDO4_UV */
902#define WM8400_SDR_LDO4_UV_MASK 0x0008 /* SDR_LDO4_UV */
903#define WM8400_SDR_LDO4_UV_SHIFT 3 /* SDR_LDO4_UV */
904#define WM8400_SDR_LDO4_UV_WIDTH 1 /* SDR_LDO4_UV */
905#define WM8400_SDR_LDO3_UV 0x0004 /* SDR_LDO3_UV */
906#define WM8400_SDR_LDO3_UV_MASK 0x0004 /* SDR_LDO3_UV */
907#define WM8400_SDR_LDO3_UV_SHIFT 2 /* SDR_LDO3_UV */
908#define WM8400_SDR_LDO3_UV_WIDTH 1 /* SDR_LDO3_UV */
909#define WM8400_SDR_LDO2_UV 0x0002 /* SDR_LDO2_UV */
910#define WM8400_SDR_LDO2_UV_MASK 0x0002 /* SDR_LDO2_UV */
911#define WM8400_SDR_LDO2_UV_SHIFT 1 /* SDR_LDO2_UV */
912#define WM8400_SDR_LDO2_UV_WIDTH 1 /* SDR_LDO2_UV */
913#define WM8400_SDR_LDO1_UV 0x0001 /* SDR_LDO1_UV */
914#define WM8400_SDR_LDO1_UV_MASK 0x0001 /* SDR_LDO1_UV */
915#define WM8400_SDR_LDO1_UV_SHIFT 0 /* SDR_LDO1_UV */
916#define WM8400_SDR_LDO1_UV_WIDTH 1 /* SDR_LDO1_UV */
917
918/*
919 * R84 (0x54) - Line Circuits
920 */
921#define WM8400_BG_LINE_COMP 0x8000 /* BG_LINE_COMP */
922#define WM8400_BG_LINE_COMP_MASK 0x8000 /* BG_LINE_COMP */
923#define WM8400_BG_LINE_COMP_SHIFT 15 /* BG_LINE_COMP */
924#define WM8400_BG_LINE_COMP_WIDTH 1 /* BG_LINE_COMP */
925#define WM8400_LINE_CMP_VTHI_MASK 0x00F0 /* LINE_CMP_VTHI - [7:4] */
926#define WM8400_LINE_CMP_VTHI_SHIFT 4 /* LINE_CMP_VTHI - [7:4] */
927#define WM8400_LINE_CMP_VTHI_WIDTH 4 /* LINE_CMP_VTHI - [7:4] */
928#define WM8400_LINE_CMP_VTHD_MASK 0x000F /* LINE_CMP_VTHD - [3:0] */
929#define WM8400_LINE_CMP_VTHD_SHIFT 0 /* LINE_CMP_VTHD - [3:0] */
930#define WM8400_LINE_CMP_VTHD_WIDTH 4 /* LINE_CMP_VTHD - [3:0] */
931
932u16 wm8400_reg_read(struct wm8400 *wm8400, u8 reg);
933int wm8400_block_read(struct wm8400 *wm8400, u8 reg, int count, u16 *data);
934int wm8400_set_bits(struct wm8400 *wm8400, u8 reg, u16 mask, u16 val);
935
936#endif
diff --git a/include/linux/mfd/wm8400.h b/include/linux/mfd/wm8400.h
new file mode 100644
index 000000000000..b46b566ac1ac
--- /dev/null
+++ b/include/linux/mfd/wm8400.h
@@ -0,0 +1,40 @@
1/*
2 * wm8400 client interface
3 *
4 * Copyright 2008 Wolfson Microelectronics plc
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
21#ifndef __LINUX_MFD_WM8400_H
22#define __LINUX_MFD_WM8400_H
23
24#include <linux/regulator/machine.h>
25
26#define WM8400_LDO1 0
27#define WM8400_LDO2 1
28#define WM8400_LDO3 2
29#define WM8400_LDO4 3
30#define WM8400_DCDC1 4
31#define WM8400_DCDC2 5
32
33struct wm8400_platform_data {
34 int (*platform_init)(struct device *dev);
35};
36
37int wm8400_register_regulator(struct device *dev, int reg,
38 struct regulator_init_data *initdata);
39
40#endif
diff --git a/include/linux/migrate.h b/include/linux/migrate.h
index e10a90a93b5d..3f34005068d4 100644
--- a/include/linux/migrate.h
+++ b/include/linux/migrate.h
@@ -3,29 +3,10 @@
3 3
4#include <linux/mm.h> 4#include <linux/mm.h>
5#include <linux/mempolicy.h> 5#include <linux/mempolicy.h>
6#include <linux/pagemap.h>
7 6
8typedef struct page *new_page_t(struct page *, unsigned long private, int **); 7typedef struct page *new_page_t(struct page *, unsigned long private, int **);
9 8
10#ifdef CONFIG_MIGRATION 9#ifdef CONFIG_MIGRATION
11/* Check if a vma is migratable */
12static inline int vma_migratable(struct vm_area_struct *vma)
13{
14 if (vma->vm_flags & (VM_IO|VM_HUGETLB|VM_PFNMAP|VM_RESERVED))
15 return 0;
16 /*
17 * Migration allocates pages in the highest zone. If we cannot
18 * do so then migration (at least from node to node) is not
19 * possible.
20 */
21 if (vma->vm_file &&
22 gfp_zone(mapping_gfp_mask(vma->vm_file->f_mapping))
23 < policy_zone)
24 return 0;
25 return 1;
26}
27
28extern int isolate_lru_page(struct page *p, struct list_head *pagelist);
29extern int putback_lru_pages(struct list_head *l); 10extern int putback_lru_pages(struct list_head *l);
30extern int migrate_page(struct address_space *, 11extern int migrate_page(struct address_space *,
31 struct page *, struct page *); 12 struct page *, struct page *);
@@ -39,11 +20,6 @@ extern int migrate_vmas(struct mm_struct *mm,
39 const nodemask_t *from, const nodemask_t *to, 20 const nodemask_t *from, const nodemask_t *to,
40 unsigned long flags); 21 unsigned long flags);
41#else 22#else
42static inline int vma_migratable(struct vm_area_struct *vma)
43 { return 0; }
44
45static inline int isolate_lru_page(struct page *p, struct list_head *list)
46 { return -ENOSYS; }
47static inline int putback_lru_pages(struct list_head *l) { return 0; } 23static inline int putback_lru_pages(struct list_head *l) { return 0; }
48static inline int migrate_pages(struct list_head *l, new_page_t x, 24static inline int migrate_pages(struct list_head *l, new_page_t x,
49 unsigned long private) { return -ENOSYS; } 25 unsigned long private) { return -ENOSYS; }
diff --git a/include/linux/mlx4/cmd.h b/include/linux/mlx4/cmd.h
index 77323a72dd3c..cf9c679ab38b 100644
--- a/include/linux/mlx4/cmd.h
+++ b/include/linux/mlx4/cmd.h
@@ -132,6 +132,15 @@ enum {
132 MLX4_MAILBOX_SIZE = 4096 132 MLX4_MAILBOX_SIZE = 4096
133}; 133};
134 134
135enum {
136 /* set port opcode modifiers */
137 MLX4_SET_PORT_GENERAL = 0x0,
138 MLX4_SET_PORT_RQP_CALC = 0x1,
139 MLX4_SET_PORT_MAC_TABLE = 0x2,
140 MLX4_SET_PORT_VLAN_TABLE = 0x3,
141 MLX4_SET_PORT_PRIO_MAP = 0x4,
142};
143
135struct mlx4_dev; 144struct mlx4_dev;
136 145
137struct mlx4_cmd_mailbox { 146struct mlx4_cmd_mailbox {
diff --git a/include/linux/mlx4/cq.h b/include/linux/mlx4/cq.h
index 071cf96cf01f..6f65b2c8bb89 100644
--- a/include/linux/mlx4/cq.h
+++ b/include/linux/mlx4/cq.h
@@ -39,17 +39,18 @@
39#include <linux/mlx4/doorbell.h> 39#include <linux/mlx4/doorbell.h>
40 40
41struct mlx4_cqe { 41struct mlx4_cqe {
42 __be32 my_qpn; 42 __be32 vlan_my_qpn;
43 __be32 immed_rss_invalid; 43 __be32 immed_rss_invalid;
44 __be32 g_mlpath_rqpn; 44 __be32 g_mlpath_rqpn;
45 u8 sl; 45 __be16 sl_vid;
46 u8 reserved1;
47 __be16 rlid; 46 __be16 rlid;
48 __be32 ipoib_status; 47 __be16 status;
48 u8 ipv6_ext_mask;
49 u8 badfcs_enc;
49 __be32 byte_cnt; 50 __be32 byte_cnt;
50 __be16 wqe_index; 51 __be16 wqe_index;
51 __be16 checksum; 52 __be16 checksum;
52 u8 reserved2[3]; 53 u8 reserved[3];
53 u8 owner_sr_opcode; 54 u8 owner_sr_opcode;
54}; 55};
55 56
@@ -64,6 +65,11 @@ struct mlx4_err_cqe {
64}; 65};
65 66
66enum { 67enum {
68 MLX4_CQE_VLAN_PRESENT_MASK = 1 << 29,
69 MLX4_CQE_QPN_MASK = 0xffffff,
70};
71
72enum {
67 MLX4_CQE_OWNER_MASK = 0x80, 73 MLX4_CQE_OWNER_MASK = 0x80,
68 MLX4_CQE_IS_SEND_MASK = 0x40, 74 MLX4_CQE_IS_SEND_MASK = 0x40,
69 MLX4_CQE_OPCODE_MASK = 0x1f 75 MLX4_CQE_OPCODE_MASK = 0x1f
@@ -86,13 +92,19 @@ enum {
86}; 92};
87 93
88enum { 94enum {
89 MLX4_CQE_IPOIB_STATUS_IPV4 = 1 << 22, 95 MLX4_CQE_STATUS_IPV4 = 1 << 6,
90 MLX4_CQE_IPOIB_STATUS_IPV4F = 1 << 23, 96 MLX4_CQE_STATUS_IPV4F = 1 << 7,
91 MLX4_CQE_IPOIB_STATUS_IPV6 = 1 << 24, 97 MLX4_CQE_STATUS_IPV6 = 1 << 8,
92 MLX4_CQE_IPOIB_STATUS_IPV4OPT = 1 << 25, 98 MLX4_CQE_STATUS_IPV4OPT = 1 << 9,
93 MLX4_CQE_IPOIB_STATUS_TCP = 1 << 26, 99 MLX4_CQE_STATUS_TCP = 1 << 10,
94 MLX4_CQE_IPOIB_STATUS_UDP = 1 << 27, 100 MLX4_CQE_STATUS_UDP = 1 << 11,
95 MLX4_CQE_IPOIB_STATUS_IPOK = 1 << 28, 101 MLX4_CQE_STATUS_IPOK = 1 << 12,
102};
103
104enum {
105 MLX4_CQE_LLC = 1,
106 MLX4_CQE_SNAP = 1 << 1,
107 MLX4_CQE_BAD_FCS = 1 << 4,
96}; 108};
97 109
98static inline void mlx4_cq_arm(struct mlx4_cq *cq, u32 cmd, 110static inline void mlx4_cq_arm(struct mlx4_cq *cq, u32 cmd,
diff --git a/include/linux/mlx4/device.h b/include/linux/mlx4/device.h
index 81b3dd5206e0..bd9977b89490 100644
--- a/include/linux/mlx4/device.h
+++ b/include/linux/mlx4/device.h
@@ -60,6 +60,7 @@ enum {
60 MLX4_DEV_CAP_FLAG_IPOIB_CSUM = 1 << 7, 60 MLX4_DEV_CAP_FLAG_IPOIB_CSUM = 1 << 7,
61 MLX4_DEV_CAP_FLAG_BAD_PKEY_CNTR = 1 << 8, 61 MLX4_DEV_CAP_FLAG_BAD_PKEY_CNTR = 1 << 8,
62 MLX4_DEV_CAP_FLAG_BAD_QKEY_CNTR = 1 << 9, 62 MLX4_DEV_CAP_FLAG_BAD_QKEY_CNTR = 1 << 9,
63 MLX4_DEV_CAP_FLAG_DPDP = 1 << 12,
63 MLX4_DEV_CAP_FLAG_MEM_WINDOW = 1 << 16, 64 MLX4_DEV_CAP_FLAG_MEM_WINDOW = 1 << 16,
64 MLX4_DEV_CAP_FLAG_APM = 1 << 17, 65 MLX4_DEV_CAP_FLAG_APM = 1 << 17,
65 MLX4_DEV_CAP_FLAG_ATOMIC = 1 << 18, 66 MLX4_DEV_CAP_FLAG_ATOMIC = 1 << 18,
@@ -68,6 +69,14 @@ enum {
68 MLX4_DEV_CAP_FLAG_UD_MCAST = 1 << 21 69 MLX4_DEV_CAP_FLAG_UD_MCAST = 1 << 21
69}; 70};
70 71
72enum {
73 MLX4_BMME_FLAG_LOCAL_INV = 1 << 6,
74 MLX4_BMME_FLAG_REMOTE_INV = 1 << 7,
75 MLX4_BMME_FLAG_TYPE_2_WIN = 1 << 9,
76 MLX4_BMME_FLAG_RESERVED_LKEY = 1 << 10,
77 MLX4_BMME_FLAG_FAST_REG_WR = 1 << 11,
78};
79
71enum mlx4_event { 80enum mlx4_event {
72 MLX4_EVENT_TYPE_COMP = 0x00, 81 MLX4_EVENT_TYPE_COMP = 0x00,
73 MLX4_EVENT_TYPE_PATH_MIG = 0x01, 82 MLX4_EVENT_TYPE_PATH_MIG = 0x01,
@@ -133,6 +142,33 @@ enum {
133 MLX4_STAT_RATE_OFFSET = 5 142 MLX4_STAT_RATE_OFFSET = 5
134}; 143};
135 144
145enum {
146 MLX4_MTT_FLAG_PRESENT = 1
147};
148
149enum mlx4_qp_region {
150 MLX4_QP_REGION_FW = 0,
151 MLX4_QP_REGION_ETH_ADDR,
152 MLX4_QP_REGION_FC_ADDR,
153 MLX4_QP_REGION_FC_EXCH,
154 MLX4_NUM_QP_REGION
155};
156
157enum mlx4_port_type {
158 MLX4_PORT_TYPE_IB = 1 << 0,
159 MLX4_PORT_TYPE_ETH = 1 << 1,
160};
161
162enum mlx4_special_vlan_idx {
163 MLX4_NO_VLAN_IDX = 0,
164 MLX4_VLAN_MISS_IDX,
165 MLX4_VLAN_REGULAR
166};
167
168enum {
169 MLX4_NUM_FEXCH = 64 * 1024,
170};
171
136static inline u64 mlx4_fw_ver(u64 major, u64 minor, u64 subminor) 172static inline u64 mlx4_fw_ver(u64 major, u64 minor, u64 subminor)
137{ 173{
138 return (major << 32) | (minor << 16) | subminor; 174 return (major << 32) | (minor << 16) | subminor;
@@ -142,7 +178,9 @@ struct mlx4_caps {
142 u64 fw_ver; 178 u64 fw_ver;
143 int num_ports; 179 int num_ports;
144 int vl_cap[MLX4_MAX_PORTS + 1]; 180 int vl_cap[MLX4_MAX_PORTS + 1];
145 int mtu_cap[MLX4_MAX_PORTS + 1]; 181 int ib_mtu_cap[MLX4_MAX_PORTS + 1];
182 u64 def_mac[MLX4_MAX_PORTS + 1];
183 int eth_mtu_cap[MLX4_MAX_PORTS + 1];
146 int gid_table_len[MLX4_MAX_PORTS + 1]; 184 int gid_table_len[MLX4_MAX_PORTS + 1];
147 int pkey_table_len[MLX4_MAX_PORTS + 1]; 185 int pkey_table_len[MLX4_MAX_PORTS + 1];
148 int local_ca_ack_delay; 186 int local_ca_ack_delay;
@@ -157,7 +195,6 @@ struct mlx4_caps {
157 int max_rq_desc_sz; 195 int max_rq_desc_sz;
158 int max_qp_init_rdma; 196 int max_qp_init_rdma;
159 int max_qp_dest_rdma; 197 int max_qp_dest_rdma;
160 int reserved_qps;
161 int sqp_start; 198 int sqp_start;
162 int num_srqs; 199 int num_srqs;
163 int max_srq_wqes; 200 int max_srq_wqes;
@@ -184,9 +221,20 @@ struct mlx4_caps {
184 u32 max_msg_sz; 221 u32 max_msg_sz;
185 u32 page_size_cap; 222 u32 page_size_cap;
186 u32 flags; 223 u32 flags;
224 u32 bmme_flags;
225 u32 reserved_lkey;
187 u16 stat_rate_support; 226 u16 stat_rate_support;
188 u8 port_width_cap[MLX4_MAX_PORTS + 1]; 227 u8 port_width_cap[MLX4_MAX_PORTS + 1];
189 int max_gso_sz; 228 int max_gso_sz;
229 int reserved_qps_cnt[MLX4_NUM_QP_REGION];
230 int reserved_qps;
231 int reserved_qps_base[MLX4_NUM_QP_REGION];
232 int log_num_macs;
233 int log_num_vlans;
234 int log_num_prios;
235 enum mlx4_port_type port_type[MLX4_MAX_PORTS + 1];
236 u8 supported_type[MLX4_MAX_PORTS + 1];
237 u32 port_mask;
190}; 238};
191 239
192struct mlx4_buf_list { 240struct mlx4_buf_list {
@@ -341,6 +389,11 @@ struct mlx4_init_port_param {
341 u64 si_guid; 389 u64 si_guid;
342}; 390};
343 391
392#define mlx4_foreach_port(port, dev, type) \
393 for ((port) = 1; (port) <= (dev)->caps.num_ports; (port)++) \
394 if (((type) == MLX4_PORT_TYPE_IB ? (dev)->caps.port_mask : \
395 ~(dev)->caps.port_mask) & 1 << ((port) - 1))
396
344int mlx4_buf_alloc(struct mlx4_dev *dev, int size, int max_direct, 397int mlx4_buf_alloc(struct mlx4_dev *dev, int size, int max_direct,
345 struct mlx4_buf *buf); 398 struct mlx4_buf *buf);
346void mlx4_buf_free(struct mlx4_dev *dev, int size, struct mlx4_buf *buf); 399void mlx4_buf_free(struct mlx4_dev *dev, int size, struct mlx4_buf *buf);
@@ -386,7 +439,10 @@ int mlx4_cq_alloc(struct mlx4_dev *dev, int nent, struct mlx4_mtt *mtt,
386 int collapsed); 439 int collapsed);
387void mlx4_cq_free(struct mlx4_dev *dev, struct mlx4_cq *cq); 440void mlx4_cq_free(struct mlx4_dev *dev, struct mlx4_cq *cq);
388 441
389int mlx4_qp_alloc(struct mlx4_dev *dev, int sqpn, struct mlx4_qp *qp); 442int mlx4_qp_reserve_range(struct mlx4_dev *dev, int cnt, int align, int *base);
443void mlx4_qp_release_range(struct mlx4_dev *dev, int base_qpn, int cnt);
444
445int mlx4_qp_alloc(struct mlx4_dev *dev, int qpn, struct mlx4_qp *qp);
390void mlx4_qp_free(struct mlx4_dev *dev, struct mlx4_qp *qp); 446void mlx4_qp_free(struct mlx4_dev *dev, struct mlx4_qp *qp);
391 447
392int mlx4_srq_alloc(struct mlx4_dev *dev, u32 pdn, struct mlx4_mtt *mtt, 448int mlx4_srq_alloc(struct mlx4_dev *dev, u32 pdn, struct mlx4_mtt *mtt,
@@ -402,6 +458,12 @@ int mlx4_multicast_attach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
402 int block_mcast_loopback); 458 int block_mcast_loopback);
403int mlx4_multicast_detach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16]); 459int mlx4_multicast_detach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16]);
404 460
461int mlx4_register_mac(struct mlx4_dev *dev, u8 port, u64 mac, int *index);
462void mlx4_unregister_mac(struct mlx4_dev *dev, u8 port, int index);
463
464int mlx4_register_vlan(struct mlx4_dev *dev, u8 port, u16 vlan, int *index);
465void mlx4_unregister_vlan(struct mlx4_dev *dev, u8 port, int index);
466
405int mlx4_map_phys_fmr(struct mlx4_dev *dev, struct mlx4_fmr *fmr, u64 *page_list, 467int mlx4_map_phys_fmr(struct mlx4_dev *dev, struct mlx4_fmr *fmr, u64 *page_list,
406 int npages, u64 iova, u32 *lkey, u32 *rkey); 468 int npages, u64 iova, u32 *lkey, u32 *rkey);
407int mlx4_fmr_alloc(struct mlx4_dev *dev, u32 pd, u32 access, int max_pages, 469int mlx4_fmr_alloc(struct mlx4_dev *dev, u32 pd, u32 access, int max_pages,
diff --git a/include/linux/mlx4/qp.h b/include/linux/mlx4/qp.h
index 7f128b266faa..bf8f11982dae 100644
--- a/include/linux/mlx4/qp.h
+++ b/include/linux/mlx4/qp.h
@@ -164,11 +164,13 @@ enum {
164 MLX4_WQE_CTRL_SOLICITED = 1 << 1, 164 MLX4_WQE_CTRL_SOLICITED = 1 << 1,
165 MLX4_WQE_CTRL_IP_CSUM = 1 << 4, 165 MLX4_WQE_CTRL_IP_CSUM = 1 << 4,
166 MLX4_WQE_CTRL_TCP_UDP_CSUM = 1 << 5, 166 MLX4_WQE_CTRL_TCP_UDP_CSUM = 1 << 5,
167 MLX4_WQE_CTRL_INS_VLAN = 1 << 6,
167}; 168};
168 169
169struct mlx4_wqe_ctrl_seg { 170struct mlx4_wqe_ctrl_seg {
170 __be32 owner_opcode; 171 __be32 owner_opcode;
171 u8 reserved2[3]; 172 __be16 vlan_tag;
173 u8 ins_vlan;
172 u8 fence_size; 174 u8 fence_size;
173 /* 175 /*
174 * High 24 bits are SRC remote buffer; low 8 bits are flags: 176 * High 24 bits are SRC remote buffer; low 8 bits are flags:
@@ -219,7 +221,7 @@ struct mlx4_wqe_datagram_seg {
219 __be32 reservd[2]; 221 __be32 reservd[2];
220}; 222};
221 223
222struct mlx4_lso_seg { 224struct mlx4_wqe_lso_seg {
223 __be32 mss_hdr_size; 225 __be32 mss_hdr_size;
224 __be32 header[0]; 226 __be32 header[0];
225}; 227};
@@ -233,6 +235,14 @@ struct mlx4_wqe_bind_seg {
233 __be64 length; 235 __be64 length;
234}; 236};
235 237
238enum {
239 MLX4_WQE_FMR_PERM_LOCAL_READ = 1 << 27,
240 MLX4_WQE_FMR_PERM_LOCAL_WRITE = 1 << 28,
241 MLX4_WQE_FMR_PERM_REMOTE_READ = 1 << 29,
242 MLX4_WQE_FMR_PERM_REMOTE_WRITE = 1 << 30,
243 MLX4_WQE_FMR_PERM_ATOMIC = 1 << 31
244};
245
236struct mlx4_wqe_fmr_seg { 246struct mlx4_wqe_fmr_seg {
237 __be32 flags; 247 __be32 flags;
238 __be32 mem_key; 248 __be32 mem_key;
@@ -255,11 +265,11 @@ struct mlx4_wqe_fmr_ext_seg {
255}; 265};
256 266
257struct mlx4_wqe_local_inval_seg { 267struct mlx4_wqe_local_inval_seg {
258 u8 flags; 268 __be32 flags;
259 u8 reserved1[3]; 269 u32 reserved1;
260 __be32 mem_key; 270 __be32 mem_key;
261 u8 reserved2[3]; 271 u32 reserved2[2];
262 u8 guest_id; 272 __be32 guest_id;
263 __be64 pa; 273 __be64 pa;
264}; 274};
265 275
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 2128ef7780c6..ffee2f743418 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -7,6 +7,7 @@
7 7
8#include <linux/gfp.h> 8#include <linux/gfp.h>
9#include <linux/list.h> 9#include <linux/list.h>
10#include <linux/mmdebug.h>
10#include <linux/mmzone.h> 11#include <linux/mmzone.h>
11#include <linux/rbtree.h> 12#include <linux/rbtree.h>
12#include <linux/prio_tree.h> 13#include <linux/prio_tree.h>
@@ -41,6 +42,9 @@ extern unsigned long mmap_min_addr;
41 42
42#define nth_page(page,n) pfn_to_page(page_to_pfn((page)) + (n)) 43#define nth_page(page,n) pfn_to_page(page_to_pfn((page)) + (n))
43 44
45/* to align the pointer to the (next) page boundary */
46#define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE)
47
44/* 48/*
45 * Linux kernel virtual memory manager primitives. 49 * Linux kernel virtual memory manager primitives.
46 * The idea being to have a "virtual" mm in the same way 50 * The idea being to have a "virtual" mm in the same way
@@ -70,7 +74,7 @@ extern unsigned int kobjsize(const void *objp);
70#endif 74#endif
71 75
72/* 76/*
73 * vm_flags.. 77 * vm_flags in vm_area_struct, see mm_types.h.
74 */ 78 */
75#define VM_READ 0x00000001 /* currently active flags */ 79#define VM_READ 0x00000001 /* currently active flags */
76#define VM_WRITE 0x00000002 80#define VM_WRITE 0x00000002
@@ -100,6 +104,7 @@ extern unsigned int kobjsize(const void *objp);
100#define VM_DONTEXPAND 0x00040000 /* Cannot expand with mremap() */ 104#define VM_DONTEXPAND 0x00040000 /* Cannot expand with mremap() */
101#define VM_RESERVED 0x00080000 /* Count as reserved_vm like IO */ 105#define VM_RESERVED 0x00080000 /* Count as reserved_vm like IO */
102#define VM_ACCOUNT 0x00100000 /* Is a VM accounted object */ 106#define VM_ACCOUNT 0x00100000 /* Is a VM accounted object */
107#define VM_NORESERVE 0x00200000 /* should the VM suppress accounting */
103#define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */ 108#define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
104#define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */ 109#define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
105#define VM_MAPPED_COPY 0x01000000 /* T if mapped copy of data (nommu mmap) */ 110#define VM_MAPPED_COPY 0x01000000 /* T if mapped copy of data (nommu mmap) */
@@ -127,6 +132,11 @@ extern unsigned int kobjsize(const void *objp);
127#define VM_RandomReadHint(v) ((v)->vm_flags & VM_RAND_READ) 132#define VM_RandomReadHint(v) ((v)->vm_flags & VM_RAND_READ)
128 133
129/* 134/*
135 * special vmas that are non-mergable, non-mlock()able
136 */
137#define VM_SPECIAL (VM_IO | VM_DONTEXPAND | VM_RESERVED | VM_PFNMAP)
138
139/*
130 * mapping from the currently active vm_flags protection bits (the 140 * mapping from the currently active vm_flags protection bits (the
131 * low four bits) to a page protection mask.. 141 * low four bits) to a page protection mask..
132 */ 142 */
@@ -166,12 +176,16 @@ struct vm_operations_struct {
166 void (*open)(struct vm_area_struct * area); 176 void (*open)(struct vm_area_struct * area);
167 void (*close)(struct vm_area_struct * area); 177 void (*close)(struct vm_area_struct * area);
168 int (*fault)(struct vm_area_struct *vma, struct vm_fault *vmf); 178 int (*fault)(struct vm_area_struct *vma, struct vm_fault *vmf);
169 unsigned long (*nopfn)(struct vm_area_struct *area,
170 unsigned long address);
171 179
172 /* notification that a previously read-only page is about to become 180 /* notification that a previously read-only page is about to become
173 * writable, if an error is returned it will cause a SIGBUS */ 181 * writable, if an error is returned it will cause a SIGBUS */
174 int (*page_mkwrite)(struct vm_area_struct *vma, struct page *page); 182 int (*page_mkwrite)(struct vm_area_struct *vma, struct page *page);
183
184 /* called by access_process_vm when get_user_pages() fails, typically
185 * for use by special VMAs that can switch between memory and hardware
186 */
187 int (*access)(struct vm_area_struct *vma, unsigned long addr,
188 void *buf, int len, int write);
175#ifdef CONFIG_NUMA 189#ifdef CONFIG_NUMA
176 /* 190 /*
177 * set_policy() op must add a reference to any non-NULL @new mempolicy 191 * set_policy() op must add a reference to any non-NULL @new mempolicy
@@ -211,12 +225,6 @@ struct inode;
211 */ 225 */
212#include <linux/page-flags.h> 226#include <linux/page-flags.h>
213 227
214#ifdef CONFIG_DEBUG_VM
215#define VM_BUG_ON(cond) BUG_ON(cond)
216#else
217#define VM_BUG_ON(condition) do { } while(0)
218#endif
219
220/* 228/*
221 * Methods to modify the page usage count. 229 * Methods to modify the page usage count.
222 * 230 *
@@ -675,13 +683,6 @@ static inline int page_mapped(struct page *page)
675} 683}
676 684
677/* 685/*
678 * Error return values for the *_nopfn functions
679 */
680#define NOPFN_SIGBUS ((unsigned long) -1)
681#define NOPFN_OOM ((unsigned long) -2)
682#define NOPFN_REFAULT ((unsigned long) -3)
683
684/*
685 * Different kinds of faults, as returned by handle_mm_fault(). 686 * Different kinds of faults, as returned by handle_mm_fault().
686 * Used to decide whether a process gets delivered SIGBUS or 687 * Used to decide whether a process gets delivered SIGBUS or
687 * just gets major/minor fault counters bumped up. 688 * just gets major/minor fault counters bumped up.
@@ -704,10 +705,10 @@ static inline int page_mapped(struct page *page)
704extern void show_free_areas(void); 705extern void show_free_areas(void);
705 706
706#ifdef CONFIG_SHMEM 707#ifdef CONFIG_SHMEM
707int shmem_lock(struct file *file, int lock, struct user_struct *user); 708extern int shmem_lock(struct file *file, int lock, struct user_struct *user);
708#else 709#else
709static inline int shmem_lock(struct file *file, int lock, 710static inline int shmem_lock(struct file *file, int lock,
710 struct user_struct *user) 711 struct user_struct *user)
711{ 712{
712 return 0; 713 return 0;
713} 714}
@@ -743,6 +744,8 @@ struct zap_details {
743struct page *vm_normal_page(struct vm_area_struct *vma, unsigned long addr, 744struct page *vm_normal_page(struct vm_area_struct *vma, unsigned long addr,
744 pte_t pte); 745 pte_t pte);
745 746
747int zap_vma_ptes(struct vm_area_struct *vma, unsigned long address,
748 unsigned long size);
746unsigned long zap_page_range(struct vm_area_struct *vma, unsigned long address, 749unsigned long zap_page_range(struct vm_area_struct *vma, unsigned long address,
747 unsigned long size, struct zap_details *); 750 unsigned long size, struct zap_details *);
748unsigned long unmap_vmas(struct mmu_gather **tlb, 751unsigned long unmap_vmas(struct mmu_gather **tlb,
@@ -772,14 +775,14 @@ struct mm_walk {
772 775
773int walk_page_range(unsigned long addr, unsigned long end, 776int walk_page_range(unsigned long addr, unsigned long end,
774 struct mm_walk *walk); 777 struct mm_walk *walk);
775void free_pgd_range(struct mmu_gather **tlb, unsigned long addr, 778void free_pgd_range(struct mmu_gather *tlb, unsigned long addr,
776 unsigned long end, unsigned long floor, unsigned long ceiling); 779 unsigned long end, unsigned long floor, unsigned long ceiling);
777void free_pgtables(struct mmu_gather **tlb, struct vm_area_struct *start_vma,
778 unsigned long floor, unsigned long ceiling);
779int copy_page_range(struct mm_struct *dst, struct mm_struct *src, 780int copy_page_range(struct mm_struct *dst, struct mm_struct *src,
780 struct vm_area_struct *vma); 781 struct vm_area_struct *vma);
781void unmap_mapping_range(struct address_space *mapping, 782void unmap_mapping_range(struct address_space *mapping,
782 loff_t const holebegin, loff_t const holelen, int even_cows); 783 loff_t const holebegin, loff_t const holelen, int even_cows);
784int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
785 void *buf, int len, int write);
783 786
784static inline void unmap_shared_mapping_range(struct address_space *mapping, 787static inline void unmap_shared_mapping_range(struct address_space *mapping,
785 loff_t const holebegin, loff_t const holelen) 788 loff_t const holebegin, loff_t const holelen)
@@ -809,7 +812,6 @@ extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *
809 812
810int get_user_pages(struct task_struct *tsk, struct mm_struct *mm, unsigned long start, 813int get_user_pages(struct task_struct *tsk, struct mm_struct *mm, unsigned long start,
811 int len, int write, int force, struct page **pages, struct vm_area_struct **vmas); 814 int len, int write, int force, struct page **pages, struct vm_area_struct **vmas);
812void print_bad_pte(struct vm_area_struct *, pte_t, unsigned long);
813 815
814extern int try_to_release_page(struct page * page, gfp_t gfp_mask); 816extern int try_to_release_page(struct page * page, gfp_t gfp_mask);
815extern void do_invalidatepage(struct page *page, unsigned long offset); 817extern void do_invalidatepage(struct page *page, unsigned long offset);
@@ -833,6 +835,19 @@ extern int mprotect_fixup(struct vm_area_struct *vma,
833 unsigned long end, unsigned long newflags); 835 unsigned long end, unsigned long newflags);
834 836
835/* 837/*
838 * get_user_pages_fast provides equivalent functionality to get_user_pages,
839 * operating on current and current->mm (force=0 and doesn't return any vmas).
840 *
841 * get_user_pages_fast may take mmap_sem and page tables, so no assumptions
842 * can be made about locking. get_user_pages_fast is to be implemented in a
843 * way that is advantageous (vs get_user_pages()) when the user memory area is
844 * already faulted in and present in ptes. However if the pages have to be
845 * faulted in, it may turn out to be slightly slower).
846 */
847int get_user_pages_fast(unsigned long start, int nr_pages, int write,
848 struct page **pages);
849
850/*
836 * A callback you can register to apply pressure to ageable caches. 851 * A callback you can register to apply pressure to ageable caches.
837 * 852 *
838 * 'shrink' is passed a count 'nr_to_scan' and a 'gfpmask'. It should 853 * 'shrink' is passed a count 'nr_to_scan' and a 'gfpmask'. It should
@@ -904,7 +919,7 @@ static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long a
904} 919}
905#endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */ 920#endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
906 921
907#if NR_CPUS >= CONFIG_SPLIT_PTLOCK_CPUS 922#if USE_SPLIT_PTLOCKS
908/* 923/*
909 * We tuck a spinlock to guard each pagetable page into its struct page, 924 * We tuck a spinlock to guard each pagetable page into its struct page,
910 * at page->private, with BUILD_BUG_ON to make sure that this will not 925 * at page->private, with BUILD_BUG_ON to make sure that this will not
@@ -917,14 +932,14 @@ static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long a
917} while (0) 932} while (0)
918#define pte_lock_deinit(page) ((page)->mapping = NULL) 933#define pte_lock_deinit(page) ((page)->mapping = NULL)
919#define pte_lockptr(mm, pmd) ({(void)(mm); __pte_lockptr(pmd_page(*(pmd)));}) 934#define pte_lockptr(mm, pmd) ({(void)(mm); __pte_lockptr(pmd_page(*(pmd)));})
920#else 935#else /* !USE_SPLIT_PTLOCKS */
921/* 936/*
922 * We use mm->page_table_lock to guard all pagetable pages of the mm. 937 * We use mm->page_table_lock to guard all pagetable pages of the mm.
923 */ 938 */
924#define pte_lock_init(page) do {} while (0) 939#define pte_lock_init(page) do {} while (0)
925#define pte_lock_deinit(page) do {} while (0) 940#define pte_lock_deinit(page) do {} while (0)
926#define pte_lockptr(mm, pmd) ({(void)(pmd); &(mm)->page_table_lock;}) 941#define pte_lockptr(mm, pmd) ({(void)(pmd); &(mm)->page_table_lock;})
927#endif /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */ 942#endif /* USE_SPLIT_PTLOCKS */
928 943
929static inline void pgtable_page_ctor(struct page *page) 944static inline void pgtable_page_ctor(struct page *page)
930{ 945{
@@ -965,9 +980,8 @@ static inline void pgtable_page_dtor(struct page *page)
965 NULL: pte_offset_kernel(pmd, address)) 980 NULL: pte_offset_kernel(pmd, address))
966 981
967extern void free_area_init(unsigned long * zones_size); 982extern void free_area_init(unsigned long * zones_size);
968extern void free_area_init_node(int nid, pg_data_t *pgdat, 983extern void free_area_init_node(int nid, unsigned long * zones_size,
969 unsigned long * zones_size, unsigned long zone_start_pfn, 984 unsigned long zone_start_pfn, unsigned long *zholes_size);
970 unsigned long *zholes_size);
971#ifdef CONFIG_ARCH_POPULATES_NODE_MAP 985#ifdef CONFIG_ARCH_POPULATES_NODE_MAP
972/* 986/*
973 * With CONFIG_ARCH_POPULATES_NODE_MAP set, an architecture may initialise its 987 * With CONFIG_ARCH_POPULATES_NODE_MAP set, an architecture may initialise its
@@ -1009,7 +1023,6 @@ extern unsigned long absent_pages_in_range(unsigned long start_pfn,
1009extern void get_pfn_range_for_nid(unsigned int nid, 1023extern void get_pfn_range_for_nid(unsigned int nid,
1010 unsigned long *start_pfn, unsigned long *end_pfn); 1024 unsigned long *start_pfn, unsigned long *end_pfn);
1011extern unsigned long find_min_pfn_with_active_regions(void); 1025extern unsigned long find_min_pfn_with_active_regions(void);
1012extern unsigned long find_max_pfn_with_active_regions(void);
1013extern void free_bootmem_with_active_regions(int nid, 1026extern void free_bootmem_with_active_regions(int nid,
1014 unsigned long max_low_pfn); 1027 unsigned long max_low_pfn);
1015typedef int (*work_fn_t)(unsigned long, unsigned long, void *); 1028typedef int (*work_fn_t)(unsigned long, unsigned long, void *);
@@ -1072,6 +1085,9 @@ extern struct vm_area_struct *copy_vma(struct vm_area_struct **,
1072 unsigned long addr, unsigned long len, pgoff_t pgoff); 1085 unsigned long addr, unsigned long len, pgoff_t pgoff);
1073extern void exit_mmap(struct mm_struct *); 1086extern void exit_mmap(struct mm_struct *);
1074 1087
1088extern int mm_take_all_locks(struct mm_struct *mm);
1089extern void mm_drop_all_locks(struct mm_struct *mm);
1090
1075#ifdef CONFIG_PROC_FS 1091#ifdef CONFIG_PROC_FS
1076/* From fs/proc/base.c. callers must _not_ hold the mm's exe_file_lock */ 1092/* From fs/proc/base.c. callers must _not_ hold the mm's exe_file_lock */
1077extern void added_exe_file_vma(struct mm_struct *mm); 1093extern void added_exe_file_vma(struct mm_struct *mm);
diff --git a/include/linux/mm_inline.h b/include/linux/mm_inline.h
index 895bc4e93039..c948350c378e 100644
--- a/include/linux/mm_inline.h
+++ b/include/linux/mm_inline.h
@@ -1,40 +1,100 @@
1static inline void 1#ifndef LINUX_MM_INLINE_H
2add_page_to_active_list(struct zone *zone, struct page *page) 2#define LINUX_MM_INLINE_H
3{
4 list_add(&page->lru, &zone->active_list);
5 __inc_zone_state(zone, NR_ACTIVE);
6}
7 3
8static inline void 4/**
9add_page_to_inactive_list(struct zone *zone, struct page *page) 5 * page_is_file_cache - should the page be on a file LRU or anon LRU?
6 * @page: the page to test
7 *
8 * Returns LRU_FILE if @page is page cache page backed by a regular filesystem,
9 * or 0 if @page is anonymous, tmpfs or otherwise ram or swap backed.
10 * Used by functions that manipulate the LRU lists, to sort a page
11 * onto the right LRU list.
12 *
13 * We would like to get this info without a page flag, but the state
14 * needs to survive until the page is last deleted from the LRU, which
15 * could be as far down as __page_cache_release.
16 */
17static inline int page_is_file_cache(struct page *page)
10{ 18{
11 list_add(&page->lru, &zone->inactive_list); 19 if (PageSwapBacked(page))
12 __inc_zone_state(zone, NR_INACTIVE); 20 return 0;
21
22 /* The page is page cache backed by a normal filesystem. */
23 return LRU_FILE;
13} 24}
14 25
15static inline void 26static inline void
16del_page_from_active_list(struct zone *zone, struct page *page) 27add_page_to_lru_list(struct zone *zone, struct page *page, enum lru_list l)
17{ 28{
18 list_del(&page->lru); 29 list_add(&page->lru, &zone->lru[l].list);
19 __dec_zone_state(zone, NR_ACTIVE); 30 __inc_zone_state(zone, NR_LRU_BASE + l);
20} 31}
21 32
22static inline void 33static inline void
23del_page_from_inactive_list(struct zone *zone, struct page *page) 34del_page_from_lru_list(struct zone *zone, struct page *page, enum lru_list l)
24{ 35{
25 list_del(&page->lru); 36 list_del(&page->lru);
26 __dec_zone_state(zone, NR_INACTIVE); 37 __dec_zone_state(zone, NR_LRU_BASE + l);
27} 38}
28 39
29static inline void 40static inline void
30del_page_from_lru(struct zone *zone, struct page *page) 41del_page_from_lru(struct zone *zone, struct page *page)
31{ 42{
43 enum lru_list l = LRU_BASE;
44
32 list_del(&page->lru); 45 list_del(&page->lru);
33 if (PageActive(page)) { 46 if (PageUnevictable(page)) {
34 __ClearPageActive(page); 47 __ClearPageUnevictable(page);
35 __dec_zone_state(zone, NR_ACTIVE); 48 l = LRU_UNEVICTABLE;
36 } else { 49 } else {
37 __dec_zone_state(zone, NR_INACTIVE); 50 if (PageActive(page)) {
51 __ClearPageActive(page);
52 l += LRU_ACTIVE;
53 }
54 l += page_is_file_cache(page);
55 }
56 __dec_zone_state(zone, NR_LRU_BASE + l);
57}
58
59/**
60 * page_lru - which LRU list should a page be on?
61 * @page: the page to test
62 *
63 * Returns the LRU list a page should be on, as an index
64 * into the array of LRU lists.
65 */
66static inline enum lru_list page_lru(struct page *page)
67{
68 enum lru_list lru = LRU_BASE;
69
70 if (PageUnevictable(page))
71 lru = LRU_UNEVICTABLE;
72 else {
73 if (PageActive(page))
74 lru += LRU_ACTIVE;
75 lru += page_is_file_cache(page);
38 } 76 }
77
78 return lru;
39} 79}
40 80
81/**
82 * inactive_anon_is_low - check if anonymous pages need to be deactivated
83 * @zone: zone to check
84 *
85 * Returns true if the zone does not have enough inactive anon pages,
86 * meaning some active anon pages need to be deactivated.
87 */
88static inline int inactive_anon_is_low(struct zone *zone)
89{
90 unsigned long active, inactive;
91
92 active = zone_page_state(zone, NR_ACTIVE_ANON);
93 inactive = zone_page_state(zone, NR_INACTIVE_ANON);
94
95 if (inactive * zone->inactive_ratio < active)
96 return 1;
97
98 return 0;
99}
100#endif
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index 02a27ae78539..fe825471d5aa 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -10,6 +10,7 @@
10#include <linux/rbtree.h> 10#include <linux/rbtree.h>
11#include <linux/rwsem.h> 11#include <linux/rwsem.h>
12#include <linux/completion.h> 12#include <linux/completion.h>
13#include <linux/cpumask.h>
13#include <asm/page.h> 14#include <asm/page.h>
14#include <asm/mmu.h> 15#include <asm/mmu.h>
15 16
@@ -20,11 +21,13 @@
20 21
21struct address_space; 22struct address_space;
22 23
23#if NR_CPUS >= CONFIG_SPLIT_PTLOCK_CPUS 24#define USE_SPLIT_PTLOCKS (NR_CPUS >= CONFIG_SPLIT_PTLOCK_CPUS)
25
26#if USE_SPLIT_PTLOCKS
24typedef atomic_long_t mm_counter_t; 27typedef atomic_long_t mm_counter_t;
25#else /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */ 28#else /* !USE_SPLIT_PTLOCKS */
26typedef unsigned long mm_counter_t; 29typedef unsigned long mm_counter_t;
27#endif /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */ 30#endif /* !USE_SPLIT_PTLOCKS */
28 31
29/* 32/*
30 * Each physical page in the system has a struct page associated with 33 * Each physical page in the system has a struct page associated with
@@ -64,7 +67,7 @@ struct page {
64 * see PAGE_MAPPING_ANON below. 67 * see PAGE_MAPPING_ANON below.
65 */ 68 */
66 }; 69 };
67#if NR_CPUS >= CONFIG_SPLIT_PTLOCK_CPUS 70#if USE_SPLIT_PTLOCKS
68 spinlock_t ptl; 71 spinlock_t ptl;
69#endif 72#endif
70 struct kmem_cache *slab; /* SLUB: Pointer to slab */ 73 struct kmem_cache *slab; /* SLUB: Pointer to slab */
@@ -91,9 +94,6 @@ struct page {
91 void *virtual; /* Kernel virtual address (NULL if 94 void *virtual; /* Kernel virtual address (NULL if
92 not kmapped, ie. highmem) */ 95 not kmapped, ie. highmem) */
93#endif /* WANT_PAGE_VIRTUAL */ 96#endif /* WANT_PAGE_VIRTUAL */
94#ifdef CONFIG_CGROUP_MEM_RES_CTLR
95 unsigned long page_cgroup;
96#endif
97}; 97};
98 98
99/* 99/*
@@ -112,7 +112,7 @@ struct vm_area_struct {
112 struct vm_area_struct *vm_next; 112 struct vm_area_struct *vm_next;
113 113
114 pgprot_t vm_page_prot; /* Access permissions of this VMA. */ 114 pgprot_t vm_page_prot; /* Access permissions of this VMA. */
115 unsigned long vm_flags; /* Flags, listed below. */ 115 unsigned long vm_flags; /* Flags, see mm.h. */
116 116
117 struct rb_node vm_rb; 117 struct rb_node vm_rb;
118 118
@@ -159,6 +159,17 @@ struct vm_area_struct {
159#endif 159#endif
160}; 160};
161 161
162struct core_thread {
163 struct task_struct *task;
164 struct core_thread *next;
165};
166
167struct core_state {
168 atomic_t nr_threads;
169 struct core_thread dumper;
170 struct completion startup;
171};
172
162struct mm_struct { 173struct mm_struct {
163 struct vm_area_struct * mmap; /* list of VMAs */ 174 struct vm_area_struct * mmap; /* list of VMAs */
164 struct rb_root mm_rb; 175 struct rb_root mm_rb;
@@ -175,7 +186,6 @@ struct mm_struct {
175 atomic_t mm_users; /* How many users with user space? */ 186 atomic_t mm_users; /* How many users with user space? */
176 atomic_t mm_count; /* How many references to "struct mm_struct" (users count as 1) */ 187 atomic_t mm_count; /* How many references to "struct mm_struct" (users count as 1) */
177 int map_count; /* number of VMAs */ 188 int map_count; /* number of VMAs */
178 int core_waiters;
179 struct rw_semaphore mmap_sem; 189 struct rw_semaphore mmap_sem;
180 spinlock_t page_table_lock; /* Protects page tables and some counters */ 190 spinlock_t page_table_lock; /* Protects page tables and some counters */
181 191
@@ -219,8 +229,7 @@ struct mm_struct {
219 229
220 unsigned long flags; /* Must use atomic bitops to access the bits */ 230 unsigned long flags; /* Must use atomic bitops to access the bits */
221 231
222 /* coredumping support */ 232 struct core_state *core_state; /* coredumping support */
223 struct completion *core_startup_done, core_done;
224 233
225 /* aio bits */ 234 /* aio bits */
226 rwlock_t ioctx_list_lock; /* aio lock */ 235 rwlock_t ioctx_list_lock; /* aio lock */
@@ -244,6 +253,9 @@ struct mm_struct {
244 struct file *exe_file; 253 struct file *exe_file;
245 unsigned long num_exe_file_vmas; 254 unsigned long num_exe_file_vmas;
246#endif 255#endif
256#ifdef CONFIG_MMU_NOTIFIER
257 struct mmu_notifier_mm *mmu_notifier_mm;
258#endif
247}; 259};
248 260
249#endif /* _LINUX_MM_TYPES_H */ 261#endif /* _LINUX_MM_TYPES_H */
diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h
index 0d508ac17d64..ee6e822d5994 100644
--- a/include/linux/mmc/card.h
+++ b/include/linux/mmc/card.h
@@ -111,6 +111,8 @@ struct mmc_card {
111 unsigned num_info; /* number of info strings */ 111 unsigned num_info; /* number of info strings */
112 const char **info; /* info strings */ 112 const char **info; /* info strings */
113 struct sdio_func_tuple *tuples; /* unknown common tuples */ 113 struct sdio_func_tuple *tuples; /* unknown common tuples */
114
115 struct dentry *debugfs_root;
114}; 116};
115 117
116#define mmc_card_mmc(c) ((c)->type == MMC_TYPE_MMC) 118#define mmc_card_mmc(c) ((c)->type == MMC_TYPE_MMC)
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index 10a2080086ca..bde891f64591 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -65,7 +65,7 @@ struct mmc_host_ops {
65 * -ENOSYS when not supported (equal to NULL callback) 65 * -ENOSYS when not supported (equal to NULL callback)
66 * or a negative errno value when something bad happened 66 * or a negative errno value when something bad happened
67 * 67 *
68 * Return values for the get_ro callback should be: 68 * Return values for the get_cd callback should be:
69 * 0 for a absent card 69 * 0 for a absent card
70 * 1 for a present card 70 * 1 for a present card
71 * -ENOSYS when not supported (equal to NULL callback) 71 * -ENOSYS when not supported (equal to NULL callback)
@@ -157,6 +157,8 @@ struct mmc_host {
157 struct led_trigger *led; /* activity led */ 157 struct led_trigger *led; /* activity led */
158#endif 158#endif
159 159
160 struct dentry *debugfs_root;
161
160 unsigned long private[0] ____cacheline_aligned; 162 unsigned long private[0] ____cacheline_aligned;
161}; 163};
162 164
diff --git a/include/linux/mmdebug.h b/include/linux/mmdebug.h
new file mode 100644
index 000000000000..8a5509877192
--- /dev/null
+++ b/include/linux/mmdebug.h
@@ -0,0 +1,18 @@
1#ifndef LINUX_MM_DEBUG_H
2#define LINUX_MM_DEBUG_H 1
3
4#include <linux/autoconf.h>
5
6#ifdef CONFIG_DEBUG_VM
7#define VM_BUG_ON(cond) BUG_ON(cond)
8#else
9#define VM_BUG_ON(cond) do { } while (0)
10#endif
11
12#ifdef CONFIG_DEBUG_VIRTUAL
13#define VIRTUAL_BUG_ON(cond) BUG_ON(cond)
14#else
15#define VIRTUAL_BUG_ON(cond) do { } while (0)
16#endif
17
18#endif
diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
index 61d19e1b7a0b..139d7c88d9c9 100644
--- a/include/linux/mmiotrace.h
+++ b/include/linux/mmiotrace.h
@@ -34,11 +34,15 @@ extern void unregister_kmmio_probe(struct kmmio_probe *p);
34/* Called from page fault handler. */ 34/* Called from page fault handler. */
35extern int kmmio_handler(struct pt_regs *regs, unsigned long addr); 35extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
36 36
37/* Called from ioremap.c */
38#ifdef CONFIG_MMIOTRACE 37#ifdef CONFIG_MMIOTRACE
38/* Called from ioremap.c */
39extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size, 39extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
40 void __iomem *addr); 40 void __iomem *addr);
41extern void mmiotrace_iounmap(volatile void __iomem *addr); 41extern void mmiotrace_iounmap(volatile void __iomem *addr);
42
43/* For anyone to insert markers. Remember trailing newline. */
44extern int mmiotrace_printk(const char *fmt, ...)
45 __attribute__ ((format (printf, 1, 2)));
42#else 46#else
43static inline void mmiotrace_ioremap(resource_size_t offset, 47static inline void mmiotrace_ioremap(resource_size_t offset,
44 unsigned long size, void __iomem *addr) 48 unsigned long size, void __iomem *addr)
@@ -48,15 +52,22 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
48static inline void mmiotrace_iounmap(volatile void __iomem *addr) 52static inline void mmiotrace_iounmap(volatile void __iomem *addr)
49{ 53{
50} 54}
51#endif /* CONFIG_MMIOTRACE_HOOKS */ 55
56static inline int mmiotrace_printk(const char *fmt, ...)
57 __attribute__ ((format (printf, 1, 0)));
58
59static inline int mmiotrace_printk(const char *fmt, ...)
60{
61 return 0;
62}
63#endif /* CONFIG_MMIOTRACE */
52 64
53enum mm_io_opcode { 65enum mm_io_opcode {
54 MMIO_READ = 0x1, /* struct mmiotrace_rw */ 66 MMIO_READ = 0x1, /* struct mmiotrace_rw */
55 MMIO_WRITE = 0x2, /* struct mmiotrace_rw */ 67 MMIO_WRITE = 0x2, /* struct mmiotrace_rw */
56 MMIO_PROBE = 0x3, /* struct mmiotrace_map */ 68 MMIO_PROBE = 0x3, /* struct mmiotrace_map */
57 MMIO_UNPROBE = 0x4, /* struct mmiotrace_map */ 69 MMIO_UNPROBE = 0x4, /* struct mmiotrace_map */
58 MMIO_MARKER = 0x5, /* raw char data */ 70 MMIO_UNKNOWN_OP = 0x5, /* struct mmiotrace_rw */
59 MMIO_UNKNOWN_OP = 0x6, /* struct mmiotrace_rw */
60}; 71};
61 72
62struct mmiotrace_rw { 73struct mmiotrace_rw {
@@ -81,5 +92,6 @@ extern void enable_mmiotrace(void);
81extern void disable_mmiotrace(void); 92extern void disable_mmiotrace(void);
82extern void mmio_trace_rw(struct mmiotrace_rw *rw); 93extern void mmio_trace_rw(struct mmiotrace_rw *rw);
83extern void mmio_trace_mapping(struct mmiotrace_map *map); 94extern void mmio_trace_mapping(struct mmiotrace_map *map);
95extern int mmio_trace_printk(const char *fmt, va_list args);
84 96
85#endif /* MMIOTRACE_H */ 97#endif /* MMIOTRACE_H */
diff --git a/include/linux/mmu_notifier.h b/include/linux/mmu_notifier.h
new file mode 100644
index 000000000000..b77486d152cd
--- /dev/null
+++ b/include/linux/mmu_notifier.h
@@ -0,0 +1,279 @@
1#ifndef _LINUX_MMU_NOTIFIER_H
2#define _LINUX_MMU_NOTIFIER_H
3
4#include <linux/list.h>
5#include <linux/spinlock.h>
6#include <linux/mm_types.h>
7
8struct mmu_notifier;
9struct mmu_notifier_ops;
10
11#ifdef CONFIG_MMU_NOTIFIER
12
13/*
14 * The mmu notifier_mm structure is allocated and installed in
15 * mm->mmu_notifier_mm inside the mm_take_all_locks() protected
16 * critical section and it's released only when mm_count reaches zero
17 * in mmdrop().
18 */
19struct mmu_notifier_mm {
20 /* all mmu notifiers registerd in this mm are queued in this list */
21 struct hlist_head list;
22 /* to serialize the list modifications and hlist_unhashed */
23 spinlock_t lock;
24};
25
26struct mmu_notifier_ops {
27 /*
28 * Called either by mmu_notifier_unregister or when the mm is
29 * being destroyed by exit_mmap, always before all pages are
30 * freed. This can run concurrently with other mmu notifier
31 * methods (the ones invoked outside the mm context) and it
32 * should tear down all secondary mmu mappings and freeze the
33 * secondary mmu. If this method isn't implemented you've to
34 * be sure that nothing could possibly write to the pages
35 * through the secondary mmu by the time the last thread with
36 * tsk->mm == mm exits.
37 *
38 * As side note: the pages freed after ->release returns could
39 * be immediately reallocated by the gart at an alias physical
40 * address with a different cache model, so if ->release isn't
41 * implemented because all _software_ driven memory accesses
42 * through the secondary mmu are terminated by the time the
43 * last thread of this mm quits, you've also to be sure that
44 * speculative _hardware_ operations can't allocate dirty
45 * cachelines in the cpu that could not be snooped and made
46 * coherent with the other read and write operations happening
47 * through the gart alias address, so leading to memory
48 * corruption.
49 */
50 void (*release)(struct mmu_notifier *mn,
51 struct mm_struct *mm);
52
53 /*
54 * clear_flush_young is called after the VM is
55 * test-and-clearing the young/accessed bitflag in the
56 * pte. This way the VM will provide proper aging to the
57 * accesses to the page through the secondary MMUs and not
58 * only to the ones through the Linux pte.
59 */
60 int (*clear_flush_young)(struct mmu_notifier *mn,
61 struct mm_struct *mm,
62 unsigned long address);
63
64 /*
65 * Before this is invoked any secondary MMU is still ok to
66 * read/write to the page previously pointed to by the Linux
67 * pte because the page hasn't been freed yet and it won't be
68 * freed until this returns. If required set_page_dirty has to
69 * be called internally to this method.
70 */
71 void (*invalidate_page)(struct mmu_notifier *mn,
72 struct mm_struct *mm,
73 unsigned long address);
74
75 /*
76 * invalidate_range_start() and invalidate_range_end() must be
77 * paired and are called only when the mmap_sem and/or the
78 * locks protecting the reverse maps are held. The subsystem
79 * must guarantee that no additional references are taken to
80 * the pages in the range established between the call to
81 * invalidate_range_start() and the matching call to
82 * invalidate_range_end().
83 *
84 * Invalidation of multiple concurrent ranges may be
85 * optionally permitted by the driver. Either way the
86 * establishment of sptes is forbidden in the range passed to
87 * invalidate_range_begin/end for the whole duration of the
88 * invalidate_range_begin/end critical section.
89 *
90 * invalidate_range_start() is called when all pages in the
91 * range are still mapped and have at least a refcount of one.
92 *
93 * invalidate_range_end() is called when all pages in the
94 * range have been unmapped and the pages have been freed by
95 * the VM.
96 *
97 * The VM will remove the page table entries and potentially
98 * the page between invalidate_range_start() and
99 * invalidate_range_end(). If the page must not be freed
100 * because of pending I/O or other circumstances then the
101 * invalidate_range_start() callback (or the initial mapping
102 * by the driver) must make sure that the refcount is kept
103 * elevated.
104 *
105 * If the driver increases the refcount when the pages are
106 * initially mapped into an address space then either
107 * invalidate_range_start() or invalidate_range_end() may
108 * decrease the refcount. If the refcount is decreased on
109 * invalidate_range_start() then the VM can free pages as page
110 * table entries are removed. If the refcount is only
111 * droppped on invalidate_range_end() then the driver itself
112 * will drop the last refcount but it must take care to flush
113 * any secondary tlb before doing the final free on the
114 * page. Pages will no longer be referenced by the linux
115 * address space but may still be referenced by sptes until
116 * the last refcount is dropped.
117 */
118 void (*invalidate_range_start)(struct mmu_notifier *mn,
119 struct mm_struct *mm,
120 unsigned long start, unsigned long end);
121 void (*invalidate_range_end)(struct mmu_notifier *mn,
122 struct mm_struct *mm,
123 unsigned long start, unsigned long end);
124};
125
126/*
127 * The notifier chains are protected by mmap_sem and/or the reverse map
128 * semaphores. Notifier chains are only changed when all reverse maps and
129 * the mmap_sem locks are taken.
130 *
131 * Therefore notifier chains can only be traversed when either
132 *
133 * 1. mmap_sem is held.
134 * 2. One of the reverse map locks is held (i_mmap_lock or anon_vma->lock).
135 * 3. No other concurrent thread can access the list (release)
136 */
137struct mmu_notifier {
138 struct hlist_node hlist;
139 const struct mmu_notifier_ops *ops;
140};
141
142static inline int mm_has_notifiers(struct mm_struct *mm)
143{
144 return unlikely(mm->mmu_notifier_mm);
145}
146
147extern int mmu_notifier_register(struct mmu_notifier *mn,
148 struct mm_struct *mm);
149extern int __mmu_notifier_register(struct mmu_notifier *mn,
150 struct mm_struct *mm);
151extern void mmu_notifier_unregister(struct mmu_notifier *mn,
152 struct mm_struct *mm);
153extern void __mmu_notifier_mm_destroy(struct mm_struct *mm);
154extern void __mmu_notifier_release(struct mm_struct *mm);
155extern int __mmu_notifier_clear_flush_young(struct mm_struct *mm,
156 unsigned long address);
157extern void __mmu_notifier_invalidate_page(struct mm_struct *mm,
158 unsigned long address);
159extern void __mmu_notifier_invalidate_range_start(struct mm_struct *mm,
160 unsigned long start, unsigned long end);
161extern void __mmu_notifier_invalidate_range_end(struct mm_struct *mm,
162 unsigned long start, unsigned long end);
163
164static inline void mmu_notifier_release(struct mm_struct *mm)
165{
166 if (mm_has_notifiers(mm))
167 __mmu_notifier_release(mm);
168}
169
170static inline int mmu_notifier_clear_flush_young(struct mm_struct *mm,
171 unsigned long address)
172{
173 if (mm_has_notifiers(mm))
174 return __mmu_notifier_clear_flush_young(mm, address);
175 return 0;
176}
177
178static inline void mmu_notifier_invalidate_page(struct mm_struct *mm,
179 unsigned long address)
180{
181 if (mm_has_notifiers(mm))
182 __mmu_notifier_invalidate_page(mm, address);
183}
184
185static inline void mmu_notifier_invalidate_range_start(struct mm_struct *mm,
186 unsigned long start, unsigned long end)
187{
188 if (mm_has_notifiers(mm))
189 __mmu_notifier_invalidate_range_start(mm, start, end);
190}
191
192static inline void mmu_notifier_invalidate_range_end(struct mm_struct *mm,
193 unsigned long start, unsigned long end)
194{
195 if (mm_has_notifiers(mm))
196 __mmu_notifier_invalidate_range_end(mm, start, end);
197}
198
199static inline void mmu_notifier_mm_init(struct mm_struct *mm)
200{
201 mm->mmu_notifier_mm = NULL;
202}
203
204static inline void mmu_notifier_mm_destroy(struct mm_struct *mm)
205{
206 if (mm_has_notifiers(mm))
207 __mmu_notifier_mm_destroy(mm);
208}
209
210/*
211 * These two macros will sometime replace ptep_clear_flush.
212 * ptep_clear_flush is impleemnted as macro itself, so this also is
213 * implemented as a macro until ptep_clear_flush will converted to an
214 * inline function, to diminish the risk of compilation failure. The
215 * invalidate_page method over time can be moved outside the PT lock
216 * and these two macros can be later removed.
217 */
218#define ptep_clear_flush_notify(__vma, __address, __ptep) \
219({ \
220 pte_t __pte; \
221 struct vm_area_struct *___vma = __vma; \
222 unsigned long ___address = __address; \
223 __pte = ptep_clear_flush(___vma, ___address, __ptep); \
224 mmu_notifier_invalidate_page(___vma->vm_mm, ___address); \
225 __pte; \
226})
227
228#define ptep_clear_flush_young_notify(__vma, __address, __ptep) \
229({ \
230 int __young; \
231 struct vm_area_struct *___vma = __vma; \
232 unsigned long ___address = __address; \
233 __young = ptep_clear_flush_young(___vma, ___address, __ptep); \
234 __young |= mmu_notifier_clear_flush_young(___vma->vm_mm, \
235 ___address); \
236 __young; \
237})
238
239#else /* CONFIG_MMU_NOTIFIER */
240
241static inline void mmu_notifier_release(struct mm_struct *mm)
242{
243}
244
245static inline int mmu_notifier_clear_flush_young(struct mm_struct *mm,
246 unsigned long address)
247{
248 return 0;
249}
250
251static inline void mmu_notifier_invalidate_page(struct mm_struct *mm,
252 unsigned long address)
253{
254}
255
256static inline void mmu_notifier_invalidate_range_start(struct mm_struct *mm,
257 unsigned long start, unsigned long end)
258{
259}
260
261static inline void mmu_notifier_invalidate_range_end(struct mm_struct *mm,
262 unsigned long start, unsigned long end)
263{
264}
265
266static inline void mmu_notifier_mm_init(struct mm_struct *mm)
267{
268}
269
270static inline void mmu_notifier_mm_destroy(struct mm_struct *mm)
271{
272}
273
274#define ptep_clear_flush_young_notify ptep_clear_flush_young
275#define ptep_clear_flush_notify ptep_clear_flush
276
277#endif /* CONFIG_MMU_NOTIFIER */
278
279#endif /* _LINUX_MMU_NOTIFIER_H */
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 443bc7cd8c62..35a7b5e19465 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -81,21 +81,31 @@ struct zone_padding {
81enum zone_stat_item { 81enum zone_stat_item {
82 /* First 128 byte cacheline (assuming 64 bit words) */ 82 /* First 128 byte cacheline (assuming 64 bit words) */
83 NR_FREE_PAGES, 83 NR_FREE_PAGES,
84 NR_INACTIVE, 84 NR_LRU_BASE,
85 NR_ACTIVE, 85 NR_INACTIVE_ANON = NR_LRU_BASE, /* must match order of LRU_[IN]ACTIVE */
86 NR_ACTIVE_ANON, /* " " " " " */
87 NR_INACTIVE_FILE, /* " " " " " */
88 NR_ACTIVE_FILE, /* " " " " " */
89#ifdef CONFIG_UNEVICTABLE_LRU
90 NR_UNEVICTABLE, /* " " " " " */
91 NR_MLOCK, /* mlock()ed pages found and moved off LRU */
92#else
93 NR_UNEVICTABLE = NR_ACTIVE_FILE, /* avoid compiler errors in dead code */
94 NR_MLOCK = NR_ACTIVE_FILE,
95#endif
86 NR_ANON_PAGES, /* Mapped anonymous pages */ 96 NR_ANON_PAGES, /* Mapped anonymous pages */
87 NR_FILE_MAPPED, /* pagecache pages mapped into pagetables. 97 NR_FILE_MAPPED, /* pagecache pages mapped into pagetables.
88 only modified from process context */ 98 only modified from process context */
89 NR_FILE_PAGES, 99 NR_FILE_PAGES,
90 NR_FILE_DIRTY, 100 NR_FILE_DIRTY,
91 NR_WRITEBACK, 101 NR_WRITEBACK,
92 /* Second 128 byte cacheline */
93 NR_SLAB_RECLAIMABLE, 102 NR_SLAB_RECLAIMABLE,
94 NR_SLAB_UNRECLAIMABLE, 103 NR_SLAB_UNRECLAIMABLE,
95 NR_PAGETABLE, /* used for pagetables */ 104 NR_PAGETABLE, /* used for pagetables */
96 NR_UNSTABLE_NFS, /* NFS unstable pages */ 105 NR_UNSTABLE_NFS, /* NFS unstable pages */
97 NR_BOUNCE, 106 NR_BOUNCE,
98 NR_VMSCAN_WRITE, 107 NR_VMSCAN_WRITE,
108 /* Second 128 byte cacheline */
99 NR_WRITEBACK_TEMP, /* Writeback using temporary buffers */ 109 NR_WRITEBACK_TEMP, /* Writeback using temporary buffers */
100#ifdef CONFIG_NUMA 110#ifdef CONFIG_NUMA
101 NUMA_HIT, /* allocated in intended node */ 111 NUMA_HIT, /* allocated in intended node */
@@ -107,6 +117,55 @@ enum zone_stat_item {
107#endif 117#endif
108 NR_VM_ZONE_STAT_ITEMS }; 118 NR_VM_ZONE_STAT_ITEMS };
109 119
120/*
121 * We do arithmetic on the LRU lists in various places in the code,
122 * so it is important to keep the active lists LRU_ACTIVE higher in
123 * the array than the corresponding inactive lists, and to keep
124 * the *_FILE lists LRU_FILE higher than the corresponding _ANON lists.
125 *
126 * This has to be kept in sync with the statistics in zone_stat_item
127 * above and the descriptions in vmstat_text in mm/vmstat.c
128 */
129#define LRU_BASE 0
130#define LRU_ACTIVE 1
131#define LRU_FILE 2
132
133enum lru_list {
134 LRU_INACTIVE_ANON = LRU_BASE,
135 LRU_ACTIVE_ANON = LRU_BASE + LRU_ACTIVE,
136 LRU_INACTIVE_FILE = LRU_BASE + LRU_FILE,
137 LRU_ACTIVE_FILE = LRU_BASE + LRU_FILE + LRU_ACTIVE,
138#ifdef CONFIG_UNEVICTABLE_LRU
139 LRU_UNEVICTABLE,
140#else
141 LRU_UNEVICTABLE = LRU_ACTIVE_FILE, /* avoid compiler errors in dead code */
142#endif
143 NR_LRU_LISTS
144};
145
146#define for_each_lru(l) for (l = 0; l < NR_LRU_LISTS; l++)
147
148#define for_each_evictable_lru(l) for (l = 0; l <= LRU_ACTIVE_FILE; l++)
149
150static inline int is_file_lru(enum lru_list l)
151{
152 return (l == LRU_INACTIVE_FILE || l == LRU_ACTIVE_FILE);
153}
154
155static inline int is_active_lru(enum lru_list l)
156{
157 return (l == LRU_ACTIVE_ANON || l == LRU_ACTIVE_FILE);
158}
159
160static inline int is_unevictable_lru(enum lru_list l)
161{
162#ifdef CONFIG_UNEVICTABLE_LRU
163 return (l == LRU_UNEVICTABLE);
164#else
165 return 0;
166#endif
167}
168
110struct per_cpu_pages { 169struct per_cpu_pages {
111 int count; /* number of pages in the list */ 170 int count; /* number of pages in the list */
112 int high; /* high watermark, emptying needed */ 171 int high; /* high watermark, emptying needed */
@@ -251,10 +310,22 @@ struct zone {
251 310
252 /* Fields commonly accessed by the page reclaim scanner */ 311 /* Fields commonly accessed by the page reclaim scanner */
253 spinlock_t lru_lock; 312 spinlock_t lru_lock;
254 struct list_head active_list; 313 struct {
255 struct list_head inactive_list; 314 struct list_head list;
256 unsigned long nr_scan_active; 315 unsigned long nr_scan;
257 unsigned long nr_scan_inactive; 316 } lru[NR_LRU_LISTS];
317
318 /*
319 * The pageout code in vmscan.c keeps track of how many of the
320 * mem/swap backed and file backed pages are refeferenced.
321 * The higher the rotated/scanned ratio, the more valuable
322 * that cache is.
323 *
324 * The anon LRU stats live in [0], file LRU stats in [1]
325 */
326 unsigned long recent_rotated[2];
327 unsigned long recent_scanned[2];
328
258 unsigned long pages_scanned; /* since last reclaim */ 329 unsigned long pages_scanned; /* since last reclaim */
259 unsigned long flags; /* zone flags, see below */ 330 unsigned long flags; /* zone flags, see below */
260 331
@@ -276,6 +347,12 @@ struct zone {
276 */ 347 */
277 int prev_priority; 348 int prev_priority;
278 349
350 /*
351 * The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on
352 * this zone's LRU. Maintained by the pageout code.
353 */
354 unsigned int inactive_ratio;
355
279 356
280 ZONE_PADDING(_pad2_) 357 ZONE_PADDING(_pad2_)
281 /* Rarely used or read-mostly fields */ 358 /* Rarely used or read-mostly fields */
@@ -524,8 +601,11 @@ typedef struct pglist_data {
524 struct zone node_zones[MAX_NR_ZONES]; 601 struct zone node_zones[MAX_NR_ZONES];
525 struct zonelist node_zonelists[MAX_ZONELISTS]; 602 struct zonelist node_zonelists[MAX_ZONELISTS];
526 int nr_zones; 603 int nr_zones;
527#ifdef CONFIG_FLAT_NODE_MEM_MAP 604#ifdef CONFIG_FLAT_NODE_MEM_MAP /* means !SPARSEMEM */
528 struct page *node_mem_map; 605 struct page *node_mem_map;
606#ifdef CONFIG_CGROUP_MEM_RES_CTLR
607 struct page_cgroup *node_page_cgroup;
608#endif
529#endif 609#endif
530 struct bootmem_data *bdata; 610 struct bootmem_data *bdata;
531#ifdef CONFIG_MEMORY_HOTPLUG 611#ifdef CONFIG_MEMORY_HOTPLUG
@@ -751,8 +831,9 @@ static inline int zonelist_node_idx(struct zoneref *zoneref)
751 * 831 *
752 * This function returns the next zone at or below a given zone index that is 832 * This function returns the next zone at or below a given zone index that is
753 * within the allowed nodemask using a cursor as the starting point for the 833 * within the allowed nodemask using a cursor as the starting point for the
754 * search. The zoneref returned is a cursor that is used as the next starting 834 * search. The zoneref returned is a cursor that represents the current zone
755 * point for future calls to next_zones_zonelist(). 835 * being examined. It should be advanced by one before calling
836 * next_zones_zonelist again.
756 */ 837 */
757struct zoneref *next_zones_zonelist(struct zoneref *z, 838struct zoneref *next_zones_zonelist(struct zoneref *z,
758 enum zone_type highest_zoneidx, 839 enum zone_type highest_zoneidx,
@@ -768,9 +849,8 @@ struct zoneref *next_zones_zonelist(struct zoneref *z,
768 * 849 *
769 * This function returns the first zone at or below a given zone index that is 850 * This function returns the first zone at or below a given zone index that is
770 * within the allowed nodemask. The zoneref returned is a cursor that can be 851 * within the allowed nodemask. The zoneref returned is a cursor that can be
771 * used to iterate the zonelist with next_zones_zonelist. The cursor should 852 * used to iterate the zonelist with next_zones_zonelist by advancing it by
772 * not be used by the caller as it does not match the value of the zone 853 * one before calling.
773 * returned.
774 */ 854 */
775static inline struct zoneref *first_zones_zonelist(struct zonelist *zonelist, 855static inline struct zoneref *first_zones_zonelist(struct zonelist *zonelist,
776 enum zone_type highest_zoneidx, 856 enum zone_type highest_zoneidx,
@@ -795,7 +875,7 @@ static inline struct zoneref *first_zones_zonelist(struct zonelist *zonelist,
795#define for_each_zone_zonelist_nodemask(zone, z, zlist, highidx, nodemask) \ 875#define for_each_zone_zonelist_nodemask(zone, z, zlist, highidx, nodemask) \
796 for (z = first_zones_zonelist(zlist, highidx, nodemask, &zone); \ 876 for (z = first_zones_zonelist(zlist, highidx, nodemask, &zone); \
797 zone; \ 877 zone; \
798 z = next_zones_zonelist(z, highidx, nodemask, &zone)) \ 878 z = next_zones_zonelist(++z, highidx, nodemask, &zone)) \
799 879
800/** 880/**
801 * for_each_zone_zonelist - helper macro to iterate over valid zones in a zonelist at or below a given zone index 881 * for_each_zone_zonelist - helper macro to iterate over valid zones in a zonelist at or below a given zone index
@@ -854,6 +934,7 @@ static inline unsigned long early_pfn_to_nid(unsigned long pfn)
854#endif 934#endif
855 935
856struct page; 936struct page;
937struct page_cgroup;
857struct mem_section { 938struct mem_section {
858 /* 939 /*
859 * This is, logically, a pointer to an array of struct 940 * This is, logically, a pointer to an array of struct
@@ -871,6 +952,14 @@ struct mem_section {
871 952
872 /* See declaration of similar field in struct zone */ 953 /* See declaration of similar field in struct zone */
873 unsigned long *pageblock_flags; 954 unsigned long *pageblock_flags;
955#ifdef CONFIG_CGROUP_MEM_RES_CTLR
956 /*
957 * If !SPARSEMEM, pgdat doesn't have page_cgroup pointer. We use
958 * section. (see memcontrol.h/page_cgroup.h about this.)
959 */
960 struct page_cgroup *page_cgroup;
961 unsigned long pad;
962#endif
874}; 963};
875 964
876#ifdef CONFIG_SPARSEMEM_EXTREME 965#ifdef CONFIG_SPARSEMEM_EXTREME
diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index c4db5827963d..eb71b45fdf5a 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -131,6 +131,16 @@ struct usb_device_id {
131#define USB_DEVICE_ID_MATCH_INT_SUBCLASS 0x0100 131#define USB_DEVICE_ID_MATCH_INT_SUBCLASS 0x0100
132#define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200 132#define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
133 133
134#define HID_ANY_ID (~0)
135
136struct hid_device_id {
137 __u16 bus;
138 __u32 vendor;
139 __u32 product;
140 kernel_ulong_t driver_data
141 __attribute__((aligned(sizeof(kernel_ulong_t))));
142};
143
134/* s390 CCW devices */ 144/* s390 CCW devices */
135struct ccw_device_id { 145struct ccw_device_id {
136 __u16 match_flags; /* which fields to match against */ 146 __u16 match_flags; /* which fields to match against */
@@ -274,7 +284,7 @@ struct pcmcia_device_id {
274/* Input */ 284/* Input */
275#define INPUT_DEVICE_ID_EV_MAX 0x1f 285#define INPUT_DEVICE_ID_EV_MAX 0x1f
276#define INPUT_DEVICE_ID_KEY_MIN_INTERESTING 0x71 286#define INPUT_DEVICE_ID_KEY_MIN_INTERESTING 0x71
277#define INPUT_DEVICE_ID_KEY_MAX 0x1ff 287#define INPUT_DEVICE_ID_KEY_MAX 0x2ff
278#define INPUT_DEVICE_ID_REL_MAX 0x0f 288#define INPUT_DEVICE_ID_REL_MAX 0x0f
279#define INPUT_DEVICE_ID_ABS_MAX 0x3f 289#define INPUT_DEVICE_ID_ABS_MAX 0x3f
280#define INPUT_DEVICE_ID_MSC_MAX 0x07 290#define INPUT_DEVICE_ID_MSC_MAX 0x07
@@ -388,5 +398,52 @@ struct i2c_device_id {
388 __attribute__((aligned(sizeof(kernel_ulong_t)))); 398 __attribute__((aligned(sizeof(kernel_ulong_t))));
389}; 399};
390 400
401/* dmi */
402enum dmi_field {
403 DMI_NONE,
404 DMI_BIOS_VENDOR,
405 DMI_BIOS_VERSION,
406 DMI_BIOS_DATE,
407 DMI_SYS_VENDOR,
408 DMI_PRODUCT_NAME,
409 DMI_PRODUCT_VERSION,
410 DMI_PRODUCT_SERIAL,
411 DMI_PRODUCT_UUID,
412 DMI_BOARD_VENDOR,
413 DMI_BOARD_NAME,
414 DMI_BOARD_VERSION,
415 DMI_BOARD_SERIAL,
416 DMI_BOARD_ASSET_TAG,
417 DMI_CHASSIS_VENDOR,
418 DMI_CHASSIS_TYPE,
419 DMI_CHASSIS_VERSION,
420 DMI_CHASSIS_SERIAL,
421 DMI_CHASSIS_ASSET_TAG,
422 DMI_STRING_MAX,
423};
424
425struct dmi_strmatch {
426 unsigned char slot;
427 char substr[79];
428};
429
430#ifndef __KERNEL__
431struct dmi_system_id {
432 kernel_ulong_t callback;
433 kernel_ulong_t ident;
434 struct dmi_strmatch matches[4];
435 kernel_ulong_t driver_data
436 __attribute__((aligned(sizeof(kernel_ulong_t))));
437};
438#else
439struct dmi_system_id {
440 int (*callback)(const struct dmi_system_id *);
441 const char *ident;
442 struct dmi_strmatch matches[4];
443 void *driver_data;
444};
445#endif
446
447#define DMI_MATCH(a, b) { a, b }
391 448
392#endif /* LINUX_MOD_DEVICETABLE_H */ 449#endif /* LINUX_MOD_DEVICETABLE_H */
diff --git a/include/linux/module.h b/include/linux/module.h
index 3e03b1acbc94..3bfed013350b 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -16,6 +16,7 @@
16#include <linux/kobject.h> 16#include <linux/kobject.h>
17#include <linux/moduleparam.h> 17#include <linux/moduleparam.h>
18#include <linux/marker.h> 18#include <linux/marker.h>
19#include <linux/tracepoint.h>
19#include <asm/local.h> 20#include <asm/local.h>
20 21
21#include <asm/module.h> 22#include <asm/module.h>
@@ -23,12 +24,12 @@
23/* Not Yet Implemented */ 24/* Not Yet Implemented */
24#define MODULE_SUPPORTED_DEVICE(name) 25#define MODULE_SUPPORTED_DEVICE(name)
25 26
26/* v850 toolchain uses a `_' prefix for all user symbols */ 27/* some toolchains uses a `_' prefix for all user symbols */
27#ifndef MODULE_SYMBOL_PREFIX 28#ifndef MODULE_SYMBOL_PREFIX
28#define MODULE_SYMBOL_PREFIX "" 29#define MODULE_SYMBOL_PREFIX ""
29#endif 30#endif
30 31
31#define MODULE_NAME_LEN (64 - sizeof(unsigned long)) 32#define MODULE_NAME_LEN MAX_PARAM_PREFIX_LEN
32 33
33struct kernel_symbol 34struct kernel_symbol
34{ 35{
@@ -59,6 +60,7 @@ struct module_kobject
59 struct kobject kobj; 60 struct kobject kobj;
60 struct module *mod; 61 struct module *mod;
61 struct kobject *drivers_dir; 62 struct kobject *drivers_dir;
63 struct module_param_attrs *mp;
62}; 64};
63 65
64/* These are either module local, or the kernel's dummy ones. */ 66/* These are either module local, or the kernel's dummy ones. */
@@ -241,7 +243,6 @@ struct module
241 243
242 /* Sysfs stuff. */ 244 /* Sysfs stuff. */
243 struct module_kobject mkobj; 245 struct module_kobject mkobj;
244 struct module_param_attrs *param_attrs;
245 struct module_attribute *modinfo_attrs; 246 struct module_attribute *modinfo_attrs;
246 const char *version; 247 const char *version;
247 const char *srcversion; 248 const char *srcversion;
@@ -249,31 +250,34 @@ struct module
249 250
250 /* Exported symbols */ 251 /* Exported symbols */
251 const struct kernel_symbol *syms; 252 const struct kernel_symbol *syms;
252 unsigned int num_syms;
253 const unsigned long *crcs; 253 const unsigned long *crcs;
254 unsigned int num_syms;
254 255
255 /* GPL-only exported symbols. */ 256 /* GPL-only exported symbols. */
256 const struct kernel_symbol *gpl_syms;
257 unsigned int num_gpl_syms; 257 unsigned int num_gpl_syms;
258 const struct kernel_symbol *gpl_syms;
258 const unsigned long *gpl_crcs; 259 const unsigned long *gpl_crcs;
259 260
261#ifdef CONFIG_UNUSED_SYMBOLS
260 /* unused exported symbols. */ 262 /* unused exported symbols. */
261 const struct kernel_symbol *unused_syms; 263 const struct kernel_symbol *unused_syms;
262 unsigned int num_unused_syms;
263 const unsigned long *unused_crcs; 264 const unsigned long *unused_crcs;
265 unsigned int num_unused_syms;
266
264 /* GPL-only, unused exported symbols. */ 267 /* GPL-only, unused exported symbols. */
265 const struct kernel_symbol *unused_gpl_syms;
266 unsigned int num_unused_gpl_syms; 268 unsigned int num_unused_gpl_syms;
269 const struct kernel_symbol *unused_gpl_syms;
267 const unsigned long *unused_gpl_crcs; 270 const unsigned long *unused_gpl_crcs;
271#endif
268 272
269 /* symbols that will be GPL-only in the near future. */ 273 /* symbols that will be GPL-only in the near future. */
270 const struct kernel_symbol *gpl_future_syms; 274 const struct kernel_symbol *gpl_future_syms;
271 unsigned int num_gpl_future_syms;
272 const unsigned long *gpl_future_crcs; 275 const unsigned long *gpl_future_crcs;
276 unsigned int num_gpl_future_syms;
273 277
274 /* Exception table */ 278 /* Exception table */
275 unsigned int num_exentries; 279 unsigned int num_exentries;
276 const struct exception_table_entry *extable; 280 struct exception_table_entry *extable;
277 281
278 /* Startup function. */ 282 /* Startup function. */
279 int (*init)(void); 283 int (*init)(void);
@@ -285,10 +289,10 @@ struct module
285 void *module_core; 289 void *module_core;
286 290
287 /* Here are the sizes of the init and core sections */ 291 /* Here are the sizes of the init and core sections */
288 unsigned long init_size, core_size; 292 unsigned int init_size, core_size;
289 293
290 /* The size of the executable code in each section. */ 294 /* The size of the executable code in each section. */
291 unsigned long init_text_size, core_text_size; 295 unsigned int init_text_size, core_text_size;
292 296
293 /* The handle returned from unwind_add_table. */ 297 /* The handle returned from unwind_add_table. */
294 void *unwind_info; 298 void *unwind_info;
@@ -300,29 +304,15 @@ struct module
300 304
301#ifdef CONFIG_GENERIC_BUG 305#ifdef CONFIG_GENERIC_BUG
302 /* Support for BUG */ 306 /* Support for BUG */
307 unsigned num_bugs;
303 struct list_head bug_list; 308 struct list_head bug_list;
304 struct bug_entry *bug_table; 309 struct bug_entry *bug_table;
305 unsigned num_bugs;
306#endif
307
308#ifdef CONFIG_MODULE_UNLOAD
309 /* Reference counts */
310 struct module_ref ref[NR_CPUS];
311
312 /* What modules depend on me? */
313 struct list_head modules_which_use_me;
314
315 /* Who is waiting for us to be unloaded */
316 struct task_struct *waiter;
317
318 /* Destruction function. */
319 void (*exit)(void);
320#endif 310#endif
321 311
322#ifdef CONFIG_KALLSYMS 312#ifdef CONFIG_KALLSYMS
323 /* We keep the symbol and string tables for kallsyms. */ 313 /* We keep the symbol and string tables for kallsyms. */
324 Elf_Sym *symtab; 314 Elf_Sym *symtab;
325 unsigned long num_symtab; 315 unsigned int num_symtab;
326 char *strtab; 316 char *strtab;
327 317
328 /* Section attributes */ 318 /* Section attributes */
@@ -342,6 +332,24 @@ struct module
342 struct marker *markers; 332 struct marker *markers;
343 unsigned int num_markers; 333 unsigned int num_markers;
344#endif 334#endif
335#ifdef CONFIG_TRACEPOINTS
336 struct tracepoint *tracepoints;
337 unsigned int num_tracepoints;
338#endif
339
340#ifdef CONFIG_MODULE_UNLOAD
341 /* What modules depend on me? */
342 struct list_head modules_which_use_me;
343
344 /* Who is waiting for us to be unloaded */
345 struct task_struct *waiter;
346
347 /* Destruction function. */
348 void (*exit)(void);
349
350 /* Reference counts */
351 struct module_ref ref[NR_CPUS];
352#endif
345}; 353};
346#ifndef MODULE_ARCH_INIT 354#ifndef MODULE_ARCH_INIT
347#define MODULE_ARCH_INIT {} 355#define MODULE_ARCH_INIT {}
@@ -450,6 +458,9 @@ extern void print_modules(void);
450 458
451extern void module_update_markers(void); 459extern void module_update_markers(void);
452 460
461extern void module_update_tracepoints(void);
462extern int module_get_iter_tracepoints(struct tracepoint_iter *iter);
463
453#else /* !CONFIG_MODULES... */ 464#else /* !CONFIG_MODULES... */
454#define EXPORT_SYMBOL(sym) 465#define EXPORT_SYMBOL(sym)
455#define EXPORT_SYMBOL_GPL(sym) 466#define EXPORT_SYMBOL_GPL(sym)
@@ -554,6 +565,15 @@ static inline void module_update_markers(void)
554{ 565{
555} 566}
556 567
568static inline void module_update_tracepoints(void)
569{
570}
571
572static inline int module_get_iter_tracepoints(struct tracepoint_iter *iter)
573{
574 return 0;
575}
576
557#endif /* CONFIG_MODULES */ 577#endif /* CONFIG_MODULES */
558 578
559struct device_driver; 579struct device_driver;
diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
index ec624381c844..e4af3399ef48 100644
--- a/include/linux/moduleparam.h
+++ b/include/linux/moduleparam.h
@@ -13,6 +13,9 @@
13#define MODULE_PARAM_PREFIX KBUILD_MODNAME "." 13#define MODULE_PARAM_PREFIX KBUILD_MODNAME "."
14#endif 14#endif
15 15
16/* Chosen so that structs with an unsigned long line up. */
17#define MAX_PARAM_PREFIX_LEN (64 - sizeof(unsigned long))
18
16#ifdef MODULE 19#ifdef MODULE
17#define ___module_cat(a,b) __mod_ ## a ## b 20#define ___module_cat(a,b) __mod_ ## a ## b
18#define __module_cat(a,b) ___module_cat(a,b) 21#define __module_cat(a,b) ___module_cat(a,b)
@@ -79,7 +82,8 @@ struct kparam_array
79#define __module_param_call(prefix, name, set, get, arg, perm) \ 82#define __module_param_call(prefix, name, set, get, arg, perm) \
80 /* Default value instead of permissions? */ \ 83 /* Default value instead of permissions? */ \
81 static int __param_perm_check_##name __attribute__((unused)) = \ 84 static int __param_perm_check_##name __attribute__((unused)) = \
82 BUILD_BUG_ON_ZERO((perm) < 0 || (perm) > 0777 || ((perm) & 2)); \ 85 BUILD_BUG_ON_ZERO((perm) < 0 || (perm) > 0777 || ((perm) & 2)) \
86 + BUILD_BUG_ON_ZERO(sizeof(""prefix) > MAX_PARAM_PREFIX_LEN); \
83 static const char __param_str_##name[] = prefix #name; \ 87 static const char __param_str_##name[] = prefix #name; \
84 static struct kernel_param __moduleparam_const __param_##name \ 88 static struct kernel_param __moduleparam_const __param_##name \
85 __used \ 89 __used \
@@ -100,6 +104,25 @@ struct kparam_array
100#define module_param(name, type, perm) \ 104#define module_param(name, type, perm) \
101 module_param_named(name, name, type, perm) 105 module_param_named(name, name, type, perm)
102 106
107#ifndef MODULE
108/**
109 * core_param - define a historical core kernel parameter.
110 * @name: the name of the cmdline and sysfs parameter (often the same as var)
111 * @var: the variable
112 * @type: the type (for param_set_##type and param_get_##type)
113 * @perm: visibility in sysfs
114 *
115 * core_param is just like module_param(), but cannot be modular and
116 * doesn't add a prefix (such as "printk."). This is for compatibility
117 * with __setup(), and it makes sense as truly core parameters aren't
118 * tied to the particular file they're in.
119 */
120#define core_param(name, var, type, perm) \
121 param_check_##type(name, &(var)); \
122 __module_param_call("", name, param_set_##type, param_get_##type, \
123 &var, perm)
124#endif /* !MODULE */
125
103/* Actually copy string: maxlen param is usually sizeof(string). */ 126/* Actually copy string: maxlen param is usually sizeof(string). */
104#define module_param_string(name, string, len, perm) \ 127#define module_param_string(name, string, len, perm) \
105 static const struct kparam_string __param_string_##name \ 128 static const struct kparam_string __param_string_##name \
diff --git a/include/linux/mount.h b/include/linux/mount.h
index 4374d1adeb4b..cab2a85e2ee8 100644
--- a/include/linux/mount.h
+++ b/include/linux/mount.h
@@ -5,8 +5,6 @@
5 * 5 *
6 * Author: Marco van Wieringen <mvw@planets.elm.net> 6 * Author: Marco van Wieringen <mvw@planets.elm.net>
7 * 7 *
8 * Version: $Id: mount.h,v 2.0 1996/11/17 16:48:14 mvw Exp mvw $
9 *
10 */ 8 */
11#ifndef _LINUX_MOUNT_H 9#ifndef _LINUX_MOUNT_H
12#define _LINUX_MOUNT_H 10#define _LINUX_MOUNT_H
@@ -47,7 +45,7 @@ struct vfsmount {
47 struct list_head mnt_child; /* and going through their mnt_child */ 45 struct list_head mnt_child; /* and going through their mnt_child */
48 int mnt_flags; 46 int mnt_flags;
49 /* 4 bytes hole on 64bits arches */ 47 /* 4 bytes hole on 64bits arches */
50 char *mnt_devname; /* Name of device e.g. /dev/dsk/hda1 */ 48 const char *mnt_devname; /* Name of device e.g. /dev/dsk/hda1 */
51 struct list_head mnt_list; 49 struct list_head mnt_list;
52 struct list_head mnt_expire; /* link in fs-specific expiry list */ 50 struct list_head mnt_expire; /* link in fs-specific expiry list */
53 struct list_head mnt_share; /* circular list of shared mounts */ 51 struct list_head mnt_share; /* circular list of shared mounts */
@@ -105,7 +103,8 @@ extern struct vfsmount *vfs_kern_mount(struct file_system_type *type,
105 103
106struct nameidata; 104struct nameidata;
107 105
108extern int do_add_mount(struct vfsmount *newmnt, struct nameidata *nd, 106struct path;
107extern int do_add_mount(struct vfsmount *newmnt, struct path *path,
109 int mnt_flags, struct list_head *fslist); 108 int mnt_flags, struct list_head *fslist);
110 109
111extern void mark_mounts_for_expiry(struct list_head *mounts); 110extern void mark_mounts_for_expiry(struct list_head *mounts);
diff --git a/include/linux/mroute.h b/include/linux/mroute.h
index de4decfa1bfc..8a455694d682 100644
--- a/include/linux/mroute.h
+++ b/include/linux/mroute.h
@@ -6,7 +6,6 @@
6#ifdef __KERNEL__ 6#ifdef __KERNEL__
7#include <linux/in.h> 7#include <linux/in.h>
8#endif 8#endif
9#include <linux/pim.h>
10 9
11/* 10/*
12 * Based on the MROUTING 3.5 defines primarily to keep 11 * Based on the MROUTING 3.5 defines primarily to keep
@@ -130,6 +129,7 @@ struct igmpmsg
130 */ 129 */
131 130
132#ifdef __KERNEL__ 131#ifdef __KERNEL__
132#include <linux/pim.h>
133#include <net/sock.h> 133#include <net/sock.h>
134 134
135#ifdef CONFIG_IP_MROUTE 135#ifdef CONFIG_IP_MROUTE
@@ -144,11 +144,37 @@ static inline int ip_mroute_opt(int opt)
144} 144}
145#endif 145#endif
146 146
147#ifdef CONFIG_IP_MROUTE
147extern int ip_mroute_setsockopt(struct sock *, int, char __user *, int); 148extern int ip_mroute_setsockopt(struct sock *, int, char __user *, int);
148extern int ip_mroute_getsockopt(struct sock *, int, char __user *, int __user *); 149extern int ip_mroute_getsockopt(struct sock *, int, char __user *, int __user *);
149extern int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg); 150extern int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg);
150extern void ip_mr_init(void); 151extern int ip_mr_init(void);
152#else
153static inline
154int ip_mroute_setsockopt(struct sock *sock,
155 int optname, char __user *optval, int optlen)
156{
157 return -ENOPROTOOPT;
158}
159
160static inline
161int ip_mroute_getsockopt(struct sock *sock,
162 int optname, char __user *optval, int __user *optlen)
163{
164 return -ENOPROTOOPT;
165}
166
167static inline
168int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg)
169{
170 return -ENOIOCTLCMD;
171}
151 172
173static inline int ip_mr_init(void)
174{
175 return 0;
176}
177#endif
152 178
153struct vif_device 179struct vif_device
154{ 180{
diff --git a/include/linux/mroute6.h b/include/linux/mroute6.h
index e7989593142b..6f4c180179e2 100644
--- a/include/linux/mroute6.h
+++ b/include/linux/mroute6.h
@@ -115,6 +115,7 @@ struct sioc_mif_req6
115 115
116#ifdef __KERNEL__ 116#ifdef __KERNEL__
117 117
118#include <linux/pim.h>
118#include <linux/skbuff.h> /* for struct sk_buff_head */ 119#include <linux/skbuff.h> /* for struct sk_buff_head */
119 120
120#ifdef CONFIG_IPV6_MROUTE 121#ifdef CONFIG_IPV6_MROUTE
@@ -131,11 +132,44 @@ static inline int ip6_mroute_opt(int opt)
131 132
132struct sock; 133struct sock;
133 134
135#ifdef CONFIG_IPV6_MROUTE
134extern int ip6_mroute_setsockopt(struct sock *, int, char __user *, int); 136extern int ip6_mroute_setsockopt(struct sock *, int, char __user *, int);
135extern int ip6_mroute_getsockopt(struct sock *, int, char __user *, int __user *); 137extern int ip6_mroute_getsockopt(struct sock *, int, char __user *, int __user *);
136extern int ip6_mr_input(struct sk_buff *skb); 138extern int ip6_mr_input(struct sk_buff *skb);
137extern int ip6mr_ioctl(struct sock *sk, int cmd, void __user *arg); 139extern int ip6mr_ioctl(struct sock *sk, int cmd, void __user *arg);
138extern void ip6_mr_init(void); 140extern int ip6_mr_init(void);
141extern void ip6_mr_cleanup(void);
142#else
143static inline
144int ip6_mroute_setsockopt(struct sock *sock,
145 int optname, char __user *optval, int optlen)
146{
147 return -ENOPROTOOPT;
148}
149
150static inline
151int ip6_mroute_getsockopt(struct sock *sock,
152 int optname, char __user *optval, int __user *optlen)
153{
154 return -ENOPROTOOPT;
155}
156
157static inline
158int ip6mr_ioctl(struct sock *sk, int cmd, void __user *arg)
159{
160 return -ENOIOCTLCMD;
161}
162
163static inline int ip6_mr_init(void)
164{
165 return 0;
166}
167
168static inline void ip6_mr_cleanup(void)
169{
170 return;
171}
172#endif
139 173
140struct mif_device 174struct mif_device
141{ 175{
diff --git a/include/linux/msdos_fs.h b/include/linux/msdos_fs.h
index 81cd36b735b0..ba63858056c7 100644
--- a/include/linux/msdos_fs.h
+++ b/include/linux/msdos_fs.h
@@ -2,11 +2,11 @@
2#define _LINUX_MSDOS_FS_H 2#define _LINUX_MSDOS_FS_H
3 3
4#include <linux/magic.h> 4#include <linux/magic.h>
5#include <asm/byteorder.h>
5 6
6/* 7/*
7 * The MS-DOS filesystem constants/structures 8 * The MS-DOS filesystem constants/structures
8 */ 9 */
9#include <asm/byteorder.h>
10 10
11#define SECTOR_SIZE 512 /* sector size (bytes) */ 11#define SECTOR_SIZE 512 /* sector size (bytes) */
12#define SECTOR_BITS 9 /* log2(SECTOR_SIZE) */ 12#define SECTOR_BITS 9 /* log2(SECTOR_SIZE) */
@@ -89,24 +89,22 @@
89#define IS_FSINFO(x) (le32_to_cpu((x)->signature1) == FAT_FSINFO_SIG1 \ 89#define IS_FSINFO(x) (le32_to_cpu((x)->signature1) == FAT_FSINFO_SIG1 \
90 && le32_to_cpu((x)->signature2) == FAT_FSINFO_SIG2) 90 && le32_to_cpu((x)->signature2) == FAT_FSINFO_SIG2)
91 91
92struct __fat_dirent {
93 long d_ino;
94 __kernel_off_t d_off;
95 unsigned short d_reclen;
96 char d_name[256]; /* We must not include limits.h! */
97};
98
92/* 99/*
93 * ioctl commands 100 * ioctl commands
94 */ 101 */
95#define VFAT_IOCTL_READDIR_BOTH _IOR('r', 1, struct dirent [2]) 102#define VFAT_IOCTL_READDIR_BOTH _IOR('r', 1, struct __fat_dirent[2])
96#define VFAT_IOCTL_READDIR_SHORT _IOR('r', 2, struct dirent [2]) 103#define VFAT_IOCTL_READDIR_SHORT _IOR('r', 2, struct __fat_dirent[2])
97/* <linux/videotext.h> has used 0x72 ('r') in collision, so skip a few */ 104/* <linux/videotext.h> has used 0x72 ('r') in collision, so skip a few */
98#define FAT_IOCTL_GET_ATTRIBUTES _IOR('r', 0x10, __u32) 105#define FAT_IOCTL_GET_ATTRIBUTES _IOR('r', 0x10, __u32)
99#define FAT_IOCTL_SET_ATTRIBUTES _IOW('r', 0x11, __u32) 106#define FAT_IOCTL_SET_ATTRIBUTES _IOW('r', 0x11, __u32)
100 107
101/*
102 * vfat shortname flags
103 */
104#define VFAT_SFN_DISPLAY_LOWER 0x0001 /* convert to lowercase for display */
105#define VFAT_SFN_DISPLAY_WIN95 0x0002 /* emulate win95 rule for display */
106#define VFAT_SFN_DISPLAY_WINNT 0x0004 /* emulate winnt rule for display */
107#define VFAT_SFN_CREATE_WIN95 0x0100 /* emulate win95 rule for create */
108#define VFAT_SFN_CREATE_WINNT 0x0200 /* emulate winnt rule for create */
109
110struct fat_boot_sector { 108struct fat_boot_sector {
111 __u8 ignored[3]; /* Boot strap short or near jump */ 109 __u8 ignored[3]; /* Boot strap short or near jump */
112 __u8 system_id[8]; /* Name - can be used to special case 110 __u8 system_id[8]; /* Name - can be used to special case
@@ -168,14 +166,6 @@ struct msdos_dir_slot {
168 __u8 name11_12[4]; /* last 2 characters in name */ 166 __u8 name11_12[4]; /* last 2 characters in name */
169}; 167};
170 168
171struct fat_slot_info {
172 loff_t i_pos; /* on-disk position of directory entry */
173 loff_t slot_off; /* offset for slot or de start */
174 int nr_slots; /* number of slots + 1(de) in filename */
175 struct msdos_dir_entry *de;
176 struct buffer_head *bh;
177};
178
179#ifdef __KERNEL__ 169#ifdef __KERNEL__
180 170
181#include <linux/buffer_head.h> 171#include <linux/buffer_head.h>
@@ -184,6 +174,15 @@ struct fat_slot_info {
184#include <linux/fs.h> 174#include <linux/fs.h>
185#include <linux/mutex.h> 175#include <linux/mutex.h>
186 176
177/*
178 * vfat shortname flags
179 */
180#define VFAT_SFN_DISPLAY_LOWER 0x0001 /* convert to lowercase for display */
181#define VFAT_SFN_DISPLAY_WIN95 0x0002 /* emulate win95 rule for display */
182#define VFAT_SFN_DISPLAY_WINNT 0x0004 /* emulate winnt rule for display */
183#define VFAT_SFN_CREATE_WIN95 0x0100 /* emulate win95 rule for create */
184#define VFAT_SFN_CREATE_WINNT 0x0200 /* emulate winnt rule for create */
185
187struct fat_mount_options { 186struct fat_mount_options {
188 uid_t fs_uid; 187 uid_t fs_uid;
189 gid_t fs_gid; 188 gid_t fs_gid;
@@ -202,10 +201,10 @@ struct fat_mount_options {
202 utf8:1, /* Use of UTF-8 character set (Default) */ 201 utf8:1, /* Use of UTF-8 character set (Default) */
203 unicode_xlate:1, /* create escape sequences for unhandled Unicode */ 202 unicode_xlate:1, /* create escape sequences for unhandled Unicode */
204 numtail:1, /* Does first alias have a numeric '~1' type tail? */ 203 numtail:1, /* Does first alias have a numeric '~1' type tail? */
205 atari:1, /* Use Atari GEMDOS variation of MS-DOS fs */
206 flush:1, /* write things quickly */ 204 flush:1, /* write things quickly */
207 nocase:1, /* Does this need case conversion? 0=need case conversion*/ 205 nocase:1, /* Does this need case conversion? 0=need case conversion*/
208 usefree:1; /* Use free_clusters for FAT32 */ 206 usefree:1, /* Use free_clusters for FAT32 */
207 tz_utc:1; /* Filesystem timestamps are in UTC */
209}; 208};
210 209
211#define FAT_HASH_BITS 8 210#define FAT_HASH_BITS 8
@@ -267,6 +266,14 @@ struct msdos_inode_info {
267 struct inode vfs_inode; 266 struct inode vfs_inode;
268}; 267};
269 268
269struct fat_slot_info {
270 loff_t i_pos; /* on-disk position of directory entry */
271 loff_t slot_off; /* offset for slot or de start */
272 int nr_slots; /* number of slots + 1(de) in filename */
273 struct msdos_dir_entry *de;
274 struct buffer_head *bh;
275};
276
270static inline struct msdos_sb_info *MSDOS_SB(struct super_block *sb) 277static inline struct msdos_sb_info *MSDOS_SB(struct super_block *sb)
271{ 278{
272 return sb->s_fs_info; 279 return sb->s_fs_info;
@@ -428,8 +435,9 @@ extern int fat_flush_inodes(struct super_block *sb, struct inode *i1,
428extern void fat_fs_panic(struct super_block *s, const char *fmt, ...); 435extern void fat_fs_panic(struct super_block *s, const char *fmt, ...);
429extern void fat_clusters_flush(struct super_block *sb); 436extern void fat_clusters_flush(struct super_block *sb);
430extern int fat_chain_add(struct inode *inode, int new_dclus, int nr_cluster); 437extern int fat_chain_add(struct inode *inode, int new_dclus, int nr_cluster);
431extern int date_dos2unix(unsigned short time, unsigned short date); 438extern int date_dos2unix(unsigned short time, unsigned short date, int tz_utc);
432extern void fat_date_unix2dos(int unix_date, __le16 *time, __le16 *date); 439extern void fat_date_unix2dos(int unix_date, __le16 *time, __le16 *date,
440 int tz_utc);
433extern int fat_sync_bhs(struct buffer_head **bhs, int nr_bhs); 441extern int fat_sync_bhs(struct buffer_head **bhs, int nr_bhs);
434 442
435int fat_cache_init(void); 443int fat_cache_init(void);
diff --git a/include/linux/mtd/blktrans.h b/include/linux/mtd/blktrans.h
index 9a6e2f953cba..8b4aa0523db7 100644
--- a/include/linux/mtd/blktrans.h
+++ b/include/linux/mtd/blktrans.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: blktrans.h,v 1.6 2005/11/07 11:14:54 gleixner Exp $
3 *
4 * (C) 2003 David Woodhouse <dwmw2@infradead.org> 2 * (C) 2003 David Woodhouse <dwmw2@infradead.org>
5 * 3 *
6 * Interface to Linux block layer for MTD 'translation layers'. 4 * Interface to Linux block layer for MTD 'translation layers'.
@@ -43,6 +41,8 @@ struct mtd_blktrans_ops {
43 unsigned long block, char *buffer); 41 unsigned long block, char *buffer);
44 int (*writesect)(struct mtd_blktrans_dev *dev, 42 int (*writesect)(struct mtd_blktrans_dev *dev,
45 unsigned long block, char *buffer); 43 unsigned long block, char *buffer);
44 int (*discard)(struct mtd_blktrans_dev *dev,
45 unsigned long block, unsigned nr_blocks);
46 46
47 /* Block layer ioctls */ 47 /* Block layer ioctls */
48 int (*getgeo)(struct mtd_blktrans_dev *dev, struct hd_geometry *geo); 48 int (*getgeo)(struct mtd_blktrans_dev *dev, struct hd_geometry *geo);
diff --git a/include/linux/mtd/cfi.h b/include/linux/mtd/cfi.h
index b0ddf4b25862..ee5124ec319e 100644
--- a/include/linux/mtd/cfi.h
+++ b/include/linux/mtd/cfi.h
@@ -1,7 +1,6 @@
1 1
2/* Common Flash Interface structures 2/* Common Flash Interface structures
3 * See http://support.intel.com/design/flash/technote/index.htm 3 * See http://support.intel.com/design/flash/technote/index.htm
4 * $Id: cfi.h,v 1.57 2005/11/15 23:28:17 tpoynor Exp $
5 */ 4 */
6 5
7#ifndef __MTD_CFI_H__ 6#ifndef __MTD_CFI_H__
@@ -13,6 +12,7 @@
13#include <linux/mtd/flashchip.h> 12#include <linux/mtd/flashchip.h>
14#include <linux/mtd/map.h> 13#include <linux/mtd/map.h>
15#include <linux/mtd/cfi_endian.h> 14#include <linux/mtd/cfi_endian.h>
15#include <linux/mtd/xip.h>
16 16
17#ifdef CONFIG_MTD_CFI_I1 17#ifdef CONFIG_MTD_CFI_I1
18#define cfi_interleave(cfi) 1 18#define cfi_interleave(cfi) 1
@@ -431,7 +431,6 @@ static inline uint32_t cfi_send_gen_cmd(u_char cmd, uint32_t cmd_addr, uint32_t
431{ 431{
432 map_word val; 432 map_word val;
433 uint32_t addr = base + cfi_build_cmd_addr(cmd_addr, cfi_interleave(cfi), type); 433 uint32_t addr = base + cfi_build_cmd_addr(cmd_addr, cfi_interleave(cfi), type);
434
435 val = cfi_build_cmd(cmd, map, cfi); 434 val = cfi_build_cmd(cmd, map, cfi);
436 435
437 if (prev_val) 436 if (prev_val)
@@ -484,6 +483,13 @@ static inline void cfi_udelay(int us)
484 } 483 }
485} 484}
486 485
486int __xipram cfi_qry_present(struct map_info *map, __u32 base,
487 struct cfi_private *cfi);
488int __xipram cfi_qry_mode_on(uint32_t base, struct map_info *map,
489 struct cfi_private *cfi);
490void __xipram cfi_qry_mode_off(uint32_t base, struct map_info *map,
491 struct cfi_private *cfi);
492
487struct cfi_extquery *cfi_read_pri(struct map_info *map, uint16_t adr, uint16_t size, 493struct cfi_extquery *cfi_read_pri(struct map_info *map, uint16_t adr, uint16_t size,
488 const char* name); 494 const char* name);
489struct cfi_fixup { 495struct cfi_fixup {
diff --git a/include/linux/mtd/cfi_endian.h b/include/linux/mtd/cfi_endian.h
index 25724f7d3867..d802f7736be3 100644
--- a/include/linux/mtd/cfi_endian.h
+++ b/include/linux/mtd/cfi_endian.h
@@ -1,8 +1,3 @@
1/*
2 * $Id: cfi_endian.h,v 1.11 2002/01/30 23:20:48 awozniak Exp $
3 *
4 */
5
6#include <asm/byteorder.h> 1#include <asm/byteorder.h>
7 2
8#ifndef CONFIG_MTD_CFI_ADV_OPTIONS 3#ifndef CONFIG_MTD_CFI_ADV_OPTIONS
diff --git a/include/linux/mtd/concat.h b/include/linux/mtd/concat.h
index ed8dc6755219..c02f3d264ecf 100644
--- a/include/linux/mtd/concat.h
+++ b/include/linux/mtd/concat.h
@@ -4,8 +4,6 @@
4 * (C) 2002 Robert Kaiser <rkaiser@sysgo.de> 4 * (C) 2002 Robert Kaiser <rkaiser@sysgo.de>
5 * 5 *
6 * This code is GPL 6 * This code is GPL
7 *
8 * $Id: concat.h,v 1.1 2002/03/08 16:34:36 rkaiser Exp $
9 */ 7 */
10 8
11#ifndef MTD_CONCAT_H 9#ifndef MTD_CONCAT_H
diff --git a/include/linux/mtd/doc2000.h b/include/linux/mtd/doc2000.h
index 9addd073bf15..0a6d516ab71d 100644
--- a/include/linux/mtd/doc2000.h
+++ b/include/linux/mtd/doc2000.h
@@ -6,8 +6,6 @@
6 * Copyright (C) 2002-2003 Greg Ungerer <gerg@snapgear.com> 6 * Copyright (C) 2002-2003 Greg Ungerer <gerg@snapgear.com>
7 * Copyright (C) 2002-2003 SnapGear Inc 7 * Copyright (C) 2002-2003 SnapGear Inc
8 * 8 *
9 * $Id: doc2000.h,v 1.25 2005/11/07 11:14:54 gleixner Exp $
10 *
11 * Released under GPL 9 * Released under GPL
12 */ 10 */
13 11
diff --git a/include/linux/mtd/flashchip.h b/include/linux/mtd/flashchip.h
index 39e7d2a1be9a..d4f38c5fd44e 100644
--- a/include/linux/mtd/flashchip.h
+++ b/include/linux/mtd/flashchip.h
@@ -5,9 +5,6 @@
5 * Contains information about the location and state of a given flash device 5 * Contains information about the location and state of a given flash device
6 * 6 *
7 * (C) 2000 Red Hat. GPLd. 7 * (C) 2000 Red Hat. GPLd.
8 *
9 * $Id: flashchip.h,v 1.18 2005/11/07 11:14:54 gleixner Exp $
10 *
11 */ 8 */
12 9
13#ifndef __MTD_FLASHCHIP_H__ 10#ifndef __MTD_FLASHCHIP_H__
@@ -76,6 +73,10 @@ struct flchip {
76 int buffer_write_time; 73 int buffer_write_time;
77 int erase_time; 74 int erase_time;
78 75
76 int word_write_time_max;
77 int buffer_write_time_max;
78 int erase_time_max;
79
79 void *priv; 80 void *priv;
80}; 81};
81 82
diff --git a/include/linux/mtd/ftl.h b/include/linux/mtd/ftl.h
index d99609113307..0be442f881dd 100644
--- a/include/linux/mtd/ftl.h
+++ b/include/linux/mtd/ftl.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: ftl.h,v 1.7 2005/11/07 11:14:54 gleixner Exp $
3 *
4 * Derived from (and probably identical to): 2 * Derived from (and probably identical to):
5 * ftl.h 1.7 1999/10/25 20:23:17 3 * ftl.h 1.7 1999/10/25 20:23:17
6 * 4 *
diff --git a/include/linux/mtd/gen_probe.h b/include/linux/mtd/gen_probe.h
index 256e7342ed1e..df362ddf2949 100644
--- a/include/linux/mtd/gen_probe.h
+++ b/include/linux/mtd/gen_probe.h
@@ -1,7 +1,6 @@
1/* 1/*
2 * (C) 2001, 2001 Red Hat, Inc. 2 * (C) 2001, 2001 Red Hat, Inc.
3 * GPL'd 3 * GPL'd
4 * $Id: gen_probe.h,v 1.4 2005/11/07 11:14:54 gleixner Exp $
5 */ 4 */
6 5
7#ifndef __LINUX_MTD_GEN_PROBE_H__ 6#ifndef __LINUX_MTD_GEN_PROBE_H__
diff --git a/include/linux/mtd/inftl.h b/include/linux/mtd/inftl.h
index 85fd041d44ad..64ee53ce95a9 100644
--- a/include/linux/mtd/inftl.h
+++ b/include/linux/mtd/inftl.h
@@ -2,8 +2,6 @@
2 * inftl.h -- defines to support the Inverse NAND Flash Translation Layer 2 * inftl.h -- defines to support the Inverse NAND Flash Translation Layer
3 * 3 *
4 * (C) Copyright 2002, Greg Ungerer (gerg@snapgear.com) 4 * (C) Copyright 2002, Greg Ungerer (gerg@snapgear.com)
5 *
6 * $Id: inftl.h,v 1.7 2005/06/13 13:08:45 sean Exp $
7 */ 5 */
8 6
9#ifndef __MTD_INFTL_H__ 7#ifndef __MTD_INFTL_H__
@@ -52,8 +50,6 @@ struct INFTLrecord {
52int INFTL_mount(struct INFTLrecord *s); 50int INFTL_mount(struct INFTLrecord *s);
53int INFTL_formatblock(struct INFTLrecord *s, int block); 51int INFTL_formatblock(struct INFTLrecord *s, int block);
54 52
55extern char inftlmountrev[];
56
57void INFTL_dumptables(struct INFTLrecord *s); 53void INFTL_dumptables(struct INFTLrecord *s);
58void INFTL_dumpVUchains(struct INFTLrecord *s); 54void INFTL_dumpVUchains(struct INFTLrecord *s);
59 55
diff --git a/include/linux/mtd/map.h b/include/linux/mtd/map.h
index a9fae032ba81..aa30244492c6 100644
--- a/include/linux/mtd/map.h
+++ b/include/linux/mtd/map.h
@@ -1,6 +1,5 @@
1 1
2/* Overhauled routines for dealing with different mmap regions of flash */ 2/* Overhauled routines for dealing with different mmap regions of flash */
3/* $Id: map.h,v 1.54 2005/11/07 11:14:54 gleixner Exp $ */
4 3
5#ifndef __LINUX_MTD_MAP_H__ 4#ifndef __LINUX_MTD_MAP_H__
6#define __LINUX_MTD_MAP_H__ 5#define __LINUX_MTD_MAP_H__
@@ -189,7 +188,7 @@ typedef union {
189*/ 188*/
190 189
191struct map_info { 190struct map_info {
192 char *name; 191 const char *name;
193 unsigned long size; 192 unsigned long size;
194 resource_size_t phys; 193 resource_size_t phys;
195#define NO_XIP (-1UL) 194#define NO_XIP (-1UL)
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index 245f9098e171..eae26bb6430a 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: mtd.h,v 1.61 2005/11/07 11:14:54 gleixner Exp $
3 *
4 * Copyright (C) 1999-2003 David Woodhouse <dwmw2@infradead.org> et al. 2 * Copyright (C) 1999-2003 David Woodhouse <dwmw2@infradead.org> et al.
5 * 3 *
6 * Released under GPL 4 * Released under GPL
@@ -27,8 +25,10 @@
27#define MTD_ERASE_DONE 0x08 25#define MTD_ERASE_DONE 0x08
28#define MTD_ERASE_FAILED 0x10 26#define MTD_ERASE_FAILED 0x10
29 27
28#define MTD_FAIL_ADDR_UNKNOWN 0xffffffff
29
30/* If the erase fails, fail_addr might indicate exactly which block failed. If 30/* If the erase fails, fail_addr might indicate exactly which block failed. If
31 fail_addr = 0xffffffff, the failure was not at the device level or was not 31 fail_addr = MTD_FAIL_ADDR_UNKNOWN, the failure was not at the device level or was not
32 specific to any particular block. */ 32 specific to any particular block. */
33struct erase_info { 33struct erase_info {
34 struct mtd_info *mtd; 34 struct mtd_info *mtd;
@@ -121,7 +121,7 @@ struct mtd_info {
121 u_int32_t oobavail; // Available OOB bytes per block 121 u_int32_t oobavail; // Available OOB bytes per block
122 122
123 // Kernel-only stuff starts here. 123 // Kernel-only stuff starts here.
124 char *name; 124 const char *name;
125 int index; 125 int index;
126 126
127 /* ecc layout structure pointer - read only ! */ 127 /* ecc layout structure pointer - read only ! */
@@ -274,7 +274,11 @@ static inline void mtd_erase_callback(struct erase_info *instr)
274 printk(KERN_INFO args); \ 274 printk(KERN_INFO args); \
275 } while(0) 275 } while(0)
276#else /* CONFIG_MTD_DEBUG */ 276#else /* CONFIG_MTD_DEBUG */
277#define DEBUG(n, args...) do { } while(0) 277#define DEBUG(n, args...) \
278 do { \
279 if (0) \
280 printk(KERN_INFO args); \
281 } while(0)
278 282
279#endif /* CONFIG_MTD_DEBUG */ 283#endif /* CONFIG_MTD_DEBUG */
280 284
diff --git a/include/linux/mtd/nand-gpio.h b/include/linux/mtd/nand-gpio.h
new file mode 100644
index 000000000000..51534e50f7fc
--- /dev/null
+++ b/include/linux/mtd/nand-gpio.h
@@ -0,0 +1,19 @@
1#ifndef __LINUX_MTD_NAND_GPIO_H
2#define __LINUX_MTD_NAND_GPIO_H
3
4#include <linux/mtd/nand.h>
5
6struct gpio_nand_platdata {
7 int gpio_nce;
8 int gpio_nwp;
9 int gpio_cle;
10 int gpio_ale;
11 int gpio_rdy;
12 void (*adjust_parts)(struct gpio_nand_platdata *, size_t);
13 struct mtd_partition *parts;
14 unsigned int num_parts;
15 unsigned int options;
16 int chip_delay;
17};
18
19#endif
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index 53ea3dc8b0e8..733d3f3b4eb8 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -5,8 +5,6 @@
5 * Steven J. Hill <sjhill@realitydiluted.com> 5 * Steven J. Hill <sjhill@realitydiluted.com>
6 * Thomas Gleixner <tglx@linutronix.de> 6 * Thomas Gleixner <tglx@linutronix.de>
7 * 7 *
8 * $Id: nand.h,v 1.74 2005/09/15 13:58:50 vwool Exp $
9 *
10 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as 9 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation. 10 * published by the Free Software Foundation.
@@ -179,6 +177,9 @@ typedef enum {
179#define NAND_MUST_PAD(chip) (!(chip->options & NAND_NO_PADDING)) 177#define NAND_MUST_PAD(chip) (!(chip->options & NAND_NO_PADDING))
180#define NAND_HAS_CACHEPROG(chip) ((chip->options & NAND_CACHEPRG)) 178#define NAND_HAS_CACHEPROG(chip) ((chip->options & NAND_CACHEPRG))
181#define NAND_HAS_COPYBACK(chip) ((chip->options & NAND_COPYBACK)) 179#define NAND_HAS_COPYBACK(chip) ((chip->options & NAND_COPYBACK))
180/* Large page NAND with SOFT_ECC should support subpage reads */
181#define NAND_SUBPAGE_READ(chip) ((chip->ecc.mode == NAND_ECC_SOFT) \
182 && (chip->page_shift > 9))
182 183
183/* Mask to zero out the chip options, which come from the id table */ 184/* Mask to zero out the chip options, which come from the id table */
184#define NAND_CHIPOPTIONS_MSK (0x0000ffff & ~NAND_NO_AUTOINCR) 185#define NAND_CHIPOPTIONS_MSK (0x0000ffff & ~NAND_NO_AUTOINCR)
@@ -247,6 +248,7 @@ struct nand_hw_control {
247 * @read_page_raw: function to read a raw page without ECC 248 * @read_page_raw: function to read a raw page without ECC
248 * @write_page_raw: function to write a raw page without ECC 249 * @write_page_raw: function to write a raw page without ECC
249 * @read_page: function to read a page according to the ecc generator requirements 250 * @read_page: function to read a page according to the ecc generator requirements
251 * @read_subpage: function to read parts of the page covered by ECC.
250 * @write_page: function to write a page according to the ecc generator requirements 252 * @write_page: function to write a page according to the ecc generator requirements
251 * @read_oob: function to read chip OOB data 253 * @read_oob: function to read chip OOB data
252 * @write_oob: function to write chip OOB data 254 * @write_oob: function to write chip OOB data
@@ -276,6 +278,10 @@ struct nand_ecc_ctrl {
276 int (*read_page)(struct mtd_info *mtd, 278 int (*read_page)(struct mtd_info *mtd,
277 struct nand_chip *chip, 279 struct nand_chip *chip,
278 uint8_t *buf); 280 uint8_t *buf);
281 int (*read_subpage)(struct mtd_info *mtd,
282 struct nand_chip *chip,
283 uint32_t offs, uint32_t len,
284 uint8_t *buf);
279 void (*write_page)(struct mtd_info *mtd, 285 void (*write_page)(struct mtd_info *mtd,
280 struct nand_chip *chip, 286 struct nand_chip *chip,
281 const uint8_t *buf); 287 const uint8_t *buf);
diff --git a/include/linux/mtd/nand_ecc.h b/include/linux/mtd/nand_ecc.h
index 12c5bc342ead..090da505425d 100644
--- a/include/linux/mtd/nand_ecc.h
+++ b/include/linux/mtd/nand_ecc.h
@@ -3,8 +3,6 @@
3 * 3 *
4 * Copyright (C) 2000 Steven J. Hill (sjhill@realitydiluted.com) 4 * Copyright (C) 2000 Steven J. Hill (sjhill@realitydiluted.com)
5 * 5 *
6 * $Id: nand_ecc.h,v 1.4 2004/06/17 02:35:02 dbrown Exp $
7 *
8 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as 7 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation. 8 * published by the Free Software Foundation.
diff --git a/include/linux/mtd/nftl.h b/include/linux/mtd/nftl.h
index 001eec50cac6..dcaf611ed748 100644
--- a/include/linux/mtd/nftl.h
+++ b/include/linux/mtd/nftl.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: nftl.h,v 1.16 2004/06/30 14:49:00 dbrown Exp $
3 *
4 * (C) 1999-2003 David Woodhouse <dwmw2@infradead.org> 2 * (C) 1999-2003 David Woodhouse <dwmw2@infradead.org>
5 */ 3 */
6 4
diff --git a/include/linux/mtd/onenand_regs.h b/include/linux/mtd/onenand_regs.h
index d1b310c92eb4..0c6bbe28f38c 100644
--- a/include/linux/mtd/onenand_regs.h
+++ b/include/linux/mtd/onenand_regs.h
@@ -152,6 +152,8 @@
152#define ONENAND_SYS_CFG1_INT (1 << 6) 152#define ONENAND_SYS_CFG1_INT (1 << 6)
153#define ONENAND_SYS_CFG1_IOBE (1 << 5) 153#define ONENAND_SYS_CFG1_IOBE (1 << 5)
154#define ONENAND_SYS_CFG1_RDY_CONF (1 << 4) 154#define ONENAND_SYS_CFG1_RDY_CONF (1 << 4)
155#define ONENAND_SYS_CFG1_HF (1 << 2)
156#define ONENAND_SYS_CFG1_SYNC_WRITE (1 << 1)
155 157
156/* 158/*
157 * Controller Status Register F240h (R) 159 * Controller Status Register F240h (R)
diff --git a/include/linux/mtd/partitions.h b/include/linux/mtd/partitions.h
index 7c37d7e55abc..c92b4d439609 100644
--- a/include/linux/mtd/partitions.h
+++ b/include/linux/mtd/partitions.h
@@ -4,8 +4,6 @@
4 * (C) 2000 Nicolas Pitre <nico@cam.org> 4 * (C) 2000 Nicolas Pitre <nico@cam.org>
5 * 5 *
6 * This code is GPL 6 * This code is GPL
7 *
8 * $Id: partitions.h,v 1.17 2005/11/07 11:14:55 gleixner Exp $
9 */ 7 */
10 8
11#ifndef MTD_PARTITIONS_H 9#ifndef MTD_PARTITIONS_H
@@ -75,7 +73,6 @@ struct device;
75struct device_node; 73struct device_node;
76 74
77int __devinit of_mtd_parse_partitions(struct device *dev, 75int __devinit of_mtd_parse_partitions(struct device *dev,
78 struct mtd_info *mtd,
79 struct device_node *node, 76 struct device_node *node,
80 struct mtd_partition **pparts); 77 struct mtd_partition **pparts);
81 78
diff --git a/include/linux/mtd/physmap.h b/include/linux/mtd/physmap.h
index 0dc07d5f3354..c8e63a5ee72e 100644
--- a/include/linux/mtd/physmap.h
+++ b/include/linux/mtd/physmap.h
@@ -2,8 +2,6 @@
2 * For boards with physically mapped flash and using 2 * For boards with physically mapped flash and using
3 * drivers/mtd/maps/physmap.c mapping driver. 3 * drivers/mtd/maps/physmap.c mapping driver.
4 * 4 *
5 * $Id: physmap.h,v 1.4 2005/11/07 11:14:55 gleixner Exp $
6 *
7 * Copyright (C) 2003 MontaVista Software Inc. 5 * Copyright (C) 2003 MontaVista Software Inc.
8 * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net 6 * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
9 * 7 *
diff --git a/include/linux/mtd/plat-ram.h b/include/linux/mtd/plat-ram.h
index 0e37ad07bce2..e07890aff1cf 100644
--- a/include/linux/mtd/plat-ram.h
+++ b/include/linux/mtd/plat-ram.h
@@ -6,8 +6,6 @@
6 * 6 *
7 * Generic platform device based RAM map 7 * Generic platform device based RAM map
8 * 8 *
9 * $Id: plat-ram.h,v 1.2 2005/01/24 00:37:40 bjd Exp $
10 *
11 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as 10 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation. 11 * published by the Free Software Foundation.
diff --git a/include/linux/mtd/pmc551.h b/include/linux/mtd/pmc551.h
index 5cc070c24d88..27ad40aed19f 100644
--- a/include/linux/mtd/pmc551.h
+++ b/include/linux/mtd/pmc551.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: pmc551.h,v 1.6 2005/11/07 11:14:55 gleixner Exp $
3 *
4 * PMC551 PCI Mezzanine Ram Device 2 * PMC551 PCI Mezzanine Ram Device
5 * 3 *
6 * Author: 4 * Author:
@@ -17,7 +15,7 @@
17 15
18#include <linux/mtd/mtd.h> 16#include <linux/mtd/mtd.h>
19 17
20#define PMC551_VERSION "$Id: pmc551.h,v 1.6 2005/11/07 11:14:55 gleixner Exp $\n"\ 18#define PMC551_VERSION \
21 "Ramix PMC551 PCI Mezzanine Ram Driver. (C) 1999,2000 Nortel Networks.\n" 19 "Ramix PMC551 PCI Mezzanine Ram Driver. (C) 1999,2000 Nortel Networks.\n"
22 20
23/* 21/*
diff --git a/include/linux/mtd/sh_flctl.h b/include/linux/mtd/sh_flctl.h
new file mode 100644
index 000000000000..e77c1cea404d
--- /dev/null
+++ b/include/linux/mtd/sh_flctl.h
@@ -0,0 +1,125 @@
1/*
2 * SuperH FLCTL nand controller
3 *
4 * Copyright © 2008 Renesas Solutions Corp.
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; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20#ifndef __SH_FLCTL_H__
21#define __SH_FLCTL_H__
22
23#include <linux/mtd/mtd.h>
24#include <linux/mtd/nand.h>
25#include <linux/mtd/partitions.h>
26
27/* FLCTL registers */
28#define FLCMNCR(f) (f->reg + 0x0)
29#define FLCMDCR(f) (f->reg + 0x4)
30#define FLCMCDR(f) (f->reg + 0x8)
31#define FLADR(f) (f->reg + 0xC)
32#define FLADR2(f) (f->reg + 0x3C)
33#define FLDATAR(f) (f->reg + 0x10)
34#define FLDTCNTR(f) (f->reg + 0x14)
35#define FLINTDMACR(f) (f->reg + 0x18)
36#define FLBSYTMR(f) (f->reg + 0x1C)
37#define FLBSYCNT(f) (f->reg + 0x20)
38#define FLDTFIFO(f) (f->reg + 0x24)
39#define FLECFIFO(f) (f->reg + 0x28)
40#define FLTRCR(f) (f->reg + 0x2C)
41#define FL4ECCRESULT0(f) (f->reg + 0x80)
42#define FL4ECCRESULT1(f) (f->reg + 0x84)
43#define FL4ECCRESULT2(f) (f->reg + 0x88)
44#define FL4ECCRESULT3(f) (f->reg + 0x8C)
45#define FL4ECCCR(f) (f->reg + 0x90)
46#define FL4ECCCNT(f) (f->reg + 0x94)
47#define FLERRADR(f) (f->reg + 0x98)
48
49/* FLCMNCR control bits */
50#define ECCPOS2 (0x1 << 25)
51#define _4ECCCNTEN (0x1 << 24)
52#define _4ECCEN (0x1 << 23)
53#define _4ECCCORRECT (0x1 << 22)
54#define SNAND_E (0x1 << 18) /* SNAND (0=512 1=2048)*/
55#define QTSEL_E (0x1 << 17)
56#define ENDIAN (0x1 << 16) /* 1 = little endian */
57#define FCKSEL_E (0x1 << 15)
58#define ECCPOS_00 (0x00 << 12)
59#define ECCPOS_01 (0x01 << 12)
60#define ECCPOS_02 (0x02 << 12)
61#define ACM_SACCES_MODE (0x01 << 10)
62#define NANWF_E (0x1 << 9)
63#define SE_D (0x1 << 8) /* Spare area disable */
64#define CE1_ENABLE (0x1 << 4) /* Chip Enable 1 */
65#define CE0_ENABLE (0x1 << 3) /* Chip Enable 0 */
66#define TYPESEL_SET (0x1 << 0)
67
68/* FLCMDCR control bits */
69#define ADRCNT2_E (0x1 << 31) /* 5byte address enable */
70#define ADRMD_E (0x1 << 26) /* Sector address access */
71#define CDSRC_E (0x1 << 25) /* Data buffer selection */
72#define DOSR_E (0x1 << 24) /* Status read check */
73#define SELRW (0x1 << 21) /* 0:read 1:write */
74#define DOADR_E (0x1 << 20) /* Address stage execute */
75#define ADRCNT_1 (0x00 << 18) /* Address data bytes: 1byte */
76#define ADRCNT_2 (0x01 << 18) /* Address data bytes: 2byte */
77#define ADRCNT_3 (0x02 << 18) /* Address data bytes: 3byte */
78#define ADRCNT_4 (0x03 << 18) /* Address data bytes: 4byte */
79#define DOCMD2_E (0x1 << 17) /* 2nd cmd stage execute */
80#define DOCMD1_E (0x1 << 16) /* 1st cmd stage execute */
81
82/* FLTRCR control bits */
83#define TRSTRT (0x1 << 0) /* translation start */
84#define TREND (0x1 << 1) /* translation end */
85
86/* FL4ECCCR control bits */
87#define _4ECCFA (0x1 << 2) /* 4 symbols correct fault */
88#define _4ECCEND (0x1 << 1) /* 4 symbols end */
89#define _4ECCEXST (0x1 << 0) /* 4 symbols exist */
90
91#define INIT_FL4ECCRESULT_VAL 0x03FF03FF
92#define LOOP_TIMEOUT_MAX 0x00010000
93
94#define mtd_to_flctl(mtd) container_of(mtd, struct sh_flctl, mtd)
95
96struct sh_flctl {
97 struct mtd_info mtd;
98 struct nand_chip chip;
99 void __iomem *reg;
100
101 uint8_t done_buff[2048 + 64]; /* max size 2048 + 64 */
102 int read_bytes;
103 int index;
104 int seqin_column; /* column in SEQIN cmd */
105 int seqin_page_addr; /* page_addr in SEQIN cmd */
106 uint32_t seqin_read_cmd; /* read cmd in SEQIN cmd */
107 int erase1_page_addr; /* page_addr in ERASE1 cmd */
108 uint32_t erase_ADRCNT; /* bits of FLCMDCR in ERASE1 cmd */
109 uint32_t rw_ADRCNT; /* bits of FLCMDCR in READ WRITE cmd */
110
111 int hwecc_cant_correct[4];
112
113 unsigned page_size:1; /* NAND page size (0 = 512, 1 = 2048) */
114 unsigned hwecc:1; /* Hardware ECC (0 = disabled, 1 = enabled) */
115};
116
117struct sh_flctl_platform_data {
118 struct mtd_partition *parts;
119 int nr_parts;
120 unsigned long flcmncr_val;
121
122 unsigned has_hwecc:1;
123};
124
125#endif /* __SH_FLCTL_H__ */
diff --git a/include/linux/mtd/ubi.h b/include/linux/mtd/ubi.h
index f71201d0f3e7..6316fafe5c2a 100644
--- a/include/linux/mtd/ubi.h
+++ b/include/linux/mtd/ubi.h
@@ -45,13 +45,13 @@ enum {
45 * @size: how many physical eraseblocks are reserved for this volume 45 * @size: how many physical eraseblocks are reserved for this volume
46 * @used_bytes: how many bytes of data this volume contains 46 * @used_bytes: how many bytes of data this volume contains
47 * @used_ebs: how many physical eraseblocks of this volume actually contain any 47 * @used_ebs: how many physical eraseblocks of this volume actually contain any
48 * data 48 * data
49 * @vol_type: volume type (%UBI_DYNAMIC_VOLUME or %UBI_STATIC_VOLUME) 49 * @vol_type: volume type (%UBI_DYNAMIC_VOLUME or %UBI_STATIC_VOLUME)
50 * @corrupted: non-zero if the volume is corrupted (static volumes only) 50 * @corrupted: non-zero if the volume is corrupted (static volumes only)
51 * @upd_marker: non-zero if the volume has update marker set 51 * @upd_marker: non-zero if the volume has update marker set
52 * @alignment: volume alignment 52 * @alignment: volume alignment
53 * @usable_leb_size: how many bytes are available in logical eraseblocks of 53 * @usable_leb_size: how many bytes are available in logical eraseblocks of
54 * this volume 54 * this volume
55 * @name_len: volume name length 55 * @name_len: volume name length
56 * @name: volume name 56 * @name: volume name
57 * @cdev: UBI volume character device major and minor numbers 57 * @cdev: UBI volume character device major and minor numbers
@@ -152,6 +152,7 @@ int ubi_leb_erase(struct ubi_volume_desc *desc, int lnum);
152int ubi_leb_unmap(struct ubi_volume_desc *desc, int lnum); 152int ubi_leb_unmap(struct ubi_volume_desc *desc, int lnum);
153int ubi_leb_map(struct ubi_volume_desc *desc, int lnum, int dtype); 153int ubi_leb_map(struct ubi_volume_desc *desc, int lnum, int dtype);
154int ubi_is_mapped(struct ubi_volume_desc *desc, int lnum); 154int ubi_is_mapped(struct ubi_volume_desc *desc, int lnum);
155int ubi_sync(int ubi_num);
155 156
156/* 157/*
157 * This function is the same as the 'ubi_leb_read()' function, but it does not 158 * This function is the same as the 'ubi_leb_read()' function, but it does not
diff --git a/include/linux/mtd/xip.h b/include/linux/mtd/xip.h
index e9d40bdde48c..36efcba15ecd 100644
--- a/include/linux/mtd/xip.h
+++ b/include/linux/mtd/xip.h
@@ -11,8 +11,6 @@
11 * This program is free software; you can redistribute it and/or modify 11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as 12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation. 13 * published by the Free Software Foundation.
14 *
15 * $Id: xip.h,v 1.5 2005/11/07 11:14:55 gleixner Exp $
16 */ 14 */
17 15
18#ifndef __LINUX_MTD_XIP_H__ 16#ifndef __LINUX_MTD_XIP_H__
diff --git a/include/linux/mv643xx_eth.h b/include/linux/mv643xx_eth.h
index a15cdd4a8e58..cbbbe9bfecad 100644
--- a/include/linux/mv643xx_eth.h
+++ b/include/linux/mv643xx_eth.h
@@ -17,30 +17,62 @@
17 17
18struct mv643xx_eth_shared_platform_data { 18struct mv643xx_eth_shared_platform_data {
19 struct mbus_dram_target_info *dram; 19 struct mbus_dram_target_info *dram;
20 unsigned int t_clk; 20 struct platform_device *shared_smi;
21 unsigned int t_clk;
21}; 22};
22 23
24#define MV643XX_ETH_PHY_ADDR_DEFAULT 0
25#define MV643XX_ETH_PHY_ADDR(x) (0x80 | (x))
26#define MV643XX_ETH_PHY_NONE 0xff
27
23struct mv643xx_eth_platform_data { 28struct mv643xx_eth_platform_data {
29 /*
30 * Pointer back to our parent instance, and our port number.
31 */
24 struct platform_device *shared; 32 struct platform_device *shared;
25 int port_number; 33 int port_number;
26 34
27 struct platform_device *shared_smi; 35 /*
36 * Whether a PHY is present, and if yes, at which address.
37 */
38 int phy_addr;
39
40 /*
41 * Use this MAC address if it is valid, overriding the
42 * address that is already in the hardware.
43 */
44 u8 mac_addr[6];
28 45
29 u16 force_phy_addr; /* force override if phy_addr == 0 */ 46 /*
30 u16 phy_addr; 47 * If speed is 0, autonegotiation is enabled.
31 48 * Valid values for speed: 0, SPEED_10, SPEED_100, SPEED_1000.
32 /* If speed is 0, then speed and duplex are autonegotiated. */ 49 * Valid values for duplex: DUPLEX_HALF, DUPLEX_FULL.
33 int speed; /* 0, SPEED_10, SPEED_100, SPEED_1000 */ 50 */
34 int duplex; /* DUPLEX_HALF or DUPLEX_FULL */ 51 int speed;
35 52 int duplex;
36 /* non-zero values of the following fields override defaults */ 53
37 u32 tx_queue_size; 54 /*
38 u32 rx_queue_size; 55 * How many RX/TX queues to use.
39 u32 tx_sram_addr; 56 */
40 u32 tx_sram_size; 57 int rx_queue_count;
41 u32 rx_sram_addr; 58 int tx_queue_count;
42 u32 rx_sram_size; 59
43 u8 mac_addr[6]; /* mac address if non-zero*/ 60 /*
61 * Override default RX/TX queue sizes if nonzero.
62 */
63 int rx_queue_size;
64 int tx_queue_size;
65
66 /*
67 * Use on-chip SRAM for RX/TX descriptors if size is nonzero
68 * and sufficient to contain all descriptors for the requested
69 * ring sizes.
70 */
71 unsigned long rx_sram_addr;
72 int rx_sram_size;
73 unsigned long tx_sram_addr;
74 int tx_sram_size;
44}; 75};
45 76
46#endif /* __LINUX_MV643XX_ETH_H */ 77
78#endif
diff --git a/include/linux/namei.h b/include/linux/namei.h
index 24d88e98a626..99eb80306dc5 100644
--- a/include/linux/namei.h
+++ b/include/linux/namei.h
@@ -47,27 +47,28 @@ enum {LAST_NORM, LAST_ROOT, LAST_DOT, LAST_DOTDOT, LAST_BIND};
47#define LOOKUP_DIRECTORY 2 47#define LOOKUP_DIRECTORY 2
48#define LOOKUP_CONTINUE 4 48#define LOOKUP_CONTINUE 4
49#define LOOKUP_PARENT 16 49#define LOOKUP_PARENT 16
50#define LOOKUP_NOALT 32
51#define LOOKUP_REVAL 64 50#define LOOKUP_REVAL 64
52/* 51/*
53 * Intent data 52 * Intent data
54 */ 53 */
55#define LOOKUP_OPEN (0x0100) 54#define LOOKUP_OPEN 0x0100
56#define LOOKUP_CREATE (0x0200) 55#define LOOKUP_CREATE 0x0200
57#define LOOKUP_ACCESS (0x0400) 56#define LOOKUP_EXCL 0x0400
58#define LOOKUP_CHDIR (0x0800) 57#define LOOKUP_RENAME_TARGET 0x0800
59 58
60extern int __user_walk(const char __user *, unsigned, struct nameidata *); 59extern int user_path_at(int, const char __user *, unsigned, struct path *);
61extern int __user_walk_fd(int dfd, const char __user *, unsigned, struct nameidata *); 60
62#define user_path_walk(name,nd) \ 61#define user_path(name, path) user_path_at(AT_FDCWD, name, LOOKUP_FOLLOW, path)
63 __user_walk_fd(AT_FDCWD, name, LOOKUP_FOLLOW, nd) 62#define user_lpath(name, path) user_path_at(AT_FDCWD, name, 0, path)
64#define user_path_walk_link(name,nd) \ 63#define user_path_dir(name, path) \
65 __user_walk_fd(AT_FDCWD, name, 0, nd) 64 user_path_at(AT_FDCWD, name, LOOKUP_FOLLOW | LOOKUP_DIRECTORY, path)
65
66extern int kern_path(const char *, unsigned, struct path *);
67
66extern int path_lookup(const char *, unsigned, struct nameidata *); 68extern int path_lookup(const char *, unsigned, struct nameidata *);
67extern int vfs_path_lookup(struct dentry *, struct vfsmount *, 69extern int vfs_path_lookup(struct dentry *, struct vfsmount *,
68 const char *, unsigned int, struct nameidata *); 70 const char *, unsigned int, struct nameidata *);
69 71
70extern int __user_path_lookup_open(const char __user *, unsigned lookup_flags, struct nameidata *nd, int open_flags);
71extern int path_lookup_open(int dfd, const char *name, unsigned lookup_flags, struct nameidata *, int open_flags); 72extern int path_lookup_open(int dfd, const char *name, unsigned lookup_flags, struct nameidata *, int open_flags);
72extern struct file *lookup_instantiate_filp(struct nameidata *nd, struct dentry *dentry, 73extern struct file *lookup_instantiate_filp(struct nameidata *nd, struct dentry *dentry,
73 int (*open)(struct inode *, struct file *)); 74 int (*open)(struct inode *, struct file *));
diff --git a/include/linux/net.h b/include/linux/net.h
index 71f7dd559285..6dc14a240042 100644
--- a/include/linux/net.h
+++ b/include/linux/net.h
@@ -18,15 +18,9 @@
18#ifndef _LINUX_NET_H 18#ifndef _LINUX_NET_H
19#define _LINUX_NET_H 19#define _LINUX_NET_H
20 20
21#include <linux/wait.h>
22#include <linux/socket.h> 21#include <linux/socket.h>
23#include <asm/socket.h> 22#include <asm/socket.h>
24 23
25struct poll_table_struct;
26struct pipe_inode_info;
27struct inode;
28struct net;
29
30#define NPROTO AF_MAX 24#define NPROTO AF_MAX
31 25
32#define SYS_SOCKET 1 /* sys_socket(2) */ 26#define SYS_SOCKET 1 /* sys_socket(2) */
@@ -46,6 +40,7 @@ struct net;
46#define SYS_GETSOCKOPT 15 /* sys_getsockopt(2) */ 40#define SYS_GETSOCKOPT 15 /* sys_getsockopt(2) */
47#define SYS_SENDMSG 16 /* sys_sendmsg(2) */ 41#define SYS_SENDMSG 16 /* sys_sendmsg(2) */
48#define SYS_RECVMSG 17 /* sys_recvmsg(2) */ 42#define SYS_RECVMSG 17 /* sys_recvmsg(2) */
43#define SYS_PACCEPT 18 /* sys_paccept(2) */
49 44
50typedef enum { 45typedef enum {
51 SS_FREE = 0, /* not allocated */ 46 SS_FREE = 0, /* not allocated */
@@ -60,6 +55,13 @@ typedef enum {
60#ifdef __KERNEL__ 55#ifdef __KERNEL__
61#include <linux/stringify.h> 56#include <linux/stringify.h>
62#include <linux/random.h> 57#include <linux/random.h>
58#include <linux/wait.h>
59#include <linux/fcntl.h> /* For O_CLOEXEC and O_NONBLOCK */
60
61struct poll_table_struct;
62struct pipe_inode_info;
63struct inode;
64struct net;
63 65
64#define SOCK_ASYNC_NOSPACE 0 66#define SOCK_ASYNC_NOSPACE 0
65#define SOCK_ASYNC_WAITDATA 1 67#define SOCK_ASYNC_WAITDATA 1
@@ -94,6 +96,15 @@ enum sock_type {
94}; 96};
95 97
96#define SOCK_MAX (SOCK_PACKET + 1) 98#define SOCK_MAX (SOCK_PACKET + 1)
99/* Mask which covers at least up to SOCK_MASK-1. The
100 * remaining bits are used as flags. */
101#define SOCK_TYPE_MASK 0xf
102
103/* Flags for socket, socketpair, paccept */
104#define SOCK_CLOEXEC O_CLOEXEC
105#ifndef SOCK_NONBLOCK
106#define SOCK_NONBLOCK O_NONBLOCK
107#endif
97 108
98#endif /* ARCH_HAS_SOCKET_TYPES */ 109#endif /* ARCH_HAS_SOCKET_TYPES */
99 110
@@ -106,23 +117,23 @@ enum sock_shutdown_cmd {
106/** 117/**
107 * struct socket - general BSD socket 118 * struct socket - general BSD socket
108 * @state: socket state (%SS_CONNECTED, etc) 119 * @state: socket state (%SS_CONNECTED, etc)
120 * @type: socket type (%SOCK_STREAM, etc)
109 * @flags: socket flags (%SOCK_ASYNC_NOSPACE, etc) 121 * @flags: socket flags (%SOCK_ASYNC_NOSPACE, etc)
110 * @ops: protocol specific socket operations 122 * @ops: protocol specific socket operations
111 * @fasync_list: Asynchronous wake up list 123 * @fasync_list: Asynchronous wake up list
112 * @file: File back pointer for gc 124 * @file: File back pointer for gc
113 * @sk: internal networking protocol agnostic socket representation 125 * @sk: internal networking protocol agnostic socket representation
114 * @wait: wait queue for several uses 126 * @wait: wait queue for several uses
115 * @type: socket type (%SOCK_STREAM, etc)
116 */ 127 */
117struct socket { 128struct socket {
118 socket_state state; 129 socket_state state;
130 short type;
119 unsigned long flags; 131 unsigned long flags;
120 const struct proto_ops *ops; 132 const struct proto_ops *ops;
121 struct fasync_struct *fasync_list; 133 struct fasync_struct *fasync_list;
122 struct file *file; 134 struct file *file;
123 struct sock *sk; 135 struct sock *sk;
124 wait_queue_head_t wait; 136 wait_queue_head_t wait;
125 short type;
126}; 137};
127 138
128struct vm_area_struct; 139struct vm_area_struct;
@@ -208,10 +219,12 @@ extern int sock_sendmsg(struct socket *sock, struct msghdr *msg,
208 size_t len); 219 size_t len);
209extern int sock_recvmsg(struct socket *sock, struct msghdr *msg, 220extern int sock_recvmsg(struct socket *sock, struct msghdr *msg,
210 size_t size, int flags); 221 size_t size, int flags);
211extern int sock_map_fd(struct socket *sock); 222extern int sock_map_fd(struct socket *sock, int flags);
212extern struct socket *sockfd_lookup(int fd, int *err); 223extern struct socket *sockfd_lookup(int fd, int *err);
213#define sockfd_put(sock) fput(sock->file) 224#define sockfd_put(sock) fput(sock->file)
214extern int net_ratelimit(void); 225extern int net_ratelimit(void);
226extern long do_accept(int fd, struct sockaddr __user *upeer_sockaddr,
227 int __user *upeer_addrlen, int flags);
215 228
216#define net_random() random32() 229#define net_random() random32()
217#define net_srandom(seed) srandom32((__force u32)seed) 230#define net_srandom(seed) srandom32((__force u32)seed)
@@ -338,8 +351,7 @@ static const struct proto_ops name##_ops = { \
338 351
339#ifdef CONFIG_SYSCTL 352#ifdef CONFIG_SYSCTL
340#include <linux/sysctl.h> 353#include <linux/sysctl.h>
341extern int net_msg_cost; 354extern struct ratelimit_state net_ratelimit_state;
342extern int net_msg_burst;
343#endif 355#endif
344 356
345#endif /* __KERNEL__ */ 357#endif /* __KERNEL__ */
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 25f87102ab66..c8bcb59adfdf 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -11,7 +11,7 @@
11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> 11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
12 * Corey Minyard <wf-rch!minyard@relay.EU.net> 12 * Corey Minyard <wf-rch!minyard@relay.EU.net>
13 * Donald J. Becker, <becker@cesdis.gsfc.nasa.gov> 13 * Donald J. Becker, <becker@cesdis.gsfc.nasa.gov>
14 * Alan Cox, <Alan.Cox@linux.org> 14 * Alan Cox, <alan@lxorguk.ukuu.org.uk>
15 * Bjorn Ekwall. <bj0rn@blox.se> 15 * Bjorn Ekwall. <bj0rn@blox.se>
16 * Pekka Riikonen <priikone@poseidon.pspt.fi> 16 * Pekka Riikonen <priikone@poseidon.pspt.fi>
17 * 17 *
@@ -42,6 +42,7 @@
42#include <linux/workqueue.h> 42#include <linux/workqueue.h>
43 43
44#include <net/net_namespace.h> 44#include <net/net_namespace.h>
45#include <net/dsa.h>
45 46
46struct vlan_group; 47struct vlan_group;
47struct ethtool_ops; 48struct ethtool_ops;
@@ -61,9 +62,7 @@ struct wireless_dev;
61#define NET_XMIT_DROP 1 /* skb dropped */ 62#define NET_XMIT_DROP 1 /* skb dropped */
62#define NET_XMIT_CN 2 /* congestion notification */ 63#define NET_XMIT_CN 2 /* congestion notification */
63#define NET_XMIT_POLICED 3 /* skb is shot by police */ 64#define NET_XMIT_POLICED 3 /* skb is shot by police */
64#define NET_XMIT_BYPASS 4 /* packet does not leave via dequeue; 65#define NET_XMIT_MASK 0xFFFF /* qdisc flags in net/sch_generic.h */
65 (TC use only - dev_queue_xmit
66 returns this as NET_XMIT_SUCCESS) */
67 66
68/* Backlog congestion levels */ 67/* Backlog congestion levels */
69#define NET_RX_SUCCESS 0 /* keep 'em coming, baby */ 68#define NET_RX_SUCCESS 0 /* keep 'em coming, baby */
@@ -118,14 +117,6 @@ struct wireless_dev;
118 117
119#endif /* __KERNEL__ */ 118#endif /* __KERNEL__ */
120 119
121struct net_device_subqueue
122{
123 /* Give a control state for each queue. This struct may contain
124 * per-queue locks in the future.
125 */
126 unsigned long state;
127};
128
129/* 120/*
130 * Network device statistics. Akin to the 2.0 ether stats but 121 * Network device statistics. Akin to the 2.0 ether stats but
131 * with byte counters. 122 * with byte counters.
@@ -281,14 +272,11 @@ struct header_ops {
281 272
282enum netdev_state_t 273enum netdev_state_t
283{ 274{
284 __LINK_STATE_XOFF=0,
285 __LINK_STATE_START, 275 __LINK_STATE_START,
286 __LINK_STATE_PRESENT, 276 __LINK_STATE_PRESENT,
287 __LINK_STATE_SCHED,
288 __LINK_STATE_NOCARRIER, 277 __LINK_STATE_NOCARRIER,
289 __LINK_STATE_LINKWATCH_PENDING, 278 __LINK_STATE_LINKWATCH_PENDING,
290 __LINK_STATE_DORMANT, 279 __LINK_STATE_DORMANT,
291 __LINK_STATE_QDISC_RUNNING,
292}; 280};
293 281
294 282
@@ -448,6 +436,21 @@ static inline void napi_synchronize(const struct napi_struct *n)
448# define napi_synchronize(n) barrier() 436# define napi_synchronize(n) barrier()
449#endif 437#endif
450 438
439enum netdev_queue_state_t
440{
441 __QUEUE_STATE_XOFF,
442 __QUEUE_STATE_FROZEN,
443};
444
445struct netdev_queue {
446 struct net_device *dev;
447 struct Qdisc *qdisc;
448 unsigned long state;
449 spinlock_t _xmit_lock;
450 int xmit_lock_owner;
451 struct Qdisc *qdisc_sleeping;
452} ____cacheline_aligned_in_smp;
453
451/* 454/*
452 * The DEVICE structure. 455 * The DEVICE structure.
453 * Actually, this whole structure is a big mistake. It mixes I/O 456 * Actually, this whole structure is a big mistake. It mixes I/O
@@ -469,6 +472,8 @@ struct net_device
469 char name[IFNAMSIZ]; 472 char name[IFNAMSIZ];
470 /* device name hash chain */ 473 /* device name hash chain */
471 struct hlist_node name_hlist; 474 struct hlist_node name_hlist;
475 /* snmp alias */
476 char *ifalias;
472 477
473 /* 478 /*
474 * I/O specific fields 479 * I/O specific fields
@@ -516,7 +521,6 @@ struct net_device
516#define NETIF_F_LLTX 4096 /* LockLess TX - deprecated. Please */ 521#define NETIF_F_LLTX 4096 /* LockLess TX - deprecated. Please */
517 /* do not use LLTX in new drivers */ 522 /* do not use LLTX in new drivers */
518#define NETIF_F_NETNS_LOCAL 8192 /* Does not change network namespaces */ 523#define NETIF_F_NETNS_LOCAL 8192 /* Does not change network namespaces */
519#define NETIF_F_MULTI_QUEUE 16384 /* Has multiple TX/RX queues */
520#define NETIF_F_LRO 32768 /* large receive offload */ 524#define NETIF_F_LRO 32768 /* large receive offload */
521 525
522 /* Segmentation offload features */ 526 /* Segmentation offload features */
@@ -537,7 +541,13 @@ struct net_device
537#define NETIF_F_V6_CSUM (NETIF_F_GEN_CSUM | NETIF_F_IPV6_CSUM) 541#define NETIF_F_V6_CSUM (NETIF_F_GEN_CSUM | NETIF_F_IPV6_CSUM)
538#define NETIF_F_ALL_CSUM (NETIF_F_V4_CSUM | NETIF_F_V6_CSUM) 542#define NETIF_F_ALL_CSUM (NETIF_F_V4_CSUM | NETIF_F_V6_CSUM)
539 543
540 struct net_device *next_sched; 544 /*
545 * If one device supports one of these features, then enable them
546 * for all in netdev_increment_features.
547 */
548#define NETIF_F_ONE_FOR_ALL (NETIF_F_GSO_SOFTWARE | NETIF_F_GSO_ROBUST | \
549 NETIF_F_SG | NETIF_F_HIGHDMA | \
550 NETIF_F_FRAGLIST)
541 551
542 /* Interface index. Unique device identifier */ 552 /* Interface index. Unique device identifier */
543 int ifindex; 553 int ifindex;
@@ -594,17 +604,21 @@ struct net_device
594 unsigned char addr_len; /* hardware address length */ 604 unsigned char addr_len; /* hardware address length */
595 unsigned short dev_id; /* for shared network cards */ 605 unsigned short dev_id; /* for shared network cards */
596 606
607 spinlock_t addr_list_lock;
597 struct dev_addr_list *uc_list; /* Secondary unicast mac addresses */ 608 struct dev_addr_list *uc_list; /* Secondary unicast mac addresses */
598 int uc_count; /* Number of installed ucasts */ 609 int uc_count; /* Number of installed ucasts */
599 int uc_promisc; 610 int uc_promisc;
600 struct dev_addr_list *mc_list; /* Multicast mac addresses */ 611 struct dev_addr_list *mc_list; /* Multicast mac addresses */
601 int mc_count; /* Number of installed mcasts */ 612 int mc_count; /* Number of installed mcasts */
602 int promiscuity; 613 unsigned int promiscuity;
603 int allmulti; 614 unsigned int allmulti;
604 615
605 616
606 /* Protocol specific pointers */ 617 /* Protocol specific pointers */
607 618
619#ifdef CONFIG_NET_DSA
620 void *dsa_ptr; /* dsa specific data */
621#endif
608 void *atalk_ptr; /* AppleTalk link */ 622 void *atalk_ptr; /* AppleTalk link */
609 void *ip_ptr; /* IPv4 specific data */ 623 void *ip_ptr; /* IPv4 specific data */
610 void *dn_ptr; /* DECnet specific data */ 624 void *dn_ptr; /* DECnet specific data */
@@ -624,32 +638,21 @@ struct net_device
624 638
625 unsigned char broadcast[MAX_ADDR_LEN]; /* hw bcast add */ 639 unsigned char broadcast[MAX_ADDR_LEN]; /* hw bcast add */
626 640
627 /* ingress path synchronizer */ 641 struct netdev_queue rx_queue;
628 spinlock_t ingress_lock;
629 struct Qdisc *qdisc_ingress;
630 642
631/* 643 struct netdev_queue *_tx ____cacheline_aligned_in_smp;
632 * Cache line mostly used on queue transmit path (qdisc) 644
633 */ 645 /* Number of TX queues allocated at alloc_netdev_mq() time */
634 /* device queue lock */ 646 unsigned int num_tx_queues;
635 spinlock_t queue_lock ____cacheline_aligned_in_smp;
636 struct Qdisc *qdisc;
637 struct Qdisc *qdisc_sleeping;
638 struct list_head qdisc_list;
639 unsigned long tx_queue_len; /* Max frames per queue allowed */
640 647
641 /* Partially transmitted GSO packet. */ 648 /* Number of TX queues currently active in device */
642 struct sk_buff *gso_skb; 649 unsigned int real_num_tx_queues;
643 650
651 unsigned long tx_queue_len; /* Max frames per queue allowed */
652 spinlock_t tx_global_lock;
644/* 653/*
645 * One part is mostly used on xmit path (device) 654 * One part is mostly used on xmit path (device)
646 */ 655 */
647 /* hard_start_xmit synchronizer */
648 spinlock_t _xmit_lock ____cacheline_aligned_in_smp;
649 /* cpu id of processor entered to hard_start_xmit or -1,
650 if nobody entered there.
651 */
652 int xmit_lock_owner;
653 void *priv; /* pointer to private data */ 656 void *priv; /* pointer to private data */
654 int (*hard_start_xmit) (struct sk_buff *skb, 657 int (*hard_start_xmit) (struct sk_buff *skb,
655 struct net_device *dev); 658 struct net_device *dev);
@@ -728,6 +731,9 @@ struct net_device
728 void (*poll_controller)(struct net_device *dev); 731 void (*poll_controller)(struct net_device *dev);
729#endif 732#endif
730 733
734 u16 (*select_queue)(struct net_device *dev,
735 struct sk_buff *skb);
736
731#ifdef CONFIG_NET_NS 737#ifdef CONFIG_NET_NS
732 /* Network namespace this network device is inside */ 738 /* Network namespace this network device is inside */
733 struct net *nd_net; 739 struct net *nd_net;
@@ -740,6 +746,8 @@ struct net_device
740 struct net_bridge_port *br_port; 746 struct net_bridge_port *br_port;
741 /* macvlan */ 747 /* macvlan */
742 struct macvlan_port *macvlan_port; 748 struct macvlan_port *macvlan_port;
749 /* GARP */
750 struct garp_port *garp_port;
743 751
744 /* class/net/name entry */ 752 /* class/net/name entry */
745 struct device dev; 753 struct device dev;
@@ -755,16 +763,31 @@ struct net_device
755 /* for setting kernel sock attribute on TCP connection setup */ 763 /* for setting kernel sock attribute on TCP connection setup */
756#define GSO_MAX_SIZE 65536 764#define GSO_MAX_SIZE 65536
757 unsigned int gso_max_size; 765 unsigned int gso_max_size;
758
759 /* The TX queue control structures */
760 unsigned int egress_subqueue_count;
761 struct net_device_subqueue egress_subqueue[1];
762}; 766};
763#define to_net_dev(d) container_of(d, struct net_device, dev) 767#define to_net_dev(d) container_of(d, struct net_device, dev)
764 768
765#define NETDEV_ALIGN 32 769#define NETDEV_ALIGN 32
766#define NETDEV_ALIGN_CONST (NETDEV_ALIGN - 1) 770#define NETDEV_ALIGN_CONST (NETDEV_ALIGN - 1)
767 771
772static inline
773struct netdev_queue *netdev_get_tx_queue(const struct net_device *dev,
774 unsigned int index)
775{
776 return &dev->_tx[index];
777}
778
779static inline void netdev_for_each_tx_queue(struct net_device *dev,
780 void (*f)(struct net_device *,
781 struct netdev_queue *,
782 void *),
783 void *arg)
784{
785 unsigned int i;
786
787 for (i = 0; i < dev->num_tx_queues; i++)
788 f(dev, &dev->_tx[i], arg);
789}
790
768/* 791/*
769 * Net namespace inlines 792 * Net namespace inlines
770 */ 793 */
@@ -787,6 +810,26 @@ void dev_net_set(struct net_device *dev, struct net *net)
787#endif 810#endif
788} 811}
789 812
813static inline bool netdev_uses_dsa_tags(struct net_device *dev)
814{
815#ifdef CONFIG_NET_DSA_TAG_DSA
816 if (dev->dsa_ptr != NULL)
817 return dsa_uses_dsa_tags(dev->dsa_ptr);
818#endif
819
820 return 0;
821}
822
823static inline bool netdev_uses_trailer_tags(struct net_device *dev)
824{
825#ifdef CONFIG_NET_DSA_TAG_TRAILER
826 if (dev->dsa_ptr != NULL)
827 return dsa_uses_trailer_tags(dev->dsa_ptr);
828#endif
829
830 return 0;
831}
832
790/** 833/**
791 * netdev_priv - access network device private data 834 * netdev_priv - access network device private data
792 * @dev: network device 835 * @dev: network device
@@ -795,7 +838,9 @@ void dev_net_set(struct net_device *dev, struct net *net)
795 */ 838 */
796static inline void *netdev_priv(const struct net_device *dev) 839static inline void *netdev_priv(const struct net_device *dev)
797{ 840{
798 return dev->priv; 841 return (char *)dev + ((sizeof(struct net_device)
842 + NETDEV_ALIGN_CONST)
843 & ~NETDEV_ALIGN_CONST);
799} 844}
800 845
801/* Set the sysfs physical device reference for the network logical device 846/* Set the sysfs physical device reference for the network logical device
@@ -830,6 +875,19 @@ static inline void netif_napi_add(struct net_device *dev,
830 set_bit(NAPI_STATE_SCHED, &napi->state); 875 set_bit(NAPI_STATE_SCHED, &napi->state);
831} 876}
832 877
878/**
879 * netif_napi_del - remove a napi context
880 * @napi: napi context
881 *
882 * netif_napi_del() removes a napi context from the network device napi list
883 */
884static inline void netif_napi_del(struct napi_struct *napi)
885{
886#ifdef CONFIG_NETPOLL
887 list_del(&napi->dev_list);
888#endif
889}
890
833struct packet_type { 891struct packet_type {
834 __be16 type; /* This is really htons(ether_type). */ 892 __be16 type; /* This is really htons(ether_type). */
835 struct net_device *dev; /* NULL is wildcarded here */ 893 struct net_device *dev; /* NULL is wildcarded here */
@@ -890,6 +948,7 @@ extern struct net_device *__dev_get_by_name(struct net *net, const char *name);
890extern int dev_alloc_name(struct net_device *dev, const char *name); 948extern int dev_alloc_name(struct net_device *dev, const char *name);
891extern int dev_open(struct net_device *dev); 949extern int dev_open(struct net_device *dev);
892extern int dev_close(struct net_device *dev); 950extern int dev_close(struct net_device *dev);
951extern void dev_disable_lro(struct net_device *dev);
893extern int dev_queue_xmit(struct sk_buff *skb); 952extern int dev_queue_xmit(struct sk_buff *skb);
894extern int register_netdevice(struct net_device *dev); 953extern int register_netdevice(struct net_device *dev);
895extern void unregister_netdevice(struct net_device *dev); 954extern void unregister_netdevice(struct net_device *dev);
@@ -939,7 +998,7 @@ static inline int unregister_gifconf(unsigned int family)
939 */ 998 */
940struct softnet_data 999struct softnet_data
941{ 1000{
942 struct net_device *output_queue; 1001 struct Qdisc *output_queue;
943 struct sk_buff_head input_pkt_queue; 1002 struct sk_buff_head input_pkt_queue;
944 struct list_head poll_list; 1003 struct list_head poll_list;
945 struct sk_buff *completion_queue; 1004 struct sk_buff *completion_queue;
@@ -954,12 +1013,25 @@ DECLARE_PER_CPU(struct softnet_data,softnet_data);
954 1013
955#define HAVE_NETIF_QUEUE 1014#define HAVE_NETIF_QUEUE
956 1015
957extern void __netif_schedule(struct net_device *dev); 1016extern void __netif_schedule(struct Qdisc *q);
1017
1018static inline void netif_schedule_queue(struct netdev_queue *txq)
1019{
1020 if (!test_bit(__QUEUE_STATE_XOFF, &txq->state))
1021 __netif_schedule(txq->qdisc);
1022}
1023
1024static inline void netif_tx_schedule_all(struct net_device *dev)
1025{
1026 unsigned int i;
1027
1028 for (i = 0; i < dev->num_tx_queues; i++)
1029 netif_schedule_queue(netdev_get_tx_queue(dev, i));
1030}
958 1031
959static inline void netif_schedule(struct net_device *dev) 1032static inline void netif_tx_start_queue(struct netdev_queue *dev_queue)
960{ 1033{
961 if (!test_bit(__LINK_STATE_XOFF, &dev->state)) 1034 clear_bit(__QUEUE_STATE_XOFF, &dev_queue->state);
962 __netif_schedule(dev);
963} 1035}
964 1036
965/** 1037/**
@@ -970,7 +1042,29 @@ static inline void netif_schedule(struct net_device *dev)
970 */ 1042 */
971static inline void netif_start_queue(struct net_device *dev) 1043static inline void netif_start_queue(struct net_device *dev)
972{ 1044{
973 clear_bit(__LINK_STATE_XOFF, &dev->state); 1045 netif_tx_start_queue(netdev_get_tx_queue(dev, 0));
1046}
1047
1048static inline void netif_tx_start_all_queues(struct net_device *dev)
1049{
1050 unsigned int i;
1051
1052 for (i = 0; i < dev->num_tx_queues; i++) {
1053 struct netdev_queue *txq = netdev_get_tx_queue(dev, i);
1054 netif_tx_start_queue(txq);
1055 }
1056}
1057
1058static inline void netif_tx_wake_queue(struct netdev_queue *dev_queue)
1059{
1060#ifdef CONFIG_NETPOLL_TRAP
1061 if (netpoll_trap()) {
1062 clear_bit(__QUEUE_STATE_XOFF, &dev_queue->state);
1063 return;
1064 }
1065#endif
1066 if (test_and_clear_bit(__QUEUE_STATE_XOFF, &dev_queue->state))
1067 __netif_schedule(dev_queue->qdisc);
974} 1068}
975 1069
976/** 1070/**
@@ -982,14 +1076,22 @@ static inline void netif_start_queue(struct net_device *dev)
982 */ 1076 */
983static inline void netif_wake_queue(struct net_device *dev) 1077static inline void netif_wake_queue(struct net_device *dev)
984{ 1078{
985#ifdef CONFIG_NETPOLL_TRAP 1079 netif_tx_wake_queue(netdev_get_tx_queue(dev, 0));
986 if (netpoll_trap()) { 1080}
987 clear_bit(__LINK_STATE_XOFF, &dev->state); 1081
988 return; 1082static inline void netif_tx_wake_all_queues(struct net_device *dev)
1083{
1084 unsigned int i;
1085
1086 for (i = 0; i < dev->num_tx_queues; i++) {
1087 struct netdev_queue *txq = netdev_get_tx_queue(dev, i);
1088 netif_tx_wake_queue(txq);
989 } 1089 }
990#endif 1090}
991 if (test_and_clear_bit(__LINK_STATE_XOFF, &dev->state)) 1091
992 __netif_schedule(dev); 1092static inline void netif_tx_stop_queue(struct netdev_queue *dev_queue)
1093{
1094 set_bit(__QUEUE_STATE_XOFF, &dev_queue->state);
993} 1095}
994 1096
995/** 1097/**
@@ -1001,7 +1103,22 @@ static inline void netif_wake_queue(struct net_device *dev)
1001 */ 1103 */
1002static inline void netif_stop_queue(struct net_device *dev) 1104static inline void netif_stop_queue(struct net_device *dev)
1003{ 1105{
1004 set_bit(__LINK_STATE_XOFF, &dev->state); 1106 netif_tx_stop_queue(netdev_get_tx_queue(dev, 0));
1107}
1108
1109static inline void netif_tx_stop_all_queues(struct net_device *dev)
1110{
1111 unsigned int i;
1112
1113 for (i = 0; i < dev->num_tx_queues; i++) {
1114 struct netdev_queue *txq = netdev_get_tx_queue(dev, i);
1115 netif_tx_stop_queue(txq);
1116 }
1117}
1118
1119static inline int netif_tx_queue_stopped(const struct netdev_queue *dev_queue)
1120{
1121 return test_bit(__QUEUE_STATE_XOFF, &dev_queue->state);
1005} 1122}
1006 1123
1007/** 1124/**
@@ -1012,7 +1129,12 @@ static inline void netif_stop_queue(struct net_device *dev)
1012 */ 1129 */
1013static inline int netif_queue_stopped(const struct net_device *dev) 1130static inline int netif_queue_stopped(const struct net_device *dev)
1014{ 1131{
1015 return test_bit(__LINK_STATE_XOFF, &dev->state); 1132 return netif_tx_queue_stopped(netdev_get_tx_queue(dev, 0));
1133}
1134
1135static inline int netif_tx_queue_frozen(const struct netdev_queue *dev_queue)
1136{
1137 return test_bit(__QUEUE_STATE_FROZEN, &dev_queue->state);
1016} 1138}
1017 1139
1018/** 1140/**
@@ -1042,9 +1164,8 @@ static inline int netif_running(const struct net_device *dev)
1042 */ 1164 */
1043static inline void netif_start_subqueue(struct net_device *dev, u16 queue_index) 1165static inline void netif_start_subqueue(struct net_device *dev, u16 queue_index)
1044{ 1166{
1045#ifdef CONFIG_NETDEVICES_MULTIQUEUE 1167 struct netdev_queue *txq = netdev_get_tx_queue(dev, queue_index);
1046 clear_bit(__LINK_STATE_XOFF, &dev->egress_subqueue[queue_index].state); 1168 clear_bit(__QUEUE_STATE_XOFF, &txq->state);
1047#endif
1048} 1169}
1049 1170
1050/** 1171/**
@@ -1056,13 +1177,12 @@ static inline void netif_start_subqueue(struct net_device *dev, u16 queue_index)
1056 */ 1177 */
1057static inline void netif_stop_subqueue(struct net_device *dev, u16 queue_index) 1178static inline void netif_stop_subqueue(struct net_device *dev, u16 queue_index)
1058{ 1179{
1059#ifdef CONFIG_NETDEVICES_MULTIQUEUE 1180 struct netdev_queue *txq = netdev_get_tx_queue(dev, queue_index);
1060#ifdef CONFIG_NETPOLL_TRAP 1181#ifdef CONFIG_NETPOLL_TRAP
1061 if (netpoll_trap()) 1182 if (netpoll_trap())
1062 return; 1183 return;
1063#endif 1184#endif
1064 set_bit(__LINK_STATE_XOFF, &dev->egress_subqueue[queue_index].state); 1185 set_bit(__QUEUE_STATE_XOFF, &txq->state);
1065#endif
1066} 1186}
1067 1187
1068/** 1188/**
@@ -1075,12 +1195,8 @@ static inline void netif_stop_subqueue(struct net_device *dev, u16 queue_index)
1075static inline int __netif_subqueue_stopped(const struct net_device *dev, 1195static inline int __netif_subqueue_stopped(const struct net_device *dev,
1076 u16 queue_index) 1196 u16 queue_index)
1077{ 1197{
1078#ifdef CONFIG_NETDEVICES_MULTIQUEUE 1198 struct netdev_queue *txq = netdev_get_tx_queue(dev, queue_index);
1079 return test_bit(__LINK_STATE_XOFF, 1199 return test_bit(__QUEUE_STATE_XOFF, &txq->state);
1080 &dev->egress_subqueue[queue_index].state);
1081#else
1082 return 0;
1083#endif
1084} 1200}
1085 1201
1086static inline int netif_subqueue_stopped(const struct net_device *dev, 1202static inline int netif_subqueue_stopped(const struct net_device *dev,
@@ -1098,15 +1214,13 @@ static inline int netif_subqueue_stopped(const struct net_device *dev,
1098 */ 1214 */
1099static inline void netif_wake_subqueue(struct net_device *dev, u16 queue_index) 1215static inline void netif_wake_subqueue(struct net_device *dev, u16 queue_index)
1100{ 1216{
1101#ifdef CONFIG_NETDEVICES_MULTIQUEUE 1217 struct netdev_queue *txq = netdev_get_tx_queue(dev, queue_index);
1102#ifdef CONFIG_NETPOLL_TRAP 1218#ifdef CONFIG_NETPOLL_TRAP
1103 if (netpoll_trap()) 1219 if (netpoll_trap())
1104 return; 1220 return;
1105#endif 1221#endif
1106 if (test_and_clear_bit(__LINK_STATE_XOFF, 1222 if (test_and_clear_bit(__QUEUE_STATE_XOFF, &txq->state))
1107 &dev->egress_subqueue[queue_index].state)) 1223 __netif_schedule(txq->qdisc);
1108 __netif_schedule(dev);
1109#endif
1110} 1224}
1111 1225
1112/** 1226/**
@@ -1114,15 +1228,10 @@ static inline void netif_wake_subqueue(struct net_device *dev, u16 queue_index)
1114 * @dev: network device 1228 * @dev: network device
1115 * 1229 *
1116 * Check if device has multiple transmit queues 1230 * Check if device has multiple transmit queues
1117 * Always falls if NETDEVICE_MULTIQUEUE is not configured
1118 */ 1231 */
1119static inline int netif_is_multiqueue(const struct net_device *dev) 1232static inline int netif_is_multiqueue(const struct net_device *dev)
1120{ 1233{
1121#ifdef CONFIG_NETDEVICES_MULTIQUEUE 1234 return (dev->num_tx_queues > 1);
1122 return (!!(NETIF_F_MULTI_QUEUE & dev->features));
1123#else
1124 return 0;
1125#endif
1126} 1235}
1127 1236
1128/* Use this variant when it is known for sure that it 1237/* Use this variant when it is known for sure that it
@@ -1142,19 +1251,22 @@ extern int netif_rx(struct sk_buff *skb);
1142extern int netif_rx_ni(struct sk_buff *skb); 1251extern int netif_rx_ni(struct sk_buff *skb);
1143#define HAVE_NETIF_RECEIVE_SKB 1 1252#define HAVE_NETIF_RECEIVE_SKB 1
1144extern int netif_receive_skb(struct sk_buff *skb); 1253extern int netif_receive_skb(struct sk_buff *skb);
1254extern void netif_nit_deliver(struct sk_buff *skb);
1145extern int dev_valid_name(const char *name); 1255extern int dev_valid_name(const char *name);
1146extern int dev_ioctl(struct net *net, unsigned int cmd, void __user *); 1256extern int dev_ioctl(struct net *net, unsigned int cmd, void __user *);
1147extern int dev_ethtool(struct net *net, struct ifreq *); 1257extern int dev_ethtool(struct net *net, struct ifreq *);
1148extern unsigned dev_get_flags(const struct net_device *); 1258extern unsigned dev_get_flags(const struct net_device *);
1149extern int dev_change_flags(struct net_device *, unsigned); 1259extern int dev_change_flags(struct net_device *, unsigned);
1150extern int dev_change_name(struct net_device *, char *); 1260extern int dev_change_name(struct net_device *, const char *);
1261extern int dev_set_alias(struct net_device *, const char *, size_t);
1151extern int dev_change_net_namespace(struct net_device *, 1262extern int dev_change_net_namespace(struct net_device *,
1152 struct net *, const char *); 1263 struct net *, const char *);
1153extern int dev_set_mtu(struct net_device *, int); 1264extern int dev_set_mtu(struct net_device *, int);
1154extern int dev_set_mac_address(struct net_device *, 1265extern int dev_set_mac_address(struct net_device *,
1155 struct sockaddr *); 1266 struct sockaddr *);
1156extern int dev_hard_start_xmit(struct sk_buff *skb, 1267extern int dev_hard_start_xmit(struct sk_buff *skb,
1157 struct net_device *dev); 1268 struct net_device *dev,
1269 struct netdev_queue *txq);
1158 1270
1159extern int netdev_budget; 1271extern int netdev_budget;
1160 1272
@@ -1390,6 +1502,38 @@ static inline void netif_rx_complete(struct net_device *dev,
1390 local_irq_restore(flags); 1502 local_irq_restore(flags);
1391} 1503}
1392 1504
1505static inline void __netif_tx_lock(struct netdev_queue *txq, int cpu)
1506{
1507 spin_lock(&txq->_xmit_lock);
1508 txq->xmit_lock_owner = cpu;
1509}
1510
1511static inline void __netif_tx_lock_bh(struct netdev_queue *txq)
1512{
1513 spin_lock_bh(&txq->_xmit_lock);
1514 txq->xmit_lock_owner = smp_processor_id();
1515}
1516
1517static inline int __netif_tx_trylock(struct netdev_queue *txq)
1518{
1519 int ok = spin_trylock(&txq->_xmit_lock);
1520 if (likely(ok))
1521 txq->xmit_lock_owner = smp_processor_id();
1522 return ok;
1523}
1524
1525static inline void __netif_tx_unlock(struct netdev_queue *txq)
1526{
1527 txq->xmit_lock_owner = -1;
1528 spin_unlock(&txq->_xmit_lock);
1529}
1530
1531static inline void __netif_tx_unlock_bh(struct netdev_queue *txq)
1532{
1533 txq->xmit_lock_owner = -1;
1534 spin_unlock_bh(&txq->_xmit_lock);
1535}
1536
1393/** 1537/**
1394 * netif_tx_lock - grab network device transmit lock 1538 * netif_tx_lock - grab network device transmit lock
1395 * @dev: network device 1539 * @dev: network device
@@ -1397,60 +1541,105 @@ static inline void netif_rx_complete(struct net_device *dev,
1397 * 1541 *
1398 * Get network device transmit lock 1542 * Get network device transmit lock
1399 */ 1543 */
1400static inline void __netif_tx_lock(struct net_device *dev, int cpu)
1401{
1402 spin_lock(&dev->_xmit_lock);
1403 dev->xmit_lock_owner = cpu;
1404}
1405
1406static inline void netif_tx_lock(struct net_device *dev) 1544static inline void netif_tx_lock(struct net_device *dev)
1407{ 1545{
1408 __netif_tx_lock(dev, smp_processor_id()); 1546 unsigned int i;
1547 int cpu;
1548
1549 spin_lock(&dev->tx_global_lock);
1550 cpu = smp_processor_id();
1551 for (i = 0; i < dev->num_tx_queues; i++) {
1552 struct netdev_queue *txq = netdev_get_tx_queue(dev, i);
1553
1554 /* We are the only thread of execution doing a
1555 * freeze, but we have to grab the _xmit_lock in
1556 * order to synchronize with threads which are in
1557 * the ->hard_start_xmit() handler and already
1558 * checked the frozen bit.
1559 */
1560 __netif_tx_lock(txq, cpu);
1561 set_bit(__QUEUE_STATE_FROZEN, &txq->state);
1562 __netif_tx_unlock(txq);
1563 }
1409} 1564}
1410 1565
1411static inline void netif_tx_lock_bh(struct net_device *dev) 1566static inline void netif_tx_lock_bh(struct net_device *dev)
1412{ 1567{
1413 spin_lock_bh(&dev->_xmit_lock); 1568 local_bh_disable();
1414 dev->xmit_lock_owner = smp_processor_id(); 1569 netif_tx_lock(dev);
1415}
1416
1417static inline int netif_tx_trylock(struct net_device *dev)
1418{
1419 int ok = spin_trylock(&dev->_xmit_lock);
1420 if (likely(ok))
1421 dev->xmit_lock_owner = smp_processor_id();
1422 return ok;
1423} 1570}
1424 1571
1425static inline void netif_tx_unlock(struct net_device *dev) 1572static inline void netif_tx_unlock(struct net_device *dev)
1426{ 1573{
1427 dev->xmit_lock_owner = -1; 1574 unsigned int i;
1428 spin_unlock(&dev->_xmit_lock); 1575
1576 for (i = 0; i < dev->num_tx_queues; i++) {
1577 struct netdev_queue *txq = netdev_get_tx_queue(dev, i);
1578
1579 /* No need to grab the _xmit_lock here. If the
1580 * queue is not stopped for another reason, we
1581 * force a schedule.
1582 */
1583 clear_bit(__QUEUE_STATE_FROZEN, &txq->state);
1584 if (!test_bit(__QUEUE_STATE_XOFF, &txq->state))
1585 __netif_schedule(txq->qdisc);
1586 }
1587 spin_unlock(&dev->tx_global_lock);
1429} 1588}
1430 1589
1431static inline void netif_tx_unlock_bh(struct net_device *dev) 1590static inline void netif_tx_unlock_bh(struct net_device *dev)
1432{ 1591{
1433 dev->xmit_lock_owner = -1; 1592 netif_tx_unlock(dev);
1434 spin_unlock_bh(&dev->_xmit_lock); 1593 local_bh_enable();
1435} 1594}
1436 1595
1437#define HARD_TX_LOCK(dev, cpu) { \ 1596#define HARD_TX_LOCK(dev, txq, cpu) { \
1438 if ((dev->features & NETIF_F_LLTX) == 0) { \ 1597 if ((dev->features & NETIF_F_LLTX) == 0) { \
1439 __netif_tx_lock(dev, cpu); \ 1598 __netif_tx_lock(txq, cpu); \
1440 } \ 1599 } \
1441} 1600}
1442 1601
1443#define HARD_TX_UNLOCK(dev) { \ 1602#define HARD_TX_UNLOCK(dev, txq) { \
1444 if ((dev->features & NETIF_F_LLTX) == 0) { \ 1603 if ((dev->features & NETIF_F_LLTX) == 0) { \
1445 netif_tx_unlock(dev); \ 1604 __netif_tx_unlock(txq); \
1446 } \ 1605 } \
1447} 1606}
1448 1607
1449static inline void netif_tx_disable(struct net_device *dev) 1608static inline void netif_tx_disable(struct net_device *dev)
1450{ 1609{
1451 netif_tx_lock_bh(dev); 1610 unsigned int i;
1452 netif_stop_queue(dev); 1611 int cpu;
1453 netif_tx_unlock_bh(dev); 1612
1613 local_bh_disable();
1614 cpu = smp_processor_id();
1615 for (i = 0; i < dev->num_tx_queues; i++) {
1616 struct netdev_queue *txq = netdev_get_tx_queue(dev, i);
1617
1618 __netif_tx_lock(txq, cpu);
1619 netif_tx_stop_queue(txq);
1620 __netif_tx_unlock(txq);
1621 }
1622 local_bh_enable();
1623}
1624
1625static inline void netif_addr_lock(struct net_device *dev)
1626{
1627 spin_lock(&dev->addr_list_lock);
1628}
1629
1630static inline void netif_addr_lock_bh(struct net_device *dev)
1631{
1632 spin_lock_bh(&dev->addr_list_lock);
1633}
1634
1635static inline void netif_addr_unlock(struct net_device *dev)
1636{
1637 spin_unlock(&dev->addr_list_lock);
1638}
1639
1640static inline void netif_addr_unlock_bh(struct net_device *dev)
1641{
1642 spin_unlock_bh(&dev->addr_list_lock);
1454} 1643}
1455 1644
1456/* These functions live elsewhere (drivers/net/net_init.c, but related) */ 1645/* These functions live elsewhere (drivers/net/net_init.c, but related) */
@@ -1480,9 +1669,10 @@ extern int __dev_addr_delete(struct dev_addr_list **list, int *count, void *ad
1480extern int __dev_addr_add(struct dev_addr_list **list, int *count, void *addr, int alen, int newonly); 1669extern int __dev_addr_add(struct dev_addr_list **list, int *count, void *addr, int alen, int newonly);
1481extern int __dev_addr_sync(struct dev_addr_list **to, int *to_count, struct dev_addr_list **from, int *from_count); 1670extern int __dev_addr_sync(struct dev_addr_list **to, int *to_count, struct dev_addr_list **from, int *from_count);
1482extern void __dev_addr_unsync(struct dev_addr_list **to, int *to_count, struct dev_addr_list **from, int *from_count); 1671extern void __dev_addr_unsync(struct dev_addr_list **to, int *to_count, struct dev_addr_list **from, int *from_count);
1483extern void dev_set_promiscuity(struct net_device *dev, int inc); 1672extern int dev_set_promiscuity(struct net_device *dev, int inc);
1484extern void dev_set_allmulti(struct net_device *dev, int inc); 1673extern int dev_set_allmulti(struct net_device *dev, int inc);
1485extern void netdev_state_change(struct net_device *dev); 1674extern void netdev_state_change(struct net_device *dev);
1675extern void netdev_bonding_change(struct net_device *dev);
1486extern void netdev_features_change(struct net_device *dev); 1676extern void netdev_features_change(struct net_device *dev);
1487/* Load a device via the kmod */ 1677/* Load a device via the kmod */
1488extern void dev_load(struct net *net, const char *name); 1678extern void dev_load(struct net *net, const char *name);
@@ -1509,9 +1699,16 @@ extern void *dev_seq_next(struct seq_file *seq, void *v, loff_t *pos);
1509extern void dev_seq_stop(struct seq_file *seq, void *v); 1699extern void dev_seq_stop(struct seq_file *seq, void *v);
1510#endif 1700#endif
1511 1701
1702extern int netdev_class_create_file(struct class_attribute *class_attr);
1703extern void netdev_class_remove_file(struct class_attribute *class_attr);
1704
1705extern char *netdev_drivername(const struct net_device *dev, char *buffer, int len);
1706
1512extern void linkwatch_run_queue(void); 1707extern void linkwatch_run_queue(void);
1513 1708
1514extern int netdev_compute_features(unsigned long all, unsigned long one); 1709unsigned long netdev_increment_features(unsigned long all, unsigned long one,
1710 unsigned long mask);
1711unsigned long netdev_fix_features(unsigned long features, const char *name);
1515 1712
1516static inline int net_gso_ok(int features, int gso_type) 1713static inline int net_gso_ok(int features, int gso_type)
1517{ 1714{
diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
index 0c5eb7ed8b3f..48cfe51bfddc 100644
--- a/include/linux/netfilter.h
+++ b/include/linux/netfilter.h
@@ -5,13 +5,11 @@
5#include <linux/init.h> 5#include <linux/init.h>
6#include <linux/skbuff.h> 6#include <linux/skbuff.h>
7#include <linux/net.h> 7#include <linux/net.h>
8#include <linux/netdevice.h>
9#include <linux/if.h> 8#include <linux/if.h>
10#include <linux/in.h> 9#include <linux/in.h>
11#include <linux/in6.h> 10#include <linux/in6.h>
12#include <linux/wait.h> 11#include <linux/wait.h>
13#include <linux/list.h> 12#include <linux/list.h>
14#include <net/net_namespace.h>
15#endif 13#endif
16#include <linux/types.h> 14#include <linux/types.h>
17#include <linux/compiler.h> 15#include <linux/compiler.h>
@@ -52,6 +50,16 @@ enum nf_inet_hooks {
52 NF_INET_NUMHOOKS 50 NF_INET_NUMHOOKS
53}; 51};
54 52
53enum {
54 NFPROTO_UNSPEC = 0,
55 NFPROTO_IPV4 = 2,
56 NFPROTO_ARP = 3,
57 NFPROTO_BRIDGE = 7,
58 NFPROTO_IPV6 = 10,
59 NFPROTO_DECNET = 12,
60 NFPROTO_NUMPROTO,
61};
62
55union nf_inet_addr { 63union nf_inet_addr {
56 __u32 all[4]; 64 __u32 all[4];
57 __be32 ip; 65 __be32 ip;
@@ -92,8 +100,8 @@ struct nf_hook_ops
92 /* User fills in from here down. */ 100 /* User fills in from here down. */
93 nf_hookfn *hook; 101 nf_hookfn *hook;
94 struct module *owner; 102 struct module *owner;
95 int pf; 103 u_int8_t pf;
96 int hooknum; 104 unsigned int hooknum;
97 /* Hooks are ordered in ascending priority. */ 105 /* Hooks are ordered in ascending priority. */
98 int priority; 106 int priority;
99}; 107};
@@ -102,7 +110,7 @@ struct nf_sockopt_ops
102{ 110{
103 struct list_head list; 111 struct list_head list;
104 112
105 int pf; 113 u_int8_t pf;
106 114
107 /* Non-inclusive ranges: use 0/0/NULL to never get called. */ 115 /* Non-inclusive ranges: use 0/0/NULL to never get called. */
108 int set_optmin; 116 int set_optmin;
@@ -138,9 +146,9 @@ extern struct ctl_path nf_net_netfilter_sysctl_path[];
138extern struct ctl_path nf_net_ipv4_netfilter_sysctl_path[]; 146extern struct ctl_path nf_net_ipv4_netfilter_sysctl_path[];
139#endif /* CONFIG_SYSCTL */ 147#endif /* CONFIG_SYSCTL */
140 148
141extern struct list_head nf_hooks[NPROTO][NF_MAX_HOOKS]; 149extern struct list_head nf_hooks[NFPROTO_NUMPROTO][NF_MAX_HOOKS];
142 150
143int nf_hook_slow(int pf, unsigned int hook, struct sk_buff *skb, 151int nf_hook_slow(u_int8_t pf, unsigned int hook, struct sk_buff *skb,
144 struct net_device *indev, struct net_device *outdev, 152 struct net_device *indev, struct net_device *outdev,
145 int (*okfn)(struct sk_buff *), int thresh); 153 int (*okfn)(struct sk_buff *), int thresh);
146 154
@@ -151,7 +159,7 @@ int nf_hook_slow(int pf, unsigned int hook, struct sk_buff *skb,
151 * okfn must be invoked by the caller in this case. Any other return 159 * okfn must be invoked by the caller in this case. Any other return
152 * value indicates the packet has been consumed by the hook. 160 * value indicates the packet has been consumed by the hook.
153 */ 161 */
154static inline int nf_hook_thresh(int pf, unsigned int hook, 162static inline int nf_hook_thresh(u_int8_t pf, unsigned int hook,
155 struct sk_buff *skb, 163 struct sk_buff *skb,
156 struct net_device *indev, 164 struct net_device *indev,
157 struct net_device *outdev, 165 struct net_device *outdev,
@@ -167,7 +175,7 @@ static inline int nf_hook_thresh(int pf, unsigned int hook,
167 return nf_hook_slow(pf, hook, skb, indev, outdev, okfn, thresh); 175 return nf_hook_slow(pf, hook, skb, indev, outdev, okfn, thresh);
168} 176}
169 177
170static inline int nf_hook(int pf, unsigned int hook, struct sk_buff *skb, 178static inline int nf_hook(u_int8_t pf, unsigned int hook, struct sk_buff *skb,
171 struct net_device *indev, struct net_device *outdev, 179 struct net_device *indev, struct net_device *outdev,
172 int (*okfn)(struct sk_buff *)) 180 int (*okfn)(struct sk_buff *))
173{ 181{
@@ -212,14 +220,14 @@ __ret;})
212 NF_HOOK_THRESH(pf, hook, skb, indev, outdev, okfn, INT_MIN) 220 NF_HOOK_THRESH(pf, hook, skb, indev, outdev, okfn, INT_MIN)
213 221
214/* Call setsockopt() */ 222/* Call setsockopt() */
215int nf_setsockopt(struct sock *sk, int pf, int optval, char __user *opt, 223int nf_setsockopt(struct sock *sk, u_int8_t pf, int optval, char __user *opt,
216 int len); 224 int len);
217int nf_getsockopt(struct sock *sk, int pf, int optval, char __user *opt, 225int nf_getsockopt(struct sock *sk, u_int8_t pf, int optval, char __user *opt,
218 int *len); 226 int *len);
219 227
220int compat_nf_setsockopt(struct sock *sk, int pf, int optval, 228int compat_nf_setsockopt(struct sock *sk, u_int8_t pf, int optval,
221 char __user *opt, int len); 229 char __user *opt, int len);
222int compat_nf_getsockopt(struct sock *sk, int pf, int optval, 230int compat_nf_getsockopt(struct sock *sk, u_int8_t pf, int optval,
223 char __user *opt, int *len); 231 char __user *opt, int *len);
224 232
225/* Call this before modifying an existing packet: ensures it is 233/* Call this before modifying an existing packet: ensures it is
@@ -247,7 +255,7 @@ struct nf_afinfo {
247 int route_key_size; 255 int route_key_size;
248}; 256};
249 257
250extern const struct nf_afinfo *nf_afinfo[NPROTO]; 258extern const struct nf_afinfo *nf_afinfo[NFPROTO_NUMPROTO];
251static inline const struct nf_afinfo *nf_get_afinfo(unsigned short family) 259static inline const struct nf_afinfo *nf_get_afinfo(unsigned short family)
252{ 260{
253 return rcu_dereference(nf_afinfo[family]); 261 return rcu_dereference(nf_afinfo[family]);
@@ -292,7 +300,7 @@ extern void nf_unregister_afinfo(const struct nf_afinfo *afinfo);
292extern void (*ip_nat_decode_session)(struct sk_buff *, struct flowi *); 300extern void (*ip_nat_decode_session)(struct sk_buff *, struct flowi *);
293 301
294static inline void 302static inline void
295nf_nat_decode_session(struct sk_buff *skb, struct flowi *fl, int family) 303nf_nat_decode_session(struct sk_buff *skb, struct flowi *fl, u_int8_t family)
296{ 304{
297#ifdef CONFIG_NF_NAT_NEEDED 305#ifdef CONFIG_NF_NAT_NEEDED
298 void (*decodefn)(struct sk_buff *, struct flowi *); 306 void (*decodefn)(struct sk_buff *, struct flowi *);
@@ -315,7 +323,7 @@ extern struct proc_dir_entry *proc_net_netfilter;
315#else /* !CONFIG_NETFILTER */ 323#else /* !CONFIG_NETFILTER */
316#define NF_HOOK(pf, hook, skb, indev, outdev, okfn) (okfn)(skb) 324#define NF_HOOK(pf, hook, skb, indev, outdev, okfn) (okfn)(skb)
317#define NF_HOOK_COND(pf, hook, skb, indev, outdev, okfn, cond) (okfn)(skb) 325#define NF_HOOK_COND(pf, hook, skb, indev, outdev, okfn, cond) (okfn)(skb)
318static inline int nf_hook_thresh(int pf, unsigned int hook, 326static inline int nf_hook_thresh(u_int8_t pf, unsigned int hook,
319 struct sk_buff *skb, 327 struct sk_buff *skb,
320 struct net_device *indev, 328 struct net_device *indev,
321 struct net_device *outdev, 329 struct net_device *outdev,
@@ -324,7 +332,7 @@ static inline int nf_hook_thresh(int pf, unsigned int hook,
324{ 332{
325 return okfn(skb); 333 return okfn(skb);
326} 334}
327static inline int nf_hook(int pf, unsigned int hook, struct sk_buff *skb, 335static inline int nf_hook(u_int8_t pf, unsigned int hook, struct sk_buff *skb,
328 struct net_device *indev, struct net_device *outdev, 336 struct net_device *indev, struct net_device *outdev,
329 int (*okfn)(struct sk_buff *)) 337 int (*okfn)(struct sk_buff *))
330{ 338{
@@ -332,7 +340,9 @@ static inline int nf_hook(int pf, unsigned int hook, struct sk_buff *skb,
332} 340}
333struct flowi; 341struct flowi;
334static inline void 342static inline void
335nf_nat_decode_session(struct sk_buff *skb, struct flowi *fl, int family) {} 343nf_nat_decode_session(struct sk_buff *skb, struct flowi *fl, u_int8_t family)
344{
345}
336#endif /*CONFIG_NETFILTER*/ 346#endif /*CONFIG_NETFILTER*/
337 347
338#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) 348#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
@@ -343,56 +353,5 @@ extern void (*nf_ct_destroy)(struct nf_conntrack *);
343static inline void nf_ct_attach(struct sk_buff *new, struct sk_buff *skb) {} 353static inline void nf_ct_attach(struct sk_buff *new, struct sk_buff *skb) {}
344#endif 354#endif
345 355
346static inline struct net *nf_pre_routing_net(const struct net_device *in,
347 const struct net_device *out)
348{
349#ifdef CONFIG_NET_NS
350 return in->nd_net;
351#else
352 return &init_net;
353#endif
354}
355
356static inline struct net *nf_local_in_net(const struct net_device *in,
357 const struct net_device *out)
358{
359#ifdef CONFIG_NET_NS
360 return in->nd_net;
361#else
362 return &init_net;
363#endif
364}
365
366static inline struct net *nf_forward_net(const struct net_device *in,
367 const struct net_device *out)
368{
369#ifdef CONFIG_NET_NS
370 BUG_ON(in->nd_net != out->nd_net);
371 return in->nd_net;
372#else
373 return &init_net;
374#endif
375}
376
377static inline struct net *nf_local_out_net(const struct net_device *in,
378 const struct net_device *out)
379{
380#ifdef CONFIG_NET_NS
381 return out->nd_net;
382#else
383 return &init_net;
384#endif
385}
386
387static inline struct net *nf_post_routing_net(const struct net_device *in,
388 const struct net_device *out)
389{
390#ifdef CONFIG_NET_NS
391 return out->nd_net;
392#else
393 return &init_net;
394#endif
395}
396
397#endif /*__KERNEL__*/ 356#endif /*__KERNEL__*/
398#endif /*__LINUX_NETFILTER_H*/ 357#endif /*__LINUX_NETFILTER_H*/
diff --git a/include/linux/netfilter/Kbuild b/include/linux/netfilter/Kbuild
index 3aff513d12c8..5a8af875bce2 100644
--- a/include/linux/netfilter/Kbuild
+++ b/include/linux/netfilter/Kbuild
@@ -32,6 +32,7 @@ header-y += xt_owner.h
32header-y += xt_pkttype.h 32header-y += xt_pkttype.h
33header-y += xt_rateest.h 33header-y += xt_rateest.h
34header-y += xt_realm.h 34header-y += xt_realm.h
35header-y += xt_recent.h
35header-y += xt_sctp.h 36header-y += xt_sctp.h
36header-y += xt_state.h 37header-y += xt_state.h
37header-y += xt_statistic.h 38header-y += xt_statistic.h
diff --git a/include/linux/netfilter/nf_conntrack_common.h b/include/linux/netfilter/nf_conntrack_common.h
index bad1eb760f61..885cbe282260 100644
--- a/include/linux/netfilter/nf_conntrack_common.h
+++ b/include/linux/netfilter/nf_conntrack_common.h
@@ -122,7 +122,7 @@ enum ip_conntrack_events
122 IPCT_NATINFO_BIT = 10, 122 IPCT_NATINFO_BIT = 10,
123 IPCT_NATINFO = (1 << IPCT_NATINFO_BIT), 123 IPCT_NATINFO = (1 << IPCT_NATINFO_BIT),
124 124
125 /* Counter highest bit has been set */ 125 /* Counter highest bit has been set, unused */
126 IPCT_COUNTER_FILLING_BIT = 11, 126 IPCT_COUNTER_FILLING_BIT = 11,
127 IPCT_COUNTER_FILLING = (1 << IPCT_COUNTER_FILLING_BIT), 127 IPCT_COUNTER_FILLING = (1 << IPCT_COUNTER_FILLING_BIT),
128 128
@@ -145,12 +145,6 @@ enum ip_conntrack_expect_events {
145}; 145};
146 146
147#ifdef __KERNEL__ 147#ifdef __KERNEL__
148struct ip_conntrack_counter
149{
150 u_int32_t packets;
151 u_int32_t bytes;
152};
153
154struct ip_conntrack_stat 148struct ip_conntrack_stat
155{ 149{
156 unsigned int searched; 150 unsigned int searched;
diff --git a/include/linux/netfilter/nf_conntrack_proto_gre.h b/include/linux/netfilter/nf_conntrack_proto_gre.h
index 535e4219d2bb..2a10efda17fb 100644
--- a/include/linux/netfilter/nf_conntrack_proto_gre.h
+++ b/include/linux/netfilter/nf_conntrack_proto_gre.h
@@ -87,7 +87,7 @@ int nf_ct_gre_keymap_add(struct nf_conn *ct, enum ip_conntrack_dir dir,
87/* delete keymap entries */ 87/* delete keymap entries */
88void nf_ct_gre_keymap_destroy(struct nf_conn *ct); 88void nf_ct_gre_keymap_destroy(struct nf_conn *ct);
89 89
90extern void nf_ct_gre_keymap_flush(void); 90extern void nf_ct_gre_keymap_flush(struct net *net);
91extern void nf_nat_need_gre(void); 91extern void nf_nat_need_gre(void);
92 92
93#endif /* __KERNEL__ */ 93#endif /* __KERNEL__ */
diff --git a/include/linux/netfilter/nf_conntrack_tcp.h b/include/linux/netfilter/nf_conntrack_tcp.h
index 22ce29995f13..a049df4f2236 100644
--- a/include/linux/netfilter/nf_conntrack_tcp.h
+++ b/include/linux/netfilter/nf_conntrack_tcp.h
@@ -30,6 +30,9 @@ enum tcp_conntrack {
30/* Be liberal in window checking */ 30/* Be liberal in window checking */
31#define IP_CT_TCP_FLAG_BE_LIBERAL 0x08 31#define IP_CT_TCP_FLAG_BE_LIBERAL 0x08
32 32
33/* Has unacknowledged data */
34#define IP_CT_TCP_FLAG_DATA_UNACKNOWLEDGED 0x10
35
33struct nf_ct_tcp_flags { 36struct nf_ct_tcp_flags {
34 u_int8_t flags; 37 u_int8_t flags;
35 u_int8_t mask; 38 u_int8_t mask;
diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
index 0d8424f76899..7d8e0455ccac 100644
--- a/include/linux/netfilter/nfnetlink.h
+++ b/include/linux/netfilter/nfnetlink.h
@@ -78,6 +78,9 @@ extern int nfnetlink_send(struct sk_buff *skb, u32 pid, unsigned group,
78 int echo); 78 int echo);
79extern int nfnetlink_unicast(struct sk_buff *skb, u_int32_t pid, int flags); 79extern int nfnetlink_unicast(struct sk_buff *skb, u_int32_t pid, int flags);
80 80
81extern void nfnl_lock(void);
82extern void nfnl_unlock(void);
83
81#define MODULE_ALIAS_NFNL_SUBSYS(subsys) \ 84#define MODULE_ALIAS_NFNL_SUBSYS(subsys) \
82 MODULE_ALIAS("nfnetlink-subsys-" __stringify(subsys)) 85 MODULE_ALIAS("nfnetlink-subsys-" __stringify(subsys))
83 86
diff --git a/include/linux/netfilter/nfnetlink_conntrack.h b/include/linux/netfilter/nfnetlink_conntrack.h
index 0a383ac083cb..c19595c89304 100644
--- a/include/linux/netfilter/nfnetlink_conntrack.h
+++ b/include/linux/netfilter/nfnetlink_conntrack.h
@@ -81,6 +81,7 @@ enum ctattr_protoinfo {
81 CTA_PROTOINFO_UNSPEC, 81 CTA_PROTOINFO_UNSPEC,
82 CTA_PROTOINFO_TCP, 82 CTA_PROTOINFO_TCP,
83 CTA_PROTOINFO_DCCP, 83 CTA_PROTOINFO_DCCP,
84 CTA_PROTOINFO_SCTP,
84 __CTA_PROTOINFO_MAX 85 __CTA_PROTOINFO_MAX
85}; 86};
86#define CTA_PROTOINFO_MAX (__CTA_PROTOINFO_MAX - 1) 87#define CTA_PROTOINFO_MAX (__CTA_PROTOINFO_MAX - 1)
@@ -103,12 +104,21 @@ enum ctattr_protoinfo_dccp {
103}; 104};
104#define CTA_PROTOINFO_DCCP_MAX (__CTA_PROTOINFO_DCCP_MAX - 1) 105#define CTA_PROTOINFO_DCCP_MAX (__CTA_PROTOINFO_DCCP_MAX - 1)
105 106
107enum ctattr_protoinfo_sctp {
108 CTA_PROTOINFO_SCTP_UNSPEC,
109 CTA_PROTOINFO_SCTP_STATE,
110 CTA_PROTOINFO_SCTP_VTAG_ORIGINAL,
111 CTA_PROTOINFO_SCTP_VTAG_REPLY,
112 __CTA_PROTOINFO_SCTP_MAX
113};
114#define CTA_PROTOINFO_SCTP_MAX (__CTA_PROTOINFO_SCTP_MAX - 1)
115
106enum ctattr_counters { 116enum ctattr_counters {
107 CTA_COUNTERS_UNSPEC, 117 CTA_COUNTERS_UNSPEC,
108 CTA_COUNTERS_PACKETS, /* old 64bit counters */ 118 CTA_COUNTERS_PACKETS, /* 64bit counters */
109 CTA_COUNTERS_BYTES, /* old 64bit counters */ 119 CTA_COUNTERS_BYTES, /* 64bit counters */
110 CTA_COUNTERS32_PACKETS, 120 CTA_COUNTERS32_PACKETS, /* old 32bit counters, unused */
111 CTA_COUNTERS32_BYTES, 121 CTA_COUNTERS32_BYTES, /* old 32bit counters, unused */
112 __CTA_COUNTERS_MAX 122 __CTA_COUNTERS_MAX
113}; 123};
114#define CTA_COUNTERS_MAX (__CTA_COUNTERS_MAX - 1) 124#define CTA_COUNTERS_MAX (__CTA_COUNTERS_MAX - 1)
diff --git a/include/linux/netfilter/nfnetlink_log.h b/include/linux/netfilter/nfnetlink_log.h
index a85721332924..f661731f3cb1 100644
--- a/include/linux/netfilter/nfnetlink_log.h
+++ b/include/linux/netfilter/nfnetlink_log.h
@@ -48,6 +48,9 @@ enum nfulnl_attr_type {
48 NFULA_SEQ, /* instance-local sequence number */ 48 NFULA_SEQ, /* instance-local sequence number */
49 NFULA_SEQ_GLOBAL, /* global sequence number */ 49 NFULA_SEQ_GLOBAL, /* global sequence number */
50 NFULA_GID, /* group id of socket */ 50 NFULA_GID, /* group id of socket */
51 NFULA_HWTYPE, /* hardware type */
52 NFULA_HWHEADER, /* hardware header */
53 NFULA_HWLEN, /* hardware header length */
51 54
52 __NFULA_MAX 55 __NFULA_MAX
53}; 56};
diff --git a/include/linux/netfilter/x_tables.h b/include/linux/netfilter/x_tables.h
index 2326296b6f25..be41b609c88f 100644
--- a/include/linux/netfilter/x_tables.h
+++ b/include/linux/netfilter/x_tables.h
@@ -173,6 +173,98 @@ struct xt_counters_info
173 173
174#include <linux/netdevice.h> 174#include <linux/netdevice.h>
175 175
176/**
177 * struct xt_match_param - parameters for match extensions' match functions
178 *
179 * @in: input netdevice
180 * @out: output netdevice
181 * @match: struct xt_match through which this function was invoked
182 * @matchinfo: per-match data
183 * @fragoff: packet is a fragment, this is the data offset
184 * @thoff: position of transport header relative to skb->data
185 * @hotdrop: drop packet if we had inspection problems
186 * @family: Actual NFPROTO_* through which the function is invoked
187 * (helpful when match->family == NFPROTO_UNSPEC)
188 */
189struct xt_match_param {
190 const struct net_device *in, *out;
191 const struct xt_match *match;
192 const void *matchinfo;
193 int fragoff;
194 unsigned int thoff;
195 bool *hotdrop;
196 u_int8_t family;
197};
198
199/**
200 * struct xt_mtchk_param - parameters for match extensions'
201 * checkentry functions
202 *
203 * @table: table the rule is tried to be inserted into
204 * @entryinfo: the family-specific rule data
205 * (struct ipt_ip, ip6t_ip, ebt_entry)
206 * @match: struct xt_match through which this function was invoked
207 * @matchinfo: per-match data
208 * @hook_mask: via which hooks the new rule is reachable
209 */
210struct xt_mtchk_param {
211 const char *table;
212 const void *entryinfo;
213 const struct xt_match *match;
214 void *matchinfo;
215 unsigned int hook_mask;
216 u_int8_t family;
217};
218
219/* Match destructor parameters */
220struct xt_mtdtor_param {
221 const struct xt_match *match;
222 void *matchinfo;
223 u_int8_t family;
224};
225
226/**
227 * struct xt_target_param - parameters for target extensions' target functions
228 *
229 * @hooknum: hook through which this target was invoked
230 * @target: struct xt_target through which this function was invoked
231 * @targinfo: per-target data
232 *
233 * Other fields see above.
234 */
235struct xt_target_param {
236 const struct net_device *in, *out;
237 unsigned int hooknum;
238 const struct xt_target *target;
239 const void *targinfo;
240 u_int8_t family;
241};
242
243/**
244 * struct xt_tgchk_param - parameters for target extensions'
245 * checkentry functions
246 *
247 * @entryinfo: the family-specific rule data
248 * (struct ipt_entry, ip6t_entry, arpt_entry, ebt_entry)
249 *
250 * Other fields see above.
251 */
252struct xt_tgchk_param {
253 const char *table;
254 void *entryinfo;
255 const struct xt_target *target;
256 void *targinfo;
257 unsigned int hook_mask;
258 u_int8_t family;
259};
260
261/* Target destructor parameters */
262struct xt_tgdtor_param {
263 const struct xt_target *target;
264 void *targinfo;
265 u_int8_t family;
266};
267
176struct xt_match 268struct xt_match
177{ 269{
178 struct list_head list; 270 struct list_head list;
@@ -185,24 +277,13 @@ struct xt_match
185 non-linear skb, using skb_header_pointer and 277 non-linear skb, using skb_header_pointer and
186 skb_ip_make_writable. */ 278 skb_ip_make_writable. */
187 bool (*match)(const struct sk_buff *skb, 279 bool (*match)(const struct sk_buff *skb,
188 const struct net_device *in, 280 const struct xt_match_param *);
189 const struct net_device *out,
190 const struct xt_match *match,
191 const void *matchinfo,
192 int offset,
193 unsigned int protoff,
194 bool *hotdrop);
195 281
196 /* Called when user tries to insert an entry of this type. */ 282 /* Called when user tries to insert an entry of this type. */
197 /* Should return true or false. */ 283 bool (*checkentry)(const struct xt_mtchk_param *);
198 bool (*checkentry)(const char *tablename,
199 const void *ip,
200 const struct xt_match *match,
201 void *matchinfo,
202 unsigned int hook_mask);
203 284
204 /* Called when entry of this type deleted. */ 285 /* Called when entry of this type deleted. */
205 void (*destroy)(const struct xt_match *match, void *matchinfo); 286 void (*destroy)(const struct xt_mtdtor_param *);
206 287
207 /* Called when userspace align differs from kernel space one */ 288 /* Called when userspace align differs from kernel space one */
208 void (*compat_from_user)(void *dst, void *src); 289 void (*compat_from_user)(void *dst, void *src);
@@ -235,24 +316,16 @@ struct xt_target
235 must now handle non-linear skbs, using skb_copy_bits and 316 must now handle non-linear skbs, using skb_copy_bits and
236 skb_ip_make_writable. */ 317 skb_ip_make_writable. */
237 unsigned int (*target)(struct sk_buff *skb, 318 unsigned int (*target)(struct sk_buff *skb,
238 const struct net_device *in, 319 const struct xt_target_param *);
239 const struct net_device *out,
240 unsigned int hooknum,
241 const struct xt_target *target,
242 const void *targinfo);
243 320
244 /* Called when user tries to insert an entry of this type: 321 /* Called when user tries to insert an entry of this type:
245 hook_mask is a bitmask of hooks from which it can be 322 hook_mask is a bitmask of hooks from which it can be
246 called. */ 323 called. */
247 /* Should return true or false. */ 324 /* Should return true or false. */
248 bool (*checkentry)(const char *tablename, 325 bool (*checkentry)(const struct xt_tgchk_param *);
249 const void *entry,
250 const struct xt_target *target,
251 void *targinfo,
252 unsigned int hook_mask);
253 326
254 /* Called when entry of this type deleted. */ 327 /* Called when entry of this type deleted. */
255 void (*destroy)(const struct xt_target *target, void *targinfo); 328 void (*destroy)(const struct xt_tgdtor_param *);
256 329
257 /* Called when userspace align differs from kernel space one */ 330 /* Called when userspace align differs from kernel space one */
258 void (*compat_from_user)(void *dst, void *src); 331 void (*compat_from_user)(void *dst, void *src);
@@ -292,7 +365,7 @@ struct xt_table
292 /* Set this to THIS_MODULE if you are a module, otherwise NULL */ 365 /* Set this to THIS_MODULE if you are a module, otherwise NULL */
293 struct module *me; 366 struct module *me;
294 367
295 int af; /* address/protocol family */ 368 u_int8_t af; /* address/protocol family */
296}; 369};
297 370
298#include <linux/netfilter_ipv4.h> 371#include <linux/netfilter_ipv4.h>
@@ -328,12 +401,10 @@ extern void xt_unregister_match(struct xt_match *target);
328extern int xt_register_matches(struct xt_match *match, unsigned int n); 401extern int xt_register_matches(struct xt_match *match, unsigned int n);
329extern void xt_unregister_matches(struct xt_match *match, unsigned int n); 402extern void xt_unregister_matches(struct xt_match *match, unsigned int n);
330 403
331extern int xt_check_match(const struct xt_match *match, unsigned short family, 404extern int xt_check_match(struct xt_mtchk_param *,
332 unsigned int size, const char *table, unsigned int hook, 405 unsigned int size, u_int8_t proto, bool inv_proto);
333 unsigned short proto, int inv_proto); 406extern int xt_check_target(struct xt_tgchk_param *,
334extern int xt_check_target(const struct xt_target *target, unsigned short family, 407 unsigned int size, u_int8_t proto, bool inv_proto);
335 unsigned int size, const char *table, unsigned int hook,
336 unsigned short proto, int inv_proto);
337 408
338extern struct xt_table *xt_register_table(struct net *net, 409extern struct xt_table *xt_register_table(struct net *net,
339 struct xt_table *table, 410 struct xt_table *table,
@@ -346,19 +417,19 @@ extern struct xt_table_info *xt_replace_table(struct xt_table *table,
346 struct xt_table_info *newinfo, 417 struct xt_table_info *newinfo,
347 int *error); 418 int *error);
348 419
349extern struct xt_match *xt_find_match(int af, const char *name, u8 revision); 420extern struct xt_match *xt_find_match(u8 af, const char *name, u8 revision);
350extern struct xt_target *xt_find_target(int af, const char *name, u8 revision); 421extern struct xt_target *xt_find_target(u8 af, const char *name, u8 revision);
351extern struct xt_target *xt_request_find_target(int af, const char *name, 422extern struct xt_target *xt_request_find_target(u8 af, const char *name,
352 u8 revision); 423 u8 revision);
353extern int xt_find_revision(int af, const char *name, u8 revision, int target, 424extern int xt_find_revision(u8 af, const char *name, u8 revision,
354 int *err); 425 int target, int *err);
355 426
356extern struct xt_table *xt_find_table_lock(struct net *net, int af, 427extern struct xt_table *xt_find_table_lock(struct net *net, u_int8_t af,
357 const char *name); 428 const char *name);
358extern void xt_table_unlock(struct xt_table *t); 429extern void xt_table_unlock(struct xt_table *t);
359 430
360extern int xt_proto_init(struct net *net, int af); 431extern int xt_proto_init(struct net *net, u_int8_t af);
361extern void xt_proto_fini(struct net *net, int af); 432extern void xt_proto_fini(struct net *net, u_int8_t af);
362 433
363extern struct xt_table_info *xt_alloc_table_info(unsigned int size); 434extern struct xt_table_info *xt_alloc_table_info(unsigned int size);
364extern void xt_free_table_info(struct xt_table_info *info); 435extern void xt_free_table_info(struct xt_table_info *info);
@@ -423,12 +494,12 @@ struct compat_xt_counters_info
423#define COMPAT_XT_ALIGN(s) (((s) + (__alignof__(struct compat_xt_counters)-1)) \ 494#define COMPAT_XT_ALIGN(s) (((s) + (__alignof__(struct compat_xt_counters)-1)) \
424 & ~(__alignof__(struct compat_xt_counters)-1)) 495 & ~(__alignof__(struct compat_xt_counters)-1))
425 496
426extern void xt_compat_lock(int af); 497extern void xt_compat_lock(u_int8_t af);
427extern void xt_compat_unlock(int af); 498extern void xt_compat_unlock(u_int8_t af);
428 499
429extern int xt_compat_add_offset(int af, unsigned int offset, short delta); 500extern int xt_compat_add_offset(u_int8_t af, unsigned int offset, short delta);
430extern void xt_compat_flush_offsets(int af); 501extern void xt_compat_flush_offsets(u_int8_t af);
431extern short xt_compat_calc_jump(int af, unsigned int offset); 502extern short xt_compat_calc_jump(u_int8_t af, unsigned int offset);
432 503
433extern int xt_compat_match_offset(const struct xt_match *match); 504extern int xt_compat_match_offset(const struct xt_match *match);
434extern int xt_compat_match_from_user(struct xt_entry_match *m, 505extern int xt_compat_match_from_user(struct xt_entry_match *m,
diff --git a/include/linux/netfilter/xt_TPROXY.h b/include/linux/netfilter/xt_TPROXY.h
new file mode 100644
index 000000000000..152e8f97132b
--- /dev/null
+++ b/include/linux/netfilter/xt_TPROXY.h
@@ -0,0 +1,14 @@
1#ifndef _XT_TPROXY_H_target
2#define _XT_TPROXY_H_target
3
4/* TPROXY target is capable of marking the packet to perform
5 * redirection. We can get rid of that whenever we get support for
6 * mutliple targets in the same rule. */
7struct xt_tproxy_target_info {
8 u_int32_t mark_mask;
9 u_int32_t mark_value;
10 __be32 laddr;
11 __be16 lport;
12};
13
14#endif /* _XT_TPROXY_H_target */
diff --git a/include/linux/netfilter/xt_recent.h b/include/linux/netfilter/xt_recent.h
new file mode 100644
index 000000000000..5cfeb81c6794
--- /dev/null
+++ b/include/linux/netfilter/xt_recent.h
@@ -0,0 +1,26 @@
1#ifndef _LINUX_NETFILTER_XT_RECENT_H
2#define _LINUX_NETFILTER_XT_RECENT_H 1
3
4enum {
5 XT_RECENT_CHECK = 1 << 0,
6 XT_RECENT_SET = 1 << 1,
7 XT_RECENT_UPDATE = 1 << 2,
8 XT_RECENT_REMOVE = 1 << 3,
9 XT_RECENT_TTL = 1 << 4,
10
11 XT_RECENT_SOURCE = 0,
12 XT_RECENT_DEST = 1,
13
14 XT_RECENT_NAME_LEN = 200,
15};
16
17struct xt_recent_mtinfo {
18 u_int32_t seconds;
19 u_int32_t hit_count;
20 u_int8_t check_set;
21 u_int8_t invert;
22 char name[XT_RECENT_NAME_LEN];
23 u_int8_t side;
24};
25
26#endif /* _LINUX_NETFILTER_XT_RECENT_H */
diff --git a/include/linux/netfilter/xt_string.h b/include/linux/netfilter/xt_string.h
index bb21dd1aee2d..8a6ba7bbef9f 100644
--- a/include/linux/netfilter/xt_string.h
+++ b/include/linux/netfilter/xt_string.h
@@ -4,6 +4,11 @@
4#define XT_STRING_MAX_PATTERN_SIZE 128 4#define XT_STRING_MAX_PATTERN_SIZE 128
5#define XT_STRING_MAX_ALGO_NAME_SIZE 16 5#define XT_STRING_MAX_ALGO_NAME_SIZE 16
6 6
7enum {
8 XT_STRING_FLAG_INVERT = 0x01,
9 XT_STRING_FLAG_IGNORECASE = 0x02
10};
11
7struct xt_string_info 12struct xt_string_info
8{ 13{
9 u_int16_t from_offset; 14 u_int16_t from_offset;
@@ -11,7 +16,15 @@ struct xt_string_info
11 char algo[XT_STRING_MAX_ALGO_NAME_SIZE]; 16 char algo[XT_STRING_MAX_ALGO_NAME_SIZE];
12 char pattern[XT_STRING_MAX_PATTERN_SIZE]; 17 char pattern[XT_STRING_MAX_PATTERN_SIZE];
13 u_int8_t patlen; 18 u_int8_t patlen;
14 u_int8_t invert; 19 union {
20 struct {
21 u_int8_t invert;
22 } v0;
23
24 struct {
25 u_int8_t flags;
26 } v1;
27 } u;
15 28
16 /* Used internally by the kernel */ 29 /* Used internally by the kernel */
17 struct ts_config __attribute__((aligned(8))) *config; 30 struct ts_config __attribute__((aligned(8))) *config;
diff --git a/include/linux/netfilter_bridge/ebt_ip6.h b/include/linux/netfilter_bridge/ebt_ip6.h
new file mode 100644
index 000000000000..2273c3ae33ca
--- /dev/null
+++ b/include/linux/netfilter_bridge/ebt_ip6.h
@@ -0,0 +1,40 @@
1/*
2 * ebt_ip6
3 *
4 * Authors:
5 * Kuo-Lang Tseng <kuo-lang.tseng@intel.com>
6 * Manohar Castelino <manohar.r.castelino@intel.com>
7 *
8 * Jan 11, 2008
9 *
10 */
11
12#ifndef __LINUX_BRIDGE_EBT_IP6_H
13#define __LINUX_BRIDGE_EBT_IP6_H
14
15#define EBT_IP6_SOURCE 0x01
16#define EBT_IP6_DEST 0x02
17#define EBT_IP6_TCLASS 0x04
18#define EBT_IP6_PROTO 0x08
19#define EBT_IP6_SPORT 0x10
20#define EBT_IP6_DPORT 0x20
21#define EBT_IP6_MASK (EBT_IP6_SOURCE | EBT_IP6_DEST | EBT_IP6_TCLASS |\
22 EBT_IP6_PROTO | EBT_IP6_SPORT | EBT_IP6_DPORT)
23#define EBT_IP6_MATCH "ip6"
24
25/* the same values are used for the invflags */
26struct ebt_ip6_info
27{
28 struct in6_addr saddr;
29 struct in6_addr daddr;
30 struct in6_addr smsk;
31 struct in6_addr dmsk;
32 uint8_t tclass;
33 uint8_t protocol;
34 uint8_t bitmask;
35 uint8_t invflags;
36 uint16_t sport[2];
37 uint16_t dport[2];
38};
39
40#endif
diff --git a/include/linux/netfilter_bridge/ebt_log.h b/include/linux/netfilter_bridge/ebt_log.h
index 96e231ae7554..b76e653157e5 100644
--- a/include/linux/netfilter_bridge/ebt_log.h
+++ b/include/linux/netfilter_bridge/ebt_log.h
@@ -4,7 +4,8 @@
4#define EBT_LOG_IP 0x01 /* if the frame is made by ip, log the ip information */ 4#define EBT_LOG_IP 0x01 /* if the frame is made by ip, log the ip information */
5#define EBT_LOG_ARP 0x02 5#define EBT_LOG_ARP 0x02
6#define EBT_LOG_NFLOG 0x04 6#define EBT_LOG_NFLOG 0x04
7#define EBT_LOG_MASK (EBT_LOG_IP | EBT_LOG_ARP) 7#define EBT_LOG_IP6 0x08
8#define EBT_LOG_MASK (EBT_LOG_IP | EBT_LOG_ARP | EBT_LOG_IP6)
8#define EBT_LOG_PREFIX_SIZE 30 9#define EBT_LOG_PREFIX_SIZE 30
9#define EBT_LOG_WATCHER "log" 10#define EBT_LOG_WATCHER "log"
10 11
diff --git a/include/linux/netfilter_bridge/ebtables.h b/include/linux/netfilter_bridge/ebtables.h
index 892f5b7771c7..d45e29cd1cfb 100644
--- a/include/linux/netfilter_bridge/ebtables.h
+++ b/include/linux/netfilter_bridge/ebtables.h
@@ -31,6 +31,9 @@
31 * The 4 lsb are more than enough to store the verdict. */ 31 * The 4 lsb are more than enough to store the verdict. */
32#define EBT_VERDICT_BITS 0x0000000F 32#define EBT_VERDICT_BITS 0x0000000F
33 33
34struct xt_match;
35struct xt_target;
36
34struct ebt_counter 37struct ebt_counter
35{ 38{
36 uint64_t pcnt; 39 uint64_t pcnt;
@@ -121,7 +124,7 @@ struct ebt_entry_match
121{ 124{
122 union { 125 union {
123 char name[EBT_FUNCTION_MAXNAMELEN]; 126 char name[EBT_FUNCTION_MAXNAMELEN];
124 struct ebt_match *match; 127 struct xt_match *match;
125 } u; 128 } u;
126 /* size of data */ 129 /* size of data */
127 unsigned int match_size; 130 unsigned int match_size;
@@ -132,7 +135,7 @@ struct ebt_entry_watcher
132{ 135{
133 union { 136 union {
134 char name[EBT_FUNCTION_MAXNAMELEN]; 137 char name[EBT_FUNCTION_MAXNAMELEN];
135 struct ebt_watcher *watcher; 138 struct xt_target *watcher;
136 } u; 139 } u;
137 /* size of data */ 140 /* size of data */
138 unsigned int watcher_size; 141 unsigned int watcher_size;
@@ -143,7 +146,7 @@ struct ebt_entry_target
143{ 146{
144 union { 147 union {
145 char name[EBT_FUNCTION_MAXNAMELEN]; 148 char name[EBT_FUNCTION_MAXNAMELEN];
146 struct ebt_target *target; 149 struct xt_target *target;
147 } u; 150 } u;
148 /* size of data */ 151 /* size of data */
149 unsigned int target_size; 152 unsigned int target_size;
@@ -207,14 +210,17 @@ struct ebt_match
207{ 210{
208 struct list_head list; 211 struct list_head list;
209 const char name[EBT_FUNCTION_MAXNAMELEN]; 212 const char name[EBT_FUNCTION_MAXNAMELEN];
210 /* 0 == it matches */ 213 bool (*match)(const struct sk_buff *skb, const struct net_device *in,
211 int (*match)(const struct sk_buff *skb, const struct net_device *in, 214 const struct net_device *out, const struct xt_match *match,
212 const struct net_device *out, const void *matchdata, 215 const void *matchinfo, int offset, unsigned int protoff,
213 unsigned int datalen); 216 bool *hotdrop);
214 /* 0 == let it in */ 217 bool (*checkentry)(const char *table, const void *entry,
215 int (*check)(const char *tablename, unsigned int hookmask, 218 const struct xt_match *match, void *matchinfo,
216 const struct ebt_entry *e, void *matchdata, unsigned int datalen); 219 unsigned int hook_mask);
217 void (*destroy)(void *matchdata, unsigned int datalen); 220 void (*destroy)(const struct xt_match *match, void *matchinfo);
221 unsigned int matchsize;
222 u_int8_t revision;
223 u_int8_t family;
218 struct module *me; 224 struct module *me;
219}; 225};
220 226
@@ -222,13 +228,17 @@ struct ebt_watcher
222{ 228{
223 struct list_head list; 229 struct list_head list;
224 const char name[EBT_FUNCTION_MAXNAMELEN]; 230 const char name[EBT_FUNCTION_MAXNAMELEN];
225 void (*watcher)(const struct sk_buff *skb, unsigned int hooknr, 231 unsigned int (*target)(struct sk_buff *skb,
226 const struct net_device *in, const struct net_device *out, 232 const struct net_device *in, const struct net_device *out,
227 const void *watcherdata, unsigned int datalen); 233 unsigned int hook_num, const struct xt_target *target,
228 /* 0 == let it in */ 234 const void *targinfo);
229 int (*check)(const char *tablename, unsigned int hookmask, 235 bool (*checkentry)(const char *table, const void *entry,
230 const struct ebt_entry *e, void *watcherdata, unsigned int datalen); 236 const struct xt_target *target, void *targinfo,
231 void (*destroy)(void *watcherdata, unsigned int datalen); 237 unsigned int hook_mask);
238 void (*destroy)(const struct xt_target *target, void *targinfo);
239 unsigned int targetsize;
240 u_int8_t revision;
241 u_int8_t family;
232 struct module *me; 242 struct module *me;
233}; 243};
234 244
@@ -236,14 +246,18 @@ struct ebt_target
236{ 246{
237 struct list_head list; 247 struct list_head list;
238 const char name[EBT_FUNCTION_MAXNAMELEN]; 248 const char name[EBT_FUNCTION_MAXNAMELEN];
239 /* returns one of the standard verdicts */ 249 /* returns one of the standard EBT_* verdicts */
240 int (*target)(struct sk_buff *skb, unsigned int hooknr, 250 unsigned int (*target)(struct sk_buff *skb,
241 const struct net_device *in, const struct net_device *out, 251 const struct net_device *in, const struct net_device *out,
242 const void *targetdata, unsigned int datalen); 252 unsigned int hook_num, const struct xt_target *target,
243 /* 0 == let it in */ 253 const void *targinfo);
244 int (*check)(const char *tablename, unsigned int hookmask, 254 bool (*checkentry)(const char *table, const void *entry,
245 const struct ebt_entry *e, void *targetdata, unsigned int datalen); 255 const struct xt_target *target, void *targinfo,
246 void (*destroy)(void *targetdata, unsigned int datalen); 256 unsigned int hook_mask);
257 void (*destroy)(const struct xt_target *target, void *targinfo);
258 unsigned int targetsize;
259 u_int8_t revision;
260 u_int8_t family;
247 struct module *me; 261 struct module *me;
248}; 262};
249 263
@@ -288,12 +302,6 @@ struct ebt_table
288 ~(__alignof__(struct ebt_replace)-1)) 302 ~(__alignof__(struct ebt_replace)-1))
289extern int ebt_register_table(struct ebt_table *table); 303extern int ebt_register_table(struct ebt_table *table);
290extern void ebt_unregister_table(struct ebt_table *table); 304extern void ebt_unregister_table(struct ebt_table *table);
291extern int ebt_register_match(struct ebt_match *match);
292extern void ebt_unregister_match(struct ebt_match *match);
293extern int ebt_register_watcher(struct ebt_watcher *watcher);
294extern void ebt_unregister_watcher(struct ebt_watcher *watcher);
295extern int ebt_register_target(struct ebt_target *target);
296extern void ebt_unregister_target(struct ebt_target *target);
297extern unsigned int ebt_do_table(unsigned int hook, struct sk_buff *skb, 305extern unsigned int ebt_do_table(unsigned int hook, struct sk_buff *skb,
298 const struct net_device *in, const struct net_device *out, 306 const struct net_device *in, const struct net_device *out,
299 struct ebt_table *table); 307 struct ebt_table *table);
@@ -302,9 +310,9 @@ extern unsigned int ebt_do_table(unsigned int hook, struct sk_buff *skb,
302#define FWINV(bool,invflg) ((bool) ^ !!(info->invflags & invflg)) 310#define FWINV(bool,invflg) ((bool) ^ !!(info->invflags & invflg))
303/* True if the hook mask denotes that the rule is in a base chain, 311/* True if the hook mask denotes that the rule is in a base chain,
304 * used in the check() functions */ 312 * used in the check() functions */
305#define BASE_CHAIN (hookmask & (1 << NF_BR_NUMHOOKS)) 313#define BASE_CHAIN (par->hook_mask & (1 << NF_BR_NUMHOOKS))
306/* Clear the bit in the hook mask that tells if the rule is on a base chain */ 314/* Clear the bit in the hook mask that tells if the rule is on a base chain */
307#define CLEAR_BASE_CHAIN_BIT (hookmask &= ~(1 << NF_BR_NUMHOOKS)) 315#define CLEAR_BASE_CHAIN_BIT (par->hook_mask &= ~(1 << NF_BR_NUMHOOKS))
308/* True if the target is not a standard target */ 316/* True if the target is not a standard target */
309#define INVALID_TARGET (info->target < -NUM_STANDARD_TARGETS || info->target >= 0) 317#define INVALID_TARGET (info->target < -NUM_STANDARD_TARGETS || info->target >= 0)
310 318
diff --git a/include/linux/netfilter_ipv4.h b/include/linux/netfilter_ipv4.h
index 650318b0c405..29c7727ff0e8 100644
--- a/include/linux/netfilter_ipv4.h
+++ b/include/linux/netfilter_ipv4.h
@@ -60,6 +60,7 @@ enum nf_ip_hook_priorities {
60 NF_IP_PRI_MANGLE = -150, 60 NF_IP_PRI_MANGLE = -150,
61 NF_IP_PRI_NAT_DST = -100, 61 NF_IP_PRI_NAT_DST = -100,
62 NF_IP_PRI_FILTER = 0, 62 NF_IP_PRI_FILTER = 0,
63 NF_IP_PRI_SECURITY = 50,
63 NF_IP_PRI_NAT_SRC = 100, 64 NF_IP_PRI_NAT_SRC = 100,
64 NF_IP_PRI_SELINUX_LAST = 225, 65 NF_IP_PRI_SELINUX_LAST = 225,
65 NF_IP_PRI_CONNTRACK_CONFIRM = INT_MAX, 66 NF_IP_PRI_CONNTRACK_CONFIRM = INT_MAX,
diff --git a/include/linux/netfilter_ipv4/ipt_recent.h b/include/linux/netfilter_ipv4/ipt_recent.h
index 6508a4592651..d636cca133c2 100644
--- a/include/linux/netfilter_ipv4/ipt_recent.h
+++ b/include/linux/netfilter_ipv4/ipt_recent.h
@@ -1,27 +1,21 @@
1#ifndef _IPT_RECENT_H 1#ifndef _IPT_RECENT_H
2#define _IPT_RECENT_H 2#define _IPT_RECENT_H
3 3
4#define RECENT_NAME "ipt_recent" 4#include <linux/netfilter/xt_recent.h>
5#define RECENT_VER "v0.3.1"
6 5
7#define IPT_RECENT_CHECK 1 6#define ipt_recent_info xt_recent_mtinfo
8#define IPT_RECENT_SET 2
9#define IPT_RECENT_UPDATE 4
10#define IPT_RECENT_REMOVE 8
11#define IPT_RECENT_TTL 16
12 7
13#define IPT_RECENT_SOURCE 0 8enum {
14#define IPT_RECENT_DEST 1 9 IPT_RECENT_CHECK = XT_RECENT_CHECK,
10 IPT_RECENT_SET = XT_RECENT_SET,
11 IPT_RECENT_UPDATE = XT_RECENT_UPDATE,
12 IPT_RECENT_REMOVE = XT_RECENT_REMOVE,
13 IPT_RECENT_TTL = XT_RECENT_TTL,
15 14
16#define IPT_RECENT_NAME_LEN 200 15 IPT_RECENT_SOURCE = XT_RECENT_SOURCE,
16 IPT_RECENT_DEST = XT_RECENT_DEST,
17 17
18struct ipt_recent_info { 18 IPT_RECENT_NAME_LEN = XT_RECENT_NAME_LEN,
19 u_int32_t seconds;
20 u_int32_t hit_count;
21 u_int8_t check_set;
22 u_int8_t invert;
23 char name[IPT_RECENT_NAME_LEN];
24 u_int8_t side;
25}; 19};
26 20
27#endif /*_IPT_RECENT_H*/ 21#endif /*_IPT_RECENT_H*/
diff --git a/include/linux/netfilter_ipv6.h b/include/linux/netfilter_ipv6.h
index 3475a65dae9b..d654873aa25a 100644
--- a/include/linux/netfilter_ipv6.h
+++ b/include/linux/netfilter_ipv6.h
@@ -64,11 +64,14 @@ enum nf_ip6_hook_priorities {
64 NF_IP6_PRI_MANGLE = -150, 64 NF_IP6_PRI_MANGLE = -150,
65 NF_IP6_PRI_NAT_DST = -100, 65 NF_IP6_PRI_NAT_DST = -100,
66 NF_IP6_PRI_FILTER = 0, 66 NF_IP6_PRI_FILTER = 0,
67 NF_IP6_PRI_SECURITY = 50,
67 NF_IP6_PRI_NAT_SRC = 100, 68 NF_IP6_PRI_NAT_SRC = 100,
68 NF_IP6_PRI_SELINUX_LAST = 225, 69 NF_IP6_PRI_SELINUX_LAST = 225,
69 NF_IP6_PRI_LAST = INT_MAX, 70 NF_IP6_PRI_LAST = INT_MAX,
70}; 71};
71 72
73#ifdef __KERNEL__
74
72#ifdef CONFIG_NETFILTER 75#ifdef CONFIG_NETFILTER
73extern int ip6_route_me_harder(struct sk_buff *skb); 76extern int ip6_route_me_harder(struct sk_buff *skb);
74extern __sum16 nf_ip6_checksum(struct sk_buff *skb, unsigned int hook, 77extern __sum16 nf_ip6_checksum(struct sk_buff *skb, unsigned int hook,
@@ -81,4 +84,6 @@ static inline int ipv6_netfilter_init(void) { return 0; }
81static inline void ipv6_netfilter_fini(void) { return; } 84static inline void ipv6_netfilter_fini(void) { return; }
82#endif /* CONFIG_NETFILTER */ 85#endif /* CONFIG_NETFILTER */
83 86
87#endif /* __KERNEL__ */
88
84#endif /*__LINUX_IP6_NETFILTER_H*/ 89#endif /*__LINUX_IP6_NETFILTER_H*/
diff --git a/include/linux/netlink.h b/include/linux/netlink.h
index bec1062a25a1..9ff1b54908f3 100644
--- a/include/linux/netlink.h
+++ b/include/linux/netlink.h
@@ -193,7 +193,7 @@ extern int netlink_unregister_notifier(struct notifier_block *nb);
193 193
194/* finegrained unicast helpers: */ 194/* finegrained unicast helpers: */
195struct sock *netlink_getsockbyfilp(struct file *filp); 195struct sock *netlink_getsockbyfilp(struct file *filp);
196int netlink_attachskb(struct sock *sk, struct sk_buff *skb, int nonblock, 196int netlink_attachskb(struct sock *sk, struct sk_buff *skb,
197 long *timeo, struct sock *ssk); 197 long *timeo, struct sock *ssk);
198void netlink_detachskb(struct sock *sk, struct sk_buff *skb); 198void netlink_detachskb(struct sock *sk, struct sk_buff *skb);
199int netlink_sendskb(struct sock *sk, struct sk_buff *skb); 199int netlink_sendskb(struct sock *sk, struct sk_buff *skb);
diff --git a/include/linux/nfs4.h b/include/linux/nfs4.h
index 8726491de154..ea0366769484 100644
--- a/include/linux/nfs4.h
+++ b/include/linux/nfs4.h
@@ -65,9 +65,6 @@
65#define NFS4_ACE_SUCCESSFUL_ACCESS_ACE_FLAG 0x00000010 65#define NFS4_ACE_SUCCESSFUL_ACCESS_ACE_FLAG 0x00000010
66#define NFS4_ACE_FAILED_ACCESS_ACE_FLAG 0x00000020 66#define NFS4_ACE_FAILED_ACCESS_ACE_FLAG 0x00000020
67#define NFS4_ACE_IDENTIFIER_GROUP 0x00000040 67#define NFS4_ACE_IDENTIFIER_GROUP 0x00000040
68#define NFS4_ACE_OWNER 0x00000080
69#define NFS4_ACE_GROUP 0x00000100
70#define NFS4_ACE_EVERYONE 0x00000200
71 68
72#define NFS4_ACE_READ_DATA 0x00000001 69#define NFS4_ACE_READ_DATA 0x00000001
73#define NFS4_ACE_LIST_DIRECTORY 0x00000001 70#define NFS4_ACE_LIST_DIRECTORY 0x00000001
diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h
index 29d261918734..4eaa8347a0d9 100644
--- a/include/linux/nfs_fs.h
+++ b/include/linux/nfs_fs.h
@@ -42,7 +42,6 @@
42#include <linux/in.h> 42#include <linux/in.h>
43#include <linux/kref.h> 43#include <linux/kref.h>
44#include <linux/mm.h> 44#include <linux/mm.h>
45#include <linux/namei.h>
46#include <linux/pagemap.h> 45#include <linux/pagemap.h>
47#include <linux/rbtree.h> 46#include <linux/rbtree.h>
48#include <linux/rwsem.h> 47#include <linux/rwsem.h>
@@ -138,7 +137,7 @@ struct nfs_inode {
138 unsigned long attrtimeo_timestamp; 137 unsigned long attrtimeo_timestamp;
139 __u64 change_attr; /* v4 only */ 138 __u64 change_attr; /* v4 only */
140 139
141 unsigned long last_updated; 140 unsigned long attr_gencount;
142 /* "Generation counter" for the attribute cache. This is 141 /* "Generation counter" for the attribute cache. This is
143 * bumped whenever we update the metadata on the 142 * bumped whenever we update the metadata on the
144 * server. 143 * server.
@@ -201,11 +200,10 @@ struct nfs_inode {
201/* 200/*
202 * Bit offsets in flags field 201 * Bit offsets in flags field
203 */ 202 */
204#define NFS_INO_REVALIDATING (0) /* revalidating attrs */ 203#define NFS_INO_ADVISE_RDPLUS (0) /* advise readdirplus */
205#define NFS_INO_ADVISE_RDPLUS (1) /* advise readdirplus */ 204#define NFS_INO_STALE (1) /* possible stale inode */
206#define NFS_INO_STALE (2) /* possible stale inode */ 205#define NFS_INO_ACL_LRU_SET (2) /* Inode is on the LRU list */
207#define NFS_INO_ACL_LRU_SET (3) /* Inode is on the LRU list */ 206#define NFS_INO_MOUNTPOINT (3) /* inode is remote mountpoint */
208#define NFS_INO_MOUNTPOINT (4) /* inode is remote mountpoint */
209 207
210static inline struct nfs_inode *NFS_I(const struct inode *inode) 208static inline struct nfs_inode *NFS_I(const struct inode *inode)
211{ 209{
@@ -332,7 +330,7 @@ extern int nfs_refresh_inode(struct inode *, struct nfs_fattr *);
332extern int nfs_post_op_update_inode(struct inode *inode, struct nfs_fattr *fattr); 330extern int nfs_post_op_update_inode(struct inode *inode, struct nfs_fattr *fattr);
333extern int nfs_post_op_update_inode_force_wcc(struct inode *inode, struct nfs_fattr *fattr); 331extern int nfs_post_op_update_inode_force_wcc(struct inode *inode, struct nfs_fattr *fattr);
334extern int nfs_getattr(struct vfsmount *, struct dentry *, struct kstat *); 332extern int nfs_getattr(struct vfsmount *, struct dentry *, struct kstat *);
335extern int nfs_permission(struct inode *, int, struct nameidata *); 333extern int nfs_permission(struct inode *, int);
336extern int nfs_open(struct inode *, struct file *); 334extern int nfs_open(struct inode *, struct file *);
337extern int nfs_release(struct inode *, struct file *); 335extern int nfs_release(struct inode *, struct file *);
338extern int nfs_attribute_timeout(struct inode *inode); 336extern int nfs_attribute_timeout(struct inode *inode);
@@ -346,15 +344,11 @@ extern struct nfs_open_context *get_nfs_open_context(struct nfs_open_context *ct
346extern void put_nfs_open_context(struct nfs_open_context *ctx); 344extern void put_nfs_open_context(struct nfs_open_context *ctx);
347extern struct nfs_open_context *nfs_find_open_context(struct inode *inode, struct rpc_cred *cred, int mode); 345extern struct nfs_open_context *nfs_find_open_context(struct inode *inode, struct rpc_cred *cred, int mode);
348extern u64 nfs_compat_user_ino64(u64 fileid); 346extern u64 nfs_compat_user_ino64(u64 fileid);
347extern void nfs_fattr_init(struct nfs_fattr *fattr);
349 348
350/* linux/net/ipv4/ipconfig.c: trims ip addr off front of name, too. */ 349/* linux/net/ipv4/ipconfig.c: trims ip addr off front of name, too. */
351extern __be32 root_nfs_parse_addr(char *name); /*__init*/ 350extern __be32 root_nfs_parse_addr(char *name); /*__init*/
352 351extern unsigned long nfs_inc_attr_generation_counter(void);
353static inline void nfs_fattr_init(struct nfs_fattr *fattr)
354{
355 fattr->valid = 0;
356 fattr->time_start = jiffies;
357}
358 352
359/* 353/*
360 * linux/fs/nfs/file.c 354 * linux/fs/nfs/file.c
@@ -373,8 +367,12 @@ static inline struct nfs_open_context *nfs_file_open_context(struct file *filp)
373 367
374static inline struct rpc_cred *nfs_file_cred(struct file *file) 368static inline struct rpc_cred *nfs_file_cred(struct file *file)
375{ 369{
376 if (file != NULL) 370 if (file != NULL) {
377 return nfs_file_open_context(file)->cred; 371 struct nfs_open_context *ctx =
372 nfs_file_open_context(file);
373 if (ctx)
374 return ctx->cred;
375 }
378 return NULL; 376 return NULL;
379} 377}
380 378
diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h
index c9beacd16c00..4e477ae58699 100644
--- a/include/linux/nfs_fs_sb.h
+++ b/include/linux/nfs_fs_sb.h
@@ -119,7 +119,6 @@ struct nfs_server {
119 void (*destroy)(struct nfs_server *); 119 void (*destroy)(struct nfs_server *);
120 120
121 atomic_t active; /* Keep trace of any activity to this server */ 121 atomic_t active; /* Keep trace of any activity to this server */
122 wait_queue_head_t active_wq; /* Wait for any activity to stop */
123 122
124 /* mountd-related mount options */ 123 /* mountd-related mount options */
125 struct sockaddr_storage mountd_address; 124 struct sockaddr_storage mountd_address;
diff --git a/include/linux/nfs_mount.h b/include/linux/nfs_mount.h
index df7c6b7a7ebb..6549a06ac16e 100644
--- a/include/linux/nfs_mount.h
+++ b/include/linux/nfs_mount.h
@@ -65,4 +65,8 @@ struct nfs_mount_data {
65#define NFS_MOUNT_UNSHARED 0x8000 /* 5 */ 65#define NFS_MOUNT_UNSHARED 0x8000 /* 5 */
66#define NFS_MOUNT_FLAGMASK 0xFFFF 66#define NFS_MOUNT_FLAGMASK 0xFFFF
67 67
68/* The following are for internal use only */
69#define NFS_MOUNT_LOOKUP_CACHE_NONEG 0x10000
70#define NFS_MOUNT_LOOKUP_CACHE_NONE 0x20000
71
68#endif 72#endif
diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h
index 8c77c11224d1..c1c31acb8a2b 100644
--- a/include/linux/nfs_xdr.h
+++ b/include/linux/nfs_xdr.h
@@ -36,6 +36,7 @@ struct nfs_fattr {
36 __u32 nlink; 36 __u32 nlink;
37 __u32 uid; 37 __u32 uid;
38 __u32 gid; 38 __u32 gid;
39 dev_t rdev;
39 __u64 size; 40 __u64 size;
40 union { 41 union {
41 struct { 42 struct {
@@ -46,7 +47,6 @@ struct nfs_fattr {
46 __u64 used; 47 __u64 used;
47 } nfs3; 48 } nfs3;
48 } du; 49 } du;
49 dev_t rdev;
50 struct nfs_fsid fsid; 50 struct nfs_fsid fsid;
51 __u64 fileid; 51 __u64 fileid;
52 struct timespec atime; 52 struct timespec atime;
@@ -56,6 +56,7 @@ struct nfs_fattr {
56 __u64 change_attr; /* NFSv4 change attribute */ 56 __u64 change_attr; /* NFSv4 change attribute */
57 __u64 pre_change_attr;/* pre-op NFSv4 change attribute */ 57 __u64 pre_change_attr;/* pre-op NFSv4 change attribute */
58 unsigned long time_start; 58 unsigned long time_start;
59 unsigned long gencount;
59}; 60};
60 61
61#define NFS_ATTR_WCC 0x0001 /* pre-op WCC data */ 62#define NFS_ATTR_WCC 0x0001 /* pre-op WCC data */
@@ -672,16 +673,16 @@ struct nfs4_rename_res {
672 struct nfs_fattr * new_fattr; 673 struct nfs_fattr * new_fattr;
673}; 674};
674 675
675#define NFS4_SETCLIENTID_NAMELEN (56) 676#define NFS4_SETCLIENTID_NAMELEN (127)
676struct nfs4_setclientid { 677struct nfs4_setclientid {
677 const nfs4_verifier * sc_verifier; 678 const nfs4_verifier * sc_verifier;
678 unsigned int sc_name_len; 679 unsigned int sc_name_len;
679 char sc_name[NFS4_SETCLIENTID_NAMELEN]; 680 char sc_name[NFS4_SETCLIENTID_NAMELEN + 1];
680 u32 sc_prog; 681 u32 sc_prog;
681 unsigned int sc_netid_len; 682 unsigned int sc_netid_len;
682 char sc_netid[RPCBIND_MAXNETIDLEN]; 683 char sc_netid[RPCBIND_MAXNETIDLEN + 1];
683 unsigned int sc_uaddr_len; 684 unsigned int sc_uaddr_len;
684 char sc_uaddr[RPCBIND_MAXUADDRLEN]; 685 char sc_uaddr[RPCBIND_MAXUADDRLEN + 1];
685 u32 sc_cb_ident; 686 u32 sc_cb_ident;
686}; 687};
687 688
diff --git a/include/linux/nfsd/nfsd.h b/include/linux/nfsd/nfsd.h
index 41d30c9c9de6..21269405ffe2 100644
--- a/include/linux/nfsd/nfsd.h
+++ b/include/linux/nfsd/nfsd.h
@@ -12,7 +12,6 @@
12 12
13#include <linux/types.h> 13#include <linux/types.h>
14#include <linux/unistd.h> 14#include <linux/unistd.h>
15#include <linux/dirent.h>
16#include <linux/fs.h> 15#include <linux/fs.h>
17#include <linux/posix_acl.h> 16#include <linux/posix_acl.h>
18#include <linux/mount.h> 17#include <linux/mount.h>
@@ -28,20 +27,21 @@
28#define NFSD_SUPPORTED_MINOR_VERSION 0 27#define NFSD_SUPPORTED_MINOR_VERSION 0
29 28
30/* 29/*
31 * Special flags for nfsd_permission. These must be different from MAY_READ, 30 * Flags for nfsd_permission
32 * MAY_WRITE, and MAY_EXEC.
33 */ 31 */
34#define MAY_NOP 0 32#define NFSD_MAY_NOP 0
35#define MAY_SATTR 8 33#define NFSD_MAY_EXEC 1 /* == MAY_EXEC */
36#define MAY_TRUNC 16 34#define NFSD_MAY_WRITE 2 /* == MAY_WRITE */
37#define MAY_LOCK 32 35#define NFSD_MAY_READ 4 /* == MAY_READ */
38#define MAY_OWNER_OVERRIDE 64 36#define NFSD_MAY_SATTR 8
39#define MAY_LOCAL_ACCESS 128 /* IRIX doing local access check on device special file*/ 37#define NFSD_MAY_TRUNC 16
40#if (MAY_SATTR | MAY_TRUNC | MAY_LOCK | MAY_OWNER_OVERRIDE | MAY_LOCAL_ACCESS) & (MAY_READ | MAY_WRITE | MAY_EXEC) 38#define NFSD_MAY_LOCK 32
41# error "please use a different value for MAY_SATTR or MAY_TRUNC or MAY_LOCK or MAY_LOCAL_ACCESS or MAY_OWNER_OVERRIDE." 39#define NFSD_MAY_OWNER_OVERRIDE 64
42#endif 40#define NFSD_MAY_LOCAL_ACCESS 128 /* IRIX doing local access check on device special file*/
43#define MAY_CREATE (MAY_EXEC|MAY_WRITE) 41#define NFSD_MAY_BYPASS_GSS_ON_ROOT 256
44#define MAY_REMOVE (MAY_EXEC|MAY_WRITE|MAY_TRUNC) 42
43#define NFSD_MAY_CREATE (NFSD_MAY_EXEC|NFSD_MAY_WRITE)
44#define NFSD_MAY_REMOVE (NFSD_MAY_EXEC|NFSD_MAY_WRITE|NFSD_MAY_TRUNC)
45 45
46/* 46/*
47 * Callback function for readdir 47 * Callback function for readdir
@@ -54,6 +54,7 @@ typedef int (*nfsd_dirop_t)(struct inode *, struct dentry *, int, int);
54extern struct svc_program nfsd_program; 54extern struct svc_program nfsd_program;
55extern struct svc_version nfsd_version2, nfsd_version3, 55extern struct svc_version nfsd_version2, nfsd_version3,
56 nfsd_version4; 56 nfsd_version4;
57extern struct mutex nfsd_mutex;
57extern struct svc_serv *nfsd_serv; 58extern struct svc_serv *nfsd_serv;
58 59
59extern struct seq_operations nfs_exports_op; 60extern struct seq_operations nfs_exports_op;
@@ -125,7 +126,7 @@ int nfsd_truncate(struct svc_rqst *, struct svc_fh *,
125__be32 nfsd_readdir(struct svc_rqst *, struct svc_fh *, 126__be32 nfsd_readdir(struct svc_rqst *, struct svc_fh *,
126 loff_t *, struct readdir_cd *, filldir_t); 127 loff_t *, struct readdir_cd *, filldir_t);
127__be32 nfsd_statfs(struct svc_rqst *, struct svc_fh *, 128__be32 nfsd_statfs(struct svc_rqst *, struct svc_fh *,
128 struct kstatfs *); 129 struct kstatfs *, int access);
129 130
130int nfsd_notify_change(struct inode *, struct iattr *); 131int nfsd_notify_change(struct inode *, struct iattr *);
131__be32 nfsd_permission(struct svc_rqst *, struct svc_export *, 132__be32 nfsd_permission(struct svc_rqst *, struct svc_export *,
diff --git a/include/linux/nfsd/state.h b/include/linux/nfsd/state.h
index db348f749376..d0fe2e378452 100644
--- a/include/linux/nfsd/state.h
+++ b/include/linux/nfsd/state.h
@@ -98,8 +98,6 @@ struct nfs4_callback {
98 u32 cb_ident; 98 u32 cb_ident;
99 /* RPC client info */ 99 /* RPC client info */
100 atomic_t cb_set; /* successful CB_NULL call */ 100 atomic_t cb_set; /* successful CB_NULL call */
101 struct rpc_program cb_program;
102 struct rpc_stat cb_stat;
103 struct rpc_clnt * cb_client; 101 struct rpc_clnt * cb_client;
104}; 102};
105 103
diff --git a/include/linux/nl80211.h b/include/linux/nl80211.h
index ea6517e58b04..9bad65400fba 100644
--- a/include/linux/nl80211.h
+++ b/include/linux/nl80211.h
@@ -89,6 +89,22 @@
89 * @NL80211_CMD_DEL_PATH: Remove a mesh path identified by %NL80211_ATTR_MAC 89 * @NL80211_CMD_DEL_PATH: Remove a mesh path identified by %NL80211_ATTR_MAC
90 * or, if no MAC address given, all mesh paths, on the interface identified 90 * or, if no MAC address given, all mesh paths, on the interface identified
91 * by %NL80211_ATTR_IFINDEX. 91 * by %NL80211_ATTR_IFINDEX.
92 * @NL80211_CMD_SET_BSS: Set BSS attributes for BSS identified by
93 * %NL80211_ATTR_IFINDEX.
94 *
95 * @NL80211_CMD_SET_REG: Set current regulatory domain. CRDA sends this command
96 * after being queried by the kernel. CRDA replies by sending a regulatory
97 * domain structure which consists of %NL80211_ATTR_REG_ALPHA set to our
98 * current alpha2 if it found a match. It also provides
99 * NL80211_ATTR_REG_RULE_FLAGS, and a set of regulatory rules. Each
100 * regulatory rule is a nested set of attributes given by
101 * %NL80211_ATTR_REG_RULE_FREQ_[START|END] and
102 * %NL80211_ATTR_FREQ_RANGE_MAX_BW with an attached power rule given by
103 * %NL80211_ATTR_REG_RULE_POWER_MAX_ANT_GAIN and
104 * %NL80211_ATTR_REG_RULE_POWER_MAX_EIRP.
105 * @NL80211_CMD_REQ_SET_REG: ask the wireless core to set the regulatory domain
106 * to the the specified ISO/IEC 3166-1 alpha2 country code. The core will
107 * store this as a valid request and then query userspace for it.
92 * 108 *
93 * @NL80211_CMD_MAX: highest used command number 109 * @NL80211_CMD_MAX: highest used command number
94 * @__NL80211_CMD_AFTER_LAST: internal use 110 * @__NL80211_CMD_AFTER_LAST: internal use
@@ -122,18 +138,28 @@ enum nl80211_commands {
122 NL80211_CMD_NEW_STATION, 138 NL80211_CMD_NEW_STATION,
123 NL80211_CMD_DEL_STATION, 139 NL80211_CMD_DEL_STATION,
124 140
125 /* add commands here */
126
127 NL80211_CMD_GET_MPATH, 141 NL80211_CMD_GET_MPATH,
128 NL80211_CMD_SET_MPATH, 142 NL80211_CMD_SET_MPATH,
129 NL80211_CMD_NEW_MPATH, 143 NL80211_CMD_NEW_MPATH,
130 NL80211_CMD_DEL_MPATH, 144 NL80211_CMD_DEL_MPATH,
131 145
146 NL80211_CMD_SET_BSS,
147
148 NL80211_CMD_SET_REG,
149 NL80211_CMD_REQ_SET_REG,
150
151 /* add new commands above here */
152
132 /* used to define NL80211_CMD_MAX below */ 153 /* used to define NL80211_CMD_MAX below */
133 __NL80211_CMD_AFTER_LAST, 154 __NL80211_CMD_AFTER_LAST,
134 NL80211_CMD_MAX = __NL80211_CMD_AFTER_LAST - 1 155 NL80211_CMD_MAX = __NL80211_CMD_AFTER_LAST - 1
135}; 156};
136 157
158/*
159 * Allow user space programs to use #ifdef on new commands by defining them
160 * here
161 */
162#define NL80211_CMD_SET_BSS NL80211_CMD_SET_BSS
137 163
138/** 164/**
139 * enum nl80211_attrs - nl80211 netlink attributes 165 * enum nl80211_attrs - nl80211 netlink attributes
@@ -188,10 +214,34 @@ enum nl80211_commands {
188 * info given for %NL80211_CMD_GET_MPATH, nested attribute described at 214 * info given for %NL80211_CMD_GET_MPATH, nested attribute described at
189 * &enum nl80211_mpath_info. 215 * &enum nl80211_mpath_info.
190 * 216 *
191 *
192 * @NL80211_ATTR_MNTR_FLAGS: flags, nested element with NLA_FLAG attributes of 217 * @NL80211_ATTR_MNTR_FLAGS: flags, nested element with NLA_FLAG attributes of
193 * &enum nl80211_mntr_flags. 218 * &enum nl80211_mntr_flags.
194 * 219 *
220 * @NL80211_ATTR_REG_ALPHA2: an ISO-3166-alpha2 country code for which the
221 * current regulatory domain should be set to or is already set to.
222 * For example, 'CR', for Costa Rica. This attribute is used by the kernel
223 * to query the CRDA to retrieve one regulatory domain. This attribute can
224 * also be used by userspace to query the kernel for the currently set
225 * regulatory domain. We chose an alpha2 as that is also used by the
226 * IEEE-802.11d country information element to identify a country.
227 * Users can also simply ask the wireless core to set regulatory domain
228 * to a specific alpha2.
229 * @NL80211_ATTR_REG_RULES: a nested array of regulatory domain regulatory
230 * rules.
231 *
232 * @NL80211_ATTR_BSS_CTS_PROT: whether CTS protection is enabled (u8, 0 or 1)
233 * @NL80211_ATTR_BSS_SHORT_PREAMBLE: whether short preamble is enabled
234 * (u8, 0 or 1)
235 * @NL80211_ATTR_BSS_SHORT_SLOT_TIME: whether short slot time enabled
236 * (u8, 0 or 1)
237 *
238 * @NL80211_ATTR_HT_CAPABILITY: HT Capability information element (from
239 * association request when used with NL80211_CMD_NEW_STATION)
240 *
241 * @NL80211_ATTR_SUPPORTED_IFTYPES: nested attribute containing all
242 * supported interface types, each a flag attribute with the number
243 * of the interface mode.
244 *
195 * @NL80211_ATTR_MAX: highest attribute number currently defined 245 * @NL80211_ATTR_MAX: highest attribute number currently defined
196 * @__NL80211_ATTR_AFTER_LAST: internal use 246 * @__NL80211_ATTR_AFTER_LAST: internal use
197 */ 247 */
@@ -230,18 +280,40 @@ enum nl80211_attrs {
230 280
231 NL80211_ATTR_MNTR_FLAGS, 281 NL80211_ATTR_MNTR_FLAGS,
232 282
233 /* add attributes here, update the policy in nl80211.c */
234
235 NL80211_ATTR_MESH_ID, 283 NL80211_ATTR_MESH_ID,
236 NL80211_ATTR_STA_PLINK_ACTION, 284 NL80211_ATTR_STA_PLINK_ACTION,
237 NL80211_ATTR_MPATH_NEXT_HOP, 285 NL80211_ATTR_MPATH_NEXT_HOP,
238 NL80211_ATTR_MPATH_INFO, 286 NL80211_ATTR_MPATH_INFO,
239 287
288 NL80211_ATTR_BSS_CTS_PROT,
289 NL80211_ATTR_BSS_SHORT_PREAMBLE,
290 NL80211_ATTR_BSS_SHORT_SLOT_TIME,
291
292 NL80211_ATTR_HT_CAPABILITY,
293
294 NL80211_ATTR_SUPPORTED_IFTYPES,
295
296 NL80211_ATTR_REG_ALPHA2,
297 NL80211_ATTR_REG_RULES,
298
299 /* add attributes here, update the policy in nl80211.c */
300
240 __NL80211_ATTR_AFTER_LAST, 301 __NL80211_ATTR_AFTER_LAST,
241 NL80211_ATTR_MAX = __NL80211_ATTR_AFTER_LAST - 1 302 NL80211_ATTR_MAX = __NL80211_ATTR_AFTER_LAST - 1
242}; 303};
243 304
244#define NL80211_MAX_SUPP_RATES 32 305/*
306 * Allow user space programs to use #ifdef on new attributes by defining them
307 * here
308 */
309#define NL80211_ATTR_HT_CAPABILITY NL80211_ATTR_HT_CAPABILITY
310
311#define NL80211_MAX_SUPP_RATES 32
312#define NL80211_MAX_SUPP_REG_RULES 32
313#define NL80211_TKIP_DATA_OFFSET_ENCR_KEY 0
314#define NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY 16
315#define NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY 24
316#define NL80211_HT_CAPABILITY_LEN 26
245 317
246/** 318/**
247 * enum nl80211_iftype - (virtual) interface types 319 * enum nl80211_iftype - (virtual) interface types
@@ -433,6 +505,66 @@ enum nl80211_bitrate_attr {
433}; 505};
434 506
435/** 507/**
508 * enum nl80211_reg_rule_attr - regulatory rule attributes
509 * @NL80211_ATTR_REG_RULE_FLAGS: a set of flags which specify additional
510 * considerations for a given frequency range. These are the
511 * &enum nl80211_reg_rule_flags.
512 * @NL80211_ATTR_FREQ_RANGE_START: starting frequencry for the regulatory
513 * rule in KHz. This is not a center of frequency but an actual regulatory
514 * band edge.
515 * @NL80211_ATTR_FREQ_RANGE_END: ending frequency for the regulatory rule
516 * in KHz. This is not a center a frequency but an actual regulatory
517 * band edge.
518 * @NL80211_ATTR_FREQ_RANGE_MAX_BW: maximum allowed bandwidth for this
519 * frequency range, in KHz.
520 * @NL80211_ATTR_POWER_RULE_MAX_ANT_GAIN: the maximum allowed antenna gain
521 * for a given frequency range. The value is in mBi (100 * dBi).
522 * If you don't have one then don't send this.
523 * @NL80211_ATTR_POWER_RULE_MAX_EIRP: the maximum allowed EIRP for
524 * a given frequency range. The value is in mBm (100 * dBm).
525 */
526enum nl80211_reg_rule_attr {
527 __NL80211_REG_RULE_ATTR_INVALID,
528 NL80211_ATTR_REG_RULE_FLAGS,
529
530 NL80211_ATTR_FREQ_RANGE_START,
531 NL80211_ATTR_FREQ_RANGE_END,
532 NL80211_ATTR_FREQ_RANGE_MAX_BW,
533
534 NL80211_ATTR_POWER_RULE_MAX_ANT_GAIN,
535 NL80211_ATTR_POWER_RULE_MAX_EIRP,
536
537 /* keep last */
538 __NL80211_REG_RULE_ATTR_AFTER_LAST,
539 NL80211_REG_RULE_ATTR_MAX = __NL80211_REG_RULE_ATTR_AFTER_LAST - 1
540};
541
542/**
543 * enum nl80211_reg_rule_flags - regulatory rule flags
544 *
545 * @NL80211_RRF_NO_OFDM: OFDM modulation not allowed
546 * @NL80211_RRF_NO_CCK: CCK modulation not allowed
547 * @NL80211_RRF_NO_INDOOR: indoor operation not allowed
548 * @NL80211_RRF_NO_OUTDOOR: outdoor operation not allowed
549 * @NL80211_RRF_DFS: DFS support is required to be used
550 * @NL80211_RRF_PTP_ONLY: this is only for Point To Point links
551 * @NL80211_RRF_PTMP_ONLY: this is only for Point To Multi Point links
552 * @NL80211_RRF_PASSIVE_SCAN: passive scan is required
553 * @NL80211_RRF_NO_IBSS: no IBSS is allowed
554 */
555enum nl80211_reg_rule_flags {
556 NL80211_RRF_NO_OFDM = 1<<0,
557 NL80211_RRF_NO_CCK = 1<<1,
558 NL80211_RRF_NO_INDOOR = 1<<2,
559 NL80211_RRF_NO_OUTDOOR = 1<<3,
560 NL80211_RRF_DFS = 1<<4,
561 NL80211_RRF_PTP_ONLY = 1<<5,
562 NL80211_RRF_PTMP_ONLY = 1<<6,
563 NL80211_RRF_PASSIVE_SCAN = 1<<7,
564 NL80211_RRF_NO_IBSS = 1<<8,
565};
566
567/**
436 * enum nl80211_mntr_flags - monitor configuration flags 568 * enum nl80211_mntr_flags - monitor configuration flags
437 * 569 *
438 * Monitor configuration flags. 570 * Monitor configuration flags.
diff --git a/include/linux/notifier.h b/include/linux/notifier.h
index 0ff6224d172a..b86fa2ffca0c 100644
--- a/include/linux/notifier.h
+++ b/include/linux/notifier.h
@@ -197,6 +197,7 @@ static inline int notifier_to_errno(int ret)
197#define NETDEV_GOING_DOWN 0x0009 197#define NETDEV_GOING_DOWN 0x0009
198#define NETDEV_CHANGENAME 0x000A 198#define NETDEV_CHANGENAME 0x000A
199#define NETDEV_FEAT_CHANGE 0x000B 199#define NETDEV_FEAT_CHANGE 0x000B
200#define NETDEV_BONDING_FAILOVER 0x000C
200 201
201#define SYS_DOWN 0x0001 /* Notify of system down */ 202#define SYS_DOWN 0x0001 /* Notify of system down */
202#define SYS_RESTART SYS_DOWN 203#define SYS_RESTART SYS_DOWN
@@ -212,7 +213,16 @@ static inline int notifier_to_errno(int ret)
212#define CPU_DOWN_FAILED 0x0006 /* CPU (unsigned)v NOT going down */ 213#define CPU_DOWN_FAILED 0x0006 /* CPU (unsigned)v NOT going down */
213#define CPU_DEAD 0x0007 /* CPU (unsigned)v dead */ 214#define CPU_DEAD 0x0007 /* CPU (unsigned)v dead */
214#define CPU_DYING 0x0008 /* CPU (unsigned)v not running any task, 215#define CPU_DYING 0x0008 /* CPU (unsigned)v not running any task,
215 * not handling interrupts, soon dead */ 216 * not handling interrupts, soon dead.
217 * Called on the dying cpu, interrupts
218 * are already disabled. Must not
219 * sleep, must not fail */
220#define CPU_POST_DEAD 0x0009 /* CPU (unsigned)v dead, cpu_hotplug
221 * lock is dropped */
222#define CPU_STARTING 0x000A /* CPU (unsigned)v soon running.
223 * Called on the new cpu, just before
224 * enabling interrupts. Must not sleep,
225 * must not fail */
216 226
217/* Used for CPU hotplug events occuring while tasks are frozen due to a suspend 227/* Used for CPU hotplug events occuring while tasks are frozen due to a suspend
218 * operation in progress 228 * operation in progress
@@ -226,6 +236,7 @@ static inline int notifier_to_errno(int ret)
226#define CPU_DOWN_FAILED_FROZEN (CPU_DOWN_FAILED | CPU_TASKS_FROZEN) 236#define CPU_DOWN_FAILED_FROZEN (CPU_DOWN_FAILED | CPU_TASKS_FROZEN)
227#define CPU_DEAD_FROZEN (CPU_DEAD | CPU_TASKS_FROZEN) 237#define CPU_DEAD_FROZEN (CPU_DEAD | CPU_TASKS_FROZEN)
228#define CPU_DYING_FROZEN (CPU_DYING | CPU_TASKS_FROZEN) 238#define CPU_DYING_FROZEN (CPU_DYING | CPU_TASKS_FROZEN)
239#define CPU_STARTING_FROZEN (CPU_STARTING | CPU_TASKS_FROZEN)
229 240
230/* Hibernation and suspend events */ 241/* Hibernation and suspend events */
231#define PM_HIBERNATION_PREPARE 0x0001 /* Going to hibernate */ 242#define PM_HIBERNATION_PREPARE 0x0001 /* Going to hibernate */
diff --git a/include/linux/nsproxy.h b/include/linux/nsproxy.h
index 0e66b57631fc..c8a768e59640 100644
--- a/include/linux/nsproxy.h
+++ b/include/linux/nsproxy.h
@@ -82,9 +82,12 @@ static inline void get_nsproxy(struct nsproxy *ns)
82} 82}
83 83
84#ifdef CONFIG_CGROUP_NS 84#ifdef CONFIG_CGROUP_NS
85int ns_cgroup_clone(struct task_struct *tsk); 85int ns_cgroup_clone(struct task_struct *tsk, struct pid *pid);
86#else 86#else
87static inline int ns_cgroup_clone(struct task_struct *tsk) { return 0; } 87static inline int ns_cgroup_clone(struct task_struct *tsk, struct pid *pid)
88{
89 return 0;
90}
88#endif 91#endif
89 92
90#endif 93#endif
diff --git a/include/linux/of.h b/include/linux/of.h
index 59a61bdc98b6..e2488f5e7cb2 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -70,5 +70,9 @@ extern int of_n_addr_cells(struct device_node *np);
70extern int of_n_size_cells(struct device_node *np); 70extern int of_n_size_cells(struct device_node *np);
71extern const struct of_device_id *of_match_node( 71extern const struct of_device_id *of_match_node(
72 const struct of_device_id *matches, const struct device_node *node); 72 const struct of_device_id *matches, const struct device_node *node);
73extern int of_modalias_node(struct device_node *node, char *modalias, int len);
74extern int of_parse_phandles_with_args(struct device_node *np,
75 const char *list_name, const char *cells_name, int index,
76 struct device_node **out_node, const void **out_args);
73 77
74#endif /* _LINUX_OF_H */ 78#endif /* _LINUX_OF_H */
diff --git a/include/linux/of_gpio.h b/include/linux/of_gpio.h
index 2ee97e9877a7..67db101d0eb8 100644
--- a/include/linux/of_gpio.h
+++ b/include/linux/of_gpio.h
@@ -15,7 +15,7 @@
15#define __LINUX_OF_GPIO_H 15#define __LINUX_OF_GPIO_H
16 16
17#include <linux/errno.h> 17#include <linux/errno.h>
18#include <asm/gpio.h> 18#include <linux/gpio.h>
19 19
20#ifdef CONFIG_OF_GPIO 20#ifdef CONFIG_OF_GPIO
21 21
diff --git a/include/linux/of_spi.h b/include/linux/of_spi.h
new file mode 100644
index 000000000000..5f71ee8c0868
--- /dev/null
+++ b/include/linux/of_spi.h
@@ -0,0 +1,18 @@
1/*
2 * OpenFirmware SPI support routines
3 * Copyright (C) 2008 Secret Lab Technologies Ltd.
4 *
5 * Support routines for deriving SPI device attachments from the device
6 * tree.
7 */
8
9#ifndef __LINUX_OF_SPI_H
10#define __LINUX_OF_SPI_H
11
12#include <linux/of.h>
13#include <linux/spi/spi.h>
14
15extern void of_register_spi_devices(struct spi_master *master,
16 struct device_node *np);
17
18#endif /* __LINUX_OF_SPI */
diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
index 041bb31100f4..5231861f357d 100644
--- a/include/linux/oprofile.h
+++ b/include/linux/oprofile.h
@@ -36,6 +36,8 @@
36#define XEN_ENTER_SWITCH_CODE 10 36#define XEN_ENTER_SWITCH_CODE 10
37#define SPU_PROFILING_CODE 11 37#define SPU_PROFILING_CODE 11
38#define SPU_CTX_SWITCH_CODE 12 38#define SPU_CTX_SWITCH_CODE 12
39#define IBS_FETCH_CODE 13
40#define IBS_OP_CODE 14
39 41
40struct super_block; 42struct super_block;
41struct dentry; 43struct dentry;
@@ -84,13 +86,6 @@ int oprofile_arch_init(struct oprofile_operations * ops);
84void oprofile_arch_exit(void); 86void oprofile_arch_exit(void);
85 87
86/** 88/**
87 * Add data to the event buffer.
88 * The data passed is free-form, but typically consists of
89 * file offsets, dcookies, context information, and ESCAPE codes.
90 */
91void add_event_entry(unsigned long data);
92
93/**
94 * Add a sample. This may be called from any context. Pass 89 * Add a sample. This may be called from any context. Pass
95 * smp_processor_id() as cpu. 90 * smp_processor_id() as cpu.
96 */ 91 */
@@ -160,5 +155,14 @@ int oprofilefs_ulong_from_user(unsigned long * val, char const __user * buf, siz
160 155
161/** lock for read/write safety */ 156/** lock for read/write safety */
162extern spinlock_t oprofilefs_lock; 157extern spinlock_t oprofilefs_lock;
158
159/**
160 * Add the contents of a circular buffer to the event buffer.
161 */
162void oprofile_put_buff(unsigned long *buf, unsigned int start,
163 unsigned int stop, unsigned int max);
164
165unsigned long oprofile_get_cpu_buffer_size(void);
166void oprofile_cpu_buffer_inc_smpl_lost(void);
163 167
164#endif /* OPROFILE_H */ 168#endif /* OPROFILE_H */
diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index 0d2a4e7012aa..b12f93a3c345 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -93,10 +93,30 @@ enum pageflags {
93 PG_mappedtodisk, /* Has blocks allocated on-disk */ 93 PG_mappedtodisk, /* Has blocks allocated on-disk */
94 PG_reclaim, /* To be reclaimed asap */ 94 PG_reclaim, /* To be reclaimed asap */
95 PG_buddy, /* Page is free, on buddy lists */ 95 PG_buddy, /* Page is free, on buddy lists */
96 PG_swapbacked, /* Page is backed by RAM/swap */
97#ifdef CONFIG_UNEVICTABLE_LRU
98 PG_unevictable, /* Page is "unevictable" */
99 PG_mlocked, /* Page is vma mlocked */
100#endif
96#ifdef CONFIG_IA64_UNCACHED_ALLOCATOR 101#ifdef CONFIG_IA64_UNCACHED_ALLOCATOR
97 PG_uncached, /* Page has been mapped as uncached */ 102 PG_uncached, /* Page has been mapped as uncached */
98#endif 103#endif
99 __NR_PAGEFLAGS 104 __NR_PAGEFLAGS,
105
106 /* Filesystems */
107 PG_checked = PG_owner_priv_1,
108
109 /* XEN */
110 PG_pinned = PG_owner_priv_1,
111 PG_savepinned = PG_dirty,
112
113 /* SLOB */
114 PG_slob_page = PG_active,
115 PG_slob_free = PG_private,
116
117 /* SLUB */
118 PG_slub_frozen = PG_active,
119 PG_slub_debug = PG_error,
100}; 120};
101 121
102#ifndef __GENERATING_BOUNDS_H 122#ifndef __GENERATING_BOUNDS_H
@@ -146,21 +166,41 @@ static inline int Page##uname(struct page *page) \
146#define TESTSCFLAG(uname, lname) \ 166#define TESTSCFLAG(uname, lname) \
147 TESTSETFLAG(uname, lname) TESTCLEARFLAG(uname, lname) 167 TESTSETFLAG(uname, lname) TESTCLEARFLAG(uname, lname)
148 168
169#define SETPAGEFLAG_NOOP(uname) \
170static inline void SetPage##uname(struct page *page) { }
171
172#define CLEARPAGEFLAG_NOOP(uname) \
173static inline void ClearPage##uname(struct page *page) { }
174
175#define __CLEARPAGEFLAG_NOOP(uname) \
176static inline void __ClearPage##uname(struct page *page) { }
177
178#define TESTCLEARFLAG_FALSE(uname) \
179static inline int TestClearPage##uname(struct page *page) { return 0; }
180
149struct page; /* forward declaration */ 181struct page; /* forward declaration */
150 182
151PAGEFLAG(Locked, locked) TESTSCFLAG(Locked, locked) 183TESTPAGEFLAG(Locked, locked)
152PAGEFLAG(Error, error) 184PAGEFLAG(Error, error)
153PAGEFLAG(Referenced, referenced) TESTCLEARFLAG(Referenced, referenced) 185PAGEFLAG(Referenced, referenced) TESTCLEARFLAG(Referenced, referenced)
154PAGEFLAG(Dirty, dirty) TESTSCFLAG(Dirty, dirty) __CLEARPAGEFLAG(Dirty, dirty) 186PAGEFLAG(Dirty, dirty) TESTSCFLAG(Dirty, dirty) __CLEARPAGEFLAG(Dirty, dirty)
155PAGEFLAG(LRU, lru) __CLEARPAGEFLAG(LRU, lru) 187PAGEFLAG(LRU, lru) __CLEARPAGEFLAG(LRU, lru)
156PAGEFLAG(Active, active) __CLEARPAGEFLAG(Active, active) 188PAGEFLAG(Active, active) __CLEARPAGEFLAG(Active, active)
189 TESTCLEARFLAG(Active, active)
157__PAGEFLAG(Slab, slab) 190__PAGEFLAG(Slab, slab)
158PAGEFLAG(Checked, owner_priv_1) /* Used by some filesystems */ 191PAGEFLAG(Checked, checked) /* Used by some filesystems */
159PAGEFLAG(Pinned, owner_priv_1) TESTSCFLAG(Pinned, owner_priv_1) /* Xen */ 192PAGEFLAG(Pinned, pinned) TESTSCFLAG(Pinned, pinned) /* Xen */
160PAGEFLAG(SavePinned, dirty); /* Xen */ 193PAGEFLAG(SavePinned, savepinned); /* Xen */
161PAGEFLAG(Reserved, reserved) __CLEARPAGEFLAG(Reserved, reserved) 194PAGEFLAG(Reserved, reserved) __CLEARPAGEFLAG(Reserved, reserved)
162PAGEFLAG(Private, private) __CLEARPAGEFLAG(Private, private) 195PAGEFLAG(Private, private) __CLEARPAGEFLAG(Private, private)
163 __SETPAGEFLAG(Private, private) 196 __SETPAGEFLAG(Private, private)
197PAGEFLAG(SwapBacked, swapbacked) __CLEARPAGEFLAG(SwapBacked, swapbacked)
198
199__PAGEFLAG(SlobPage, slob_page)
200__PAGEFLAG(SlobFree, slob_free)
201
202__PAGEFLAG(SlubFrozen, slub_frozen)
203__PAGEFLAG(SlubDebug, slub_debug)
164 204
165/* 205/*
166 * Only test-and-set exist for PG_writeback. The unconditional operators are 206 * Only test-and-set exist for PG_writeback. The unconditional operators are
@@ -190,6 +230,25 @@ PAGEFLAG(SwapCache, swapcache)
190PAGEFLAG_FALSE(SwapCache) 230PAGEFLAG_FALSE(SwapCache)
191#endif 231#endif
192 232
233#ifdef CONFIG_UNEVICTABLE_LRU
234PAGEFLAG(Unevictable, unevictable) __CLEARPAGEFLAG(Unevictable, unevictable)
235 TESTCLEARFLAG(Unevictable, unevictable)
236
237#define MLOCK_PAGES 1
238PAGEFLAG(Mlocked, mlocked) __CLEARPAGEFLAG(Mlocked, mlocked)
239 TESTSCFLAG(Mlocked, mlocked)
240
241#else
242
243#define MLOCK_PAGES 0
244PAGEFLAG_FALSE(Mlocked)
245 SETPAGEFLAG_NOOP(Mlocked) TESTCLEARFLAG_FALSE(Mlocked)
246
247PAGEFLAG_FALSE(Unevictable) TESTCLEARFLAG_FALSE(Unevictable)
248 SETPAGEFLAG_NOOP(Unevictable) CLEARPAGEFLAG_NOOP(Unevictable)
249 __CLEARPAGEFLAG_NOOP(Unevictable)
250#endif
251
193#ifdef CONFIG_IA64_UNCACHED_ALLOCATOR 252#ifdef CONFIG_IA64_UNCACHED_ALLOCATOR
194PAGEFLAG(Uncached, uncached) 253PAGEFLAG(Uncached, uncached)
195#else 254#else
@@ -218,9 +277,6 @@ static inline void __SetPageUptodate(struct page *page)
218{ 277{
219 smp_wmb(); 278 smp_wmb();
220 __set_bit(PG_uptodate, &(page)->flags); 279 __set_bit(PG_uptodate, &(page)->flags);
221#ifdef CONFIG_S390
222 page_clear_dirty(page);
223#endif
224} 280}
225 281
226static inline void SetPageUptodate(struct page *page) 282static inline void SetPageUptodate(struct page *page)
@@ -308,15 +364,25 @@ static inline void __ClearPageTail(struct page *page)
308 364
309#endif /* !PAGEFLAGS_EXTENDED */ 365#endif /* !PAGEFLAGS_EXTENDED */
310 366
367#ifdef CONFIG_UNEVICTABLE_LRU
368#define __PG_UNEVICTABLE (1 << PG_unevictable)
369#define __PG_MLOCKED (1 << PG_mlocked)
370#else
371#define __PG_UNEVICTABLE 0
372#define __PG_MLOCKED 0
373#endif
374
311#define PAGE_FLAGS (1 << PG_lru | 1 << PG_private | 1 << PG_locked | \ 375#define PAGE_FLAGS (1 << PG_lru | 1 << PG_private | 1 << PG_locked | \
312 1 << PG_buddy | 1 << PG_writeback | \ 376 1 << PG_buddy | 1 << PG_writeback | \
313 1 << PG_slab | 1 << PG_swapcache | 1 << PG_active) 377 1 << PG_slab | 1 << PG_swapcache | 1 << PG_active | \
378 __PG_UNEVICTABLE | __PG_MLOCKED)
314 379
315/* 380/*
316 * Flags checked in bad_page(). Pages on the free list should not have 381 * Flags checked in bad_page(). Pages on the free list should not have
317 * these flags set. It they are, there is a problem. 382 * these flags set. It they are, there is a problem.
318 */ 383 */
319#define PAGE_FLAGS_CLEAR_WHEN_BAD (PAGE_FLAGS | 1 << PG_reclaim | 1 << PG_dirty) 384#define PAGE_FLAGS_CLEAR_WHEN_BAD (PAGE_FLAGS | \
385 1 << PG_reclaim | 1 << PG_dirty | 1 << PG_swapbacked)
320 386
321/* 387/*
322 * Flags checked when a page is freed. Pages being freed should not have 388 * Flags checked when a page is freed. Pages being freed should not have
@@ -329,7 +395,8 @@ static inline void __ClearPageTail(struct page *page)
329 * Pages being prepped should not have these flags set. It they are, there 395 * Pages being prepped should not have these flags set. It they are, there
330 * is a problem. 396 * is a problem.
331 */ 397 */
332#define PAGE_FLAGS_CHECK_AT_PREP (PAGE_FLAGS | 1 << PG_reserved | 1 << PG_dirty) 398#define PAGE_FLAGS_CHECK_AT_PREP (PAGE_FLAGS | \
399 1 << PG_reserved | 1 << PG_dirty | 1 << PG_swapbacked)
333 400
334#endif /* !__GENERATING_BOUNDS_H */ 401#endif /* !__GENERATING_BOUNDS_H */
335#endif /* PAGE_FLAGS_H */ 402#endif /* PAGE_FLAGS_H */
diff --git a/include/linux/page_cgroup.h b/include/linux/page_cgroup.h
new file mode 100644
index 000000000000..f546ad6fc028
--- /dev/null
+++ b/include/linux/page_cgroup.h
@@ -0,0 +1,108 @@
1#ifndef __LINUX_PAGE_CGROUP_H
2#define __LINUX_PAGE_CGROUP_H
3
4#ifdef CONFIG_CGROUP_MEM_RES_CTLR
5#include <linux/bit_spinlock.h>
6/*
7 * Page Cgroup can be considered as an extended mem_map.
8 * A page_cgroup page is associated with every page descriptor. The
9 * page_cgroup helps us identify information about the cgroup
10 * All page cgroups are allocated at boot or memory hotplug event,
11 * then the page cgroup for pfn always exists.
12 */
13struct page_cgroup {
14 unsigned long flags;
15 struct mem_cgroup *mem_cgroup;
16 struct page *page;
17 struct list_head lru; /* per cgroup LRU list */
18};
19
20void __init pgdat_page_cgroup_init(struct pglist_data *pgdat);
21void __init page_cgroup_init(void);
22struct page_cgroup *lookup_page_cgroup(struct page *page);
23
24enum {
25 /* flags for mem_cgroup */
26 PCG_LOCK, /* page cgroup is locked */
27 PCG_CACHE, /* charged as cache */
28 PCG_USED, /* this object is in use. */
29 /* flags for LRU placement */
30 PCG_ACTIVE, /* page is active in this cgroup */
31 PCG_FILE, /* page is file system backed */
32 PCG_UNEVICTABLE, /* page is unevictableable */
33};
34
35#define TESTPCGFLAG(uname, lname) \
36static inline int PageCgroup##uname(struct page_cgroup *pc) \
37 { return test_bit(PCG_##lname, &pc->flags); }
38
39#define SETPCGFLAG(uname, lname) \
40static inline void SetPageCgroup##uname(struct page_cgroup *pc)\
41 { set_bit(PCG_##lname, &pc->flags); }
42
43#define CLEARPCGFLAG(uname, lname) \
44static inline void ClearPageCgroup##uname(struct page_cgroup *pc) \
45 { clear_bit(PCG_##lname, &pc->flags); }
46
47/* Cache flag is set only once (at allocation) */
48TESTPCGFLAG(Cache, CACHE)
49
50TESTPCGFLAG(Used, USED)
51CLEARPCGFLAG(Used, USED)
52
53/* LRU management flags (from global-lru definition) */
54TESTPCGFLAG(File, FILE)
55SETPCGFLAG(File, FILE)
56CLEARPCGFLAG(File, FILE)
57
58TESTPCGFLAG(Active, ACTIVE)
59SETPCGFLAG(Active, ACTIVE)
60CLEARPCGFLAG(Active, ACTIVE)
61
62TESTPCGFLAG(Unevictable, UNEVICTABLE)
63SETPCGFLAG(Unevictable, UNEVICTABLE)
64CLEARPCGFLAG(Unevictable, UNEVICTABLE)
65
66static inline int page_cgroup_nid(struct page_cgroup *pc)
67{
68 return page_to_nid(pc->page);
69}
70
71static inline enum zone_type page_cgroup_zid(struct page_cgroup *pc)
72{
73 return page_zonenum(pc->page);
74}
75
76static inline void lock_page_cgroup(struct page_cgroup *pc)
77{
78 bit_spin_lock(PCG_LOCK, &pc->flags);
79}
80
81static inline int trylock_page_cgroup(struct page_cgroup *pc)
82{
83 return bit_spin_trylock(PCG_LOCK, &pc->flags);
84}
85
86static inline void unlock_page_cgroup(struct page_cgroup *pc)
87{
88 bit_spin_unlock(PCG_LOCK, &pc->flags);
89}
90
91#else /* CONFIG_CGROUP_MEM_RES_CTLR */
92struct page_cgroup;
93
94static inline void pgdat_page_cgroup_init(struct pglist_data *pgdat)
95{
96}
97
98static inline struct page_cgroup *lookup_page_cgroup(struct page *page)
99{
100 return NULL;
101}
102
103static inline void page_cgroup_init(void)
104{
105}
106
107#endif
108#endif
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index d2fca802f809..709742be02f0 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -12,6 +12,7 @@
12#include <asm/uaccess.h> 12#include <asm/uaccess.h>
13#include <linux/gfp.h> 13#include <linux/gfp.h>
14#include <linux/bitops.h> 14#include <linux/bitops.h>
15#include <linux/hardirq.h> /* for in_interrupt() */
15 16
16/* 17/*
17 * Bits in mapping->flags. The lower __GFP_BITS_SHIFT bits are the page 18 * Bits in mapping->flags. The lower __GFP_BITS_SHIFT bits are the page
@@ -19,10 +20,11 @@
19 */ 20 */
20#define AS_EIO (__GFP_BITS_SHIFT + 0) /* IO error on async write */ 21#define AS_EIO (__GFP_BITS_SHIFT + 0) /* IO error on async write */
21#define AS_ENOSPC (__GFP_BITS_SHIFT + 1) /* ENOSPC on async write */ 22#define AS_ENOSPC (__GFP_BITS_SHIFT + 1) /* ENOSPC on async write */
23#define AS_MM_ALL_LOCKS (__GFP_BITS_SHIFT + 2) /* under mm_take_all_locks() */
22 24
23static inline void mapping_set_error(struct address_space *mapping, int error) 25static inline void mapping_set_error(struct address_space *mapping, int error)
24{ 26{
25 if (error) { 27 if (unlikely(error)) {
26 if (error == -ENOSPC) 28 if (error == -ENOSPC)
27 set_bit(AS_ENOSPC, &mapping->flags); 29 set_bit(AS_ENOSPC, &mapping->flags);
28 else 30 else
@@ -30,6 +32,34 @@ static inline void mapping_set_error(struct address_space *mapping, int error)
30 } 32 }
31} 33}
32 34
35#ifdef CONFIG_UNEVICTABLE_LRU
36#define AS_UNEVICTABLE (__GFP_BITS_SHIFT + 2) /* e.g., ramdisk, SHM_LOCK */
37
38static inline void mapping_set_unevictable(struct address_space *mapping)
39{
40 set_bit(AS_UNEVICTABLE, &mapping->flags);
41}
42
43static inline void mapping_clear_unevictable(struct address_space *mapping)
44{
45 clear_bit(AS_UNEVICTABLE, &mapping->flags);
46}
47
48static inline int mapping_unevictable(struct address_space *mapping)
49{
50 if (likely(mapping))
51 return test_bit(AS_UNEVICTABLE, &mapping->flags);
52 return !!mapping;
53}
54#else
55static inline void mapping_set_unevictable(struct address_space *mapping) { }
56static inline void mapping_clear_unevictable(struct address_space *mapping) { }
57static inline int mapping_unevictable(struct address_space *mapping)
58{
59 return 0;
60}
61#endif
62
33static inline gfp_t mapping_gfp_mask(struct address_space * mapping) 63static inline gfp_t mapping_gfp_mask(struct address_space * mapping)
34{ 64{
35 return (__force gfp_t)mapping->flags & __GFP_BITS_MASK; 65 return (__force gfp_t)mapping->flags & __GFP_BITS_MASK;
@@ -62,6 +92,121 @@ static inline void mapping_set_gfp_mask(struct address_space *m, gfp_t mask)
62#define page_cache_release(page) put_page(page) 92#define page_cache_release(page) put_page(page)
63void release_pages(struct page **pages, int nr, int cold); 93void release_pages(struct page **pages, int nr, int cold);
64 94
95/*
96 * speculatively take a reference to a page.
97 * If the page is free (_count == 0), then _count is untouched, and 0
98 * is returned. Otherwise, _count is incremented by 1 and 1 is returned.
99 *
100 * This function must be called inside the same rcu_read_lock() section as has
101 * been used to lookup the page in the pagecache radix-tree (or page table):
102 * this allows allocators to use a synchronize_rcu() to stabilize _count.
103 *
104 * Unless an RCU grace period has passed, the count of all pages coming out
105 * of the allocator must be considered unstable. page_count may return higher
106 * than expected, and put_page must be able to do the right thing when the
107 * page has been finished with, no matter what it is subsequently allocated
108 * for (because put_page is what is used here to drop an invalid speculative
109 * reference).
110 *
111 * This is the interesting part of the lockless pagecache (and lockless
112 * get_user_pages) locking protocol, where the lookup-side (eg. find_get_page)
113 * has the following pattern:
114 * 1. find page in radix tree
115 * 2. conditionally increment refcount
116 * 3. check the page is still in pagecache (if no, goto 1)
117 *
118 * Remove-side that cares about stability of _count (eg. reclaim) has the
119 * following (with tree_lock held for write):
120 * A. atomically check refcount is correct and set it to 0 (atomic_cmpxchg)
121 * B. remove page from pagecache
122 * C. free the page
123 *
124 * There are 2 critical interleavings that matter:
125 * - 2 runs before A: in this case, A sees elevated refcount and bails out
126 * - A runs before 2: in this case, 2 sees zero refcount and retries;
127 * subsequently, B will complete and 1 will find no page, causing the
128 * lookup to return NULL.
129 *
130 * It is possible that between 1 and 2, the page is removed then the exact same
131 * page is inserted into the same position in pagecache. That's OK: the
132 * old find_get_page using tree_lock could equally have run before or after
133 * such a re-insertion, depending on order that locks are granted.
134 *
135 * Lookups racing against pagecache insertion isn't a big problem: either 1
136 * will find the page or it will not. Likewise, the old find_get_page could run
137 * either before the insertion or afterwards, depending on timing.
138 */
139static inline int page_cache_get_speculative(struct page *page)
140{
141 VM_BUG_ON(in_interrupt());
142
143#if !defined(CONFIG_SMP) && defined(CONFIG_CLASSIC_RCU)
144# ifdef CONFIG_PREEMPT
145 VM_BUG_ON(!in_atomic());
146# endif
147 /*
148 * Preempt must be disabled here - we rely on rcu_read_lock doing
149 * this for us.
150 *
151 * Pagecache won't be truncated from interrupt context, so if we have
152 * found a page in the radix tree here, we have pinned its refcount by
153 * disabling preempt, and hence no need for the "speculative get" that
154 * SMP requires.
155 */
156 VM_BUG_ON(page_count(page) == 0);
157 atomic_inc(&page->_count);
158
159#else
160 if (unlikely(!get_page_unless_zero(page))) {
161 /*
162 * Either the page has been freed, or will be freed.
163 * In either case, retry here and the caller should
164 * do the right thing (see comments above).
165 */
166 return 0;
167 }
168#endif
169 VM_BUG_ON(PageTail(page));
170
171 return 1;
172}
173
174/*
175 * Same as above, but add instead of inc (could just be merged)
176 */
177static inline int page_cache_add_speculative(struct page *page, int count)
178{
179 VM_BUG_ON(in_interrupt());
180
181#if !defined(CONFIG_SMP) && defined(CONFIG_CLASSIC_RCU)
182# ifdef CONFIG_PREEMPT
183 VM_BUG_ON(!in_atomic());
184# endif
185 VM_BUG_ON(page_count(page) == 0);
186 atomic_add(count, &page->_count);
187
188#else
189 if (unlikely(!atomic_add_unless(&page->_count, count, 0)))
190 return 0;
191#endif
192 VM_BUG_ON(PageCompound(page) && page != compound_head(page));
193
194 return 1;
195}
196
197static inline int page_freeze_refs(struct page *page, int count)
198{
199 return likely(atomic_cmpxchg(&page->_count, count, 0) == count);
200}
201
202static inline void page_unfreeze_refs(struct page *page, int count)
203{
204 VM_BUG_ON(page_count(page) != 0);
205 VM_BUG_ON(count == 0);
206
207 atomic_set(&page->_count, count);
208}
209
65#ifdef CONFIG_NUMA 210#ifdef CONFIG_NUMA
66extern struct page *__page_cache_alloc(gfp_t gfp); 211extern struct page *__page_cache_alloc(gfp_t gfp);
67#else 212#else
@@ -133,13 +278,6 @@ static inline struct page *read_mapping_page(struct address_space *mapping,
133 return read_cache_page(mapping, index, filler, data); 278 return read_cache_page(mapping, index, filler, data);
134} 279}
135 280
136int add_to_page_cache(struct page *page, struct address_space *mapping,
137 pgoff_t index, gfp_t gfp_mask);
138int add_to_page_cache_lru(struct page *page, struct address_space *mapping,
139 pgoff_t index, gfp_t gfp_mask);
140extern void remove_from_page_cache(struct page *page);
141extern void __remove_from_page_cache(struct page *page);
142
143/* 281/*
144 * Return byte-offset into filesystem object for page. 282 * Return byte-offset into filesystem object for page.
145 */ 283 */
@@ -161,13 +299,28 @@ extern int __lock_page_killable(struct page *page);
161extern void __lock_page_nosync(struct page *page); 299extern void __lock_page_nosync(struct page *page);
162extern void unlock_page(struct page *page); 300extern void unlock_page(struct page *page);
163 301
302static inline void __set_page_locked(struct page *page)
303{
304 __set_bit(PG_locked, &page->flags);
305}
306
307static inline void __clear_page_locked(struct page *page)
308{
309 __clear_bit(PG_locked, &page->flags);
310}
311
312static inline int trylock_page(struct page *page)
313{
314 return (likely(!test_and_set_bit_lock(PG_locked, &page->flags)));
315}
316
164/* 317/*
165 * lock_page may only be called if we have the page's inode pinned. 318 * lock_page may only be called if we have the page's inode pinned.
166 */ 319 */
167static inline void lock_page(struct page *page) 320static inline void lock_page(struct page *page)
168{ 321{
169 might_sleep(); 322 might_sleep();
170 if (TestSetPageLocked(page)) 323 if (!trylock_page(page))
171 __lock_page(page); 324 __lock_page(page);
172} 325}
173 326
@@ -179,7 +332,7 @@ static inline void lock_page(struct page *page)
179static inline int lock_page_killable(struct page *page) 332static inline int lock_page_killable(struct page *page)
180{ 333{
181 might_sleep(); 334 might_sleep();
182 if (TestSetPageLocked(page)) 335 if (!trylock_page(page))
183 return __lock_page_killable(page); 336 return __lock_page_killable(page);
184 return 0; 337 return 0;
185} 338}
@@ -191,7 +344,7 @@ static inline int lock_page_killable(struct page *page)
191static inline void lock_page_nosync(struct page *page) 344static inline void lock_page_nosync(struct page *page)
192{ 345{
193 might_sleep(); 346 might_sleep();
194 if (TestSetPageLocked(page)) 347 if (!trylock_page(page))
195 __lock_page_nosync(page); 348 __lock_page_nosync(page);
196} 349}
197 350
@@ -276,4 +429,27 @@ static inline int fault_in_pages_readable(const char __user *uaddr, int size)
276 return ret; 429 return ret;
277} 430}
278 431
432int add_to_page_cache_locked(struct page *page, struct address_space *mapping,
433 pgoff_t index, gfp_t gfp_mask);
434int add_to_page_cache_lru(struct page *page, struct address_space *mapping,
435 pgoff_t index, gfp_t gfp_mask);
436extern void remove_from_page_cache(struct page *page);
437extern void __remove_from_page_cache(struct page *page);
438
439/*
440 * Like add_to_page_cache_locked, but used to add newly allocated pages:
441 * the page is new, so we can just run __set_page_locked() against it.
442 */
443static inline int add_to_page_cache(struct page *page,
444 struct address_space *mapping, pgoff_t offset, gfp_t gfp_mask)
445{
446 int error;
447
448 __set_page_locked(page);
449 error = add_to_page_cache_locked(page, mapping, offset, gfp_mask);
450 if (unlikely(error))
451 __clear_page_locked(page);
452 return error;
453}
454
279#endif /* _LINUX_PAGEMAP_H */ 455#endif /* _LINUX_PAGEMAP_H */
diff --git a/include/linux/pagevec.h b/include/linux/pagevec.h
index 8eb7fa76c1d0..e90a2cb02915 100644
--- a/include/linux/pagevec.h
+++ b/include/linux/pagevec.h
@@ -23,9 +23,9 @@ struct pagevec {
23void __pagevec_release(struct pagevec *pvec); 23void __pagevec_release(struct pagevec *pvec);
24void __pagevec_release_nonlru(struct pagevec *pvec); 24void __pagevec_release_nonlru(struct pagevec *pvec);
25void __pagevec_free(struct pagevec *pvec); 25void __pagevec_free(struct pagevec *pvec);
26void __pagevec_lru_add(struct pagevec *pvec); 26void ____pagevec_lru_add(struct pagevec *pvec, enum lru_list lru);
27void __pagevec_lru_add_active(struct pagevec *pvec);
28void pagevec_strip(struct pagevec *pvec); 27void pagevec_strip(struct pagevec *pvec);
28void pagevec_swap_free(struct pagevec *pvec);
29unsigned pagevec_lookup(struct pagevec *pvec, struct address_space *mapping, 29unsigned pagevec_lookup(struct pagevec *pvec, struct address_space *mapping,
30 pgoff_t start, unsigned nr_pages); 30 pgoff_t start, unsigned nr_pages);
31unsigned pagevec_lookup_tag(struct pagevec *pvec, 31unsigned pagevec_lookup_tag(struct pagevec *pvec,
@@ -81,10 +81,36 @@ static inline void pagevec_free(struct pagevec *pvec)
81 __pagevec_free(pvec); 81 __pagevec_free(pvec);
82} 82}
83 83
84static inline void pagevec_lru_add(struct pagevec *pvec) 84static inline void __pagevec_lru_add_anon(struct pagevec *pvec)
85{
86 ____pagevec_lru_add(pvec, LRU_INACTIVE_ANON);
87}
88
89static inline void __pagevec_lru_add_active_anon(struct pagevec *pvec)
90{
91 ____pagevec_lru_add(pvec, LRU_ACTIVE_ANON);
92}
93
94static inline void __pagevec_lru_add_file(struct pagevec *pvec)
95{
96 ____pagevec_lru_add(pvec, LRU_INACTIVE_FILE);
97}
98
99static inline void __pagevec_lru_add_active_file(struct pagevec *pvec)
100{
101 ____pagevec_lru_add(pvec, LRU_ACTIVE_FILE);
102}
103
104static inline void pagevec_lru_add_file(struct pagevec *pvec)
105{
106 if (pagevec_count(pvec))
107 __pagevec_lru_add_file(pvec);
108}
109
110static inline void pagevec_lru_add_anon(struct pagevec *pvec)
85{ 111{
86 if (pagevec_count(pvec)) 112 if (pagevec_count(pvec))
87 __pagevec_lru_add(pvec); 113 __pagevec_lru_add_anon(pvec);
88} 114}
89 115
90#endif /* _LINUX_PAGEVEC_H */ 116#endif /* _LINUX_PAGEVEC_H */
diff --git a/include/linux/parport.h b/include/linux/parport.h
index dcb9e01a69ca..e1f83c5065c5 100644
--- a/include/linux/parport.h
+++ b/include/linux/parport.h
@@ -1,5 +1,3 @@
1/* $Id: parport.h,v 1.1 1998/05/17 10:57:52 andrea Exp andrea $ */
2
3/* 1/*
4 * Any part of this program may be used in documents licensed under 2 * Any part of this program may be used in documents licensed under
5 * the GNU Free Documentation License, Version 1.1 or any later version 3 * the GNU Free Documentation License, Version 1.1 or any later version
@@ -560,5 +558,8 @@ extern int parport_device_proc_unregister(struct pardevice *device);
560 558
561#endif /* !CONFIG_PARPORT_NOT_PC */ 559#endif /* !CONFIG_PARPORT_NOT_PC */
562 560
561extern unsigned long parport_default_timeslice;
562extern int parport_default_spintime;
563
563#endif /* __KERNEL__ */ 564#endif /* __KERNEL__ */
564#endif /* _PARPORT_H_ */ 565#endif /* _PARPORT_H_ */
diff --git a/include/linux/parser.h b/include/linux/parser.h
index 7dcd05075756..ea2281e726f6 100644
--- a/include/linux/parser.h
+++ b/include/linux/parser.h
@@ -25,7 +25,7 @@ typedef struct {
25 char *to; 25 char *to;
26} substring_t; 26} substring_t;
27 27
28int match_token(char *, match_table_t table, substring_t args[]); 28int match_token(char *, const match_table_t table, substring_t args[]);
29int match_int(substring_t *, int *result); 29int match_int(substring_t *, int *result);
30int match_octal(substring_t *, int *result); 30int match_octal(substring_t *, int *result);
31int match_hex(substring_t *, int *result); 31int match_hex(substring_t *, int *result);
diff --git a/include/linux/pci-acpi.h b/include/linux/pci-acpi.h
index 3ba25065fa96..8837928fbf33 100644
--- a/include/linux/pci-acpi.h
+++ b/include/linux/pci-acpi.h
@@ -57,6 +57,15 @@ static inline acpi_status pcie_osc_support_set(u32 flags)
57{ 57{
58 return __pci_osc_support_set(flags, PCI_EXPRESS_ROOT_HID_STRING); 58 return __pci_osc_support_set(flags, PCI_EXPRESS_ROOT_HID_STRING);
59} 59}
60static inline acpi_handle acpi_find_root_bridge_handle(struct pci_dev *pdev)
61{
62 /* Find root host bridge */
63 while (pdev->bus->self)
64 pdev = pdev->bus->self;
65
66 return acpi_get_pci_rootbridge_handle(pci_domain_nr(pdev->bus),
67 pdev->bus->number);
68}
60#else 69#else
61#if !defined(AE_ERROR) 70#if !defined(AE_ERROR)
62typedef u32 acpi_status; 71typedef u32 acpi_status;
@@ -66,6 +75,8 @@ static inline acpi_status pci_osc_control_set(acpi_handle handle, u32 flags)
66{return AE_ERROR;} 75{return AE_ERROR;}
67static inline acpi_status pci_osc_support_set(u32 flags) {return AE_ERROR;} 76static inline acpi_status pci_osc_support_set(u32 flags) {return AE_ERROR;}
68static inline acpi_status pcie_osc_support_set(u32 flags) {return AE_ERROR;} 77static inline acpi_status pcie_osc_support_set(u32 flags) {return AE_ERROR;}
78static inline acpi_handle acpi_find_root_bridge_handle(struct pci_dev *pdev)
79{ return NULL; }
69#endif 80#endif
70 81
71#endif /* _PCI_ACPI_H_ */ 82#endif /* _PCI_ACPI_H_ */
diff --git a/include/linux/pci-aspm.h b/include/linux/pci-aspm.h
index a1a1e618e996..91ba0b338b47 100644
--- a/include/linux/pci-aspm.h
+++ b/include/linux/pci-aspm.h
@@ -27,6 +27,7 @@ extern void pcie_aspm_init_link_state(struct pci_dev *pdev);
27extern void pcie_aspm_exit_link_state(struct pci_dev *pdev); 27extern void pcie_aspm_exit_link_state(struct pci_dev *pdev);
28extern void pcie_aspm_pm_state_change(struct pci_dev *pdev); 28extern void pcie_aspm_pm_state_change(struct pci_dev *pdev);
29extern void pci_disable_link_state(struct pci_dev *pdev, int state); 29extern void pci_disable_link_state(struct pci_dev *pdev, int state);
30extern void pcie_no_aspm(void);
30#else 31#else
31static inline void pcie_aspm_init_link_state(struct pci_dev *pdev) 32static inline void pcie_aspm_init_link_state(struct pci_dev *pdev)
32{ 33{
@@ -40,6 +41,10 @@ static inline void pcie_aspm_pm_state_change(struct pci_dev *pdev)
40static inline void pci_disable_link_state(struct pci_dev *pdev, int state) 41static inline void pci_disable_link_state(struct pci_dev *pdev, int state)
41{ 42{
42} 43}
44
45static inline void pcie_no_aspm(void)
46{
47}
43#endif 48#endif
44 49
45#ifdef CONFIG_PCIEASPM_DEBUG /* this depends on CONFIG_PCIEASPM */ 50#ifdef CONFIG_PCIEASPM_DEBUG /* this depends on CONFIG_PCIEASPM */
diff --git a/include/linux/pci.h b/include/linux/pci.h
index cfc2297c3e28..9194adf82e20 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -51,6 +51,7 @@
51#include <linux/kobject.h> 51#include <linux/kobject.h>
52#include <asm/atomic.h> 52#include <asm/atomic.h>
53#include <linux/device.h> 53#include <linux/device.h>
54#include <linux/io.h>
54 55
55/* Include the ID list */ 56/* Include the ID list */
56#include <linux/pci_ids.h> 57#include <linux/pci_ids.h>
@@ -64,6 +65,11 @@ struct pci_slot {
64 struct kobject kobj; 65 struct kobject kobj;
65}; 66};
66 67
68static inline const char *pci_slot_name(const struct pci_slot *slot)
69{
70 return kobject_name(&slot->kobj);
71}
72
67/* File state for mmap()s on /proc/bus/pci/X/Y */ 73/* File state for mmap()s on /proc/bus/pci/X/Y */
68enum pci_mmap_state { 74enum pci_mmap_state {
69 pci_mmap_io, 75 pci_mmap_io,
@@ -124,6 +130,8 @@ enum pci_dev_flags {
124 * generation too. 130 * generation too.
125 */ 131 */
126 PCI_DEV_FLAGS_MSI_INTX_DISABLE_BUG = (__force pci_dev_flags_t) 1, 132 PCI_DEV_FLAGS_MSI_INTX_DISABLE_BUG = (__force pci_dev_flags_t) 1,
133 /* Device configuration is irrevocably lost if disabled into D3 */
134 PCI_DEV_FLAGS_NO_D3 = (__force pci_dev_flags_t) 2,
127}; 135};
128 136
129enum pci_irq_reroute_variant { 137enum pci_irq_reroute_variant {
@@ -218,6 +226,7 @@ struct pci_dev {
218 unsigned int irq_reroute_variant:2; /* device needs IRQ rerouting variant */ 226 unsigned int irq_reroute_variant:2; /* device needs IRQ rerouting variant */
219 unsigned int msi_enabled:1; 227 unsigned int msi_enabled:1;
220 unsigned int msix_enabled:1; 228 unsigned int msix_enabled:1;
229 unsigned int ari_enabled:1; /* ARI forwarding */
221 unsigned int is_managed:1; 230 unsigned int is_managed:1;
222 unsigned int is_pcie:1; 231 unsigned int is_pcie:1;
223 pci_dev_flags_t dev_flags; 232 pci_dev_flags_t dev_flags;
@@ -351,7 +360,6 @@ struct pci_bus_region {
351struct pci_dynids { 360struct pci_dynids {
352 spinlock_t lock; /* protects list, index */ 361 spinlock_t lock; /* protects list, index */
353 struct list_head list; /* for IDs added at runtime */ 362 struct list_head list; /* for IDs added at runtime */
354 unsigned int use_driver_data:1; /* pci_device_id->driver_data is used */
355}; 363};
356 364
357/* ---------------------------------------------------------------- */ 365/* ---------------------------------------------------------------- */
@@ -460,8 +468,8 @@ struct pci_driver {
460 468
461/** 469/**
462 * PCI_VDEVICE - macro used to describe a specific pci device in short form 470 * PCI_VDEVICE - macro used to describe a specific pci device in short form
463 * @vend: the vendor name 471 * @vendor: the vendor name
464 * @dev: the 16 bit PCI Device ID 472 * @device: the 16 bit PCI Device ID
465 * 473 *
466 * This macro is used to create a struct pci_device_id that matches a 474 * This macro is used to create a struct pci_device_id that matches a
467 * specific PCI device. The subvendor, and subdevice fields will be set 475 * specific PCI device. The subvendor, and subdevice fields will be set
@@ -513,9 +521,10 @@ struct pci_bus *pci_create_bus(struct device *parent, int bus,
513struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev, 521struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,
514 int busnr); 522 int busnr);
515struct pci_slot *pci_create_slot(struct pci_bus *parent, int slot_nr, 523struct pci_slot *pci_create_slot(struct pci_bus *parent, int slot_nr,
516 const char *name); 524 const char *name,
525 struct hotplug_slot *hotplug);
517void pci_destroy_slot(struct pci_slot *slot); 526void pci_destroy_slot(struct pci_slot *slot);
518void pci_update_slot_number(struct pci_slot *slot, int slot_nr); 527void pci_renumber_slot(struct pci_slot *slot, int slot_nr);
519int pci_scan_slot(struct pci_bus *bus, int devfn); 528int pci_scan_slot(struct pci_bus *bus, int devfn);
520struct pci_dev *pci_scan_single_device(struct pci_bus *bus, int devfn); 529struct pci_dev *pci_scan_single_device(struct pci_bus *bus, int devfn);
521void pci_device_add(struct pci_dev *dev, struct pci_bus *bus); 530void pci_device_add(struct pci_dev *dev, struct pci_bus *bus);
@@ -538,11 +547,18 @@ extern void pci_sort_breadthfirst(void);
538#ifdef CONFIG_PCI_LEGACY 547#ifdef CONFIG_PCI_LEGACY
539struct pci_dev __deprecated *pci_find_device(unsigned int vendor, 548struct pci_dev __deprecated *pci_find_device(unsigned int vendor,
540 unsigned int device, 549 unsigned int device,
541 const struct pci_dev *from); 550 struct pci_dev *from);
542struct pci_dev __deprecated *pci_find_slot(unsigned int bus, 551struct pci_dev __deprecated *pci_find_slot(unsigned int bus,
543 unsigned int devfn); 552 unsigned int devfn);
544#endif /* CONFIG_PCI_LEGACY */ 553#endif /* CONFIG_PCI_LEGACY */
545 554
555enum pci_lost_interrupt_reason {
556 PCI_LOST_IRQ_NO_INFORMATION = 0,
557 PCI_LOST_IRQ_DISABLE_MSI,
558 PCI_LOST_IRQ_DISABLE_MSIX,
559 PCI_LOST_IRQ_DISABLE_ACPI,
560};
561enum pci_lost_interrupt_reason pci_lost_interrupt(struct pci_dev *dev);
546int pci_find_capability(struct pci_dev *dev, int cap); 562int pci_find_capability(struct pci_dev *dev, int cap);
547int pci_find_next_capability(struct pci_dev *dev, u8 pos, int cap); 563int pci_find_next_capability(struct pci_dev *dev, u8 pos, int cap);
548int pci_find_ext_capability(struct pci_dev *dev, int cap); 564int pci_find_ext_capability(struct pci_dev *dev, int cap);
@@ -554,7 +570,7 @@ struct pci_dev *pci_get_device(unsigned int vendor, unsigned int device,
554 struct pci_dev *from); 570 struct pci_dev *from);
555struct pci_dev *pci_get_subsys(unsigned int vendor, unsigned int device, 571struct pci_dev *pci_get_subsys(unsigned int vendor, unsigned int device,
556 unsigned int ss_vendor, unsigned int ss_device, 572 unsigned int ss_vendor, unsigned int ss_device,
557 const struct pci_dev *from); 573 struct pci_dev *from);
558struct pci_dev *pci_get_slot(struct pci_bus *bus, unsigned int devfn); 574struct pci_dev *pci_get_slot(struct pci_bus *bus, unsigned int devfn);
559struct pci_dev *pci_get_bus_and_slot(unsigned int bus, unsigned int devfn); 575struct pci_dev *pci_get_bus_and_slot(unsigned int bus, unsigned int devfn);
560struct pci_dev *pci_get_class(unsigned int class, struct pci_dev *from); 576struct pci_dev *pci_get_class(unsigned int class, struct pci_dev *from);
@@ -630,11 +646,15 @@ int pcix_get_mmrbc(struct pci_dev *dev);
630int pcix_set_mmrbc(struct pci_dev *dev, int mmrbc); 646int pcix_set_mmrbc(struct pci_dev *dev, int mmrbc);
631int pcie_get_readrq(struct pci_dev *dev); 647int pcie_get_readrq(struct pci_dev *dev);
632int pcie_set_readrq(struct pci_dev *dev, int rq); 648int pcie_set_readrq(struct pci_dev *dev, int rq);
649int pci_reset_function(struct pci_dev *dev);
650int pci_execute_reset_function(struct pci_dev *dev);
633void pci_update_resource(struct pci_dev *dev, struct resource *res, int resno); 651void pci_update_resource(struct pci_dev *dev, struct resource *res, int resno);
634int __must_check pci_assign_resource(struct pci_dev *dev, int i); 652int __must_check pci_assign_resource(struct pci_dev *dev, int i);
635int pci_select_bars(struct pci_dev *dev, unsigned long flags); 653int pci_select_bars(struct pci_dev *dev, unsigned long flags);
636 654
637/* ROM control related routines */ 655/* ROM control related routines */
656int pci_enable_rom(struct pci_dev *pdev);
657void pci_disable_rom(struct pci_dev *pdev);
638void __iomem __must_check *pci_map_rom(struct pci_dev *pdev, size_t *size); 658void __iomem __must_check *pci_map_rom(struct pci_dev *pdev, size_t *size);
639void pci_unmap_rom(struct pci_dev *pdev, void __iomem *rom); 659void pci_unmap_rom(struct pci_dev *pdev, void __iomem *rom);
640size_t pci_get_rom_size(void __iomem *rom, size_t size); 660size_t pci_get_rom_size(void __iomem *rom, size_t size);
@@ -644,7 +664,11 @@ int pci_save_state(struct pci_dev *dev);
644int pci_restore_state(struct pci_dev *dev); 664int pci_restore_state(struct pci_dev *dev);
645int pci_set_power_state(struct pci_dev *dev, pci_power_t state); 665int pci_set_power_state(struct pci_dev *dev, pci_power_t state);
646pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state); 666pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state);
667bool pci_pme_capable(struct pci_dev *dev, pci_power_t state);
668void pci_pme_active(struct pci_dev *dev, bool enable);
647int pci_enable_wake(struct pci_dev *dev, pci_power_t state, int enable); 669int pci_enable_wake(struct pci_dev *dev, pci_power_t state, int enable);
670int pci_wake_from_d3(struct pci_dev *dev, bool enable);
671pci_power_t pci_target_state(struct pci_dev *dev);
648int pci_prepare_to_sleep(struct pci_dev *dev); 672int pci_prepare_to_sleep(struct pci_dev *dev);
649int pci_back_from_sleep(struct pci_dev *dev); 673int pci_back_from_sleep(struct pci_dev *dev);
650 674
@@ -682,10 +706,12 @@ void pci_enable_bridges(struct pci_bus *bus);
682/* Proper probing supporting hot-pluggable devices */ 706/* Proper probing supporting hot-pluggable devices */
683int __must_check __pci_register_driver(struct pci_driver *, struct module *, 707int __must_check __pci_register_driver(struct pci_driver *, struct module *,
684 const char *mod_name); 708 const char *mod_name);
685static inline int __must_check pci_register_driver(struct pci_driver *driver) 709
686{ 710/*
687 return __pci_register_driver(driver, THIS_MODULE, KBUILD_MODNAME); 711 * pci_register_driver must be a macro so that KBUILD_MODNAME can be expanded
688} 712 */
713#define pci_register_driver(driver) \
714 __pci_register_driver(driver, THIS_MODULE, KBUILD_MODNAME)
689 715
690void pci_unregister_driver(struct pci_driver *dev); 716void pci_unregister_driver(struct pci_driver *dev);
691void pci_remove_behind_bridge(struct pci_dev *dev); 717void pci_remove_behind_bridge(struct pci_dev *dev);
@@ -722,7 +748,7 @@ enum pci_dma_burst_strategy {
722}; 748};
723 749
724struct msix_entry { 750struct msix_entry {
725 u16 vector; /* kernel uses to write allocated vector */ 751 u32 vector; /* kernel uses to write allocated vector */
726 u16 entry; /* driver uses to specify entry, OS writes */ 752 u16 entry; /* driver uses to specify entry, OS writes */
727}; 753};
728 754
@@ -815,7 +841,7 @@ _PCI_NOP_ALL(write,)
815 841
816static inline struct pci_dev *pci_find_device(unsigned int vendor, 842static inline struct pci_dev *pci_find_device(unsigned int vendor,
817 unsigned int device, 843 unsigned int device,
818 const struct pci_dev *from) 844 struct pci_dev *from)
819{ 845{
820 return NULL; 846 return NULL;
821} 847}
@@ -837,7 +863,7 @@ static inline struct pci_dev *pci_get_subsys(unsigned int vendor,
837 unsigned int device, 863 unsigned int device,
838 unsigned int ss_vendor, 864 unsigned int ss_vendor,
839 unsigned int ss_device, 865 unsigned int ss_device,
840 const struct pci_dev *from) 866 struct pci_dev *from)
841{ 867{
842 return NULL; 868 return NULL;
843} 869}
@@ -1115,5 +1141,20 @@ static inline void pci_mmcfg_early_init(void) { }
1115static inline void pci_mmcfg_late_init(void) { } 1141static inline void pci_mmcfg_late_init(void) { }
1116#endif 1142#endif
1117 1143
1144#ifdef CONFIG_HAS_IOMEM
1145static inline void * pci_ioremap_bar(struct pci_dev *pdev, int bar)
1146{
1147 /*
1148 * Make sure the BAR is actually a memory resource, not an IO resource
1149 */
1150 if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) {
1151 WARN_ON(1);
1152 return NULL;
1153 }
1154 return ioremap_nocache(pci_resource_start(pdev, bar),
1155 pci_resource_len(pdev, bar));
1156}
1157#endif
1158
1118#endif /* __KERNEL__ */ 1159#endif /* __KERNEL__ */
1119#endif /* LINUX_PCI_H */ 1160#endif /* LINUX_PCI_H */
diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
index a08cd06b541a..a00bd1a0f156 100644
--- a/include/linux/pci_hotplug.h
+++ b/include/linux/pci_hotplug.h
@@ -142,8 +142,6 @@ struct hotplug_slot_info {
142 142
143/** 143/**
144 * struct hotplug_slot - used to register a physical slot with the hotplug pci core 144 * struct hotplug_slot - used to register a physical slot with the hotplug pci core
145 * @name: the name of the slot being registered. This string must
146 * be unique amoung slots registered on this system.
147 * @ops: pointer to the &struct hotplug_slot_ops to be used for this slot 145 * @ops: pointer to the &struct hotplug_slot_ops to be used for this slot
148 * @info: pointer to the &struct hotplug_slot_info for the initial values for 146 * @info: pointer to the &struct hotplug_slot_info for the initial values for
149 * this slot. 147 * this slot.
@@ -153,7 +151,6 @@ struct hotplug_slot_info {
153 * needs. 151 * needs.
154 */ 152 */
155struct hotplug_slot { 153struct hotplug_slot {
156 char *name;
157 struct hotplug_slot_ops *ops; 154 struct hotplug_slot_ops *ops;
158 struct hotplug_slot_info *info; 155 struct hotplug_slot_info *info;
159 void (*release) (struct hotplug_slot *slot); 156 void (*release) (struct hotplug_slot *slot);
@@ -165,7 +162,13 @@ struct hotplug_slot {
165}; 162};
166#define to_hotplug_slot(n) container_of(n, struct hotplug_slot, kobj) 163#define to_hotplug_slot(n) container_of(n, struct hotplug_slot, kobj)
167 164
168extern int pci_hp_register(struct hotplug_slot *, struct pci_bus *, int nr); 165static inline const char *hotplug_slot_name(const struct hotplug_slot *slot)
166{
167 return pci_slot_name(slot->pci_slot);
168}
169
170extern int pci_hp_register(struct hotplug_slot *, struct pci_bus *, int nr,
171 const char *name);
169extern int pci_hp_deregister(struct hotplug_slot *slot); 172extern int pci_hp_deregister(struct hotplug_slot *slot);
170extern int __must_check pci_hp_change_slot_info (struct hotplug_slot *slot, 173extern int __must_check pci_hp_change_slot_info (struct hotplug_slot *slot,
171 struct hotplug_slot_info *info); 174 struct hotplug_slot_info *info);
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index 2b3934c735b2..b6e694454280 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -497,6 +497,16 @@
497#define PCI_DEVICE_ID_AMD_K8_NB_ADDRMAP 0x1101 497#define PCI_DEVICE_ID_AMD_K8_NB_ADDRMAP 0x1101
498#define PCI_DEVICE_ID_AMD_K8_NB_MEMCTL 0x1102 498#define PCI_DEVICE_ID_AMD_K8_NB_MEMCTL 0x1102
499#define PCI_DEVICE_ID_AMD_K8_NB_MISC 0x1103 499#define PCI_DEVICE_ID_AMD_K8_NB_MISC 0x1103
500#define PCI_DEVICE_ID_AMD_10H_NB_HT 0x1200
501#define PCI_DEVICE_ID_AMD_10H_NB_MAP 0x1201
502#define PCI_DEVICE_ID_AMD_10H_NB_DRAM 0x1202
503#define PCI_DEVICE_ID_AMD_10H_NB_MISC 0x1203
504#define PCI_DEVICE_ID_AMD_10H_NB_LINK 0x1204
505#define PCI_DEVICE_ID_AMD_11H_NB_HT 0x1300
506#define PCI_DEVICE_ID_AMD_11H_NB_MAP 0x1301
507#define PCI_DEVICE_ID_AMD_11H_NB_DRAM 0x1302
508#define PCI_DEVICE_ID_AMD_11H_NB_MISC 0x1303
509#define PCI_DEVICE_ID_AMD_11H_NB_LINK 0x1304
500#define PCI_DEVICE_ID_AMD_LANCE 0x2000 510#define PCI_DEVICE_ID_AMD_LANCE 0x2000
501#define PCI_DEVICE_ID_AMD_LANCE_HOME 0x2001 511#define PCI_DEVICE_ID_AMD_LANCE_HOME 0x2001
502#define PCI_DEVICE_ID_AMD_SCSI 0x2020 512#define PCI_DEVICE_ID_AMD_SCSI 0x2020
@@ -577,6 +587,7 @@
577#define PCI_DEVICE_ID_MATROX_G200_PCI 0x0520 587#define PCI_DEVICE_ID_MATROX_G200_PCI 0x0520
578#define PCI_DEVICE_ID_MATROX_G200_AGP 0x0521 588#define PCI_DEVICE_ID_MATROX_G200_AGP 0x0521
579#define PCI_DEVICE_ID_MATROX_G400 0x0525 589#define PCI_DEVICE_ID_MATROX_G400 0x0525
590#define PCI_DEVICE_ID_MATROX_G200EV_PCI 0x0530
580#define PCI_DEVICE_ID_MATROX_G550 0x2527 591#define PCI_DEVICE_ID_MATROX_G550 0x2527
581#define PCI_DEVICE_ID_MATROX_VIA 0x4536 592#define PCI_DEVICE_ID_MATROX_VIA 0x4536
582 593
@@ -748,6 +759,7 @@
748#define PCI_VENDOR_ID_TI 0x104c 759#define PCI_VENDOR_ID_TI 0x104c
749#define PCI_DEVICE_ID_TI_TVP4020 0x3d07 760#define PCI_DEVICE_ID_TI_TVP4020 0x3d07
750#define PCI_DEVICE_ID_TI_4450 0x8011 761#define PCI_DEVICE_ID_TI_4450 0x8011
762#define PCI_DEVICE_ID_TI_TSB43AB22 0x8023
751#define PCI_DEVICE_ID_TI_XX21_XX11 0x8031 763#define PCI_DEVICE_ID_TI_XX21_XX11 0x8031
752#define PCI_DEVICE_ID_TI_XX21_XX11_FM 0x8033 764#define PCI_DEVICE_ID_TI_XX21_XX11_FM 0x8033
753#define PCI_DEVICE_ID_TI_XX21_XX11_SD 0x8034 765#define PCI_DEVICE_ID_TI_XX21_XX11_SD 0x8034
@@ -1410,6 +1422,8 @@
1410#define PCI_DEVICE_ID_EICON_MAESTRAQ_U 0xe013 1422#define PCI_DEVICE_ID_EICON_MAESTRAQ_U 0xe013
1411#define PCI_DEVICE_ID_EICON_MAESTRAP 0xe014 1423#define PCI_DEVICE_ID_EICON_MAESTRAP 0xe014
1412 1424
1425#define PCI_VENDOR_ID_CISCO 0x1137
1426
1413#define PCI_VENDOR_ID_ZIATECH 0x1138 1427#define PCI_VENDOR_ID_ZIATECH 0x1138
1414#define PCI_DEVICE_ID_ZIATECH_5550_HC 0x5550 1428#define PCI_DEVICE_ID_ZIATECH_5550_HC 0x5550
1415 1429
@@ -1520,7 +1534,9 @@
1520#define PCI_DEVICE_ID_MARVELL_GT64260 0x6430 1534#define PCI_DEVICE_ID_MARVELL_GT64260 0x6430
1521#define PCI_DEVICE_ID_MARVELL_MV64360 0x6460 1535#define PCI_DEVICE_ID_MARVELL_MV64360 0x6460
1522#define PCI_DEVICE_ID_MARVELL_MV64460 0x6480 1536#define PCI_DEVICE_ID_MARVELL_MV64460 0x6480
1523#define PCI_DEVICE_ID_MARVELL_CAFE_SD 0x4101 1537#define PCI_DEVICE_ID_MARVELL_88ALP01_NAND 0x4100
1538#define PCI_DEVICE_ID_MARVELL_88ALP01_SD 0x4101
1539#define PCI_DEVICE_ID_MARVELL_88ALP01_CCIC 0x4102
1524 1540
1525#define PCI_VENDOR_ID_V3 0x11b0 1541#define PCI_VENDOR_ID_V3 0x11b0
1526#define PCI_DEVICE_ID_V3_V960 0x0001 1542#define PCI_DEVICE_ID_V3_V960 0x0001
@@ -1832,7 +1848,13 @@
1832#define PCI_DEVICE_ID_MOXA_C320 0x3200 1848#define PCI_DEVICE_ID_MOXA_C320 0x3200
1833 1849
1834#define PCI_VENDOR_ID_CCD 0x1397 1850#define PCI_VENDOR_ID_CCD 0x1397
1851#define PCI_DEVICE_ID_CCD_HFC4S 0x08B4
1852#define PCI_SUBDEVICE_ID_CCD_PMX2S 0x1234
1853#define PCI_DEVICE_ID_CCD_HFC8S 0x16B8
1835#define PCI_DEVICE_ID_CCD_2BD0 0x2bd0 1854#define PCI_DEVICE_ID_CCD_2BD0 0x2bd0
1855#define PCI_DEVICE_ID_CCD_HFCE1 0x30B1
1856#define PCI_SUBDEVICE_ID_CCD_SPD4S 0x3136
1857#define PCI_SUBDEVICE_ID_CCD_SPDE1 0x3137
1836#define PCI_DEVICE_ID_CCD_B000 0xb000 1858#define PCI_DEVICE_ID_CCD_B000 0xb000
1837#define PCI_DEVICE_ID_CCD_B006 0xb006 1859#define PCI_DEVICE_ID_CCD_B006 0xb006
1838#define PCI_DEVICE_ID_CCD_B007 0xb007 1860#define PCI_DEVICE_ID_CCD_B007 0xb007
@@ -1842,8 +1864,32 @@
1842#define PCI_DEVICE_ID_CCD_B00B 0xb00b 1864#define PCI_DEVICE_ID_CCD_B00B 0xb00b
1843#define PCI_DEVICE_ID_CCD_B00C 0xb00c 1865#define PCI_DEVICE_ID_CCD_B00C 0xb00c
1844#define PCI_DEVICE_ID_CCD_B100 0xb100 1866#define PCI_DEVICE_ID_CCD_B100 0xb100
1867#define PCI_SUBDEVICE_ID_CCD_IOB4ST 0xB520
1868#define PCI_SUBDEVICE_ID_CCD_IOB8STR 0xB521
1869#define PCI_SUBDEVICE_ID_CCD_IOB8ST 0xB522
1870#define PCI_SUBDEVICE_ID_CCD_IOB1E1 0xB523
1871#define PCI_SUBDEVICE_ID_CCD_SWYX4S 0xB540
1872#define PCI_SUBDEVICE_ID_CCD_JH4S20 0xB550
1873#define PCI_SUBDEVICE_ID_CCD_IOB8ST_1 0xB552
1874#define PCI_SUBDEVICE_ID_CCD_BN4S 0xB560
1875#define PCI_SUBDEVICE_ID_CCD_BN8S 0xB562
1876#define PCI_SUBDEVICE_ID_CCD_BNE1 0xB563
1877#define PCI_SUBDEVICE_ID_CCD_BNE1D 0xB564
1878#define PCI_SUBDEVICE_ID_CCD_BNE1DP 0xB565
1879#define PCI_SUBDEVICE_ID_CCD_BN2S 0xB566
1880#define PCI_SUBDEVICE_ID_CCD_BN1SM 0xB567
1881#define PCI_SUBDEVICE_ID_CCD_BN4SM 0xB568
1882#define PCI_SUBDEVICE_ID_CCD_BN2SM 0xB569
1883#define PCI_SUBDEVICE_ID_CCD_BNE1M 0xB56A
1884#define PCI_SUBDEVICE_ID_CCD_BN8SP 0xB56B
1885#define PCI_SUBDEVICE_ID_CCD_HFC4S 0xB620
1886#define PCI_SUBDEVICE_ID_CCD_HFC8S 0xB622
1845#define PCI_DEVICE_ID_CCD_B700 0xb700 1887#define PCI_DEVICE_ID_CCD_B700 0xb700
1846#define PCI_DEVICE_ID_CCD_B701 0xb701 1888#define PCI_DEVICE_ID_CCD_B701 0xb701
1889#define PCI_SUBDEVICE_ID_CCD_HFCE1 0xC523
1890#define PCI_SUBDEVICE_ID_CCD_OV2S 0xE884
1891#define PCI_SUBDEVICE_ID_CCD_OV4S 0xE888
1892#define PCI_SUBDEVICE_ID_CCD_OV8S 0xE998
1847 1893
1848#define PCI_VENDOR_ID_EXAR 0x13a8 1894#define PCI_VENDOR_ID_EXAR 0x13a8
1849#define PCI_DEVICE_ID_EXAR_XR17C152 0x0152 1895#define PCI_DEVICE_ID_EXAR_XR17C152 0x0152
@@ -1898,6 +1944,14 @@
1898 1944
1899#define PCI_VENDOR_ID_OXSEMI 0x1415 1945#define PCI_VENDOR_ID_OXSEMI 0x1415
1900#define PCI_DEVICE_ID_OXSEMI_12PCI840 0x8403 1946#define PCI_DEVICE_ID_OXSEMI_12PCI840 0x8403
1947#define PCI_DEVICE_ID_OXSEMI_PCIe840 0xC000
1948#define PCI_DEVICE_ID_OXSEMI_PCIe840_G 0xC004
1949#define PCI_DEVICE_ID_OXSEMI_PCIe952_0 0xC100
1950#define PCI_DEVICE_ID_OXSEMI_PCIe952_0_G 0xC104
1951#define PCI_DEVICE_ID_OXSEMI_PCIe952_1 0xC110
1952#define PCI_DEVICE_ID_OXSEMI_PCIe952_1_G 0xC114
1953#define PCI_DEVICE_ID_OXSEMI_PCIe952_1_U 0xC118
1954#define PCI_DEVICE_ID_OXSEMI_PCIe952_1_GU 0xC11C
1901#define PCI_DEVICE_ID_OXSEMI_16PCI954 0x9501 1955#define PCI_DEVICE_ID_OXSEMI_16PCI954 0x9501
1902#define PCI_DEVICE_ID_OXSEMI_16PCI95N 0x9511 1956#define PCI_DEVICE_ID_OXSEMI_16PCI95N 0x9511
1903#define PCI_DEVICE_ID_OXSEMI_16PCI954PP 0x9513 1957#define PCI_DEVICE_ID_OXSEMI_16PCI954PP 0x9513
@@ -1950,6 +2004,8 @@
1950#define PCI_DEVICE_ID_NX2_5708 0x164c 2004#define PCI_DEVICE_ID_NX2_5708 0x164c
1951#define PCI_DEVICE_ID_TIGON3_5702FE 0x164d 2005#define PCI_DEVICE_ID_TIGON3_5702FE 0x164d
1952#define PCI_DEVICE_ID_NX2_57710 0x164e 2006#define PCI_DEVICE_ID_NX2_57710 0x164e
2007#define PCI_DEVICE_ID_NX2_57711 0x164f
2008#define PCI_DEVICE_ID_NX2_57711E 0x1650
1953#define PCI_DEVICE_ID_TIGON3_5705 0x1653 2009#define PCI_DEVICE_ID_TIGON3_5705 0x1653
1954#define PCI_DEVICE_ID_TIGON3_5705_2 0x1654 2010#define PCI_DEVICE_ID_TIGON3_5705_2 0x1654
1955#define PCI_DEVICE_ID_TIGON3_5720 0x1658 2011#define PCI_DEVICE_ID_TIGON3_5720 0x1658
@@ -1982,6 +2038,7 @@
1982#define PCI_DEVICE_ID_TIGON3_5787M 0x1693 2038#define PCI_DEVICE_ID_TIGON3_5787M 0x1693
1983#define PCI_DEVICE_ID_TIGON3_5782 0x1696 2039#define PCI_DEVICE_ID_TIGON3_5782 0x1696
1984#define PCI_DEVICE_ID_TIGON3_5784 0x1698 2040#define PCI_DEVICE_ID_TIGON3_5784 0x1698
2041#define PCI_DEVICE_ID_TIGON3_5785 0x1699
1985#define PCI_DEVICE_ID_TIGON3_5786 0x169a 2042#define PCI_DEVICE_ID_TIGON3_5786 0x169a
1986#define PCI_DEVICE_ID_TIGON3_5787 0x169b 2043#define PCI_DEVICE_ID_TIGON3_5787 0x169b
1987#define PCI_DEVICE_ID_TIGON3_5788 0x169c 2044#define PCI_DEVICE_ID_TIGON3_5788 0x169c
@@ -2143,8 +2200,6 @@
2143#define PCI_DEVICE_ID_HERC_WIN 0x5732 2200#define PCI_DEVICE_ID_HERC_WIN 0x5732
2144#define PCI_DEVICE_ID_HERC_UNI 0x5832 2201#define PCI_DEVICE_ID_HERC_UNI 0x5832
2145 2202
2146#define PCI_VENDOR_ID_RDC 0x17f3
2147
2148#define PCI_VENDOR_ID_SITECOM 0x182d 2203#define PCI_VENDOR_ID_SITECOM 0x182d
2149#define PCI_DEVICE_ID_SITECOM_DC105V2 0x3069 2204#define PCI_DEVICE_ID_SITECOM_DC105V2 0x3069
2150 2205
@@ -2181,6 +2236,7 @@
2181 2236
2182#define PCI_VENDOR_ID_ATTANSIC 0x1969 2237#define PCI_VENDOR_ID_ATTANSIC 0x1969
2183#define PCI_DEVICE_ID_ATTANSIC_L1 0x1048 2238#define PCI_DEVICE_ID_ATTANSIC_L1 0x1048
2239#define PCI_DEVICE_ID_ATTANSIC_L2 0x2048
2184 2240
2185#define PCI_VENDOR_ID_JMICRON 0x197B 2241#define PCI_VENDOR_ID_JMICRON 0x197B
2186#define PCI_DEVICE_ID_JMICRON_JMB360 0x2360 2242#define PCI_DEVICE_ID_JMICRON_JMB360 0x2360
@@ -2212,6 +2268,16 @@
2212#define PCI_DEVICE_ID_3DLABS_PERMEDIA2 0x0007 2268#define PCI_DEVICE_ID_3DLABS_PERMEDIA2 0x0007
2213#define PCI_DEVICE_ID_3DLABS_PERMEDIA2V 0x0009 2269#define PCI_DEVICE_ID_3DLABS_PERMEDIA2V 0x0009
2214 2270
2271#define PCI_VENDOR_ID_NETXEN 0x4040
2272#define PCI_DEVICE_ID_NX2031_10GXSR 0x0001
2273#define PCI_DEVICE_ID_NX2031_10GCX4 0x0002
2274#define PCI_DEVICE_ID_NX2031_4GCU 0x0003
2275#define PCI_DEVICE_ID_NX2031_IMEZ 0x0004
2276#define PCI_DEVICE_ID_NX2031_HMEZ 0x0005
2277#define PCI_DEVICE_ID_NX2031_XG_MGMT 0x0024
2278#define PCI_DEVICE_ID_NX2031_XG_MGMT2 0x0025
2279#define PCI_DEVICE_ID_NX3031 0x0100
2280
2215#define PCI_VENDOR_ID_AKS 0x416c 2281#define PCI_VENDOR_ID_AKS 0x416c
2216#define PCI_DEVICE_ID_AKS_ALADDINCARD 0x0100 2282#define PCI_DEVICE_ID_AKS_ALADDINCARD 0x0100
2217 2283
@@ -2373,6 +2439,14 @@
2373#define PCI_DEVICE_ID_INTEL_ICH9_7 0x2916 2439#define PCI_DEVICE_ID_INTEL_ICH9_7 0x2916
2374#define PCI_DEVICE_ID_INTEL_ICH9_8 0x2918 2440#define PCI_DEVICE_ID_INTEL_ICH9_8 0x2918
2375#define PCI_DEVICE_ID_INTEL_82855PM_HB 0x3340 2441#define PCI_DEVICE_ID_INTEL_82855PM_HB 0x3340
2442#define PCI_DEVICE_ID_INTEL_IOAT_TBG4 0x3429
2443#define PCI_DEVICE_ID_INTEL_IOAT_TBG5 0x342a
2444#define PCI_DEVICE_ID_INTEL_IOAT_TBG6 0x342b
2445#define PCI_DEVICE_ID_INTEL_IOAT_TBG7 0x342c
2446#define PCI_DEVICE_ID_INTEL_IOAT_TBG0 0x3430
2447#define PCI_DEVICE_ID_INTEL_IOAT_TBG1 0x3431
2448#define PCI_DEVICE_ID_INTEL_IOAT_TBG2 0x3432
2449#define PCI_DEVICE_ID_INTEL_IOAT_TBG3 0x3433
2376#define PCI_DEVICE_ID_INTEL_82830_HB 0x3575 2450#define PCI_DEVICE_ID_INTEL_82830_HB 0x3575
2377#define PCI_DEVICE_ID_INTEL_82830_CGC 0x3577 2451#define PCI_DEVICE_ID_INTEL_82830_CGC 0x3577
2378#define PCI_DEVICE_ID_INTEL_82855GM_HB 0x3580 2452#define PCI_DEVICE_ID_INTEL_82855GM_HB 0x3580
@@ -2387,13 +2461,20 @@
2387#define PCI_DEVICE_ID_INTEL_MCH_PC1 0x359a 2461#define PCI_DEVICE_ID_INTEL_MCH_PC1 0x359a
2388#define PCI_DEVICE_ID_INTEL_E7525_MCH 0x359e 2462#define PCI_DEVICE_ID_INTEL_E7525_MCH 0x359e
2389#define PCI_DEVICE_ID_INTEL_IOAT_CNB 0x360b 2463#define PCI_DEVICE_ID_INTEL_IOAT_CNB 0x360b
2464#define PCI_DEVICE_ID_INTEL_FBD_CNB 0x360c
2390#define PCI_DEVICE_ID_INTEL_ICH10_0 0x3a14 2465#define PCI_DEVICE_ID_INTEL_ICH10_0 0x3a14
2391#define PCI_DEVICE_ID_INTEL_ICH10_1 0x3a16 2466#define PCI_DEVICE_ID_INTEL_ICH10_1 0x3a16
2392#define PCI_DEVICE_ID_INTEL_ICH10_2 0x3a18 2467#define PCI_DEVICE_ID_INTEL_ICH10_2 0x3a18
2393#define PCI_DEVICE_ID_INTEL_ICH10_3 0x3a1a 2468#define PCI_DEVICE_ID_INTEL_ICH10_3 0x3a1a
2394#define PCI_DEVICE_ID_INTEL_ICH10_4 0x3a30 2469#define PCI_DEVICE_ID_INTEL_ICH10_4 0x3a30
2395#define PCI_DEVICE_ID_INTEL_ICH10_5 0x3a60 2470#define PCI_DEVICE_ID_INTEL_ICH10_5 0x3a60
2471#define PCI_DEVICE_ID_INTEL_PCH_LPC_MIN 0x3b00
2472#define PCI_DEVICE_ID_INTEL_PCH_LPC_MAX 0x3b1f
2473#define PCI_DEVICE_ID_INTEL_PCH_SMBUS 0x3b30
2396#define PCI_DEVICE_ID_INTEL_IOAT_SNB 0x402f 2474#define PCI_DEVICE_ID_INTEL_IOAT_SNB 0x402f
2475#define PCI_DEVICE_ID_INTEL_5100_16 0x65f0
2476#define PCI_DEVICE_ID_INTEL_5100_21 0x65f5
2477#define PCI_DEVICE_ID_INTEL_5100_22 0x65f6
2397#define PCI_DEVICE_ID_INTEL_5400_ERR 0x4030 2478#define PCI_DEVICE_ID_INTEL_5400_ERR 0x4030
2398#define PCI_DEVICE_ID_INTEL_5400_FBD0 0x4035 2479#define PCI_DEVICE_ID_INTEL_5400_FBD0 0x4035
2399#define PCI_DEVICE_ID_INTEL_5400_FBD1 0x4036 2480#define PCI_DEVICE_ID_INTEL_5400_FBD1 0x4036
@@ -2514,6 +2595,9 @@
2514 2595
2515#define PCI_VENDOR_ID_3COM_2 0xa727 2596#define PCI_VENDOR_ID_3COM_2 0xa727
2516 2597
2598#define PCI_VENDOR_ID_DIGIUM 0xd161
2599#define PCI_DEVICE_ID_DIGIUM_HFC4S 0xb410
2600
2517#define PCI_SUBVENDOR_ID_EXSYS 0xd84d 2601#define PCI_SUBVENDOR_ID_EXSYS 0xd84d
2518#define PCI_SUBDEVICE_ID_EXSYS_4014 0x4014 2602#define PCI_SUBDEVICE_ID_EXSYS_4014 0x4014
2519#define PCI_SUBDEVICE_ID_EXSYS_4055 0x4055 2603#define PCI_SUBDEVICE_ID_EXSYS_4055 0x4055
diff --git a/include/linux/pci_regs.h b/include/linux/pci_regs.h
index 19958b929905..e5effd47ed74 100644
--- a/include/linux/pci_regs.h
+++ b/include/linux/pci_regs.h
@@ -374,8 +374,10 @@
374#define PCI_EXP_DEVCAP_ATN_BUT 0x1000 /* Attention Button Present */ 374#define PCI_EXP_DEVCAP_ATN_BUT 0x1000 /* Attention Button Present */
375#define PCI_EXP_DEVCAP_ATN_IND 0x2000 /* Attention Indicator Present */ 375#define PCI_EXP_DEVCAP_ATN_IND 0x2000 /* Attention Indicator Present */
376#define PCI_EXP_DEVCAP_PWR_IND 0x4000 /* Power Indicator Present */ 376#define PCI_EXP_DEVCAP_PWR_IND 0x4000 /* Power Indicator Present */
377#define PCI_EXP_DEVCAP_RBER 0x8000 /* Role-Based Error Reporting */
377#define PCI_EXP_DEVCAP_PWR_VAL 0x3fc0000 /* Slot Power Limit Value */ 378#define PCI_EXP_DEVCAP_PWR_VAL 0x3fc0000 /* Slot Power Limit Value */
378#define PCI_EXP_DEVCAP_PWR_SCL 0xc000000 /* Slot Power Limit Scale */ 379#define PCI_EXP_DEVCAP_PWR_SCL 0xc000000 /* Slot Power Limit Scale */
380#define PCI_EXP_DEVCAP_FLR 0x10000000 /* Function Level Reset */
379#define PCI_EXP_DEVCTL 8 /* Device Control */ 381#define PCI_EXP_DEVCTL 8 /* Device Control */
380#define PCI_EXP_DEVCTL_CERE 0x0001 /* Correctable Error Reporting En. */ 382#define PCI_EXP_DEVCTL_CERE 0x0001 /* Correctable Error Reporting En. */
381#define PCI_EXP_DEVCTL_NFERE 0x0002 /* Non-Fatal Error Reporting Enable */ 383#define PCI_EXP_DEVCTL_NFERE 0x0002 /* Non-Fatal Error Reporting Enable */
@@ -388,6 +390,7 @@
388#define PCI_EXP_DEVCTL_AUX_PME 0x0400 /* Auxiliary Power PM Enable */ 390#define PCI_EXP_DEVCTL_AUX_PME 0x0400 /* Auxiliary Power PM Enable */
389#define PCI_EXP_DEVCTL_NOSNOOP_EN 0x0800 /* Enable No Snoop */ 391#define PCI_EXP_DEVCTL_NOSNOOP_EN 0x0800 /* Enable No Snoop */
390#define PCI_EXP_DEVCTL_READRQ 0x7000 /* Max_Read_Request_Size */ 392#define PCI_EXP_DEVCTL_READRQ 0x7000 /* Max_Read_Request_Size */
393#define PCI_EXP_DEVCTL_BCR_FLR 0x8000 /* Bridge Configuration Retry / FLR */
391#define PCI_EXP_DEVSTA 10 /* Device Status */ 394#define PCI_EXP_DEVSTA 10 /* Device Status */
392#define PCI_EXP_DEVSTA_CED 0x01 /* Correctable Error Detected */ 395#define PCI_EXP_DEVSTA_CED 0x01 /* Correctable Error Detected */
393#define PCI_EXP_DEVSTA_NFED 0x02 /* Non-Fatal Error Detected */ 396#define PCI_EXP_DEVSTA_NFED 0x02 /* Non-Fatal Error Detected */
@@ -418,6 +421,10 @@
418#define PCI_EXP_RTCTL_CRSSVE 0x10 /* CRS Software Visibility Enable */ 421#define PCI_EXP_RTCTL_CRSSVE 0x10 /* CRS Software Visibility Enable */
419#define PCI_EXP_RTCAP 30 /* Root Capabilities */ 422#define PCI_EXP_RTCAP 30 /* Root Capabilities */
420#define PCI_EXP_RTSTA 32 /* Root Status */ 423#define PCI_EXP_RTSTA 32 /* Root Status */
424#define PCI_EXP_DEVCAP2 36 /* Device Capabilities 2 */
425#define PCI_EXP_DEVCAP2_ARI 0x20 /* Alternative Routing-ID */
426#define PCI_EXP_DEVCTL2 40 /* Device Control 2 */
427#define PCI_EXP_DEVCTL2_ARI 0x20 /* Alternative Routing-ID */
421 428
422/* Extended Capabilities (PCI-X 2.0 and Express) */ 429/* Extended Capabilities (PCI-X 2.0 and Express) */
423#define PCI_EXT_CAP_ID(header) (header & 0x0000ffff) 430#define PCI_EXT_CAP_ID(header) (header & 0x0000ffff)
@@ -428,6 +435,7 @@
428#define PCI_EXT_CAP_ID_VC 2 435#define PCI_EXT_CAP_ID_VC 2
429#define PCI_EXT_CAP_ID_DSN 3 436#define PCI_EXT_CAP_ID_DSN 3
430#define PCI_EXT_CAP_ID_PWR 4 437#define PCI_EXT_CAP_ID_PWR 4
438#define PCI_EXT_CAP_ID_ARI 14
431 439
432/* Advanced Error Reporting */ 440/* Advanced Error Reporting */
433#define PCI_ERR_UNCOR_STATUS 4 /* Uncorrectable Error Status */ 441#define PCI_ERR_UNCOR_STATUS 4 /* Uncorrectable Error Status */
@@ -535,5 +543,14 @@
535#define HT_CAPTYPE_GEN3 0xD0 /* Generation 3 hypertransport configuration */ 543#define HT_CAPTYPE_GEN3 0xD0 /* Generation 3 hypertransport configuration */
536#define HT_CAPTYPE_PM 0xE0 /* Hypertransport powermanagement configuration */ 544#define HT_CAPTYPE_PM 0xE0 /* Hypertransport powermanagement configuration */
537 545
546/* Alternative Routing-ID Interpretation */
547#define PCI_ARI_CAP 0x04 /* ARI Capability Register */
548#define PCI_ARI_CAP_MFVC 0x0001 /* MFVC Function Groups Capability */
549#define PCI_ARI_CAP_ACS 0x0002 /* ACS Function Groups Capability */
550#define PCI_ARI_CAP_NFN(x) (((x) >> 8) & 0xff) /* Next Function Number */
551#define PCI_ARI_CTRL 0x06 /* ARI Control Register */
552#define PCI_ARI_CTRL_MFVC 0x0001 /* MFVC Function Groups Enable */
553#define PCI_ARI_CTRL_ACS 0x0002 /* ACS Function Groups Enable */
554#define PCI_ARI_CTRL_FG(x) (((x) >> 4) & 7) /* Function Group */
538 555
539#endif /* LINUX_PCI_REGS_H */ 556#endif /* LINUX_PCI_REGS_H */
diff --git a/include/linux/percpu.h b/include/linux/percpu.h
index 4cdd393e71e1..9f2a3751873a 100644
--- a/include/linux/percpu.h
+++ b/include/linux/percpu.h
@@ -23,12 +23,19 @@
23 __attribute__((__section__(SHARED_ALIGNED_SECTION))) \ 23 __attribute__((__section__(SHARED_ALIGNED_SECTION))) \
24 PER_CPU_ATTRIBUTES __typeof__(type) per_cpu__##name \ 24 PER_CPU_ATTRIBUTES __typeof__(type) per_cpu__##name \
25 ____cacheline_aligned_in_smp 25 ____cacheline_aligned_in_smp
26
27#define DEFINE_PER_CPU_PAGE_ALIGNED(type, name) \
28 __attribute__((__section__(".data.percpu.page_aligned"))) \
29 PER_CPU_ATTRIBUTES __typeof__(type) per_cpu__##name
26#else 30#else
27#define DEFINE_PER_CPU(type, name) \ 31#define DEFINE_PER_CPU(type, name) \
28 PER_CPU_ATTRIBUTES __typeof__(type) per_cpu__##name 32 PER_CPU_ATTRIBUTES __typeof__(type) per_cpu__##name
29 33
30#define DEFINE_PER_CPU_SHARED_ALIGNED(type, name) \ 34#define DEFINE_PER_CPU_SHARED_ALIGNED(type, name) \
31 DEFINE_PER_CPU(type, name) 35 DEFINE_PER_CPU(type, name)
36
37#define DEFINE_PER_CPU_PAGE_ALIGNED(type, name) \
38 DEFINE_PER_CPU(type, name)
32#endif 39#endif
33 40
34#define EXPORT_PER_CPU_SYMBOL(var) EXPORT_SYMBOL(per_cpu__##var) 41#define EXPORT_PER_CPU_SYMBOL(var) EXPORT_SYMBOL(per_cpu__##var)
@@ -74,11 +81,6 @@ struct percpu_data {
74 (__typeof__(ptr))__p->ptrs[(cpu)]; \ 81 (__typeof__(ptr))__p->ptrs[(cpu)]; \
75}) 82})
76 83
77extern void *percpu_populate(void *__pdata, size_t size, gfp_t gfp, int cpu);
78extern void percpu_depopulate(void *__pdata, int cpu);
79extern int __percpu_populate_mask(void *__pdata, size_t size, gfp_t gfp,
80 cpumask_t *mask);
81extern void __percpu_depopulate_mask(void *__pdata, cpumask_t *mask);
82extern void *__percpu_alloc_mask(size_t size, gfp_t gfp, cpumask_t *mask); 84extern void *__percpu_alloc_mask(size_t size, gfp_t gfp, cpumask_t *mask);
83extern void percpu_free(void *__pdata); 85extern void percpu_free(void *__pdata);
84 86
@@ -86,26 +88,6 @@ extern void percpu_free(void *__pdata);
86 88
87#define percpu_ptr(ptr, cpu) ({ (void)(cpu); (ptr); }) 89#define percpu_ptr(ptr, cpu) ({ (void)(cpu); (ptr); })
88 90
89static inline void percpu_depopulate(void *__pdata, int cpu)
90{
91}
92
93static inline void __percpu_depopulate_mask(void *__pdata, cpumask_t *mask)
94{
95}
96
97static inline void *percpu_populate(void *__pdata, size_t size, gfp_t gfp,
98 int cpu)
99{
100 return percpu_ptr(__pdata, cpu);
101}
102
103static inline int __percpu_populate_mask(void *__pdata, size_t size, gfp_t gfp,
104 cpumask_t *mask)
105{
106 return 0;
107}
108
109static __always_inline void *__percpu_alloc_mask(size_t size, gfp_t gfp, cpumask_t *mask) 91static __always_inline void *__percpu_alloc_mask(size_t size, gfp_t gfp, cpumask_t *mask)
110{ 92{
111 return kzalloc(size, gfp); 93 return kzalloc(size, gfp);
@@ -118,10 +100,6 @@ static inline void percpu_free(void *__pdata)
118 100
119#endif /* CONFIG_SMP */ 101#endif /* CONFIG_SMP */
120 102
121#define percpu_populate_mask(__pdata, size, gfp, mask) \
122 __percpu_populate_mask((__pdata), (size), (gfp), &(mask))
123#define percpu_depopulate_mask(__pdata, mask) \
124 __percpu_depopulate_mask((__pdata), &(mask))
125#define percpu_alloc_mask(size, gfp, mask) \ 103#define percpu_alloc_mask(size, gfp, mask) \
126 __percpu_alloc_mask((size), (gfp), &(mask)) 104 __percpu_alloc_mask((size), (gfp), &(mask))
127 105
diff --git a/include/linux/percpu_counter.h b/include/linux/percpu_counter.h
index 208388835357..9007ccdfc112 100644
--- a/include/linux/percpu_counter.h
+++ b/include/linux/percpu_counter.h
@@ -35,7 +35,7 @@ int percpu_counter_init_irq(struct percpu_counter *fbc, s64 amount);
35void percpu_counter_destroy(struct percpu_counter *fbc); 35void percpu_counter_destroy(struct percpu_counter *fbc);
36void percpu_counter_set(struct percpu_counter *fbc, s64 amount); 36void percpu_counter_set(struct percpu_counter *fbc, s64 amount);
37void __percpu_counter_add(struct percpu_counter *fbc, s64 amount, s32 batch); 37void __percpu_counter_add(struct percpu_counter *fbc, s64 amount, s32 batch);
38s64 __percpu_counter_sum(struct percpu_counter *fbc, int set); 38s64 __percpu_counter_sum(struct percpu_counter *fbc);
39 39
40static inline void percpu_counter_add(struct percpu_counter *fbc, s64 amount) 40static inline void percpu_counter_add(struct percpu_counter *fbc, s64 amount)
41{ 41{
@@ -44,19 +44,13 @@ static inline void percpu_counter_add(struct percpu_counter *fbc, s64 amount)
44 44
45static inline s64 percpu_counter_sum_positive(struct percpu_counter *fbc) 45static inline s64 percpu_counter_sum_positive(struct percpu_counter *fbc)
46{ 46{
47 s64 ret = __percpu_counter_sum(fbc, 0); 47 s64 ret = __percpu_counter_sum(fbc);
48 return ret < 0 ? 0 : ret; 48 return ret < 0 ? 0 : ret;
49} 49}
50 50
51static inline s64 percpu_counter_sum_and_set(struct percpu_counter *fbc)
52{
53 return __percpu_counter_sum(fbc, 1);
54}
55
56
57static inline s64 percpu_counter_sum(struct percpu_counter *fbc) 51static inline s64 percpu_counter_sum(struct percpu_counter *fbc)
58{ 52{
59 return __percpu_counter_sum(fbc, 0); 53 return __percpu_counter_sum(fbc);
60} 54}
61 55
62static inline s64 percpu_counter_read(struct percpu_counter *fbc) 56static inline s64 percpu_counter_read(struct percpu_counter *fbc)
diff --git a/include/linux/pfkeyv2.h b/include/linux/pfkeyv2.h
index 700725ddcaae..01b262959f2e 100644
--- a/include/linux/pfkeyv2.h
+++ b/include/linux/pfkeyv2.h
@@ -226,6 +226,15 @@ struct sadb_x_sec_ctx {
226} __attribute__((packed)); 226} __attribute__((packed));
227/* sizeof(struct sadb_sec_ctx) = 8 */ 227/* sizeof(struct sadb_sec_ctx) = 8 */
228 228
229/* Used by MIGRATE to pass addresses IKE will use to perform
230 * negotiation with the peer */
231struct sadb_x_kmaddress {
232 uint16_t sadb_x_kmaddress_len;
233 uint16_t sadb_x_kmaddress_exttype;
234 uint32_t sadb_x_kmaddress_reserved;
235} __attribute__((packed));
236/* sizeof(struct sadb_x_kmaddress) == 8 */
237
229/* Message types */ 238/* Message types */
230#define SADB_RESERVED 0 239#define SADB_RESERVED 0
231#define SADB_GETSPI 1 240#define SADB_GETSPI 1
@@ -346,7 +355,9 @@ struct sadb_x_sec_ctx {
346#define SADB_X_EXT_NAT_T_DPORT 22 355#define SADB_X_EXT_NAT_T_DPORT 22
347#define SADB_X_EXT_NAT_T_OA 23 356#define SADB_X_EXT_NAT_T_OA 23
348#define SADB_X_EXT_SEC_CTX 24 357#define SADB_X_EXT_SEC_CTX 24
349#define SADB_EXT_MAX 24 358/* Used with MIGRATE to pass @ to IKE for negotiation */
359#define SADB_X_EXT_KMADDRESS 25
360#define SADB_EXT_MAX 25
350 361
351/* Identity Extension values */ 362/* Identity Extension values */
352#define SADB_IDENTTYPE_RESERVED 0 363#define SADB_IDENTTYPE_RESERVED 0
diff --git a/include/linux/pfn.h b/include/linux/pfn.h
index bb01f8b92b56..7646637221f3 100644
--- a/include/linux/pfn.h
+++ b/include/linux/pfn.h
@@ -1,9 +1,13 @@
1#ifndef _LINUX_PFN_H_ 1#ifndef _LINUX_PFN_H_
2#define _LINUX_PFN_H_ 2#define _LINUX_PFN_H_
3 3
4#ifndef __ASSEMBLY__
5#include <linux/types.h>
6#endif
7
4#define PFN_ALIGN(x) (((unsigned long)(x) + (PAGE_SIZE - 1)) & PAGE_MASK) 8#define PFN_ALIGN(x) (((unsigned long)(x) + (PAGE_SIZE - 1)) & PAGE_MASK)
5#define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT) 9#define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
6#define PFN_DOWN(x) ((x) >> PAGE_SHIFT) 10#define PFN_DOWN(x) ((x) >> PAGE_SHIFT)
7#define PFN_PHYS(x) ((x) << PAGE_SHIFT) 11#define PFN_PHYS(x) ((phys_addr_t)(x) << PAGE_SHIFT)
8 12
9#endif 13#endif
diff --git a/include/linux/phonet.h b/include/linux/phonet.h
new file mode 100644
index 000000000000..c9609f9aedac
--- /dev/null
+++ b/include/linux/phonet.h
@@ -0,0 +1,170 @@
1/**
2 * file phonet.h
3 *
4 * Phonet sockets kernel interface
5 *
6 * Copyright (C) 2008 Nokia Corporation. All rights reserved.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA
21 */
22
23#ifndef LINUX_PHONET_H
24#define LINUX_PHONET_H
25
26/* Automatic protocol selection */
27#define PN_PROTO_TRANSPORT 0
28/* Phonet datagram socket */
29#define PN_PROTO_PHONET 1
30/* Phonet pipe */
31#define PN_PROTO_PIPE 2
32#define PHONET_NPROTO 3
33
34/* Socket options for SOL_PNPIPE level */
35#define PNPIPE_ENCAP 1
36#define PNPIPE_IFINDEX 2
37
38#define PNADDR_ANY 0
39#define PNPORT_RESOURCE_ROUTING 0
40
41/* Values for PNPIPE_ENCAP option */
42#define PNPIPE_ENCAP_NONE 0
43#define PNPIPE_ENCAP_IP 1
44
45/* ioctls */
46#define SIOCPNGETOBJECT (SIOCPROTOPRIVATE + 0)
47
48/* Phonet protocol header */
49struct phonethdr {
50 __u8 pn_rdev;
51 __u8 pn_sdev;
52 __u8 pn_res;
53 __be16 pn_length;
54 __u8 pn_robj;
55 __u8 pn_sobj;
56} __attribute__((packed));
57
58/* Common Phonet payload header */
59struct phonetmsg {
60 __u8 pn_trans_id; /* transaction ID */
61 __u8 pn_msg_id; /* message type */
62 union {
63 struct {
64 __u8 pn_submsg_id; /* message subtype */
65 __u8 pn_data[5];
66 } base;
67 struct {
68 __u16 pn_e_res_id; /* extended resource ID */
69 __u8 pn_e_submsg_id; /* message subtype */
70 __u8 pn_e_data[3];
71 } ext;
72 } pn_msg_u;
73};
74#define PN_COMMON_MESSAGE 0xF0
75#define PN_PREFIX 0xE0 /* resource for extended messages */
76#define pn_submsg_id pn_msg_u.base.pn_submsg_id
77#define pn_e_submsg_id pn_msg_u.ext.pn_e_submsg_id
78#define pn_e_res_id pn_msg_u.ext.pn_e_res_id
79#define pn_data pn_msg_u.base.pn_data
80#define pn_e_data pn_msg_u.ext.pn_e_data
81
82/* data for unreachable errors */
83#define PN_COMM_SERVICE_NOT_IDENTIFIED_RESP 0x01
84#define PN_COMM_ISA_ENTITY_NOT_REACHABLE_RESP 0x14
85#define pn_orig_msg_id pn_data[0]
86#define pn_status pn_data[1]
87#define pn_e_orig_msg_id pn_e_data[0]
88#define pn_e_status pn_e_data[1]
89
90/* Phonet socket address structure */
91struct sockaddr_pn {
92 sa_family_t spn_family;
93 __u8 spn_obj;
94 __u8 spn_dev;
95 __u8 spn_resource;
96 __u8 spn_zero[sizeof(struct sockaddr) - sizeof(sa_family_t) - 3];
97} __attribute__ ((packed));
98
99static inline __u16 pn_object(__u8 addr, __u16 port)
100{
101 return (addr << 8) | (port & 0x3ff);
102}
103
104static inline __u8 pn_obj(__u16 handle)
105{
106 return handle & 0xff;
107}
108
109static inline __u8 pn_dev(__u16 handle)
110{
111 return handle >> 8;
112}
113
114static inline __u16 pn_port(__u16 handle)
115{
116 return handle & 0x3ff;
117}
118
119static inline __u8 pn_addr(__u16 handle)
120{
121 return (handle >> 8) & 0xfc;
122}
123
124static inline void pn_sockaddr_set_addr(struct sockaddr_pn *spn, __u8 addr)
125{
126 spn->spn_dev &= 0x03;
127 spn->spn_dev |= addr & 0xfc;
128}
129
130static inline void pn_sockaddr_set_port(struct sockaddr_pn *spn, __u16 port)
131{
132 spn->spn_dev &= 0xfc;
133 spn->spn_dev |= (port >> 8) & 0x03;
134 spn->spn_obj = port & 0xff;
135}
136
137static inline void pn_sockaddr_set_object(struct sockaddr_pn *spn,
138 __u16 handle)
139{
140 spn->spn_dev = pn_dev(handle);
141 spn->spn_obj = pn_obj(handle);
142}
143
144static inline void pn_sockaddr_set_resource(struct sockaddr_pn *spn,
145 __u8 resource)
146{
147 spn->spn_resource = resource;
148}
149
150static inline __u8 pn_sockaddr_get_addr(const struct sockaddr_pn *spn)
151{
152 return spn->spn_dev & 0xfc;
153}
154
155static inline __u16 pn_sockaddr_get_port(const struct sockaddr_pn *spn)
156{
157 return ((spn->spn_dev & 0x03) << 8) | spn->spn_obj;
158}
159
160static inline __u16 pn_sockaddr_get_object(const struct sockaddr_pn *spn)
161{
162 return pn_object(spn->spn_dev, spn->spn_obj);
163}
164
165static inline __u8 pn_sockaddr_get_resource(const struct sockaddr_pn *spn)
166{
167 return spn->spn_resource;
168}
169
170#endif
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 7224c4099a28..77c4ed60b982 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -99,7 +99,14 @@ struct mii_bus {
99 */ 99 */
100 struct mutex mdio_lock; 100 struct mutex mdio_lock;
101 101
102 struct device *dev; 102 struct device *parent;
103 enum {
104 MDIOBUS_ALLOCATED = 1,
105 MDIOBUS_REGISTERED,
106 MDIOBUS_UNREGISTERED,
107 MDIOBUS_RELEASED,
108 } state;
109 struct device dev;
103 110
104 /* list of all PHYs on bus */ 111 /* list of all PHYs on bus */
105 struct phy_device *phy_map[PHY_MAX_ADDR]; 112 struct phy_device *phy_map[PHY_MAX_ADDR];
@@ -113,6 +120,16 @@ struct mii_bus {
113 */ 120 */
114 int *irq; 121 int *irq;
115}; 122};
123#define to_mii_bus(d) container_of(d, struct mii_bus, dev)
124
125struct mii_bus *mdiobus_alloc(void);
126int mdiobus_register(struct mii_bus *bus);
127void mdiobus_unregister(struct mii_bus *bus);
128void mdiobus_free(struct mii_bus *bus);
129struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr);
130int mdiobus_read(struct mii_bus *bus, int addr, u16 regnum);
131int mdiobus_write(struct mii_bus *bus, int addr, u16 regnum, u16 val);
132
116 133
117#define PHY_INTERRUPT_DISABLED 0x0 134#define PHY_INTERRUPT_DISABLED 0x0
118#define PHY_INTERRUPT_ENABLED 0x80000000 135#define PHY_INTERRUPT_ENABLED 0x80000000
@@ -391,8 +408,35 @@ struct phy_fixup {
391 int (*run)(struct phy_device *phydev); 408 int (*run)(struct phy_device *phydev);
392}; 409};
393 410
394int phy_read(struct phy_device *phydev, u16 regnum); 411/**
395int phy_write(struct phy_device *phydev, u16 regnum, u16 val); 412 * phy_read - Convenience function for reading a given PHY register
413 * @phydev: the phy_device struct
414 * @regnum: register number to read
415 *
416 * NOTE: MUST NOT be called from interrupt context,
417 * because the bus read/write functions may wait for an interrupt
418 * to conclude the operation.
419 */
420static inline int phy_read(struct phy_device *phydev, u16 regnum)
421{
422 return mdiobus_read(phydev->bus, phydev->addr, regnum);
423}
424
425/**
426 * phy_write - Convenience function for writing a given PHY register
427 * @phydev: the phy_device struct
428 * @regnum: register number to write
429 * @val: value to write to @regnum
430 *
431 * NOTE: MUST NOT be called from interrupt context,
432 * because the bus read/write functions may wait for an interrupt
433 * to conclude the operation.
434 */
435static inline int phy_write(struct phy_device *phydev, u16 regnum, u16 val)
436{
437 return mdiobus_write(phydev->bus, phydev->addr, regnum, val);
438}
439
396int get_phy_id(struct mii_bus *bus, int addr, u32 *phy_id); 440int get_phy_id(struct mii_bus *bus, int addr, u32 *phy_id);
397struct phy_device* get_phy_device(struct mii_bus *bus, int addr); 441struct phy_device* get_phy_device(struct mii_bus *bus, int addr);
398int phy_clear_interrupt(struct phy_device *phydev); 442int phy_clear_interrupt(struct phy_device *phydev);
@@ -408,8 +452,6 @@ void phy_start(struct phy_device *phydev);
408void phy_stop(struct phy_device *phydev); 452void phy_stop(struct phy_device *phydev);
409int phy_start_aneg(struct phy_device *phydev); 453int phy_start_aneg(struct phy_device *phydev);
410 454
411int mdiobus_register(struct mii_bus *bus);
412void mdiobus_unregister(struct mii_bus *bus);
413void phy_sanitize_settings(struct phy_device *phydev); 455void phy_sanitize_settings(struct phy_device *phydev);
414int phy_stop_interrupts(struct phy_device *phydev); 456int phy_stop_interrupts(struct phy_device *phydev);
415int phy_enable_interrupts(struct phy_device *phydev); 457int phy_enable_interrupts(struct phy_device *phydev);
diff --git a/include/linux/pid.h b/include/linux/pid.h
index c21c7e8124a7..d7e98ff8021e 100644
--- a/include/linux/pid.h
+++ b/include/linux/pid.h
@@ -48,7 +48,7 @@ enum pid_type
48 */ 48 */
49 49
50struct upid { 50struct upid {
51 /* Try to keep pid_chain in the same cacheline as nr for find_pid */ 51 /* Try to keep pid_chain in the same cacheline as nr for find_vpid */
52 int nr; 52 int nr;
53 struct pid_namespace *ns; 53 struct pid_namespace *ns;
54 struct hlist_node pid_chain; 54 struct hlist_node pid_chain;
@@ -57,10 +57,10 @@ struct upid {
57struct pid 57struct pid
58{ 58{
59 atomic_t count; 59 atomic_t count;
60 unsigned int level;
60 /* lists of tasks that use this pid */ 61 /* lists of tasks that use this pid */
61 struct hlist_head tasks[PIDTYPE_MAX]; 62 struct hlist_head tasks[PIDTYPE_MAX];
62 struct rcu_head rcu; 63 struct rcu_head rcu;
63 unsigned int level;
64 struct upid numbers[1]; 64 struct upid numbers[1];
65}; 65};
66 66
@@ -105,14 +105,12 @@ extern struct pid_namespace init_pid_ns;
105 * or rcu_read_lock() held. 105 * or rcu_read_lock() held.
106 * 106 *
107 * find_pid_ns() finds the pid in the namespace specified 107 * find_pid_ns() finds the pid in the namespace specified
108 * find_pid() find the pid by its global id, i.e. in the init namespace
109 * find_vpid() finr the pid by its virtual id, i.e. in the current namespace 108 * find_vpid() finr the pid by its virtual id, i.e. in the current namespace
110 * 109 *
111 * see also find_task_by_pid() set in include/linux/sched.h 110 * see also find_task_by_vpid() set in include/linux/sched.h
112 */ 111 */
113extern struct pid *find_pid_ns(int nr, struct pid_namespace *ns); 112extern struct pid *find_pid_ns(int nr, struct pid_namespace *ns);
114extern struct pid *find_vpid(int nr); 113extern struct pid *find_vpid(int nr);
115extern struct pid *find_pid(int nr);
116 114
117/* 115/*
118 * Lookup a PID in the hash table, and return with it's count elevated. 116 * Lookup a PID in the hash table, and return with it's count elevated.
@@ -163,4 +161,13 @@ pid_t pid_vnr(struct pid *pid);
163 } \ 161 } \
164 } while (0) 162 } while (0)
165 163
164#define do_each_pid_thread(pid, type, task) \
165 do_each_pid_task(pid, type, task) { \
166 struct task_struct *tg___ = task; \
167 do {
168
169#define while_each_pid_thread(pid, type, task) \
170 } while_each_thread(tg___, task); \
171 task = tg___; \
172 } while_each_pid_task(pid, type, task)
166#endif /* _LINUX_PID_H */ 173#endif /* _LINUX_PID_H */
diff --git a/include/linux/pid_namespace.h b/include/linux/pid_namespace.h
index caff5283d15c..d82fe825d62f 100644
--- a/include/linux/pid_namespace.h
+++ b/include/linux/pid_namespace.h
@@ -14,6 +14,8 @@ struct pidmap {
14 14
15#define PIDMAP_ENTRIES ((PID_MAX_LIMIT + 8*PAGE_SIZE - 1)/PAGE_SIZE/8) 15#define PIDMAP_ENTRIES ((PID_MAX_LIMIT + 8*PAGE_SIZE - 1)/PAGE_SIZE/8)
16 16
17struct bsd_acct_struct;
18
17struct pid_namespace { 19struct pid_namespace {
18 struct kref kref; 20 struct kref kref;
19 struct pidmap pidmap[PIDMAP_ENTRIES]; 21 struct pidmap pidmap[PIDMAP_ENTRIES];
@@ -25,6 +27,9 @@ struct pid_namespace {
25#ifdef CONFIG_PROC_FS 27#ifdef CONFIG_PROC_FS
26 struct vfsmount *proc_mnt; 28 struct vfsmount *proc_mnt;
27#endif 29#endif
30#ifdef CONFIG_BSD_PROCESS_ACCT
31 struct bsd_acct_struct *bacct;
32#endif
28}; 33};
29 34
30extern struct pid_namespace init_pid_ns; 35extern struct pid_namespace init_pid_ns;
@@ -79,10 +84,7 @@ static inline struct pid_namespace *task_active_pid_ns(struct task_struct *tsk)
79 return tsk->nsproxy->pid_ns; 84 return tsk->nsproxy->pid_ns;
80} 85}
81 86
82static inline struct task_struct *task_child_reaper(struct task_struct *tsk) 87void pidhash_init(void);
83{ 88void pidmap_init(void);
84 BUG_ON(tsk != current);
85 return tsk->nsproxy->pid_ns->child_reaper;
86}
87 89
88#endif /* _LINUX_PID_NS_H */ 90#endif /* _LINUX_PID_NS_H */
diff --git a/include/linux/pim.h b/include/linux/pim.h
index 236ffd317394..1ba0661561a4 100644
--- a/include/linux/pim.h
+++ b/include/linux/pim.h
@@ -3,22 +3,6 @@
3 3
4#include <asm/byteorder.h> 4#include <asm/byteorder.h>
5 5
6#ifndef __KERNEL__
7struct pim {
8#if defined(__LITTLE_ENDIAN_BITFIELD)
9 __u8 pim_type:4, /* PIM message type */
10 pim_ver:4; /* PIM version */
11#elif defined(__BIG_ENDIAN_BITFIELD)
12 __u8 pim_ver:4; /* PIM version */
13 pim_type:4; /* PIM message type */
14#endif
15 __u8 pim_rsv; /* Reserved */
16 __be16 pim_cksum; /* Checksum */
17};
18
19#define PIM_MINLEN 8
20#endif
21
22/* Message types - V1 */ 6/* Message types - V1 */
23#define PIM_V1_VERSION __constant_htonl(0x10000000) 7#define PIM_V1_VERSION __constant_htonl(0x10000000)
24#define PIM_V1_REGISTER 1 8#define PIM_V1_REGISTER 1
@@ -27,7 +11,6 @@ struct pim {
27#define PIM_VERSION 2 11#define PIM_VERSION 2
28#define PIM_REGISTER 1 12#define PIM_REGISTER 1
29 13
30#if defined(__KERNEL__)
31#define PIM_NULL_REGISTER __constant_htonl(0x40000000) 14#define PIM_NULL_REGISTER __constant_htonl(0x40000000)
32 15
33/* PIMv2 register message header layout (ietf-draft-idmr-pimvsm-v2-00.ps */ 16/* PIMv2 register message header layout (ietf-draft-idmr-pimvsm-v2-00.ps */
@@ -42,4 +25,3 @@ struct pimreghdr
42struct sk_buff; 25struct sk_buff;
43extern int pim_rcv_v1(struct sk_buff *); 26extern int pim_rcv_v1(struct sk_buff *);
44#endif 27#endif
45#endif
diff --git a/include/linux/pkt_cls.h b/include/linux/pkt_cls.h
index 99efbed81fa2..7cf7824df778 100644
--- a/include/linux/pkt_cls.h
+++ b/include/linux/pkt_cls.h
@@ -374,6 +374,7 @@ enum
374 TCA_FLOW_ACT, 374 TCA_FLOW_ACT,
375 TCA_FLOW_POLICE, 375 TCA_FLOW_POLICE,
376 TCA_FLOW_EMATCHES, 376 TCA_FLOW_EMATCHES,
377 TCA_FLOW_PERTURB,
377 __TCA_FLOW_MAX 378 __TCA_FLOW_MAX
378}; 379};
379 380
diff --git a/include/linux/pkt_sched.h b/include/linux/pkt_sched.h
index dbb7ac37960d..5d921fa91a5b 100644
--- a/include/linux/pkt_sched.h
+++ b/include/linux/pkt_sched.h
@@ -85,6 +85,26 @@ struct tc_ratespec
85 85
86#define TC_RTAB_SIZE 1024 86#define TC_RTAB_SIZE 1024
87 87
88struct tc_sizespec {
89 unsigned char cell_log;
90 unsigned char size_log;
91 short cell_align;
92 int overhead;
93 unsigned int linklayer;
94 unsigned int mpu;
95 unsigned int mtu;
96 unsigned int tsize;
97};
98
99enum {
100 TCA_STAB_UNSPEC,
101 TCA_STAB_BASE,
102 TCA_STAB_DATA,
103 __TCA_STAB_MAX
104};
105
106#define TCA_STAB_MAX (__TCA_STAB_MAX - 1)
107
88/* FIFO section */ 108/* FIFO section */
89 109
90struct tc_fifo_qopt 110struct tc_fifo_qopt
@@ -103,14 +123,12 @@ struct tc_prio_qopt
103 __u8 priomap[TC_PRIO_MAX+1]; /* Map: logical priority -> PRIO band */ 123 __u8 priomap[TC_PRIO_MAX+1]; /* Map: logical priority -> PRIO band */
104}; 124};
105 125
106enum 126/* MULTIQ section */
107{
108 TCA_PRIO_UNSPEC,
109 TCA_PRIO_MQ,
110 __TCA_PRIO_MAX
111};
112 127
113#define TCA_PRIO_MAX (__TCA_PRIO_MAX - 1) 128struct tc_multiq_qopt {
129 __u16 bands; /* Number of bands */
130 __u16 max_bands; /* Maximum number of queues */
131};
114 132
115/* TBF section */ 133/* TBF section */
116 134
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index 95ac21ab3a09..4b8cc6a32479 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -37,6 +37,8 @@ extern int platform_add_devices(struct platform_device **, int);
37 37
38extern struct platform_device *platform_device_register_simple(const char *, int id, 38extern struct platform_device *platform_device_register_simple(const char *, int id,
39 struct resource *, unsigned int); 39 struct resource *, unsigned int);
40extern struct platform_device *platform_device_register_data(struct device *,
41 const char *, int, const void *, size_t);
40 42
41extern struct platform_device *platform_device_alloc(const char *name, int id); 43extern struct platform_device *platform_device_alloc(const char *name, int id);
42extern int platform_device_add_resources(struct platform_device *pdev, struct resource *res, unsigned int num); 44extern int platform_device_add_resources(struct platform_device *pdev, struct resource *res, unsigned int num);
diff --git a/include/linux/pm.h b/include/linux/pm.h
index 4ad9de94449a..42de4003c4ee 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -22,78 +22,6 @@
22#define _LINUX_PM_H 22#define _LINUX_PM_H
23 23
24#include <linux/list.h> 24#include <linux/list.h>
25#include <asm/atomic.h>
26#include <asm/errno.h>
27
28/*
29 * Power management requests... these are passed to pm_send_all() and friends.
30 *
31 * these functions are old and deprecated, see below.
32 */
33typedef int __bitwise pm_request_t;
34
35#define PM_SUSPEND ((__force pm_request_t) 1) /* enter D1-D3 */
36#define PM_RESUME ((__force pm_request_t) 2) /* enter D0 */
37
38
39/*
40 * Device types... these are passed to pm_register
41 */
42typedef int __bitwise pm_dev_t;
43
44#define PM_UNKNOWN_DEV ((__force pm_dev_t) 0) /* generic */
45#define PM_SYS_DEV ((__force pm_dev_t) 1) /* system device (fan, KB controller, ...) */
46#define PM_PCI_DEV ((__force pm_dev_t) 2) /* PCI device */
47#define PM_USB_DEV ((__force pm_dev_t) 3) /* USB device */
48#define PM_SCSI_DEV ((__force pm_dev_t) 4) /* SCSI device */
49#define PM_ISA_DEV ((__force pm_dev_t) 5) /* ISA device */
50#define PM_MTD_DEV ((__force pm_dev_t) 6) /* Memory Technology Device */
51
52/*
53 * System device hardware ID (PnP) values
54 */
55enum
56{
57 PM_SYS_UNKNOWN = 0x00000000, /* generic */
58 PM_SYS_KBC = 0x41d00303, /* keyboard controller */
59 PM_SYS_COM = 0x41d00500, /* serial port */
60 PM_SYS_IRDA = 0x41d00510, /* IRDA controller */
61 PM_SYS_FDC = 0x41d00700, /* floppy controller */
62 PM_SYS_VGA = 0x41d00900, /* VGA controller */
63 PM_SYS_PCMCIA = 0x41d00e00, /* PCMCIA controller */
64};
65
66/*
67 * Device identifier
68 */
69#define PM_PCI_ID(dev) ((dev)->bus->number << 16 | (dev)->devfn)
70
71/*
72 * Request handler callback
73 */
74struct pm_dev;
75
76typedef int (*pm_callback)(struct pm_dev *dev, pm_request_t rqst, void *data);
77
78/*
79 * Dynamic device information
80 */
81struct pm_dev
82{
83 pm_dev_t type;
84 unsigned long id;
85 pm_callback callback;
86 void *data;
87
88 unsigned long flags;
89 unsigned long state;
90 unsigned long prev_state;
91
92 struct list_head entry;
93};
94
95/* Functions above this comment are list-based old-style power
96 * management. Please avoid using them. */
97 25
98/* 26/*
99 * Callbacks for platform drivers to implement. 27 * Callbacks for platform drivers to implement.
@@ -317,6 +245,21 @@ struct pm_ext_ops {
317 * RECOVER Creation of a hibernation image or restoration of the main 245 * RECOVER Creation of a hibernation image or restoration of the main
318 * memory contents from a hibernation image has failed, call 246 * memory contents from a hibernation image has failed, call
319 * ->thaw() and ->complete() for all devices. 247 * ->thaw() and ->complete() for all devices.
248 *
249 * The following PM_EVENT_ messages are defined for internal use by
250 * kernel subsystems. They are never issued by the PM core.
251 *
252 * USER_SUSPEND Manual selective suspend was issued by userspace.
253 *
254 * USER_RESUME Manual selective resume was issued by userspace.
255 *
256 * REMOTE_WAKEUP Remote-wakeup request was received from the device.
257 *
258 * AUTO_SUSPEND Automatic (device idle) runtime suspend was
259 * initiated by the subsystem.
260 *
261 * AUTO_RESUME Automatic (device needed) runtime resume was
262 * requested by a driver.
320 */ 263 */
321 264
322#define PM_EVENT_ON 0x0000 265#define PM_EVENT_ON 0x0000
@@ -328,9 +271,18 @@ struct pm_ext_ops {
328#define PM_EVENT_THAW 0x0020 271#define PM_EVENT_THAW 0x0020
329#define PM_EVENT_RESTORE 0x0040 272#define PM_EVENT_RESTORE 0x0040
330#define PM_EVENT_RECOVER 0x0080 273#define PM_EVENT_RECOVER 0x0080
274#define PM_EVENT_USER 0x0100
275#define PM_EVENT_REMOTE 0x0200
276#define PM_EVENT_AUTO 0x0400
331 277
332#define PM_EVENT_SLEEP (PM_EVENT_SUSPEND | PM_EVENT_HIBERNATE) 278#define PM_EVENT_SLEEP (PM_EVENT_SUSPEND | PM_EVENT_HIBERNATE)
279#define PM_EVENT_USER_SUSPEND (PM_EVENT_USER | PM_EVENT_SUSPEND)
280#define PM_EVENT_USER_RESUME (PM_EVENT_USER | PM_EVENT_RESUME)
281#define PM_EVENT_REMOTE_WAKEUP (PM_EVENT_REMOTE | PM_EVENT_RESUME)
282#define PM_EVENT_AUTO_SUSPEND (PM_EVENT_AUTO | PM_EVENT_SUSPEND)
283#define PM_EVENT_AUTO_RESUME (PM_EVENT_AUTO | PM_EVENT_RESUME)
333 284
285#define PMSG_ON ((struct pm_message){ .event = PM_EVENT_ON, })
334#define PMSG_FREEZE ((struct pm_message){ .event = PM_EVENT_FREEZE, }) 286#define PMSG_FREEZE ((struct pm_message){ .event = PM_EVENT_FREEZE, })
335#define PMSG_QUIESCE ((struct pm_message){ .event = PM_EVENT_QUIESCE, }) 287#define PMSG_QUIESCE ((struct pm_message){ .event = PM_EVENT_QUIESCE, })
336#define PMSG_SUSPEND ((struct pm_message){ .event = PM_EVENT_SUSPEND, }) 288#define PMSG_SUSPEND ((struct pm_message){ .event = PM_EVENT_SUSPEND, })
@@ -339,7 +291,16 @@ struct pm_ext_ops {
339#define PMSG_THAW ((struct pm_message){ .event = PM_EVENT_THAW, }) 291#define PMSG_THAW ((struct pm_message){ .event = PM_EVENT_THAW, })
340#define PMSG_RESTORE ((struct pm_message){ .event = PM_EVENT_RESTORE, }) 292#define PMSG_RESTORE ((struct pm_message){ .event = PM_EVENT_RESTORE, })
341#define PMSG_RECOVER ((struct pm_message){ .event = PM_EVENT_RECOVER, }) 293#define PMSG_RECOVER ((struct pm_message){ .event = PM_EVENT_RECOVER, })
342#define PMSG_ON ((struct pm_message){ .event = PM_EVENT_ON, }) 294#define PMSG_USER_SUSPEND ((struct pm_messge) \
295 { .event = PM_EVENT_USER_SUSPEND, })
296#define PMSG_USER_RESUME ((struct pm_messge) \
297 { .event = PM_EVENT_USER_RESUME, })
298#define PMSG_REMOTE_RESUME ((struct pm_messge) \
299 { .event = PM_EVENT_REMOTE_RESUME, })
300#define PMSG_AUTO_SUSPEND ((struct pm_messge) \
301 { .event = PM_EVENT_AUTO_SUSPEND, })
302#define PMSG_AUTO_RESUME ((struct pm_messge) \
303 { .event = PM_EVENT_AUTO_RESUME, })
343 304
344/** 305/**
345 * Device power management states 306 * Device power management states
@@ -458,7 +419,7 @@ extern void __suspend_report_result(const char *function, void *fn, int ret);
458 419
459#define suspend_report_result(fn, ret) \ 420#define suspend_report_result(fn, ret) \
460 do { \ 421 do { \
461 __suspend_report_result(__FUNCTION__, fn, ret); \ 422 __suspend_report_result(__func__, fn, ret); \
462 } while (0) 423 } while (0)
463 424
464#else /* !CONFIG_PM_SLEEP */ 425#else /* !CONFIG_PM_SLEEP */
diff --git a/include/linux/pm_legacy.h b/include/linux/pm_legacy.h
deleted file mode 100644
index 446f4f42b952..000000000000
--- a/include/linux/pm_legacy.h
+++ /dev/null
@@ -1,35 +0,0 @@
1#ifndef __LINUX_PM_LEGACY_H__
2#define __LINUX_PM_LEGACY_H__
3
4
5#ifdef CONFIG_PM_LEGACY
6
7/*
8 * Register a device with power management
9 */
10struct pm_dev __deprecated *
11pm_register(pm_dev_t type, unsigned long id, pm_callback callback);
12
13/*
14 * Send a request to all devices
15 */
16int __deprecated pm_send_all(pm_request_t rqst, void *data);
17
18#else /* CONFIG_PM_LEGACY */
19
20static inline struct pm_dev *pm_register(pm_dev_t type,
21 unsigned long id,
22 pm_callback callback)
23{
24 return NULL;
25}
26
27static inline int pm_send_all(pm_request_t rqst, void *data)
28{
29 return 0;
30}
31
32#endif /* CONFIG_PM_LEGACY */
33
34#endif /* __LINUX_PM_LEGACY_H__ */
35
diff --git a/include/linux/pm_qos_params.h b/include/linux/pm_qos_params.h
index 2e4e97bd19f7..d74f75ed1e47 100644
--- a/include/linux/pm_qos_params.h
+++ b/include/linux/pm_qos_params.h
@@ -1,6 +1,6 @@
1/* interface for the pm_qos_power infrastructure of the linux kernel. 1/* interface for the pm_qos_power infrastructure of the linux kernel.
2 * 2 *
3 * Mark Gross 3 * Mark Gross <mgross@linux.intel.com>
4 */ 4 */
5#include <linux/list.h> 5#include <linux/list.h>
6#include <linux/notifier.h> 6#include <linux/notifier.h>
diff --git a/include/linux/pnp.h b/include/linux/pnp.h
index 1ce54b63085d..ca3c88773028 100644
--- a/include/linux/pnp.h
+++ b/include/linux/pnp.h
@@ -21,7 +21,16 @@ struct pnp_dev;
21/* 21/*
22 * Resource Management 22 * Resource Management
23 */ 23 */
24struct resource *pnp_get_resource(struct pnp_dev *, unsigned int, unsigned int); 24#ifdef CONFIG_PNP
25struct resource *pnp_get_resource(struct pnp_dev *dev, unsigned long type,
26 unsigned int num);
27#else
28static inline struct resource *pnp_get_resource(struct pnp_dev *dev,
29 unsigned long type, unsigned int num)
30{
31 return NULL;
32}
33#endif
25 34
26static inline int pnp_resource_valid(struct resource *res) 35static inline int pnp_resource_valid(struct resource *res)
27{ 36{
@@ -476,14 +485,4 @@ static inline void pnp_unregister_driver(struct pnp_driver *drv) { }
476 485
477#endif /* CONFIG_PNP */ 486#endif /* CONFIG_PNP */
478 487
479#define pnp_err(format, arg...) printk(KERN_ERR "pnp: " format "\n" , ## arg)
480#define pnp_info(format, arg...) printk(KERN_INFO "pnp: " format "\n" , ## arg)
481#define pnp_warn(format, arg...) printk(KERN_WARNING "pnp: " format "\n" , ## arg)
482
483#ifdef CONFIG_PNP_DEBUG
484#define pnp_dbg(format, arg...) printk(KERN_DEBUG "pnp: " format "\n" , ## arg)
485#else
486#define pnp_dbg(format, arg...) do {} while (0)
487#endif
488
489#endif /* _LINUX_PNP_H */ 488#endif /* _LINUX_PNP_H */
diff --git a/include/linux/poll.h b/include/linux/poll.h
index ef453828877a..badd98ab06f6 100644
--- a/include/linux/poll.h
+++ b/include/linux/poll.h
@@ -114,11 +114,13 @@ void zero_fd_set(unsigned long nr, unsigned long *fdset)
114 114
115#define MAX_INT64_SECONDS (((s64)(~((u64)0)>>1)/HZ)-1) 115#define MAX_INT64_SECONDS (((s64)(~((u64)0)>>1)/HZ)-1)
116 116
117extern int do_select(int n, fd_set_bits *fds, s64 *timeout); 117extern int do_select(int n, fd_set_bits *fds, struct timespec *end_time);
118extern int do_sys_poll(struct pollfd __user * ufds, unsigned int nfds, 118extern int do_sys_poll(struct pollfd __user * ufds, unsigned int nfds,
119 s64 *timeout); 119 struct timespec *end_time);
120extern int core_sys_select(int n, fd_set __user *inp, fd_set __user *outp, 120extern int core_sys_select(int n, fd_set __user *inp, fd_set __user *outp,
121 fd_set __user *exp, s64 *timeout); 121 fd_set __user *exp, struct timespec *end_time);
122
123extern int poll_select_set_timeout(struct timespec *to, long sec, long nsec);
122 124
123#endif /* KERNEL */ 125#endif /* KERNEL */
124 126
diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h
index a7dd38f30ade..a7c721355549 100644
--- a/include/linux/posix-timers.h
+++ b/include/linux/posix-timers.h
@@ -45,8 +45,6 @@ struct k_itimer {
45 int it_requeue_pending; /* waiting to requeue this timer */ 45 int it_requeue_pending; /* waiting to requeue this timer */
46#define REQUEUE_PENDING 1 46#define REQUEUE_PENDING 1
47 int it_sigev_notify; /* notify word of sigevent struct */ 47 int it_sigev_notify; /* notify word of sigevent struct */
48 int it_sigev_signo; /* signo word of sigevent struct */
49 sigval_t it_sigev_value; /* value word of sigevent struct */
50 struct task_struct *it_process; /* process to send signal to */ 48 struct task_struct *it_process; /* process to send signal to */
51 struct sigqueue *sigq; /* signal queue entry. */ 49 struct sigqueue *sigq; /* signal queue entry. */
52 union { 50 union {
@@ -115,4 +113,6 @@ void set_process_cpu_timer(struct task_struct *task, unsigned int clock_idx,
115 113
116long clock_nanosleep_restart(struct restart_block *restart_block); 114long clock_nanosleep_restart(struct restart_block *restart_block);
117 115
116void update_rlimit_cpu(unsigned long rlim_new);
117
118#endif 118#endif
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 68ed19ccf1f7..f9348cba6dc1 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -78,6 +78,7 @@ enum power_supply_property {
78 POWER_SUPPLY_PROP_CHARGE_EMPTY, 78 POWER_SUPPLY_PROP_CHARGE_EMPTY,
79 POWER_SUPPLY_PROP_CHARGE_NOW, 79 POWER_SUPPLY_PROP_CHARGE_NOW,
80 POWER_SUPPLY_PROP_CHARGE_AVG, 80 POWER_SUPPLY_PROP_CHARGE_AVG,
81 POWER_SUPPLY_PROP_CHARGE_COUNTER,
81 POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN, 82 POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN,
82 POWER_SUPPLY_PROP_ENERGY_EMPTY_DESIGN, 83 POWER_SUPPLY_PROP_ENERGY_EMPTY_DESIGN,
83 POWER_SUPPLY_PROP_ENERGY_FULL, 84 POWER_SUPPLY_PROP_ENERGY_FULL,
@@ -164,6 +165,12 @@ struct power_supply_info {
164extern void power_supply_changed(struct power_supply *psy); 165extern void power_supply_changed(struct power_supply *psy);
165extern int power_supply_am_i_supplied(struct power_supply *psy); 166extern int power_supply_am_i_supplied(struct power_supply *psy);
166 167
168#if defined(CONFIG_POWER_SUPPLY) || defined(CONFIG_POWER_SUPPLY_MODULE)
169extern int power_supply_is_system_supplied(void);
170#else
171static inline int power_supply_is_system_supplied(void) { return -ENOSYS; }
172#endif
173
167extern int power_supply_register(struct device *parent, 174extern int power_supply_register(struct device *parent,
168 struct power_supply *psy); 175 struct power_supply *psy);
169extern void power_supply_unregister(struct power_supply *psy); 176extern void power_supply_unregister(struct power_supply *psy);
diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
index e86a7a5cf355..b8d4ddd22736 100644
--- a/include/linux/ppp-comp.h
+++ b/include/linux/ppp-comp.h
@@ -23,8 +23,6 @@
23 * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO 23 * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO
24 * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, 24 * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
25 * OR MODIFICATIONS. 25 * OR MODIFICATIONS.
26 *
27 * $Id: ppp-comp.h,v 1.6 1997/11/27 06:04:44 paulus Exp $
28 */ 26 */
29 27
30/* 28/*
diff --git a/include/linux/ppp_defs.h b/include/linux/ppp_defs.h
index c6b13ff85028..6e8adc77522c 100644
--- a/include/linux/ppp_defs.h
+++ b/include/linux/ppp_defs.h
@@ -1,5 +1,3 @@
1/* $Id: ppp_defs.h,v 1.2 1994/09/21 01:31:06 paulus Exp $ */
2
3/* 1/*
4 * ppp_defs.h - PPP definitions. 2 * ppp_defs.h - PPP definitions.
5 * 3 *
diff --git a/include/linux/prctl.h b/include/linux/prctl.h
index 5ad79198d6f9..48d887e3c6e7 100644
--- a/include/linux/prctl.h
+++ b/include/linux/prctl.h
@@ -78,4 +78,11 @@
78#define PR_GET_SECUREBITS 27 78#define PR_GET_SECUREBITS 27
79#define PR_SET_SECUREBITS 28 79#define PR_SET_SECUREBITS 28
80 80
81/*
82 * Get/set the timerslack as used by poll/select/nanosleep
83 * A value of 0 means "use default"
84 */
85#define PR_SET_TIMERSLACK 29
86#define PR_GET_TIMERSLACK 30
87
81#endif /* _LINUX_PRCTL_H */ 88#endif /* _LINUX_PRCTL_H */
diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
index fff1d27ddb4c..b8bdb96eff78 100644
--- a/include/linux/proc_fs.h
+++ b/include/linux/proc_fs.h
@@ -79,6 +79,7 @@ struct proc_dir_entry {
79 int pde_users; /* number of callers into module in progress */ 79 int pde_users; /* number of callers into module in progress */
80 spinlock_t pde_unload_lock; /* proc_fops checks and pde_users bumps */ 80 spinlock_t pde_unload_lock; /* proc_fops checks and pde_users bumps */
81 struct completion *pde_unload_completion; 81 struct completion *pde_unload_completion;
82 struct list_head pde_openers; /* who did ->open, but not ->release */
82}; 83};
83 84
84struct kcore_list { 85struct kcore_list {
@@ -96,12 +97,9 @@ struct vmcore {
96 97
97#ifdef CONFIG_PROC_FS 98#ifdef CONFIG_PROC_FS
98 99
99extern struct proc_dir_entry *proc_root_kcore;
100
101extern spinlock_t proc_subdir_lock; 100extern spinlock_t proc_subdir_lock;
102 101
103extern void proc_root_init(void); 102extern void proc_root_init(void);
104extern void proc_misc_init(void);
105 103
106void proc_flush_task(struct task_struct *task); 104void proc_flush_task(struct task_struct *task);
107struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, struct nameidata *); 105struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, struct nameidata *);
@@ -137,10 +135,6 @@ extern struct inode *proc_get_inode(struct super_block *, unsigned int, struct p
137extern int proc_readdir(struct file *, void *, filldir_t); 135extern int proc_readdir(struct file *, void *, filldir_t);
138extern struct dentry *proc_lookup(struct inode *, struct dentry *, struct nameidata *); 136extern struct dentry *proc_lookup(struct inode *, struct dentry *, struct nameidata *);
139 137
140extern const struct file_operations proc_kcore_operations;
141extern const struct file_operations proc_kmsg_operations;
142extern const struct file_operations ppc_htab_operations;
143
144extern int pid_ns_prepare_proc(struct pid_namespace *ns); 138extern int pid_ns_prepare_proc(struct pid_namespace *ns);
145extern void pid_ns_release_proc(struct pid_namespace *ns); 139extern void pid_ns_release_proc(struct pid_namespace *ns);
146 140
@@ -282,11 +276,16 @@ union proc_op {
282 struct task_struct *task); 276 struct task_struct *task);
283}; 277};
284 278
279struct ctl_table_header;
280struct ctl_table;
281
285struct proc_inode { 282struct proc_inode {
286 struct pid *pid; 283 struct pid *pid;
287 int fd; 284 int fd;
288 union proc_op op; 285 union proc_op op;
289 struct proc_dir_entry *pde; 286 struct proc_dir_entry *pde;
287 struct ctl_table_header *sysctl;
288 struct ctl_table *sysctl_entry;
290 struct inode vfs_inode; 289 struct inode vfs_inode;
291}; 290};
292 291
@@ -305,8 +304,6 @@ static inline struct net *PDE_NET(struct proc_dir_entry *pde)
305 return pde->parent->data; 304 return pde->parent->data;
306} 305}
307 306
308struct net *get_proc_net(const struct inode *inode);
309
310struct proc_maps_private { 307struct proc_maps_private {
311 struct pid *pid; 308 struct pid *pid;
312 struct task_struct *task; 309 struct task_struct *task;
diff --git a/include/linux/profile.h b/include/linux/profile.h
index 05c1cc736937..a0fc32279fc0 100644
--- a/include/linux/profile.h
+++ b/include/linux/profile.h
@@ -8,8 +8,6 @@
8 8
9#include <asm/errno.h> 9#include <asm/errno.h>
10 10
11extern int prof_on __read_mostly;
12
13#define CPU_PROFILING 1 11#define CPU_PROFILING 1
14#define SCHED_PROFILING 2 12#define SCHED_PROFILING 2
15#define SLEEP_PROFILING 3 13#define SLEEP_PROFILING 3
@@ -19,14 +17,38 @@ struct proc_dir_entry;
19struct pt_regs; 17struct pt_regs;
20struct notifier_block; 18struct notifier_block;
21 19
20#if defined(CONFIG_PROFILING) && defined(CONFIG_PROC_FS)
21void create_prof_cpu_mask(struct proc_dir_entry *de);
22int create_proc_profile(void);
23#else
24static inline void create_prof_cpu_mask(struct proc_dir_entry *de)
25{
26}
27
28static inline int create_proc_profile(void)
29{
30 return 0;
31}
32#endif
33
34enum profile_type {
35 PROFILE_TASK_EXIT,
36 PROFILE_MUNMAP
37};
38
39#ifdef CONFIG_PROFILING
40
41extern int prof_on __read_mostly;
42
22/* init basic kernel profiler */ 43/* init basic kernel profiler */
23void __init profile_init(void); 44int profile_init(void);
24void profile_tick(int); 45int profile_setup(char *str);
46void profile_tick(int type);
25 47
26/* 48/*
27 * Add multiple profiler hits to a given address: 49 * Add multiple profiler hits to a given address:
28 */ 50 */
29void profile_hits(int, void *ip, unsigned int nr_hits); 51void profile_hits(int type, void *ip, unsigned int nr_hits);
30 52
31/* 53/*
32 * Single profiler hit: 54 * Single profiler hit:
@@ -40,19 +62,6 @@ static inline void profile_hit(int type, void *ip)
40 profile_hits(type, ip, 1); 62 profile_hits(type, ip, 1);
41} 63}
42 64
43#ifdef CONFIG_PROC_FS
44void create_prof_cpu_mask(struct proc_dir_entry *);
45#else
46#define create_prof_cpu_mask(x) do { (void)(x); } while (0)
47#endif
48
49enum profile_type {
50 PROFILE_TASK_EXIT,
51 PROFILE_MUNMAP
52};
53
54#ifdef CONFIG_PROFILING
55
56struct task_struct; 65struct task_struct;
57struct mm_struct; 66struct mm_struct;
58 67
@@ -80,6 +89,28 @@ struct pt_regs;
80 89
81#else 90#else
82 91
92#define prof_on 0
93
94static inline int profile_init(void)
95{
96 return 0;
97}
98
99static inline void profile_tick(int type)
100{
101 return;
102}
103
104static inline void profile_hits(int type, void *ip, unsigned int nr_hits)
105{
106 return;
107}
108
109static inline void profile_hit(int type, void *ip)
110{
111 return;
112}
113
83static inline int task_handoff_register(struct notifier_block * n) 114static inline int task_handoff_register(struct notifier_block * n)
84{ 115{
85 return -ENOSYS; 116 return -ENOSYS;
diff --git a/include/linux/proportions.h b/include/linux/proportions.h
index 5afc1b23346d..cf793bbbd05e 100644
--- a/include/linux/proportions.h
+++ b/include/linux/proportions.h
@@ -104,8 +104,8 @@ struct prop_local_single {
104 * snapshot of the last seen global state 104 * snapshot of the last seen global state
105 * and a lock protecting this state 105 * and a lock protecting this state
106 */ 106 */
107 int shift;
108 unsigned long period; 107 unsigned long period;
108 int shift;
109 spinlock_t lock; /* protect the snapshot state */ 109 spinlock_t lock; /* protect the snapshot state */
110}; 110};
111 111
diff --git a/include/linux/ptrace.h b/include/linux/ptrace.h
index c6f5f9dd0cee..22641d5d45df 100644
--- a/include/linux/ptrace.h
+++ b/include/linux/ptrace.h
@@ -94,7 +94,6 @@ extern void ptrace_notify(int exit_code);
94extern void __ptrace_link(struct task_struct *child, 94extern void __ptrace_link(struct task_struct *child,
95 struct task_struct *new_parent); 95 struct task_struct *new_parent);
96extern void __ptrace_unlink(struct task_struct *child); 96extern void __ptrace_unlink(struct task_struct *child);
97extern void ptrace_untrace(struct task_struct *child);
98#define PTRACE_MODE_READ 1 97#define PTRACE_MODE_READ 1
99#define PTRACE_MODE_ATTACH 2 98#define PTRACE_MODE_ATTACH 2
100/* Returns 0 on success, -errno on denial. */ 99/* Returns 0 on success, -errno on denial. */
@@ -121,6 +120,74 @@ static inline void ptrace_unlink(struct task_struct *child)
121int generic_ptrace_peekdata(struct task_struct *tsk, long addr, long data); 120int generic_ptrace_peekdata(struct task_struct *tsk, long addr, long data);
122int generic_ptrace_pokedata(struct task_struct *tsk, long addr, long data); 121int generic_ptrace_pokedata(struct task_struct *tsk, long addr, long data);
123 122
123/**
124 * task_ptrace - return %PT_* flags that apply to a task
125 * @task: pointer to &task_struct in question
126 *
127 * Returns the %PT_* flags that apply to @task.
128 */
129static inline int task_ptrace(struct task_struct *task)
130{
131 return task->ptrace;
132}
133
134/**
135 * ptrace_event - possibly stop for a ptrace event notification
136 * @mask: %PT_* bit to check in @current->ptrace
137 * @event: %PTRACE_EVENT_* value to report if @mask is set
138 * @message: value for %PTRACE_GETEVENTMSG to return
139 *
140 * This checks the @mask bit to see if ptrace wants stops for this event.
141 * If so we stop, reporting @event and @message to the ptrace parent.
142 *
143 * Returns nonzero if we did a ptrace notification, zero if not.
144 *
145 * Called without locks.
146 */
147static inline int ptrace_event(int mask, int event, unsigned long message)
148{
149 if (mask && likely(!(current->ptrace & mask)))
150 return 0;
151 current->ptrace_message = message;
152 ptrace_notify((event << 8) | SIGTRAP);
153 return 1;
154}
155
156/**
157 * ptrace_init_task - initialize ptrace state for a new child
158 * @child: new child task
159 * @ptrace: true if child should be ptrace'd by parent's tracer
160 *
161 * This is called immediately after adding @child to its parent's children
162 * list. @ptrace is false in the normal case, and true to ptrace @child.
163 *
164 * Called with current's siglock and write_lock_irq(&tasklist_lock) held.
165 */
166static inline void ptrace_init_task(struct task_struct *child, bool ptrace)
167{
168 INIT_LIST_HEAD(&child->ptrace_entry);
169 INIT_LIST_HEAD(&child->ptraced);
170 child->parent = child->real_parent;
171 child->ptrace = 0;
172 if (unlikely(ptrace)) {
173 child->ptrace = current->ptrace;
174 ptrace_link(child, current->parent);
175 }
176}
177
178/**
179 * ptrace_release_task - final ptrace-related cleanup of a zombie being reaped
180 * @task: task in %EXIT_DEAD state
181 *
182 * Called with write_lock(&tasklist_lock) held.
183 */
184static inline void ptrace_release_task(struct task_struct *task)
185{
186 BUG_ON(!list_empty(&task->ptraced));
187 ptrace_unlink(task);
188 BUG_ON(!list_empty(&task->ptrace_entry));
189}
190
124#ifndef force_successful_syscall_return 191#ifndef force_successful_syscall_return
125/* 192/*
126 * System call handlers that, upon successful completion, need to return a 193 * System call handlers that, upon successful completion, need to return a
@@ -246,6 +313,10 @@ static inline void user_enable_block_step(struct task_struct *task)
246#define arch_ptrace_stop(code, info) do { } while (0) 313#define arch_ptrace_stop(code, info) do { } while (0)
247#endif 314#endif
248 315
316extern int task_current_syscall(struct task_struct *target, long *callno,
317 unsigned long args[6], unsigned int maxargs,
318 unsigned long *sp, unsigned long *pc);
319
249#endif 320#endif
250 321
251#endif 322#endif
diff --git a/include/linux/quicklist.h b/include/linux/quicklist.h
index 39b66713a0bb..bd466439c588 100644
--- a/include/linux/quicklist.h
+++ b/include/linux/quicklist.h
@@ -80,6 +80,13 @@ void quicklist_trim(int nr, void (*dtor)(void *),
80 80
81unsigned long quicklist_total_size(void); 81unsigned long quicklist_total_size(void);
82 82
83#else
84
85static inline unsigned long quicklist_total_size(void)
86{
87 return 0;
88}
89
83#endif 90#endif
84 91
85#endif /* LINUX_QUICKLIST_H */ 92#endif /* LINUX_QUICKLIST_H */
diff --git a/include/linux/quota.h b/include/linux/quota.h
index dcddfb200947..40401b554484 100644
--- a/include/linux/quota.h
+++ b/include/linux/quota.h
@@ -28,8 +28,6 @@
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE. 30 * SUCH DAMAGE.
31 *
32 * Version: $Id: quota.h,v 2.0 1996/11/17 16:48:14 mvw Exp mvw $
33 */ 31 */
34 32
35#ifndef _LINUX_QUOTA_ 33#ifndef _LINUX_QUOTA_
@@ -41,9 +39,6 @@
41#define __DQUOT_VERSION__ "dquot_6.5.1" 39#define __DQUOT_VERSION__ "dquot_6.5.1"
42#define __DQUOT_NUM_VERSION__ 6*10000+5*100+1 40#define __DQUOT_NUM_VERSION__ 6*10000+5*100+1
43 41
44typedef __kernel_uid32_t qid_t; /* Type in which we store ids in memory */
45typedef __u64 qsize_t; /* Type in which we store sizes */
46
47/* Size of blocks in which are counted size limits */ 42/* Size of blocks in which are counted size limits */
48#define QUOTABLOCK_BITS 10 43#define QUOTABLOCK_BITS 10
49#define QUOTABLOCK_SIZE (1 << QUOTABLOCK_BITS) 44#define QUOTABLOCK_SIZE (1 << QUOTABLOCK_BITS)
@@ -138,6 +133,10 @@ struct if_dqinfo {
138#define QUOTA_NL_BHARDWARN 4 /* Block hardlimit reached */ 133#define QUOTA_NL_BHARDWARN 4 /* Block hardlimit reached */
139#define QUOTA_NL_BSOFTLONGWARN 5 /* Block grace time expired */ 134#define QUOTA_NL_BSOFTLONGWARN 5 /* Block grace time expired */
140#define QUOTA_NL_BSOFTWARN 6 /* Block softlimit reached */ 135#define QUOTA_NL_BSOFTWARN 6 /* Block softlimit reached */
136#define QUOTA_NL_IHARDBELOW 7 /* Usage got below inode hardlimit */
137#define QUOTA_NL_ISOFTBELOW 8 /* Usage got below inode softlimit */
138#define QUOTA_NL_BHARDBELOW 9 /* Usage got below block hardlimit */
139#define QUOTA_NL_BSOFTBELOW 10 /* Usage got below block softlimit */
141 140
142enum { 141enum {
143 QUOTA_NL_C_UNSPEC, 142 QUOTA_NL_C_UNSPEC,
@@ -172,6 +171,9 @@ enum {
172 171
173#include <asm/atomic.h> 172#include <asm/atomic.h>
174 173
174typedef __kernel_uid32_t qid_t; /* Type in which we store ids in memory */
175typedef __u64 qsize_t; /* Type in which we store sizes */
176
175extern spinlock_t dq_data_lock; 177extern spinlock_t dq_data_lock;
176 178
177/* Maximal numbers of writes for quota operation (insert/delete/update) 179/* Maximal numbers of writes for quota operation (insert/delete/update)
@@ -223,12 +225,10 @@ struct super_block;
223#define DQF_INFO_DIRTY (1 << DQF_INFO_DIRTY_B) /* Is info dirty? */ 225#define DQF_INFO_DIRTY (1 << DQF_INFO_DIRTY_B) /* Is info dirty? */
224 226
225extern void mark_info_dirty(struct super_block *sb, int type); 227extern void mark_info_dirty(struct super_block *sb, int type);
226#define info_dirty(info) test_bit(DQF_INFO_DIRTY_B, &(info)->dqi_flags) 228static inline int info_dirty(struct mem_dqinfo *info)
227#define info_any_dquot_dirty(info) (!list_empty(&(info)->dqi_dirty_list)) 229{
228#define info_any_dirty(info) (info_dirty(info) || info_any_dquot_dirty(info)) 230 return test_bit(DQF_INFO_DIRTY_B, &info->dqi_flags);
229 231}
230#define sb_dqopt(sb) (&(sb)->s_dquot)
231#define sb_dqinfo(sb, type) (sb_dqopt(sb)->info+(type))
232 232
233struct dqstats { 233struct dqstats {
234 int lookups; 234 int lookups;
@@ -337,19 +337,6 @@ struct quota_info {
337 struct quota_format_ops *ops[MAXQUOTAS]; /* Operations for each type */ 337 struct quota_format_ops *ops[MAXQUOTAS]; /* Operations for each type */
338}; 338};
339 339
340#define sb_has_quota_enabled(sb, type) ((type)==USRQUOTA ? \
341 (sb_dqopt(sb)->flags & DQUOT_USR_ENABLED) : (sb_dqopt(sb)->flags & DQUOT_GRP_ENABLED))
342
343#define sb_any_quota_enabled(sb) (sb_has_quota_enabled(sb, USRQUOTA) | \
344 sb_has_quota_enabled(sb, GRPQUOTA))
345
346#define sb_has_quota_suspended(sb, type) \
347 ((type) == USRQUOTA ? (sb_dqopt(sb)->flags & DQUOT_USR_SUSPENDED) : \
348 (sb_dqopt(sb)->flags & DQUOT_GRP_SUSPENDED))
349
350#define sb_any_quota_suspended(sb) (sb_has_quota_suspended(sb, USRQUOTA) | \
351 sb_has_quota_suspended(sb, GRPQUOTA))
352
353int register_quota_format(struct quota_format_type *fmt); 340int register_quota_format(struct quota_format_type *fmt);
354void unregister_quota_format(struct quota_format_type *fmt); 341void unregister_quota_format(struct quota_format_type *fmt);
355 342
diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h
index f86702053853..a558a4c1d35a 100644
--- a/include/linux/quotaops.h
+++ b/include/linux/quotaops.h
@@ -3,50 +3,92 @@
3 * macros expand to the right source-code. 3 * macros expand to the right source-code.
4 * 4 *
5 * Author: Marco van Wieringen <mvw@planets.elm.net> 5 * Author: Marco van Wieringen <mvw@planets.elm.net>
6 *
7 * Version: $Id: quotaops.h,v 1.2 1998/01/15 16:22:26 ecd Exp $
8 *
9 */ 6 */
10#ifndef _LINUX_QUOTAOPS_ 7#ifndef _LINUX_QUOTAOPS_
11#define _LINUX_QUOTAOPS_ 8#define _LINUX_QUOTAOPS_
12 9
13#include <linux/smp_lock.h> 10#include <linux/smp_lock.h>
14
15#include <linux/fs.h> 11#include <linux/fs.h>
16 12
13static inline struct quota_info *sb_dqopt(struct super_block *sb)
14{
15 return &sb->s_dquot;
16}
17
17#if defined(CONFIG_QUOTA) 18#if defined(CONFIG_QUOTA)
18 19
19/* 20/*
20 * declaration of quota_function calls in kernel. 21 * declaration of quota_function calls in kernel.
21 */ 22 */
22extern void sync_dquots(struct super_block *sb, int type); 23void sync_dquots(struct super_block *sb, int type);
23 24
24extern int dquot_initialize(struct inode *inode, int type); 25int dquot_initialize(struct inode *inode, int type);
25extern int dquot_drop(struct inode *inode); 26int dquot_drop(struct inode *inode);
26 27
27extern int dquot_alloc_space(struct inode *inode, qsize_t number, int prealloc); 28int dquot_alloc_space(struct inode *inode, qsize_t number, int prealloc);
28extern int dquot_alloc_inode(const struct inode *inode, unsigned long number); 29int dquot_alloc_inode(const struct inode *inode, unsigned long number);
29 30
30extern int dquot_free_space(struct inode *inode, qsize_t number); 31int dquot_free_space(struct inode *inode, qsize_t number);
31extern int dquot_free_inode(const struct inode *inode, unsigned long number); 32int dquot_free_inode(const struct inode *inode, unsigned long number);
32 33
33extern int dquot_transfer(struct inode *inode, struct iattr *iattr); 34int dquot_transfer(struct inode *inode, struct iattr *iattr);
34extern int dquot_commit(struct dquot *dquot); 35int dquot_commit(struct dquot *dquot);
35extern int dquot_acquire(struct dquot *dquot); 36int dquot_acquire(struct dquot *dquot);
36extern int dquot_release(struct dquot *dquot); 37int dquot_release(struct dquot *dquot);
37extern int dquot_commit_info(struct super_block *sb, int type); 38int dquot_commit_info(struct super_block *sb, int type);
38extern int dquot_mark_dquot_dirty(struct dquot *dquot); 39int dquot_mark_dquot_dirty(struct dquot *dquot);
39 40
40extern int vfs_quota_on(struct super_block *sb, int type, int format_id, 41int vfs_quota_on(struct super_block *sb, int type, int format_id,
41 char *path, int remount); 42 char *path, int remount);
42extern int vfs_quota_on_mount(struct super_block *sb, char *qf_name, 43int vfs_quota_on_path(struct super_block *sb, int type, int format_id,
43 int format_id, int type); 44 struct path *path);
44extern int vfs_quota_off(struct super_block *sb, int type, int remount); 45int vfs_quota_on_mount(struct super_block *sb, char *qf_name,
45extern int vfs_quota_sync(struct super_block *sb, int type); 46 int format_id, int type);
46extern int vfs_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); 47int vfs_quota_off(struct super_block *sb, int type, int remount);
47extern int vfs_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); 48int vfs_quota_sync(struct super_block *sb, int type);
48extern int vfs_get_dqblk(struct super_block *sb, int type, qid_t id, struct if_dqblk *di); 49int vfs_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii);
49extern int vfs_set_dqblk(struct super_block *sb, int type, qid_t id, struct if_dqblk *di); 50int vfs_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii);
51int vfs_get_dqblk(struct super_block *sb, int type, qid_t id, struct if_dqblk *di);
52int vfs_set_dqblk(struct super_block *sb, int type, qid_t id, struct if_dqblk *di);
53
54void vfs_dq_drop(struct inode *inode);
55int vfs_dq_transfer(struct inode *inode, struct iattr *iattr);
56int vfs_dq_quota_on_remount(struct super_block *sb);
57
58static inline struct mem_dqinfo *sb_dqinfo(struct super_block *sb, int type)
59{
60 return sb_dqopt(sb)->info + type;
61}
62
63/*
64 * Functions for checking status of quota
65 */
66
67static inline int sb_has_quota_enabled(struct super_block *sb, int type)
68{
69 if (type == USRQUOTA)
70 return sb_dqopt(sb)->flags & DQUOT_USR_ENABLED;
71 return sb_dqopt(sb)->flags & DQUOT_GRP_ENABLED;
72}
73
74static inline int sb_any_quota_enabled(struct super_block *sb)
75{
76 return sb_has_quota_enabled(sb, USRQUOTA) ||
77 sb_has_quota_enabled(sb, GRPQUOTA);
78}
79
80static inline int sb_has_quota_suspended(struct super_block *sb, int type)
81{
82 if (type == USRQUOTA)
83 return sb_dqopt(sb)->flags & DQUOT_USR_SUSPENDED;
84 return sb_dqopt(sb)->flags & DQUOT_GRP_SUSPENDED;
85}
86
87static inline int sb_any_quota_suspended(struct super_block *sb)
88{
89 return sb_has_quota_suspended(sb, USRQUOTA) ||
90 sb_has_quota_suspended(sb, GRPQUOTA);
91}
50 92
51/* 93/*
52 * Operations supported for diskquotas. 94 * Operations supported for diskquotas.
@@ -59,38 +101,16 @@ extern struct quotactl_ops vfs_quotactl_ops;
59 101
60/* It is better to call this function outside of any transaction as it might 102/* It is better to call this function outside of any transaction as it might
61 * need a lot of space in journal for dquot structure allocation. */ 103 * need a lot of space in journal for dquot structure allocation. */
62static inline void DQUOT_INIT(struct inode *inode) 104static inline void vfs_dq_init(struct inode *inode)
63{ 105{
64 BUG_ON(!inode->i_sb); 106 BUG_ON(!inode->i_sb);
65 if (sb_any_quota_enabled(inode->i_sb) && !IS_NOQUOTA(inode)) 107 if (sb_any_quota_enabled(inode->i_sb) && !IS_NOQUOTA(inode))
66 inode->i_sb->dq_op->initialize(inode, -1); 108 inode->i_sb->dq_op->initialize(inode, -1);
67} 109}
68 110
69/* The same as with DQUOT_INIT */
70static inline void DQUOT_DROP(struct inode *inode)
71{
72 /* Here we can get arbitrary inode from clear_inode() so we have
73 * to be careful. OTOH we don't need locking as quota operations
74 * are allowed to change only at mount time */
75 if (!IS_NOQUOTA(inode) && inode->i_sb && inode->i_sb->dq_op
76 && inode->i_sb->dq_op->drop) {
77 int cnt;
78 /* Test before calling to rule out calls from proc and such
79 * where we are not allowed to block. Note that this is
80 * actually reliable test even without the lock - the caller
81 * must assure that nobody can come after the DQUOT_DROP and
82 * add quota pointers back anyway */
83 for (cnt = 0; cnt < MAXQUOTAS; cnt++)
84 if (inode->i_dquot[cnt] != NODQUOT)
85 break;
86 if (cnt < MAXQUOTAS)
87 inode->i_sb->dq_op->drop(inode);
88 }
89}
90
91/* The following allocation/freeing/transfer functions *must* be called inside 111/* The following allocation/freeing/transfer functions *must* be called inside
92 * a transaction (deadlocks possible otherwise) */ 112 * a transaction (deadlocks possible otherwise) */
93static inline int DQUOT_PREALLOC_SPACE_NODIRTY(struct inode *inode, qsize_t nr) 113static inline int vfs_dq_prealloc_space_nodirty(struct inode *inode, qsize_t nr)
94{ 114{
95 if (sb_any_quota_enabled(inode->i_sb)) { 115 if (sb_any_quota_enabled(inode->i_sb)) {
96 /* Used space is updated in alloc_space() */ 116 /* Used space is updated in alloc_space() */
@@ -102,15 +122,15 @@ static inline int DQUOT_PREALLOC_SPACE_NODIRTY(struct inode *inode, qsize_t nr)
102 return 0; 122 return 0;
103} 123}
104 124
105static inline int DQUOT_PREALLOC_SPACE(struct inode *inode, qsize_t nr) 125static inline int vfs_dq_prealloc_space(struct inode *inode, qsize_t nr)
106{ 126{
107 int ret; 127 int ret;
108 if (!(ret = DQUOT_PREALLOC_SPACE_NODIRTY(inode, nr))) 128 if (!(ret = vfs_dq_prealloc_space_nodirty(inode, nr)))
109 mark_inode_dirty(inode); 129 mark_inode_dirty(inode);
110 return ret; 130 return ret;
111} 131}
112 132
113static inline int DQUOT_ALLOC_SPACE_NODIRTY(struct inode *inode, qsize_t nr) 133static inline int vfs_dq_alloc_space_nodirty(struct inode *inode, qsize_t nr)
114{ 134{
115 if (sb_any_quota_enabled(inode->i_sb)) { 135 if (sb_any_quota_enabled(inode->i_sb)) {
116 /* Used space is updated in alloc_space() */ 136 /* Used space is updated in alloc_space() */
@@ -122,25 +142,25 @@ static inline int DQUOT_ALLOC_SPACE_NODIRTY(struct inode *inode, qsize_t nr)
122 return 0; 142 return 0;
123} 143}
124 144
125static inline int DQUOT_ALLOC_SPACE(struct inode *inode, qsize_t nr) 145static inline int vfs_dq_alloc_space(struct inode *inode, qsize_t nr)
126{ 146{
127 int ret; 147 int ret;
128 if (!(ret = DQUOT_ALLOC_SPACE_NODIRTY(inode, nr))) 148 if (!(ret = vfs_dq_alloc_space_nodirty(inode, nr)))
129 mark_inode_dirty(inode); 149 mark_inode_dirty(inode);
130 return ret; 150 return ret;
131} 151}
132 152
133static inline int DQUOT_ALLOC_INODE(struct inode *inode) 153static inline int vfs_dq_alloc_inode(struct inode *inode)
134{ 154{
135 if (sb_any_quota_enabled(inode->i_sb)) { 155 if (sb_any_quota_enabled(inode->i_sb)) {
136 DQUOT_INIT(inode); 156 vfs_dq_init(inode);
137 if (inode->i_sb->dq_op->alloc_inode(inode, 1) == NO_QUOTA) 157 if (inode->i_sb->dq_op->alloc_inode(inode, 1) == NO_QUOTA)
138 return 1; 158 return 1;
139 } 159 }
140 return 0; 160 return 0;
141} 161}
142 162
143static inline void DQUOT_FREE_SPACE_NODIRTY(struct inode *inode, qsize_t nr) 163static inline void vfs_dq_free_space_nodirty(struct inode *inode, qsize_t nr)
144{ 164{
145 if (sb_any_quota_enabled(inode->i_sb)) 165 if (sb_any_quota_enabled(inode->i_sb))
146 inode->i_sb->dq_op->free_space(inode, nr); 166 inode->i_sb->dq_op->free_space(inode, nr);
@@ -148,35 +168,25 @@ static inline void DQUOT_FREE_SPACE_NODIRTY(struct inode *inode, qsize_t nr)
148 inode_sub_bytes(inode, nr); 168 inode_sub_bytes(inode, nr);
149} 169}
150 170
151static inline void DQUOT_FREE_SPACE(struct inode *inode, qsize_t nr) 171static inline void vfs_dq_free_space(struct inode *inode, qsize_t nr)
152{ 172{
153 DQUOT_FREE_SPACE_NODIRTY(inode, nr); 173 vfs_dq_free_space_nodirty(inode, nr);
154 mark_inode_dirty(inode); 174 mark_inode_dirty(inode);
155} 175}
156 176
157static inline void DQUOT_FREE_INODE(struct inode *inode) 177static inline void vfs_dq_free_inode(struct inode *inode)
158{ 178{
159 if (sb_any_quota_enabled(inode->i_sb)) 179 if (sb_any_quota_enabled(inode->i_sb))
160 inode->i_sb->dq_op->free_inode(inode, 1); 180 inode->i_sb->dq_op->free_inode(inode, 1);
161} 181}
162 182
163static inline int DQUOT_TRANSFER(struct inode *inode, struct iattr *iattr)
164{
165 if (sb_any_quota_enabled(inode->i_sb) && !IS_NOQUOTA(inode)) {
166 DQUOT_INIT(inode);
167 if (inode->i_sb->dq_op->transfer(inode, iattr) == NO_QUOTA)
168 return 1;
169 }
170 return 0;
171}
172
173/* The following two functions cannot be called inside a transaction */ 183/* The following two functions cannot be called inside a transaction */
174static inline void DQUOT_SYNC(struct super_block *sb) 184static inline void vfs_dq_sync(struct super_block *sb)
175{ 185{
176 sync_dquots(sb, -1); 186 sync_dquots(sb, -1);
177} 187}
178 188
179static inline int DQUOT_OFF(struct super_block *sb, int remount) 189static inline int vfs_dq_off(struct super_block *sb, int remount)
180{ 190{
181 int ret = -ENOSYS; 191 int ret = -ENOSYS;
182 192
@@ -185,22 +195,27 @@ static inline int DQUOT_OFF(struct super_block *sb, int remount)
185 return ret; 195 return ret;
186} 196}
187 197
188static inline int DQUOT_ON_REMOUNT(struct super_block *sb) 198#else
199
200static inline int sb_has_quota_enabled(struct super_block *sb, int type)
189{ 201{
190 int cnt; 202 return 0;
191 int ret = 0, err; 203}
192 204
193 if (!sb->s_qcop || !sb->s_qcop->quota_on) 205static inline int sb_any_quota_enabled(struct super_block *sb)
194 return -ENOSYS; 206{
195 for (cnt = 0; cnt < MAXQUOTAS; cnt++) { 207 return 0;
196 err = sb->s_qcop->quota_on(sb, cnt, 0, NULL, 1);
197 if (err < 0 && !ret)
198 ret = err;
199 }
200 return ret;
201} 208}
202 209
203#else 210static inline int sb_has_quota_suspended(struct super_block *sb, int type)
211{
212 return 0;
213}
214
215static inline int sb_any_quota_suspended(struct super_block *sb)
216{
217 return 0;
218}
204 219
205/* 220/*
206 * NO-OP when quota not configured. 221 * NO-OP when quota not configured.
@@ -208,113 +223,144 @@ static inline int DQUOT_ON_REMOUNT(struct super_block *sb)
208#define sb_dquot_ops (NULL) 223#define sb_dquot_ops (NULL)
209#define sb_quotactl_ops (NULL) 224#define sb_quotactl_ops (NULL)
210 225
211static inline void DQUOT_INIT(struct inode *inode) 226static inline void vfs_dq_init(struct inode *inode)
212{ 227{
213} 228}
214 229
215static inline void DQUOT_DROP(struct inode *inode) 230static inline void vfs_dq_drop(struct inode *inode)
216{ 231{
217} 232}
218 233
219static inline int DQUOT_ALLOC_INODE(struct inode *inode) 234static inline int vfs_dq_alloc_inode(struct inode *inode)
220{ 235{
221 return 0; 236 return 0;
222} 237}
223 238
224static inline void DQUOT_FREE_INODE(struct inode *inode) 239static inline void vfs_dq_free_inode(struct inode *inode)
225{ 240{
226} 241}
227 242
228static inline void DQUOT_SYNC(struct super_block *sb) 243static inline void vfs_dq_sync(struct super_block *sb)
229{ 244{
230} 245}
231 246
232static inline int DQUOT_OFF(struct super_block *sb, int remount) 247static inline int vfs_dq_off(struct super_block *sb, int remount)
233{ 248{
234 return 0; 249 return 0;
235} 250}
236 251
237static inline int DQUOT_ON_REMOUNT(struct super_block *sb) 252static inline int vfs_dq_quota_on_remount(struct super_block *sb)
238{ 253{
239 return 0; 254 return 0;
240} 255}
241 256
242static inline int DQUOT_TRANSFER(struct inode *inode, struct iattr *iattr) 257static inline int vfs_dq_transfer(struct inode *inode, struct iattr *iattr)
243{ 258{
244 return 0; 259 return 0;
245} 260}
246 261
247static inline int DQUOT_PREALLOC_SPACE_NODIRTY(struct inode *inode, qsize_t nr) 262static inline int vfs_dq_prealloc_space_nodirty(struct inode *inode, qsize_t nr)
248{ 263{
249 inode_add_bytes(inode, nr); 264 inode_add_bytes(inode, nr);
250 return 0; 265 return 0;
251} 266}
252 267
253static inline int DQUOT_PREALLOC_SPACE(struct inode *inode, qsize_t nr) 268static inline int vfs_dq_prealloc_space(struct inode *inode, qsize_t nr)
254{ 269{
255 DQUOT_PREALLOC_SPACE_NODIRTY(inode, nr); 270 vfs_dq_prealloc_space_nodirty(inode, nr);
256 mark_inode_dirty(inode); 271 mark_inode_dirty(inode);
257 return 0; 272 return 0;
258} 273}
259 274
260static inline int DQUOT_ALLOC_SPACE_NODIRTY(struct inode *inode, qsize_t nr) 275static inline int vfs_dq_alloc_space_nodirty(struct inode *inode, qsize_t nr)
261{ 276{
262 inode_add_bytes(inode, nr); 277 inode_add_bytes(inode, nr);
263 return 0; 278 return 0;
264} 279}
265 280
266static inline int DQUOT_ALLOC_SPACE(struct inode *inode, qsize_t nr) 281static inline int vfs_dq_alloc_space(struct inode *inode, qsize_t nr)
267{ 282{
268 DQUOT_ALLOC_SPACE_NODIRTY(inode, nr); 283 vfs_dq_alloc_space_nodirty(inode, nr);
269 mark_inode_dirty(inode); 284 mark_inode_dirty(inode);
270 return 0; 285 return 0;
271} 286}
272 287
273static inline void DQUOT_FREE_SPACE_NODIRTY(struct inode *inode, qsize_t nr) 288static inline void vfs_dq_free_space_nodirty(struct inode *inode, qsize_t nr)
274{ 289{
275 inode_sub_bytes(inode, nr); 290 inode_sub_bytes(inode, nr);
276} 291}
277 292
278static inline void DQUOT_FREE_SPACE(struct inode *inode, qsize_t nr) 293static inline void vfs_dq_free_space(struct inode *inode, qsize_t nr)
279{ 294{
280 DQUOT_FREE_SPACE_NODIRTY(inode, nr); 295 vfs_dq_free_space_nodirty(inode, nr);
281 mark_inode_dirty(inode); 296 mark_inode_dirty(inode);
282} 297}
283 298
284#endif /* CONFIG_QUOTA */ 299#endif /* CONFIG_QUOTA */
285 300
286static inline int DQUOT_PREALLOC_BLOCK_NODIRTY(struct inode *inode, qsize_t nr) 301static inline int vfs_dq_prealloc_block_nodirty(struct inode *inode, qsize_t nr)
287{ 302{
288 return DQUOT_PREALLOC_SPACE_NODIRTY(inode, 303 return vfs_dq_prealloc_space_nodirty(inode,
289 nr << inode->i_sb->s_blocksize_bits); 304 nr << inode->i_sb->s_blocksize_bits);
290} 305}
291 306
292static inline int DQUOT_PREALLOC_BLOCK(struct inode *inode, qsize_t nr) 307static inline int vfs_dq_prealloc_block(struct inode *inode, qsize_t nr)
293{ 308{
294 return DQUOT_PREALLOC_SPACE(inode, 309 return vfs_dq_prealloc_space(inode,
295 nr << inode->i_sb->s_blocksize_bits); 310 nr << inode->i_sb->s_blocksize_bits);
296} 311}
297 312
298static inline int DQUOT_ALLOC_BLOCK_NODIRTY(struct inode *inode, qsize_t nr) 313static inline int vfs_dq_alloc_block_nodirty(struct inode *inode, qsize_t nr)
299{ 314{
300 return DQUOT_ALLOC_SPACE_NODIRTY(inode, 315 return vfs_dq_alloc_space_nodirty(inode,
301 nr << inode->i_sb->s_blocksize_bits); 316 nr << inode->i_sb->s_blocksize_bits);
302} 317}
303 318
304static inline int DQUOT_ALLOC_BLOCK(struct inode *inode, qsize_t nr) 319static inline int vfs_dq_alloc_block(struct inode *inode, qsize_t nr)
305{ 320{
306 return DQUOT_ALLOC_SPACE(inode, 321 return vfs_dq_alloc_space(inode,
307 nr << inode->i_sb->s_blocksize_bits); 322 nr << inode->i_sb->s_blocksize_bits);
308} 323}
309 324
310static inline void DQUOT_FREE_BLOCK_NODIRTY(struct inode *inode, qsize_t nr) 325static inline void vfs_dq_free_block_nodirty(struct inode *inode, qsize_t nr)
311{ 326{
312 DQUOT_FREE_SPACE_NODIRTY(inode, nr << inode->i_sb->s_blocksize_bits); 327 vfs_dq_free_space_nodirty(inode, nr << inode->i_sb->s_blocksize_bits);
313} 328}
314 329
315static inline void DQUOT_FREE_BLOCK(struct inode *inode, qsize_t nr) 330static inline void vfs_dq_free_block(struct inode *inode, qsize_t nr)
316{ 331{
317 DQUOT_FREE_SPACE(inode, nr << inode->i_sb->s_blocksize_bits); 332 vfs_dq_free_space(inode, nr << inode->i_sb->s_blocksize_bits);
318} 333}
319 334
335/*
336 * Define uppercase equivalents for compatibility with old function names
337 * Can go away when we think all users have been converted (15/04/2008)
338 */
339#define DQUOT_INIT(inode) vfs_dq_init(inode)
340#define DQUOT_DROP(inode) vfs_dq_drop(inode)
341#define DQUOT_PREALLOC_SPACE_NODIRTY(inode, nr) \
342 vfs_dq_prealloc_space_nodirty(inode, nr)
343#define DQUOT_PREALLOC_SPACE(inode, nr) vfs_dq_prealloc_space(inode, nr)
344#define DQUOT_ALLOC_SPACE_NODIRTY(inode, nr) \
345 vfs_dq_alloc_space_nodirty(inode, nr)
346#define DQUOT_ALLOC_SPACE(inode, nr) vfs_dq_alloc_space(inode, nr)
347#define DQUOT_PREALLOC_BLOCK_NODIRTY(inode, nr) \
348 vfs_dq_prealloc_block_nodirty(inode, nr)
349#define DQUOT_PREALLOC_BLOCK(inode, nr) vfs_dq_prealloc_block(inode, nr)
350#define DQUOT_ALLOC_BLOCK_NODIRTY(inode, nr) \
351 vfs_dq_alloc_block_nodirty(inode, nr)
352#define DQUOT_ALLOC_BLOCK(inode, nr) vfs_dq_alloc_block(inode, nr)
353#define DQUOT_ALLOC_INODE(inode) vfs_dq_alloc_inode(inode)
354#define DQUOT_FREE_SPACE_NODIRTY(inode, nr) \
355 vfs_dq_free_space_nodirty(inode, nr)
356#define DQUOT_FREE_SPACE(inode, nr) vfs_dq_free_space(inode, nr)
357#define DQUOT_FREE_BLOCK_NODIRTY(inode, nr) \
358 vfs_dq_free_block_nodirty(inode, nr)
359#define DQUOT_FREE_BLOCK(inode, nr) vfs_dq_free_block(inode, nr)
360#define DQUOT_FREE_INODE(inode) vfs_dq_free_inode(inode)
361#define DQUOT_TRANSFER(inode, iattr) vfs_dq_transfer(inode, iattr)
362#define DQUOT_SYNC(sb) vfs_dq_sync(sb)
363#define DQUOT_OFF(sb, remount) vfs_dq_off(sb, remount)
364#define DQUOT_ON_REMOUNT(sb) vfs_dq_quota_on_remount(sb)
365
320#endif /* _LINUX_QUOTAOPS_ */ 366#endif /* _LINUX_QUOTAOPS_ */
diff --git a/include/linux/radix-tree.h b/include/linux/radix-tree.h
index b8ce2b444bb5..a916c6660dfa 100644
--- a/include/linux/radix-tree.h
+++ b/include/linux/radix-tree.h
@@ -99,12 +99,15 @@ do { \
99 * 99 *
100 * The notable exceptions to this rule are the following functions: 100 * The notable exceptions to this rule are the following functions:
101 * radix_tree_lookup 101 * radix_tree_lookup
102 * radix_tree_lookup_slot
102 * radix_tree_tag_get 103 * radix_tree_tag_get
103 * radix_tree_gang_lookup 104 * radix_tree_gang_lookup
105 * radix_tree_gang_lookup_slot
104 * radix_tree_gang_lookup_tag 106 * radix_tree_gang_lookup_tag
107 * radix_tree_gang_lookup_tag_slot
105 * radix_tree_tagged 108 * radix_tree_tagged
106 * 109 *
107 * The first 4 functions are able to be called locklessly, using RCU. The 110 * The first 7 functions are able to be called locklessly, using RCU. The
108 * caller must ensure calls to these functions are made within rcu_read_lock() 111 * caller must ensure calls to these functions are made within rcu_read_lock()
109 * regions. Other readers (lock-free or otherwise) and modifications may be 112 * regions. Other readers (lock-free or otherwise) and modifications may be
110 * running concurrently. 113 * running concurrently.
@@ -159,6 +162,9 @@ void *radix_tree_delete(struct radix_tree_root *, unsigned long);
159unsigned int 162unsigned int
160radix_tree_gang_lookup(struct radix_tree_root *root, void **results, 163radix_tree_gang_lookup(struct radix_tree_root *root, void **results,
161 unsigned long first_index, unsigned int max_items); 164 unsigned long first_index, unsigned int max_items);
165unsigned int
166radix_tree_gang_lookup_slot(struct radix_tree_root *root, void ***results,
167 unsigned long first_index, unsigned int max_items);
162unsigned long radix_tree_next_hole(struct radix_tree_root *root, 168unsigned long radix_tree_next_hole(struct radix_tree_root *root,
163 unsigned long index, unsigned long max_scan); 169 unsigned long index, unsigned long max_scan);
164int radix_tree_preload(gfp_t gfp_mask); 170int radix_tree_preload(gfp_t gfp_mask);
@@ -173,6 +179,10 @@ unsigned int
173radix_tree_gang_lookup_tag(struct radix_tree_root *root, void **results, 179radix_tree_gang_lookup_tag(struct radix_tree_root *root, void **results,
174 unsigned long first_index, unsigned int max_items, 180 unsigned long first_index, unsigned int max_items,
175 unsigned int tag); 181 unsigned int tag);
182unsigned int
183radix_tree_gang_lookup_tag_slot(struct radix_tree_root *root, void ***results,
184 unsigned long first_index, unsigned int max_items,
185 unsigned int tag);
176int radix_tree_tagged(struct radix_tree_root *root, unsigned int tag); 186int radix_tree_tagged(struct radix_tree_root *root, unsigned int tag);
177 187
178static inline void radix_tree_preload_end(void) 188static inline void radix_tree_preload_end(void)
diff --git a/include/linux/raid/bitmap.h b/include/linux/raid/bitmap.h
index 78bfdea24a8e..e98900671ca9 100644
--- a/include/linux/raid/bitmap.h
+++ b/include/linux/raid/bitmap.h
@@ -221,6 +221,7 @@ struct bitmap {
221 unsigned long syncchunk; 221 unsigned long syncchunk;
222 222
223 __u64 events_cleared; 223 __u64 events_cleared;
224 int need_sync;
224 225
225 /* bitmap spinlock */ 226 /* bitmap spinlock */
226 spinlock_t lock; 227 spinlock_t lock;
diff --git a/include/linux/raid/linear.h b/include/linux/raid/linear.h
index ba15469daf11..f38b9c586afb 100644
--- a/include/linux/raid/linear.h
+++ b/include/linux/raid/linear.h
@@ -5,8 +5,8 @@
5 5
6struct dev_info { 6struct dev_info {
7 mdk_rdev_t *rdev; 7 mdk_rdev_t *rdev;
8 sector_t size; 8 sector_t num_sectors;
9 sector_t offset; 9 sector_t start_sector;
10}; 10};
11 11
12typedef struct dev_info dev_info_t; 12typedef struct dev_info dev_info_t;
@@ -15,9 +15,11 @@ struct linear_private_data
15{ 15{
16 struct linear_private_data *prev; /* earlier version */ 16 struct linear_private_data *prev; /* earlier version */
17 dev_info_t **hash_table; 17 dev_info_t **hash_table;
18 sector_t hash_spacing; 18 sector_t spacing;
19 sector_t array_size; 19 sector_t array_sectors;
20 int preshift; /* shift before dividing by hash_spacing */ 20 int sector_shift; /* shift before dividing
21 * by spacing
22 */
21 dev_info_t disks[0]; 23 dev_info_t disks[0];
22}; 24};
23 25
diff --git a/include/linux/raid/md.h b/include/linux/raid/md.h
index b7386ae9d288..82bea14cae1a 100644
--- a/include/linux/raid/md.h
+++ b/include/linux/raid/md.h
@@ -19,27 +19,7 @@
19#define _MD_H 19#define _MD_H
20 20
21#include <linux/blkdev.h> 21#include <linux/blkdev.h>
22#include <linux/major.h>
23#include <linux/ioctl.h>
24#include <linux/types.h>
25#include <linux/bitops.h>
26#include <linux/module.h>
27#include <linux/hdreg.h>
28#include <linux/proc_fs.h>
29#include <linux/seq_file.h> 22#include <linux/seq_file.h>
30#include <linux/smp_lock.h>
31#include <linux/delay.h>
32#include <net/checksum.h>
33#include <linux/random.h>
34#include <linux/kernel_stat.h>
35#include <asm/io.h>
36#include <linux/completion.h>
37#include <linux/mempool.h>
38#include <linux/list.h>
39#include <linux/reboot.h>
40#include <linux/vmalloc.h>
41#include <linux/blkpg.h>
42#include <linux/bio.h>
43 23
44/* 24/*
45 * 'md_p.h' holds the 'physical' layout of RAID devices 25 * 'md_p.h' holds the 'physical' layout of RAID devices
@@ -74,19 +54,17 @@
74 54
75extern int mdp_major; 55extern int mdp_major;
76 56
77extern int register_md_personality (struct mdk_personality *p); 57extern int register_md_personality(struct mdk_personality *p);
78extern int unregister_md_personality (struct mdk_personality *p); 58extern int unregister_md_personality(struct mdk_personality *p);
79extern mdk_thread_t * md_register_thread (void (*run) (mddev_t *mddev), 59extern mdk_thread_t * md_register_thread(void (*run) (mddev_t *mddev),
80 mddev_t *mddev, const char *name); 60 mddev_t *mddev, const char *name);
81extern void md_unregister_thread (mdk_thread_t *thread); 61extern void md_unregister_thread(mdk_thread_t *thread);
82extern void md_wakeup_thread(mdk_thread_t *thread); 62extern void md_wakeup_thread(mdk_thread_t *thread);
83extern void md_check_recovery(mddev_t *mddev); 63extern void md_check_recovery(mddev_t *mddev);
84extern void md_write_start(mddev_t *mddev, struct bio *bi); 64extern void md_write_start(mddev_t *mddev, struct bio *bi);
85extern void md_write_end(mddev_t *mddev); 65extern void md_write_end(mddev_t *mddev);
86extern void md_handle_safemode(mddev_t *mddev);
87extern void md_done_sync(mddev_t *mddev, int blocks, int ok); 66extern void md_done_sync(mddev_t *mddev, int blocks, int ok);
88extern void md_error (mddev_t *mddev, mdk_rdev_t *rdev); 67extern void md_error(mddev_t *mddev, mdk_rdev_t *rdev);
89extern void md_unplug_mddev(mddev_t *mddev);
90 68
91extern void md_super_write(mddev_t *mddev, mdk_rdev_t *rdev, 69extern void md_super_write(mddev_t *mddev, mdk_rdev_t *rdev,
92 sector_t sector, int size, struct page *page); 70 sector_t sector, int size, struct page *page);
@@ -95,7 +73,7 @@ extern int sync_page_io(struct block_device *bdev, sector_t sector, int size,
95 struct page *page, int rw); 73 struct page *page, int rw);
96extern void md_do_sync(mddev_t *mddev); 74extern void md_do_sync(mddev_t *mddev);
97extern void md_new_event(mddev_t *mddev); 75extern void md_new_event(mddev_t *mddev);
98extern void md_allow_write(mddev_t *mddev); 76extern int md_allow_write(mddev_t *mddev);
99extern void md_wait_for_blocked_rdev(mdk_rdev_t *rdev, mddev_t *mddev); 77extern void md_wait_for_blocked_rdev(mdk_rdev_t *rdev, mddev_t *mddev);
100 78
101#endif /* CONFIG_MD */ 79#endif /* CONFIG_MD */
diff --git a/include/linux/raid/md_k.h b/include/linux/raid/md_k.h
index 3dea9f545c8f..c200b9a34aff 100644
--- a/include/linux/raid/md_k.h
+++ b/include/linux/raid/md_k.h
@@ -59,7 +59,7 @@ struct mdk_rdev_s
59 int sb_loaded; 59 int sb_loaded;
60 __u64 sb_events; 60 __u64 sb_events;
61 sector_t data_offset; /* start of data in array */ 61 sector_t data_offset; /* start of data in array */
62 sector_t sb_offset; 62 sector_t sb_start; /* offset of the super block (in 512byte sectors) */
63 int sb_size; /* bytes in the superblock */ 63 int sb_size; /* bytes in the superblock */
64 int preferred_minor; /* autorun support */ 64 int preferred_minor; /* autorun support */
65 65
@@ -87,6 +87,9 @@ struct mdk_rdev_s
87#define Blocked 8 /* An error occured on an externally 87#define Blocked 8 /* An error occured on an externally
88 * managed array, don't allow writes 88 * managed array, don't allow writes
89 * until it is cleared */ 89 * until it is cleared */
90#define StateChanged 9 /* Faulty or Blocked has changed during
91 * interrupt, so it needs to be
92 * notified by the thread */
90 wait_queue_head_t blocked_wait; 93 wait_queue_head_t blocked_wait;
91 94
92 int desc_nr; /* descriptor index in the superblock */ 95 int desc_nr; /* descriptor index in the superblock */
@@ -125,6 +128,7 @@ struct mddev_s
125#define MD_CHANGE_DEVS 0 /* Some device status has changed */ 128#define MD_CHANGE_DEVS 0 /* Some device status has changed */
126#define MD_CHANGE_CLEAN 1 /* transition to or from 'clean' */ 129#define MD_CHANGE_CLEAN 1 /* transition to or from 'clean' */
127#define MD_CHANGE_PENDING 2 /* superblock update in progress */ 130#define MD_CHANGE_PENDING 2 /* superblock update in progress */
131#define MD_NOTIFY_ARRAY_STATE 3 /* atomic context wants to notify userspace */
128 132
129 int ro; 133 int ro;
130 134
@@ -147,7 +151,7 @@ struct mddev_s
147 int raid_disks; 151 int raid_disks;
148 int max_disks; 152 int max_disks;
149 sector_t size; /* used size of component devices */ 153 sector_t size; /* used size of component devices */
150 sector_t array_size; /* exported array size */ 154 sector_t array_sectors; /* exported array size */
151 __u64 events; 155 __u64 events;
152 156
153 char uuid[16]; 157 char uuid[16];
@@ -188,6 +192,7 @@ struct mddev_s
188 * NEEDED: we might need to start a resync/recover 192 * NEEDED: we might need to start a resync/recover
189 * RUNNING: a thread is running, or about to be started 193 * RUNNING: a thread is running, or about to be started
190 * SYNC: actually doing a resync, not a recovery 194 * SYNC: actually doing a resync, not a recovery
195 * RECOVER: doing recovery, or need to try it.
191 * INTR: resync needs to be aborted for some reason 196 * INTR: resync needs to be aborted for some reason
192 * DONE: thread is done and is waiting to be reaped 197 * DONE: thread is done and is waiting to be reaped
193 * REQUEST: user-space has requested a sync (used with SYNC) 198 * REQUEST: user-space has requested a sync (used with SYNC)
@@ -198,6 +203,7 @@ struct mddev_s
198 */ 203 */
199#define MD_RECOVERY_RUNNING 0 204#define MD_RECOVERY_RUNNING 0
200#define MD_RECOVERY_SYNC 1 205#define MD_RECOVERY_SYNC 1
206#define MD_RECOVERY_RECOVER 2
201#define MD_RECOVERY_INTR 3 207#define MD_RECOVERY_INTR 3
202#define MD_RECOVERY_DONE 4 208#define MD_RECOVERY_DONE 4
203#define MD_RECOVERY_NEEDED 5 209#define MD_RECOVERY_NEEDED 5
@@ -210,7 +216,8 @@ struct mddev_s
210 216
211 int in_sync; /* know to not need resync */ 217 int in_sync; /* know to not need resync */
212 struct mutex reconfig_mutex; 218 struct mutex reconfig_mutex;
213 atomic_t active; 219 atomic_t active; /* general refcount */
220 atomic_t openers; /* number of active opens */
214 221
215 int changed; /* true if we might need to reread partition info */ 222 int changed; /* true if we might need to reread partition info */
216 int degraded; /* whether md should consider 223 int degraded; /* whether md should consider
@@ -227,6 +234,8 @@ struct mddev_s
227 atomic_t recovery_active; /* blocks scheduled, but not written */ 234 atomic_t recovery_active; /* blocks scheduled, but not written */
228 wait_queue_head_t recovery_wait; 235 wait_queue_head_t recovery_wait;
229 sector_t recovery_cp; 236 sector_t recovery_cp;
237 sector_t resync_min; /* user requested sync
238 * starts here */
230 sector_t resync_max; /* resync should pause 239 sector_t resync_max; /* resync should pause
231 * when it gets here */ 240 * when it gets here */
232 241
@@ -331,6 +340,9 @@ static inline char * mdname (mddev_t * mddev)
331#define rdev_for_each(rdev, tmp, mddev) \ 340#define rdev_for_each(rdev, tmp, mddev) \
332 rdev_for_each_list(rdev, tmp, (mddev)->disks) 341 rdev_for_each_list(rdev, tmp, (mddev)->disks)
333 342
343#define rdev_for_each_rcu(rdev, mddev) \
344 list_for_each_entry_rcu(rdev, &((mddev)->disks), same_set)
345
334typedef struct mdk_thread_s { 346typedef struct mdk_thread_s {
335 void (*run) (mddev_t *mddev); 347 void (*run) (mddev_t *mddev);
336 mddev_t *mddev; 348 mddev_t *mddev;
diff --git a/include/linux/raid/md_p.h b/include/linux/raid/md_p.h
index 3f2cd98c508b..8b4de4a41ff1 100644
--- a/include/linux/raid/md_p.h
+++ b/include/linux/raid/md_p.h
@@ -43,14 +43,11 @@
43 */ 43 */
44#define MD_RESERVED_BYTES (64 * 1024) 44#define MD_RESERVED_BYTES (64 * 1024)
45#define MD_RESERVED_SECTORS (MD_RESERVED_BYTES / 512) 45#define MD_RESERVED_SECTORS (MD_RESERVED_BYTES / 512)
46#define MD_RESERVED_BLOCKS (MD_RESERVED_BYTES / BLOCK_SIZE)
47 46
48#define MD_NEW_SIZE_SECTORS(x) ((x & ~(MD_RESERVED_SECTORS - 1)) - MD_RESERVED_SECTORS) 47#define MD_NEW_SIZE_SECTORS(x) ((x & ~(MD_RESERVED_SECTORS - 1)) - MD_RESERVED_SECTORS)
49#define MD_NEW_SIZE_BLOCKS(x) ((x & ~(MD_RESERVED_BLOCKS - 1)) - MD_RESERVED_BLOCKS)
50 48
51#define MD_SB_BYTES 4096 49#define MD_SB_BYTES 4096
52#define MD_SB_WORDS (MD_SB_BYTES / 4) 50#define MD_SB_WORDS (MD_SB_BYTES / 4)
53#define MD_SB_BLOCKS (MD_SB_BYTES / BLOCK_SIZE)
54#define MD_SB_SECTORS (MD_SB_BYTES / 512) 51#define MD_SB_SECTORS (MD_SB_BYTES / 512)
55 52
56/* 53/*
diff --git a/include/linux/raid/raid5.h b/include/linux/raid/raid5.h
index f0827d31ae6f..3b2672792457 100644
--- a/include/linux/raid/raid5.h
+++ b/include/linux/raid/raid5.h
@@ -158,6 +158,43 @@
158 * the compute block completes. 158 * the compute block completes.
159 */ 159 */
160 160
161/*
162 * Operations state - intermediate states that are visible outside of sh->lock
163 * In general _idle indicates nothing is running, _run indicates a data
164 * processing operation is active, and _result means the data processing result
165 * is stable and can be acted upon. For simple operations like biofill and
166 * compute that only have an _idle and _run state they are indicated with
167 * sh->state flags (STRIPE_BIOFILL_RUN and STRIPE_COMPUTE_RUN)
168 */
169/**
170 * enum check_states - handles syncing / repairing a stripe
171 * @check_state_idle - check operations are quiesced
172 * @check_state_run - check operation is running
173 * @check_state_result - set outside lock when check result is valid
174 * @check_state_compute_run - check failed and we are repairing
175 * @check_state_compute_result - set outside lock when compute result is valid
176 */
177enum check_states {
178 check_state_idle = 0,
179 check_state_run, /* parity check */
180 check_state_check_result,
181 check_state_compute_run, /* parity repair */
182 check_state_compute_result,
183};
184
185/**
186 * enum reconstruct_states - handles writing or expanding a stripe
187 */
188enum reconstruct_states {
189 reconstruct_state_idle = 0,
190 reconstruct_state_prexor_drain_run, /* prexor-write */
191 reconstruct_state_drain_run, /* write */
192 reconstruct_state_run, /* expand */
193 reconstruct_state_prexor_drain_result,
194 reconstruct_state_drain_result,
195 reconstruct_state_result,
196};
197
161struct stripe_head { 198struct stripe_head {
162 struct hlist_node hash; 199 struct hlist_node hash;
163 struct list_head lru; /* inactive_list or handle_list */ 200 struct list_head lru; /* inactive_list or handle_list */
@@ -169,19 +206,13 @@ struct stripe_head {
169 spinlock_t lock; 206 spinlock_t lock;
170 int bm_seq; /* sequence number for bitmap flushes */ 207 int bm_seq; /* sequence number for bitmap flushes */
171 int disks; /* disks in stripe */ 208 int disks; /* disks in stripe */
209 enum check_states check_state;
210 enum reconstruct_states reconstruct_state;
172 /* stripe_operations 211 /* stripe_operations
173 * @pending - pending ops flags (set for request->issue->complete)
174 * @ack - submitted ops flags (set for issue->complete)
175 * @complete - completed ops flags (set for complete)
176 * @target - STRIPE_OP_COMPUTE_BLK target 212 * @target - STRIPE_OP_COMPUTE_BLK target
177 * @count - raid5_runs_ops is set to run when this is non-zero
178 */ 213 */
179 struct stripe_operations { 214 struct stripe_operations {
180 unsigned long pending;
181 unsigned long ack;
182 unsigned long complete;
183 int target; 215 int target;
184 int count;
185 u32 zero_sum_result; 216 u32 zero_sum_result;
186 } ops; 217 } ops;
187 struct r5dev { 218 struct r5dev {
@@ -202,6 +233,7 @@ struct stripe_head_state {
202 int locked, uptodate, to_read, to_write, failed, written; 233 int locked, uptodate, to_read, to_write, failed, written;
203 int to_fill, compute, req_compute, non_overwrite; 234 int to_fill, compute, req_compute, non_overwrite;
204 int failed_num; 235 int failed_num;
236 unsigned long ops_request;
205}; 237};
206 238
207/* r6_state - extra state data only relevant to r6 */ 239/* r6_state - extra state data only relevant to r6 */
@@ -228,9 +260,7 @@ struct r6_state {
228#define R5_Wantfill 12 /* dev->toread contains a bio that needs 260#define R5_Wantfill 12 /* dev->toread contains a bio that needs
229 * filling 261 * filling
230 */ 262 */
231#define R5_Wantprexor 13 /* distinguish blocks ready for rmw from 263#define R5_Wantdrain 13 /* dev->towrite needs to be drained */
232 * other "towrites"
233 */
234/* 264/*
235 * Write method 265 * Write method
236 */ 266 */
@@ -254,8 +284,10 @@ struct r6_state {
254#define STRIPE_EXPAND_READY 11 284#define STRIPE_EXPAND_READY 11
255#define STRIPE_IO_STARTED 12 /* do not count towards 'bypass_count' */ 285#define STRIPE_IO_STARTED 12 /* do not count towards 'bypass_count' */
256#define STRIPE_FULL_WRITE 13 /* all blocks are set to be overwritten */ 286#define STRIPE_FULL_WRITE 13 /* all blocks are set to be overwritten */
287#define STRIPE_BIOFILL_RUN 14
288#define STRIPE_COMPUTE_RUN 15
257/* 289/*
258 * Operations flags (in issue order) 290 * Operation request flags
259 */ 291 */
260#define STRIPE_OP_BIOFILL 0 292#define STRIPE_OP_BIOFILL 0
261#define STRIPE_OP_COMPUTE_BLK 1 293#define STRIPE_OP_COMPUTE_BLK 1
@@ -263,14 +295,6 @@ struct r6_state {
263#define STRIPE_OP_BIODRAIN 3 295#define STRIPE_OP_BIODRAIN 3
264#define STRIPE_OP_POSTXOR 4 296#define STRIPE_OP_POSTXOR 4
265#define STRIPE_OP_CHECK 5 297#define STRIPE_OP_CHECK 5
266#define STRIPE_OP_IO 6
267
268/* modifiers to the base operations
269 * STRIPE_OP_MOD_REPAIR_PD - compute the parity block and write it back
270 * STRIPE_OP_MOD_DMA_CHECK - parity is not corrupted by the check
271 */
272#define STRIPE_OP_MOD_REPAIR_PD 7
273#define STRIPE_OP_MOD_DMA_CHECK 8
274 298
275/* 299/*
276 * Plugging: 300 * Plugging:
diff --git a/include/linux/ramfs.h b/include/linux/ramfs.h
index b160fb18e8d6..37aaf2b39863 100644
--- a/include/linux/ramfs.h
+++ b/include/linux/ramfs.h
@@ -6,6 +6,7 @@ extern int ramfs_get_sb(struct file_system_type *fs_type,
6 int flags, const char *dev_name, void *data, struct vfsmount *mnt); 6 int flags, const char *dev_name, void *data, struct vfsmount *mnt);
7 7
8#ifndef CONFIG_MMU 8#ifndef CONFIG_MMU
9extern int ramfs_nommu_expand_for_mapping(struct inode *inode, size_t newsize);
9extern unsigned long ramfs_nommu_get_unmapped_area(struct file *file, 10extern unsigned long ramfs_nommu_get_unmapped_area(struct file *file,
10 unsigned long addr, 11 unsigned long addr,
11 unsigned long len, 12 unsigned long len,
diff --git a/include/linux/ratelimit.h b/include/linux/ratelimit.h
new file mode 100644
index 000000000000..18a5b9ba9d40
--- /dev/null
+++ b/include/linux/ratelimit.h
@@ -0,0 +1,27 @@
1#ifndef _LINUX_RATELIMIT_H
2#define _LINUX_RATELIMIT_H
3#include <linux/param.h>
4
5#define DEFAULT_RATELIMIT_INTERVAL (5 * HZ)
6#define DEFAULT_RATELIMIT_BURST 10
7
8struct ratelimit_state {
9 int interval;
10 int burst;
11 int printed;
12 int missed;
13 unsigned long begin;
14};
15
16#define DEFINE_RATELIMIT_STATE(name, interval, burst) \
17 struct ratelimit_state name = {interval, burst,}
18
19extern int __ratelimit(struct ratelimit_state *rs);
20
21static inline int ratelimit(void)
22{
23 static DEFINE_RATELIMIT_STATE(rs, DEFAULT_RATELIMIT_INTERVAL,
24 DEFAULT_RATELIMIT_BURST);
25 return __ratelimit(&rs);
26}
27#endif
diff --git a/include/linux/rcuclassic.h b/include/linux/rcuclassic.h
index 8c774905dcfe..5f89b62e6983 100644
--- a/include/linux/rcuclassic.h
+++ b/include/linux/rcuclassic.h
@@ -40,12 +40,21 @@
40#include <linux/cpumask.h> 40#include <linux/cpumask.h>
41#include <linux/seqlock.h> 41#include <linux/seqlock.h>
42 42
43#ifdef CONFIG_RCU_CPU_STALL_DETECTOR
44#define RCU_SECONDS_TILL_STALL_CHECK ( 3 * HZ) /* for rcp->jiffies_stall */
45#define RCU_SECONDS_TILL_STALL_RECHECK (30 * HZ) /* for rcp->jiffies_stall */
46#endif /* #ifdef CONFIG_RCU_CPU_STALL_DETECTOR */
43 47
44/* Global control variables for rcupdate callback mechanism. */ 48/* Global control variables for rcupdate callback mechanism. */
45struct rcu_ctrlblk { 49struct rcu_ctrlblk {
46 long cur; /* Current batch number. */ 50 long cur; /* Current batch number. */
47 long completed; /* Number of the last completed batch */ 51 long completed; /* Number of the last completed batch */
48 int next_pending; /* Is the next batch already waiting? */ 52 long pending; /* Number of the last pending batch */
53#ifdef CONFIG_RCU_CPU_STALL_DETECTOR
54 unsigned long gp_start; /* Time at which GP started in jiffies. */
55 unsigned long jiffies_stall;
56 /* Time at which to check for CPU stalls. */
57#endif /* #ifdef CONFIG_RCU_CPU_STALL_DETECTOR */
49 58
50 int signaled; 59 int signaled;
51 60
@@ -66,11 +75,7 @@ static inline int rcu_batch_after(long a, long b)
66 return (a - b) > 0; 75 return (a - b) > 0;
67} 76}
68 77
69/* 78/* Per-CPU data for Read-Copy UPdate. */
70 * Per-CPU data for Read-Copy UPdate.
71 * nxtlist - new callbacks are added here
72 * curlist - current batch for which quiescent cycle started if any
73 */
74struct rcu_data { 79struct rcu_data {
75 /* 1) quiescent state handling : */ 80 /* 1) quiescent state handling : */
76 long quiescbatch; /* Batch # for grace period */ 81 long quiescbatch; /* Batch # for grace period */
@@ -78,12 +83,24 @@ struct rcu_data {
78 int qs_pending; /* core waits for quiesc state */ 83 int qs_pending; /* core waits for quiesc state */
79 84
80 /* 2) batch handling */ 85 /* 2) batch handling */
81 long batch; /* Batch # for current RCU batch */ 86 /*
87 * if nxtlist is not NULL, then:
88 * batch:
89 * The batch # for the last entry of nxtlist
90 * [*nxttail[1], NULL = *nxttail[2]):
91 * Entries that batch # <= batch
92 * [*nxttail[0], *nxttail[1]):
93 * Entries that batch # <= batch - 1
94 * [nxtlist, *nxttail[0]):
95 * Entries that batch # <= batch - 2
96 * The grace period for these entries has completed, and
97 * the other grace-period-completed entries may be moved
98 * here temporarily in rcu_process_callbacks().
99 */
100 long batch;
82 struct rcu_head *nxtlist; 101 struct rcu_head *nxtlist;
83 struct rcu_head **nxttail; 102 struct rcu_head **nxttail[3];
84 long qlen; /* # of queued callbacks */ 103 long qlen; /* # of queued callbacks */
85 struct rcu_head *curlist;
86 struct rcu_head **curtail;
87 struct rcu_head *donelist; 104 struct rcu_head *donelist;
88 struct rcu_head **donetail; 105 struct rcu_head **donetail;
89 long blimit; /* Upper limit on a processed batch */ 106 long blimit; /* Upper limit on a processed batch */
@@ -117,7 +134,7 @@ extern int rcu_needs_cpu(int cpu);
117#ifdef CONFIG_DEBUG_LOCK_ALLOC 134#ifdef CONFIG_DEBUG_LOCK_ALLOC
118extern struct lockdep_map rcu_lock_map; 135extern struct lockdep_map rcu_lock_map;
119# define rcu_read_acquire() \ 136# define rcu_read_acquire() \
120 lock_acquire(&rcu_lock_map, 0, 0, 2, 1, _THIS_IP_) 137 lock_acquire(&rcu_lock_map, 0, 0, 2, 1, NULL, _THIS_IP_)
121# define rcu_read_release() lock_release(&rcu_lock_map, 1, _THIS_IP_) 138# define rcu_read_release() lock_release(&rcu_lock_map, 1, _THIS_IP_)
122#else 139#else
123# define rcu_read_acquire() do { } while (0) 140# define rcu_read_acquire() do { } while (0)
diff --git a/include/linux/rculist.h b/include/linux/rculist.h
index b0f39be08b6c..e649bd3f2c97 100644
--- a/include/linux/rculist.h
+++ b/include/linux/rculist.h
@@ -98,6 +98,34 @@ static inline void list_del_rcu(struct list_head *entry)
98} 98}
99 99
100/** 100/**
101 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
102 * @n: the element to delete from the hash list.
103 *
104 * Note: list_unhashed() on the node return true after this. It is
105 * useful for RCU based read lockfree traversal if the writer side
106 * must know if the list entry is still hashed or already unhashed.
107 *
108 * In particular, it means that we can not poison the forward pointers
109 * that may still be used for walking the hash list and we can only
110 * zero the pprev pointer so list_unhashed() will return true after
111 * this.
112 *
113 * The caller must take whatever precautions are necessary (such as
114 * holding appropriate locks) to avoid racing with another
115 * list-mutation primitive, such as hlist_add_head_rcu() or
116 * hlist_del_rcu(), running on this same list. However, it is
117 * perfectly legal to run concurrently with the _rcu list-traversal
118 * primitives, such as hlist_for_each_entry_rcu().
119 */
120static inline void hlist_del_init_rcu(struct hlist_node *n)
121{
122 if (!hlist_unhashed(n)) {
123 __hlist_del(n);
124 n->pprev = NULL;
125 }
126}
127
128/**
101 * list_replace_rcu - replace old entry by new one 129 * list_replace_rcu - replace old entry by new one
102 * @old : the element to be replaced 130 * @old : the element to be replaced
103 * @new : the new element to insert 131 * @new : the new element to insert
@@ -170,20 +198,6 @@ static inline void list_splice_init_rcu(struct list_head *list,
170 at->prev = last; 198 at->prev = last;
171} 199}
172 200
173/**
174 * list_for_each_rcu - iterate over an rcu-protected list
175 * @pos: the &struct list_head to use as a loop cursor.
176 * @head: the head for your list.
177 *
178 * This list-traversal primitive may safely run concurrently with
179 * the _rcu list-mutation primitives such as list_add_rcu()
180 * as long as the traversal is guarded by rcu_read_lock().
181 */
182#define list_for_each_rcu(pos, head) \
183 for (pos = rcu_dereference((head)->next); \
184 prefetch(pos->next), pos != (head); \
185 pos = rcu_dereference(pos->next))
186
187#define __list_for_each_rcu(pos, head) \ 201#define __list_for_each_rcu(pos, head) \
188 for (pos = rcu_dereference((head)->next); \ 202 for (pos = rcu_dereference((head)->next); \
189 pos != (head); \ 203 pos != (head); \
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index e8b4039cfb2f..86f1f5e43e33 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -133,6 +133,26 @@ struct rcu_head {
133#define rcu_read_unlock_bh() __rcu_read_unlock_bh() 133#define rcu_read_unlock_bh() __rcu_read_unlock_bh()
134 134
135/** 135/**
136 * rcu_read_lock_sched - mark the beginning of a RCU-classic critical section
137 *
138 * Should be used with either
139 * - synchronize_sched()
140 * or
141 * - call_rcu_sched() and rcu_barrier_sched()
142 * on the write-side to insure proper synchronization.
143 */
144#define rcu_read_lock_sched() preempt_disable()
145
146/*
147 * rcu_read_unlock_sched - marks the end of a RCU-classic critical section
148 *
149 * See rcu_read_lock_sched for more information.
150 */
151#define rcu_read_unlock_sched() preempt_enable()
152
153
154
155/**
136 * rcu_dereference - fetch an RCU-protected pointer in an 156 * rcu_dereference - fetch an RCU-protected pointer in an
137 * RCU read-side critical section. This pointer may later 157 * RCU read-side critical section. This pointer may later
138 * be safely dereferenced. 158 * be safely dereferenced.
diff --git a/include/linux/rcupreempt.h b/include/linux/rcupreempt.h
index f04b64eca636..3e05c09b54a2 100644
--- a/include/linux/rcupreempt.h
+++ b/include/linux/rcupreempt.h
@@ -57,7 +57,13 @@ static inline void rcu_qsctr_inc(int cpu)
57 rdssp->sched_qs++; 57 rdssp->sched_qs++;
58} 58}
59#define rcu_bh_qsctr_inc(cpu) 59#define rcu_bh_qsctr_inc(cpu)
60#define call_rcu_bh(head, rcu) call_rcu(head, rcu) 60
61/*
62 * Someone might want to pass call_rcu_bh as a function pointer.
63 * So this needs to just be a rename and not a macro function.
64 * (no parentheses)
65 */
66#define call_rcu_bh call_rcu
61 67
62/** 68/**
63 * call_rcu_sched - Queue RCU callback for invocation after sched grace period. 69 * call_rcu_sched - Queue RCU callback for invocation after sched grace period.
@@ -111,20 +117,24 @@ extern struct rcupreempt_trace *rcupreempt_trace_cpu(int cpu);
111struct softirq_action; 117struct softirq_action;
112 118
113#ifdef CONFIG_NO_HZ 119#ifdef CONFIG_NO_HZ
114DECLARE_PER_CPU(struct rcu_dyntick_sched, rcu_dyntick_sched);
115 120
116static inline void rcu_enter_nohz(void) 121static inline void rcu_enter_nohz(void)
117{ 122{
123 static DEFINE_RATELIMIT_STATE(rs, 10 * HZ, 1);
124
118 smp_mb(); /* CPUs seeing ++ must see prior RCU read-side crit sects */ 125 smp_mb(); /* CPUs seeing ++ must see prior RCU read-side crit sects */
119 __get_cpu_var(rcu_dyntick_sched).dynticks++; 126 __get_cpu_var(rcu_dyntick_sched).dynticks++;
120 WARN_ON(__get_cpu_var(rcu_dyntick_sched).dynticks & 0x1); 127 WARN_ON_RATELIMIT(__get_cpu_var(rcu_dyntick_sched).dynticks & 0x1, &rs);
121} 128}
122 129
123static inline void rcu_exit_nohz(void) 130static inline void rcu_exit_nohz(void)
124{ 131{
125 smp_mb(); /* CPUs seeing ++ must see later RCU read-side crit sects */ 132 static DEFINE_RATELIMIT_STATE(rs, 10 * HZ, 1);
133
126 __get_cpu_var(rcu_dyntick_sched).dynticks++; 134 __get_cpu_var(rcu_dyntick_sched).dynticks++;
127 WARN_ON(!(__get_cpu_var(rcu_dyntick_sched).dynticks & 0x1)); 135 smp_mb(); /* CPUs seeing ++ must see later RCU read-side crit sects */
136 WARN_ON_RATELIMIT(!(__get_cpu_var(rcu_dyntick_sched).dynticks & 0x1),
137 &rs);
128} 138}
129 139
130#else /* CONFIG_NO_HZ */ 140#else /* CONFIG_NO_HZ */
diff --git a/include/linux/reboot.h b/include/linux/reboot.h
index b93b541cf111..988e55fe649b 100644
--- a/include/linux/reboot.h
+++ b/include/linux/reboot.h
@@ -59,6 +59,7 @@ extern void machine_crash_shutdown(struct pt_regs *);
59 * Architecture independent implemenations of sys_reboot commands. 59 * Architecture independent implemenations of sys_reboot commands.
60 */ 60 */
61 61
62extern void kernel_restart_prepare(char *cmd);
62extern void kernel_restart(char *cmd); 63extern void kernel_restart(char *cmd);
63extern void kernel_halt(void); 64extern void kernel_halt(void);
64extern void kernel_power_off(void); 65extern void kernel_power_off(void);
diff --git a/include/linux/regulator/bq24022.h b/include/linux/regulator/bq24022.h
new file mode 100644
index 000000000000..e84b0a9feda5
--- /dev/null
+++ b/include/linux/regulator/bq24022.h
@@ -0,0 +1,21 @@
1/*
2 * Support for TI bq24022 (bqTINY-II) Dual Input (USB/AC Adpater)
3 * 1-Cell Li-Ion Charger connected via GPIOs.
4 *
5 * Copyright (c) 2008 Philipp Zabel
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
13/**
14 * bq24022_mach_info - platform data for bq24022
15 * @gpio_nce: GPIO line connected to the nCE pin, used to enable / disable charging
16 * @gpio_iset2: GPIO line connected to the ISET2 pin, used to limit charging current to 100 mA / 500 mA
17 */
18struct bq24022_mach_info {
19 int gpio_nce;
20 int gpio_iset2;
21};
diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h
new file mode 100644
index 000000000000..afdc4558bb94
--- /dev/null
+++ b/include/linux/regulator/consumer.h
@@ -0,0 +1,284 @@
1/*
2 * consumer.h -- SoC Regulator consumer support.
3 *
4 * Copyright (C) 2007, 2008 Wolfson Microelectronics PLC.
5 *
6 * Author: Liam Girdwood <lg@opensource.wolfsonmicro.com>
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 * Regulator Consumer Interface.
13 *
14 * A Power Management Regulator framework for SoC based devices.
15 * Features:-
16 * o Voltage and current level control.
17 * o Operating mode control.
18 * o Regulator status.
19 * o sysfs entries for showing client devices and status
20 *
21 * EXPERIMENTAL FEATURES:
22 * Dynamic Regulator operating Mode Switching (DRMS) - allows regulators
23 * to use most efficient operating mode depending upon voltage and load and
24 * is transparent to client drivers.
25 *
26 * e.g. Devices x,y,z share regulator r. Device x and y draw 20mA each during
27 * IO and 1mA at idle. Device z draws 100mA when under load and 5mA when
28 * idling. Regulator r has > 90% efficiency in NORMAL mode at loads > 100mA
29 * but this drops rapidly to 60% when below 100mA. Regulator r has > 90%
30 * efficiency in IDLE mode at loads < 10mA. Thus regulator r will operate
31 * in normal mode for loads > 10mA and in IDLE mode for load <= 10mA.
32 *
33 */
34
35#ifndef __LINUX_REGULATOR_CONSUMER_H_
36#define __LINUX_REGULATOR_CONSUMER_H_
37
38/*
39 * Regulator operating modes.
40 *
41 * Regulators can run in a variety of different operating modes depending on
42 * output load. This allows further system power savings by selecting the
43 * best (and most efficient) regulator mode for a desired load.
44 *
45 * Most drivers will only care about NORMAL. The modes below are generic and
46 * will probably not match the naming convention of your regulator data sheet
47 * but should match the use cases in the datasheet.
48 *
49 * In order of power efficiency (least efficient at top).
50 *
51 * Mode Description
52 * FAST Regulator can handle fast changes in it's load.
53 * e.g. useful in CPU voltage & frequency scaling where
54 * load can quickly increase with CPU frequency increases.
55 *
56 * NORMAL Normal regulator power supply mode. Most drivers will
57 * use this mode.
58 *
59 * IDLE Regulator runs in a more efficient mode for light
60 * loads. Can be used for devices that have a low power
61 * requirement during periods of inactivity. This mode
62 * may be more noisy than NORMAL and may not be able
63 * to handle fast load switching.
64 *
65 * STANDBY Regulator runs in the most efficient mode for very
66 * light loads. Can be used by devices when they are
67 * in a sleep/standby state. This mode is likely to be
68 * the most noisy and may not be able to handle fast load
69 * switching.
70 *
71 * NOTE: Most regulators will only support a subset of these modes. Some
72 * will only just support NORMAL.
73 *
74 * These modes can be OR'ed together to make up a mask of valid register modes.
75 */
76
77#define REGULATOR_MODE_FAST 0x1
78#define REGULATOR_MODE_NORMAL 0x2
79#define REGULATOR_MODE_IDLE 0x4
80#define REGULATOR_MODE_STANDBY 0x8
81
82/*
83 * Regulator notifier events.
84 *
85 * UNDER_VOLTAGE Regulator output is under voltage.
86 * OVER_CURRENT Regulator output current is too high.
87 * REGULATION_OUT Regulator output is out of regulation.
88 * FAIL Regulator output has failed.
89 * OVER_TEMP Regulator over temp.
90 * FORCE_DISABLE Regulator shut down by software.
91 *
92 * NOTE: These events can be OR'ed together when passed into handler.
93 */
94
95#define REGULATOR_EVENT_UNDER_VOLTAGE 0x01
96#define REGULATOR_EVENT_OVER_CURRENT 0x02
97#define REGULATOR_EVENT_REGULATION_OUT 0x04
98#define REGULATOR_EVENT_FAIL 0x08
99#define REGULATOR_EVENT_OVER_TEMP 0x10
100#define REGULATOR_EVENT_FORCE_DISABLE 0x20
101
102struct regulator;
103
104/**
105 * struct regulator_bulk_data - Data used for bulk regulator operations.
106 *
107 * @supply The name of the supply. Initialised by the user before
108 * using the bulk regulator APIs.
109 * @consumer The regulator consumer for the supply. This will be managed
110 * by the bulk API.
111 *
112 * The regulator APIs provide a series of regulator_bulk_() API calls as
113 * a convenience to consumers which require multiple supplies. This
114 * structure is used to manage data for these calls.
115 */
116struct regulator_bulk_data {
117 const char *supply;
118 struct regulator *consumer;
119};
120
121#if defined(CONFIG_REGULATOR)
122
123/* regulator get and put */
124struct regulator *__must_check regulator_get(struct device *dev,
125 const char *id);
126void regulator_put(struct regulator *regulator);
127
128/* regulator output control and status */
129int regulator_enable(struct regulator *regulator);
130int regulator_disable(struct regulator *regulator);
131int regulator_force_disable(struct regulator *regulator);
132int regulator_is_enabled(struct regulator *regulator);
133
134int regulator_bulk_get(struct device *dev, int num_consumers,
135 struct regulator_bulk_data *consumers);
136int regulator_bulk_enable(int num_consumers,
137 struct regulator_bulk_data *consumers);
138int regulator_bulk_disable(int num_consumers,
139 struct regulator_bulk_data *consumers);
140void regulator_bulk_free(int num_consumers,
141 struct regulator_bulk_data *consumers);
142
143int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV);
144int regulator_get_voltage(struct regulator *regulator);
145int regulator_set_current_limit(struct regulator *regulator,
146 int min_uA, int max_uA);
147int regulator_get_current_limit(struct regulator *regulator);
148
149int regulator_set_mode(struct regulator *regulator, unsigned int mode);
150unsigned int regulator_get_mode(struct regulator *regulator);
151int regulator_set_optimum_mode(struct regulator *regulator, int load_uA);
152
153/* regulator notifier block */
154int regulator_register_notifier(struct regulator *regulator,
155 struct notifier_block *nb);
156int regulator_unregister_notifier(struct regulator *regulator,
157 struct notifier_block *nb);
158
159/* driver data - core doesn't touch */
160void *regulator_get_drvdata(struct regulator *regulator);
161void regulator_set_drvdata(struct regulator *regulator, void *data);
162
163#else
164
165/*
166 * Make sure client drivers will still build on systems with no software
167 * controllable voltage or current regulators.
168 */
169static inline struct regulator *__must_check regulator_get(struct device *dev,
170 const char *id)
171{
172 /* Nothing except the stubbed out regulator API should be
173 * looking at the value except to check if it is an error
174 * value so the actual return value doesn't matter.
175 */
176 return (struct regulator *)id;
177}
178static inline void regulator_put(struct regulator *regulator)
179{
180}
181
182static inline int regulator_enable(struct regulator *regulator)
183{
184 return 0;
185}
186
187static inline int regulator_disable(struct regulator *regulator)
188{
189 return 0;
190}
191
192static inline int regulator_is_enabled(struct regulator *regulator)
193{
194 return 1;
195}
196
197static inline int regulator_bulk_get(struct device *dev,
198 int num_consumers,
199 struct regulator_bulk_data *consumers)
200{
201 return 0;
202}
203
204static inline int regulator_bulk_enable(int num_consumers,
205 struct regulator_bulk_data *consumers)
206{
207 return 0;
208}
209
210static inline int regulator_bulk_disable(int num_consumers,
211 struct regulator_bulk_data *consumers)
212{
213 return 0;
214}
215
216static inline void regulator_bulk_free(int num_consumers,
217 struct regulator_bulk_data *consumers)
218{
219}
220
221static inline int regulator_set_voltage(struct regulator *regulator,
222 int min_uV, int max_uV)
223{
224 return 0;
225}
226
227static inline int regulator_get_voltage(struct regulator *regulator)
228{
229 return 0;
230}
231
232static inline int regulator_set_current_limit(struct regulator *regulator,
233 int min_uA, int max_uA)
234{
235 return 0;
236}
237
238static inline int regulator_get_current_limit(struct regulator *regulator)
239{
240 return 0;
241}
242
243static inline int regulator_set_mode(struct regulator *regulator,
244 unsigned int mode)
245{
246 return 0;
247}
248
249static inline unsigned int regulator_get_mode(struct regulator *regulator)
250{
251 return REGULATOR_MODE_NORMAL;
252}
253
254static inline int regulator_set_optimum_mode(struct regulator *regulator,
255 int load_uA)
256{
257 return REGULATOR_MODE_NORMAL;
258}
259
260static inline int regulator_register_notifier(struct regulator *regulator,
261 struct notifier_block *nb)
262{
263 return 0;
264}
265
266static inline int regulator_unregister_notifier(struct regulator *regulator,
267 struct notifier_block *nb)
268{
269 return 0;
270}
271
272static inline void *regulator_get_drvdata(struct regulator *regulator)
273{
274 return NULL;
275}
276
277static inline void regulator_set_drvdata(struct regulator *regulator,
278 void *data)
279{
280}
281
282#endif
283
284#endif
diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h
new file mode 100644
index 000000000000..e37d80561985
--- /dev/null
+++ b/include/linux/regulator/driver.h
@@ -0,0 +1,101 @@
1/*
2 * driver.h -- SoC Regulator driver support.
3 *
4 * Copyright (C) 2007, 2008 Wolfson Microelectronics PLC.
5 *
6 * Author: Liam Girdwood <lg@opensource.wolfsonmicro.com>
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 * Regulator Driver Interface.
13 */
14
15#ifndef __LINUX_REGULATOR_DRIVER_H_
16#define __LINUX_REGULATOR_DRIVER_H_
17
18#include <linux/device.h>
19#include <linux/regulator/consumer.h>
20
21struct regulator_dev;
22struct regulator_init_data;
23
24/**
25 * struct regulator_ops - regulator operations.
26 *
27 * This struct describes regulator operations.
28 */
29struct regulator_ops {
30
31 /* get/set regulator voltage */
32 int (*set_voltage) (struct regulator_dev *, int min_uV, int max_uV);
33 int (*get_voltage) (struct regulator_dev *);
34
35 /* get/set regulator current */
36 int (*set_current_limit) (struct regulator_dev *,
37 int min_uA, int max_uA);
38 int (*get_current_limit) (struct regulator_dev *);
39
40 /* enable/disable regulator */
41 int (*enable) (struct regulator_dev *);
42 int (*disable) (struct regulator_dev *);
43 int (*is_enabled) (struct regulator_dev *);
44
45 /* get/set regulator operating mode (defined in regulator.h) */
46 int (*set_mode) (struct regulator_dev *, unsigned int mode);
47 unsigned int (*get_mode) (struct regulator_dev *);
48
49 /* get most efficient regulator operating mode for load */
50 unsigned int (*get_optimum_mode) (struct regulator_dev *, int input_uV,
51 int output_uV, int load_uA);
52
53 /* the operations below are for configuration of regulator state when
54 * its parent PMIC enters a global STANDBY/HIBERNATE state */
55
56 /* set regulator suspend voltage */
57 int (*set_suspend_voltage) (struct regulator_dev *, int uV);
58
59 /* enable/disable regulator in suspend state */
60 int (*set_suspend_enable) (struct regulator_dev *);
61 int (*set_suspend_disable) (struct regulator_dev *);
62
63 /* set regulator suspend operating mode (defined in regulator.h) */
64 int (*set_suspend_mode) (struct regulator_dev *, unsigned int mode);
65};
66
67/*
68 * Regulators can either control voltage or current.
69 */
70enum regulator_type {
71 REGULATOR_VOLTAGE,
72 REGULATOR_CURRENT,
73};
74
75/**
76 * struct regulator_desc - Regulator descriptor
77 *
78 */
79struct regulator_desc {
80 const char *name;
81 int id;
82 struct regulator_ops *ops;
83 int irq;
84 enum regulator_type type;
85 struct module *owner;
86};
87
88struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc,
89 struct device *dev, void *driver_data);
90void regulator_unregister(struct regulator_dev *rdev);
91
92int regulator_notifier_call_chain(struct regulator_dev *rdev,
93 unsigned long event, void *data);
94
95void *rdev_get_drvdata(struct regulator_dev *rdev);
96struct device *rdev_get_dev(struct regulator_dev *rdev);
97int rdev_get_id(struct regulator_dev *rdev);
98
99void *regulator_get_init_drvdata(struct regulator_init_data *reg_init_data);
100
101#endif
diff --git a/include/linux/regulator/fixed.h b/include/linux/regulator/fixed.h
new file mode 100644
index 000000000000..1387a5d2190e
--- /dev/null
+++ b/include/linux/regulator/fixed.h
@@ -0,0 +1,22 @@
1/*
2 * fixed.h
3 *
4 * Copyright 2008 Wolfson Microelectronics PLC.
5 *
6 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of the
11 * License, or (at your option) any later version.
12 */
13
14#ifndef __REGULATOR_FIXED_H
15#define __REGULATOR_FIXED_H
16
17struct fixed_voltage_config {
18 const char *supply_name;
19 int microvolts;
20};
21
22#endif
diff --git a/include/linux/regulator/machine.h b/include/linux/regulator/machine.h
new file mode 100644
index 000000000000..c6d69331a81e
--- /dev/null
+++ b/include/linux/regulator/machine.h
@@ -0,0 +1,122 @@
1/*
2 * machine.h -- SoC Regulator support, machine/board driver API.
3 *
4 * Copyright (C) 2007, 2008 Wolfson Microelectronics PLC.
5 *
6 * Author: Liam Girdwood <lg@opensource.wolfsonmicro.com>
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 * Regulator Machine/Board Interface.
13 */
14
15#ifndef __LINUX_REGULATOR_MACHINE_H_
16#define __LINUX_REGULATOR_MACHINE_H_
17
18#include <linux/regulator/consumer.h>
19#include <linux/suspend.h>
20
21struct regulator;
22
23/*
24 * Regulator operation constraint flags. These flags are used to enable
25 * certain regulator operations and can be OR'ed together.
26 *
27 * VOLTAGE: Regulator output voltage can be changed by software on this
28 * board/machine.
29 * CURRENT: Regulator output current can be changed by software on this
30 * board/machine.
31 * MODE: Regulator operating mode can be changed by software on this
32 * board/machine.
33 * STATUS: Regulator can be enabled and disabled.
34 * DRMS: Dynamic Regulator Mode Switching is enabled for this regulator.
35 */
36
37#define REGULATOR_CHANGE_VOLTAGE 0x1
38#define REGULATOR_CHANGE_CURRENT 0x2
39#define REGULATOR_CHANGE_MODE 0x4
40#define REGULATOR_CHANGE_STATUS 0x8
41#define REGULATOR_CHANGE_DRMS 0x10
42
43/**
44 * struct regulator_state - regulator state during low power syatem states
45 *
46 * This describes a regulators state during a system wide low power state.
47 */
48struct regulator_state {
49 int uV; /* suspend voltage */
50 unsigned int mode; /* suspend regulator operating mode */
51 int enabled; /* is regulator enabled in this suspend state */
52};
53
54/**
55 * struct regulation_constraints - regulator operating constraints.
56 *
57 * This struct describes regulator and board/machine specific constraints.
58 */
59struct regulation_constraints {
60
61 char *name;
62
63 /* voltage output range (inclusive) - for voltage control */
64 int min_uV;
65 int max_uV;
66
67 /* current output range (inclusive) - for current control */
68 int min_uA;
69 int max_uA;
70
71 /* valid regulator operating modes for this machine */
72 unsigned int valid_modes_mask;
73
74 /* valid operations for regulator on this machine */
75 unsigned int valid_ops_mask;
76
77 /* regulator input voltage - only if supply is another regulator */
78 int input_uV;
79
80 /* regulator suspend states for global PMIC STANDBY/HIBERNATE */
81 struct regulator_state state_disk;
82 struct regulator_state state_mem;
83 struct regulator_state state_standby;
84 suspend_state_t initial_state; /* suspend state to set at init */
85
86 /* constriant flags */
87 unsigned always_on:1; /* regulator never off when system is on */
88 unsigned boot_on:1; /* bootloader/firmware enabled regulator */
89 unsigned apply_uV:1; /* apply uV constraint iff min == max */
90};
91
92/**
93 * struct regulator_consumer_supply - supply -> device mapping
94 *
95 * This maps a supply name to a device.
96 */
97struct regulator_consumer_supply {
98 struct device *dev; /* consumer */
99 const char *supply; /* consumer supply - e.g. "vcc" */
100};
101
102/**
103 * struct regulator_init_data - regulator platform initialisation data.
104 *
105 * Initialisation constraints, our supply and consumers supplies.
106 */
107struct regulator_init_data {
108 struct device *supply_regulator_dev; /* or NULL for LINE */
109
110 struct regulation_constraints constraints;
111
112 int num_consumer_supplies;
113 struct regulator_consumer_supply *consumer_supplies;
114
115 /* optional regulator machine specific init */
116 int (*regulator_init)(void *driver_data);
117 void *driver_data; /* core does not touch this */
118};
119
120int regulator_suspend_prepare(suspend_state_t state);
121
122#endif
diff --git a/include/linux/reiserfs_fs.h b/include/linux/reiserfs_fs.h
index 4aacaeecb56f..bc5114d35e99 100644
--- a/include/linux/reiserfs_fs.h
+++ b/include/linux/reiserfs_fs.h
@@ -87,7 +87,7 @@ void reiserfs_warning(struct super_block *s, const char *fmt, ...);
87if( !( cond ) ) \ 87if( !( cond ) ) \
88 reiserfs_panic( NULL, "reiserfs[%i]: assertion " scond " failed at " \ 88 reiserfs_panic( NULL, "reiserfs[%i]: assertion " scond " failed at " \
89 __FILE__ ":%i:%s: " format "\n", \ 89 __FILE__ ":%i:%s: " format "\n", \
90 in_interrupt() ? -1 : task_pid_nr(current), __LINE__ , __FUNCTION__ , ##args ) 90 in_interrupt() ? -1 : task_pid_nr(current), __LINE__ , __func__ , ##args )
91 91
92#define RASSERT(cond, format, args...) __RASSERT(cond, #cond, format, ##args) 92#define RASSERT(cond, format, args...) __RASSERT(cond, #cond, format, ##args)
93 93
@@ -526,8 +526,8 @@ struct item_head {
526** p is the array of __u32, i is the index into the array, v is the value 526** p is the array of __u32, i is the index into the array, v is the value
527** to store there. 527** to store there.
528*/ 528*/
529#define get_block_num(p, i) le32_to_cpu(get_unaligned((p) + (i))) 529#define get_block_num(p, i) get_unaligned_le32((p) + (i))
530#define put_block_num(p, i, v) put_unaligned(cpu_to_le32(v), (p) + (i)) 530#define put_block_num(p, i, v) put_unaligned_le32((v), (p) + (i))
531 531
532// 532//
533// in old version uniqueness field shows key type 533// in old version uniqueness field shows key type
diff --git a/include/linux/reiserfs_fs_sb.h b/include/linux/reiserfs_fs_sb.h
index 336ee43ed7d8..bda6b562a1e0 100644
--- a/include/linux/reiserfs_fs_sb.h
+++ b/include/linux/reiserfs_fs_sb.h
@@ -152,7 +152,7 @@ struct reiserfs_journal_list {
152 atomic_t j_nonzerolen; 152 atomic_t j_nonzerolen;
153 atomic_t j_commit_left; 153 atomic_t j_commit_left;
154 atomic_t j_older_commits_done; /* all commits older than this on disk */ 154 atomic_t j_older_commits_done; /* all commits older than this on disk */
155 struct semaphore j_commit_lock; 155 struct mutex j_commit_mutex;
156 unsigned long j_trans_id; 156 unsigned long j_trans_id;
157 time_t j_timestamp; 157 time_t j_timestamp;
158 struct reiserfs_list_bitmap *j_list_bitmap; 158 struct reiserfs_list_bitmap *j_list_bitmap;
@@ -178,6 +178,7 @@ struct reiserfs_journal {
178 struct reiserfs_journal_cnode *j_first; /* oldest journal block. start here for traverse */ 178 struct reiserfs_journal_cnode *j_first; /* oldest journal block. start here for traverse */
179 179
180 struct block_device *j_dev_bd; 180 struct block_device *j_dev_bd;
181 fmode_t j_dev_mode;
181 int j_1st_reserved_block; /* first block on s_dev of reserved area journal */ 182 int j_1st_reserved_block; /* first block on s_dev of reserved area journal */
182 183
183 unsigned long j_state; 184 unsigned long j_state;
@@ -193,8 +194,8 @@ struct reiserfs_journal {
193 struct buffer_head *j_header_bh; 194 struct buffer_head *j_header_bh;
194 195
195 time_t j_trans_start_time; /* time this transaction started */ 196 time_t j_trans_start_time; /* time this transaction started */
196 struct semaphore j_lock; 197 struct mutex j_mutex;
197 struct semaphore j_flush_sem; 198 struct mutex j_flush_mutex;
198 wait_queue_head_t j_join_wait; /* wait for current transaction to finish before starting new one */ 199 wait_queue_head_t j_join_wait; /* wait for current transaction to finish before starting new one */
199 atomic_t j_jlock; /* lock for j_join_wait */ 200 atomic_t j_jlock; /* lock for j_join_wait */
200 int j_list_bitmap_index; /* number of next list bitmap to use */ 201 int j_list_bitmap_index; /* number of next list bitmap to use */
diff --git a/include/linux/reiserfs_xattr.h b/include/linux/reiserfs_xattr.h
index 66a96814d614..af135ae895db 100644
--- a/include/linux/reiserfs_xattr.h
+++ b/include/linux/reiserfs_xattr.h
@@ -55,7 +55,7 @@ int reiserfs_removexattr(struct dentry *dentry, const char *name);
55int reiserfs_delete_xattrs(struct inode *inode); 55int reiserfs_delete_xattrs(struct inode *inode);
56int reiserfs_chown_xattrs(struct inode *inode, struct iattr *attrs); 56int reiserfs_chown_xattrs(struct inode *inode, struct iattr *attrs);
57int reiserfs_xattr_init(struct super_block *sb, int mount_flags); 57int reiserfs_xattr_init(struct super_block *sb, int mount_flags);
58int reiserfs_permission(struct inode *inode, int mask, struct nameidata *nd); 58int reiserfs_permission(struct inode *inode, int mask);
59 59
60int reiserfs_xattr_del(struct inode *, const char *); 60int reiserfs_xattr_del(struct inode *, const char *);
61int reiserfs_xattr_get(const struct inode *, const char *, void *, size_t); 61int reiserfs_xattr_get(const struct inode *, const char *, void *, size_t);
diff --git a/include/linux/relay.h b/include/linux/relay.h
index 6cd8c4425fc7..953fc055e875 100644
--- a/include/linux/relay.h
+++ b/include/linux/relay.h
@@ -48,6 +48,7 @@ struct rchan_buf
48 size_t *padding; /* padding counts per sub-buffer */ 48 size_t *padding; /* padding counts per sub-buffer */
49 size_t prev_padding; /* temporary variable */ 49 size_t prev_padding; /* temporary variable */
50 size_t bytes_consumed; /* bytes consumed in cur read subbuf */ 50 size_t bytes_consumed; /* bytes consumed in cur read subbuf */
51 size_t early_bytes; /* bytes consumed before VFS inited */
51 unsigned int cpu; /* this buf's cpu */ 52 unsigned int cpu; /* this buf's cpu */
52} ____cacheline_aligned; 53} ____cacheline_aligned;
53 54
@@ -68,6 +69,7 @@ struct rchan
68 int is_global; /* One global buffer ? */ 69 int is_global; /* One global buffer ? */
69 struct list_head list; /* for channel list */ 70 struct list_head list; /* for channel list */
70 struct dentry *parent; /* parent dentry passed to open */ 71 struct dentry *parent; /* parent dentry passed to open */
72 int has_base_filename; /* has a filename associated? */
71 char base_filename[NAME_MAX]; /* saved base filename */ 73 char base_filename[NAME_MAX]; /* saved base filename */
72}; 74};
73 75
@@ -169,6 +171,9 @@ struct rchan *relay_open(const char *base_filename,
169 size_t n_subbufs, 171 size_t n_subbufs,
170 struct rchan_callbacks *cb, 172 struct rchan_callbacks *cb,
171 void *private_data); 173 void *private_data);
174extern int relay_late_setup_files(struct rchan *chan,
175 const char *base_filename,
176 struct dentry *parent);
172extern void relay_close(struct rchan *chan); 177extern void relay_close(struct rchan *chan);
173extern void relay_flush(struct rchan *chan); 178extern void relay_flush(struct rchan *chan);
174extern void relay_subbufs_consumed(struct rchan *chan, 179extern void relay_subbufs_consumed(struct rchan *chan,
diff --git a/include/linux/res_counter.h b/include/linux/res_counter.h
index 6d9e1fca098c..271c1c2c9f6f 100644
--- a/include/linux/res_counter.h
+++ b/include/linux/res_counter.h
@@ -63,9 +63,14 @@ u64 res_counter_read_u64(struct res_counter *counter, int member);
63ssize_t res_counter_read(struct res_counter *counter, int member, 63ssize_t res_counter_read(struct res_counter *counter, int member,
64 const char __user *buf, size_t nbytes, loff_t *pos, 64 const char __user *buf, size_t nbytes, loff_t *pos,
65 int (*read_strategy)(unsigned long long val, char *s)); 65 int (*read_strategy)(unsigned long long val, char *s));
66ssize_t res_counter_write(struct res_counter *counter, int member, 66
67 const char __user *buf, size_t nbytes, loff_t *pos, 67typedef int (*write_strategy_fn)(const char *buf, unsigned long long *val);
68 int (*write_strategy)(char *buf, unsigned long long *val)); 68
69int res_counter_memparse_write_strategy(const char *buf,
70 unsigned long long *res);
71
72int res_counter_write(struct res_counter *counter, int member,
73 const char *buffer, write_strategy_fn write_strategy);
69 74
70/* 75/*
71 * the field descriptors. one for each member of res_counter 76 * the field descriptors. one for each member of res_counter
@@ -95,8 +100,10 @@ void res_counter_init(struct res_counter *counter);
95 * counter->limit _locked call expects the counter->lock to be taken 100 * counter->limit _locked call expects the counter->lock to be taken
96 */ 101 */
97 102
98int res_counter_charge_locked(struct res_counter *counter, unsigned long val); 103int __must_check res_counter_charge_locked(struct res_counter *counter,
99int res_counter_charge(struct res_counter *counter, unsigned long val); 104 unsigned long val);
105int __must_check res_counter_charge(struct res_counter *counter,
106 unsigned long val);
100 107
101/* 108/*
102 * uncharge - tell that some portion of the resource is released 109 * uncharge - tell that some portion of the resource is released
@@ -151,4 +158,20 @@ static inline void res_counter_reset_failcnt(struct res_counter *cnt)
151 cnt->failcnt = 0; 158 cnt->failcnt = 0;
152 spin_unlock_irqrestore(&cnt->lock, flags); 159 spin_unlock_irqrestore(&cnt->lock, flags);
153} 160}
161
162static inline int res_counter_set_limit(struct res_counter *cnt,
163 unsigned long long limit)
164{
165 unsigned long flags;
166 int ret = -EBUSY;
167
168 spin_lock_irqsave(&cnt->lock, flags);
169 if (cnt->usage <= limit) {
170 cnt->limit = limit;
171 ret = 0;
172 }
173 spin_unlock_irqrestore(&cnt->lock, flags);
174 return ret;
175}
176
154#endif 177#endif
diff --git a/include/linux/rfkill.h b/include/linux/rfkill.h
index e3ab21d7fc7f..4cd64b0d9825 100644
--- a/include/linux/rfkill.h
+++ b/include/linux/rfkill.h
@@ -34,33 +34,52 @@
34 * RFKILL_TYPE_BLUETOOTH: switch is on a bluetooth device. 34 * RFKILL_TYPE_BLUETOOTH: switch is on a bluetooth device.
35 * RFKILL_TYPE_UWB: switch is on a ultra wideband device. 35 * RFKILL_TYPE_UWB: switch is on a ultra wideband device.
36 * RFKILL_TYPE_WIMAX: switch is on a WiMAX device. 36 * RFKILL_TYPE_WIMAX: switch is on a WiMAX device.
37 * RFKILL_TYPE_WWAN: switch is on a wireless WAN device.
37 */ 38 */
38enum rfkill_type { 39enum rfkill_type {
39 RFKILL_TYPE_WLAN , 40 RFKILL_TYPE_WLAN ,
40 RFKILL_TYPE_BLUETOOTH, 41 RFKILL_TYPE_BLUETOOTH,
41 RFKILL_TYPE_UWB, 42 RFKILL_TYPE_UWB,
42 RFKILL_TYPE_WIMAX, 43 RFKILL_TYPE_WIMAX,
44 RFKILL_TYPE_WWAN,
43 RFKILL_TYPE_MAX, 45 RFKILL_TYPE_MAX,
44}; 46};
45 47
46enum rfkill_state { 48enum rfkill_state {
47 RFKILL_STATE_OFF = 0, 49 RFKILL_STATE_SOFT_BLOCKED = 0, /* Radio output blocked */
48 RFKILL_STATE_ON = 1, 50 RFKILL_STATE_UNBLOCKED = 1, /* Radio output allowed */
51 RFKILL_STATE_HARD_BLOCKED = 2, /* Output blocked, non-overrideable */
52 RFKILL_STATE_MAX, /* marker for last valid state */
49}; 53};
50 54
55/*
56 * These are DEPRECATED, drivers using them should be verified to
57 * comply with the rfkill usage guidelines in Documentation/rfkill.txt
58 * and then converted to use the new names for rfkill_state
59 */
60#define RFKILL_STATE_OFF RFKILL_STATE_SOFT_BLOCKED
61#define RFKILL_STATE_ON RFKILL_STATE_UNBLOCKED
62
51/** 63/**
52 * struct rfkill - rfkill control structure. 64 * struct rfkill - rfkill control structure.
53 * @name: Name of the switch. 65 * @name: Name of the switch.
54 * @type: Radio type which the button controls, the value stored 66 * @type: Radio type which the button controls, the value stored
55 * here should be a value from enum rfkill_type. 67 * here should be a value from enum rfkill_type.
56 * @state: State of the switch (on/off). 68 * @state: State of the switch, "UNBLOCKED" means radio can operate.
57 * @user_claim_unsupported: Whether the hardware supports exclusive 69 * @user_claim_unsupported: Whether the hardware supports exclusive
58 * RF-kill control by userspace. Set this before registering. 70 * RF-kill control by userspace. Set this before registering.
59 * @user_claim: Set when the switch is controlled exlusively by userspace. 71 * @user_claim: Set when the switch is controlled exlusively by userspace.
60 * @mutex: Guards switch state transitions 72 * @mutex: Guards switch state transitions. It serializes callbacks
73 * and also protects the state.
61 * @data: Pointer to the RF button drivers private data which will be 74 * @data: Pointer to the RF button drivers private data which will be
62 * passed along when toggling radio state. 75 * passed along when toggling radio state.
63 * @toggle_radio(): Mandatory handler to control state of the radio. 76 * @toggle_radio(): Mandatory handler to control state of the radio.
77 * only RFKILL_STATE_SOFT_BLOCKED and RFKILL_STATE_UNBLOCKED are
78 * valid parameters.
79 * @get_state(): handler to read current radio state from hardware,
80 * may be called from atomic context, should return 0 on success.
81 * Either this handler OR judicious use of rfkill_force_state() is
82 * MANDATORY for any driver capable of RFKILL_STATE_HARD_BLOCKED.
64 * @led_trigger: A LED trigger for this button's LED. 83 * @led_trigger: A LED trigger for this button's LED.
65 * @dev: Device structure integrating the switch into device tree. 84 * @dev: Device structure integrating the switch into device tree.
66 * @node: Used to place switch into list of all switches known to the 85 * @node: Used to place switch into list of all switches known to the
@@ -72,14 +91,16 @@ struct rfkill {
72 const char *name; 91 const char *name;
73 enum rfkill_type type; 92 enum rfkill_type type;
74 93
75 enum rfkill_state state;
76 bool user_claim_unsupported; 94 bool user_claim_unsupported;
77 bool user_claim; 95 bool user_claim;
78 96
97 /* the mutex serializes callbacks and also protects
98 * the state */
79 struct mutex mutex; 99 struct mutex mutex;
80 100 enum rfkill_state state;
81 void *data; 101 void *data;
82 int (*toggle_radio)(void *data, enum rfkill_state state); 102 int (*toggle_radio)(void *data, enum rfkill_state state);
103 int (*get_state)(void *data, enum rfkill_state *state);
83 104
84#ifdef CONFIG_RFKILL_LEDS 105#ifdef CONFIG_RFKILL_LEDS
85 struct led_trigger led_trigger; 106 struct led_trigger led_trigger;
@@ -90,11 +111,28 @@ struct rfkill {
90}; 111};
91#define to_rfkill(d) container_of(d, struct rfkill, dev) 112#define to_rfkill(d) container_of(d, struct rfkill, dev)
92 113
93struct rfkill *rfkill_allocate(struct device *parent, enum rfkill_type type); 114struct rfkill * __must_check rfkill_allocate(struct device *parent,
115 enum rfkill_type type);
94void rfkill_free(struct rfkill *rfkill); 116void rfkill_free(struct rfkill *rfkill);
95int rfkill_register(struct rfkill *rfkill); 117int __must_check rfkill_register(struct rfkill *rfkill);
96void rfkill_unregister(struct rfkill *rfkill); 118void rfkill_unregister(struct rfkill *rfkill);
97 119
120int rfkill_force_state(struct rfkill *rfkill, enum rfkill_state state);
121int rfkill_set_default(enum rfkill_type type, enum rfkill_state state);
122
123/**
124 * rfkill_state_complement - return complementar state
125 * @state: state to return the complement of
126 *
127 * Returns RFKILL_STATE_SOFT_BLOCKED if @state is RFKILL_STATE_UNBLOCKED,
128 * returns RFKILL_STATE_UNBLOCKED otherwise.
129 */
130static inline enum rfkill_state rfkill_state_complement(enum rfkill_state state)
131{
132 return (state == RFKILL_STATE_UNBLOCKED) ?
133 RFKILL_STATE_SOFT_BLOCKED : RFKILL_STATE_UNBLOCKED;
134}
135
98/** 136/**
99 * rfkill_get_led_name - Get the LED trigger name for the button's LED. 137 * rfkill_get_led_name - Get the LED trigger name for the button's LED.
100 * This function might return a NULL pointer if registering of the 138 * This function might return a NULL pointer if registering of the
@@ -110,4 +148,11 @@ static inline char *rfkill_get_led_name(struct rfkill *rfkill)
110#endif 148#endif
111} 149}
112 150
151/* rfkill notification chain */
152#define RFKILL_STATE_CHANGED 0x0001 /* state of a normal rfkill
153 switch has changed */
154
155int register_rfkill_notifier(struct notifier_block *nb);
156int unregister_rfkill_notifier(struct notifier_block *nb);
157
113#endif /* RFKILL_H */ 158#endif /* RFKILL_H */
diff --git a/include/linux/ring_buffer.h b/include/linux/ring_buffer.h
new file mode 100644
index 000000000000..536b0ca46a03
--- /dev/null
+++ b/include/linux/ring_buffer.h
@@ -0,0 +1,127 @@
1#ifndef _LINUX_RING_BUFFER_H
2#define _LINUX_RING_BUFFER_H
3
4#include <linux/mm.h>
5#include <linux/seq_file.h>
6
7struct ring_buffer;
8struct ring_buffer_iter;
9
10/*
11 * Don't reference this struct directly, use functions below.
12 */
13struct ring_buffer_event {
14 u32 type:2, len:3, time_delta:27;
15 u32 array[];
16};
17
18/**
19 * enum ring_buffer_type - internal ring buffer types
20 *
21 * @RINGBUF_TYPE_PADDING: Left over page padding
22 * array is ignored
23 * size is variable depending on how much
24 * padding is needed
25 *
26 * @RINGBUF_TYPE_TIME_EXTEND: Extend the time delta
27 * array[0] = time delta (28 .. 59)
28 * size = 8 bytes
29 *
30 * @RINGBUF_TYPE_TIME_STAMP: Sync time stamp with external clock
31 * array[0] = tv_nsec
32 * array[1] = tv_sec
33 * size = 16 bytes
34 *
35 * @RINGBUF_TYPE_DATA: Data record
36 * If len is zero:
37 * array[0] holds the actual length
38 * array[1..(length+3)/4-1] holds data
39 * else
40 * length = len << 2
41 * array[0..(length+3)/4] holds data
42 */
43enum ring_buffer_type {
44 RINGBUF_TYPE_PADDING,
45 RINGBUF_TYPE_TIME_EXTEND,
46 /* FIXME: RINGBUF_TYPE_TIME_STAMP not implemented */
47 RINGBUF_TYPE_TIME_STAMP,
48 RINGBUF_TYPE_DATA,
49};
50
51unsigned ring_buffer_event_length(struct ring_buffer_event *event);
52void *ring_buffer_event_data(struct ring_buffer_event *event);
53
54/**
55 * ring_buffer_event_time_delta - return the delta timestamp of the event
56 * @event: the event to get the delta timestamp of
57 *
58 * The delta timestamp is the 27 bit timestamp since the last event.
59 */
60static inline unsigned
61ring_buffer_event_time_delta(struct ring_buffer_event *event)
62{
63 return event->time_delta;
64}
65
66/*
67 * size is in bytes for each per CPU buffer.
68 */
69struct ring_buffer *
70ring_buffer_alloc(unsigned long size, unsigned flags);
71void ring_buffer_free(struct ring_buffer *buffer);
72
73int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size);
74
75struct ring_buffer_event *
76ring_buffer_lock_reserve(struct ring_buffer *buffer,
77 unsigned long length,
78 unsigned long *flags);
79int ring_buffer_unlock_commit(struct ring_buffer *buffer,
80 struct ring_buffer_event *event,
81 unsigned long flags);
82int ring_buffer_write(struct ring_buffer *buffer,
83 unsigned long length, void *data);
84
85struct ring_buffer_event *
86ring_buffer_peek(struct ring_buffer *buffer, int cpu, u64 *ts);
87struct ring_buffer_event *
88ring_buffer_consume(struct ring_buffer *buffer, int cpu, u64 *ts);
89
90struct ring_buffer_iter *
91ring_buffer_read_start(struct ring_buffer *buffer, int cpu);
92void ring_buffer_read_finish(struct ring_buffer_iter *iter);
93
94struct ring_buffer_event *
95ring_buffer_iter_peek(struct ring_buffer_iter *iter, u64 *ts);
96struct ring_buffer_event *
97ring_buffer_read(struct ring_buffer_iter *iter, u64 *ts);
98void ring_buffer_iter_reset(struct ring_buffer_iter *iter);
99int ring_buffer_iter_empty(struct ring_buffer_iter *iter);
100
101unsigned long ring_buffer_size(struct ring_buffer *buffer);
102
103void ring_buffer_reset_cpu(struct ring_buffer *buffer, int cpu);
104void ring_buffer_reset(struct ring_buffer *buffer);
105
106int ring_buffer_swap_cpu(struct ring_buffer *buffer_a,
107 struct ring_buffer *buffer_b, int cpu);
108
109int ring_buffer_empty(struct ring_buffer *buffer);
110int ring_buffer_empty_cpu(struct ring_buffer *buffer, int cpu);
111
112void ring_buffer_record_disable(struct ring_buffer *buffer);
113void ring_buffer_record_enable(struct ring_buffer *buffer);
114void ring_buffer_record_disable_cpu(struct ring_buffer *buffer, int cpu);
115void ring_buffer_record_enable_cpu(struct ring_buffer *buffer, int cpu);
116
117unsigned long ring_buffer_entries(struct ring_buffer *buffer);
118unsigned long ring_buffer_overruns(struct ring_buffer *buffer);
119
120u64 ring_buffer_time_stamp(int cpu);
121void ring_buffer_normalize_time_stamp(int cpu, u64 *ts);
122
123enum ring_buffer_flags {
124 RB_FL_OVERWRITE = 1 << 0,
125};
126
127#endif /* _LINUX_RING_BUFFER_H */
diff --git a/include/linux/rmap.h b/include/linux/rmap.h
index 1383692ac5bd..89f0564b10c8 100644
--- a/include/linux/rmap.h
+++ b/include/linux/rmap.h
@@ -26,23 +26,19 @@
26 */ 26 */
27struct anon_vma { 27struct anon_vma {
28 spinlock_t lock; /* Serialize access to vma list */ 28 spinlock_t lock; /* Serialize access to vma list */
29 /*
30 * NOTE: the LSB of the head.next is set by
31 * mm_take_all_locks() _after_ taking the above lock. So the
32 * head must only be read/written after taking the above lock
33 * to be sure to see a valid next pointer. The LSB bit itself
34 * is serialized by a system wide lock only visible to
35 * mm_take_all_locks() (mm_all_locks_mutex).
36 */
29 struct list_head head; /* List of private "related" vmas */ 37 struct list_head head; /* List of private "related" vmas */
30}; 38};
31 39
32#ifdef CONFIG_MMU 40#ifdef CONFIG_MMU
33 41
34extern struct kmem_cache *anon_vma_cachep;
35
36static inline struct anon_vma *anon_vma_alloc(void)
37{
38 return kmem_cache_alloc(anon_vma_cachep, GFP_KERNEL);
39}
40
41static inline void anon_vma_free(struct anon_vma *anon_vma)
42{
43 kmem_cache_free(anon_vma_cachep, anon_vma);
44}
45
46static inline void anon_vma_lock(struct vm_area_struct *vma) 42static inline void anon_vma_lock(struct vm_area_struct *vma)
47{ 43{
48 struct anon_vma *anon_vma = vma->anon_vma; 44 struct anon_vma *anon_vma = vma->anon_vma;
@@ -67,6 +63,9 @@ void anon_vma_unlink(struct vm_area_struct *);
67void anon_vma_link(struct vm_area_struct *); 63void anon_vma_link(struct vm_area_struct *);
68void __anon_vma_link(struct vm_area_struct *); 64void __anon_vma_link(struct vm_area_struct *);
69 65
66extern struct anon_vma *page_lock_anon_vma(struct page *page);
67extern void page_unlock_anon_vma(struct anon_vma *anon_vma);
68
70/* 69/*
71 * rmap interfaces called when adding or removing pte of page 70 * rmap interfaces called when adding or removing pte of page
72 */ 71 */
@@ -94,7 +93,7 @@ int try_to_unmap(struct page *, int ignore_refs);
94 * Called from mm/filemap_xip.c to unmap empty zero page 93 * Called from mm/filemap_xip.c to unmap empty zero page
95 */ 94 */
96pte_t *page_check_address(struct page *, struct mm_struct *, 95pte_t *page_check_address(struct page *, struct mm_struct *,
97 unsigned long, spinlock_t **); 96 unsigned long, spinlock_t **, int);
98 97
99/* 98/*
100 * Used by swapoff to help locate where page is expected in vma. 99 * Used by swapoff to help locate where page is expected in vma.
@@ -109,6 +108,19 @@ unsigned long page_address_in_vma(struct page *, struct vm_area_struct *);
109 */ 108 */
110int page_mkclean(struct page *); 109int page_mkclean(struct page *);
111 110
111#ifdef CONFIG_UNEVICTABLE_LRU
112/*
113 * called in munlock()/munmap() path to check for other vmas holding
114 * the page mlocked.
115 */
116int try_to_munlock(struct page *);
117#else
118static inline int try_to_munlock(struct page *page)
119{
120 return 0; /* a.k.a. SWAP_SUCCESS */
121}
122#endif
123
112#else /* !CONFIG_MMU */ 124#else /* !CONFIG_MMU */
113 125
114#define anon_vma_init() do {} while (0) 126#define anon_vma_init() do {} while (0)
@@ -132,5 +144,6 @@ static inline int page_mkclean(struct page *page)
132#define SWAP_SUCCESS 0 144#define SWAP_SUCCESS 0
133#define SWAP_AGAIN 1 145#define SWAP_AGAIN 1
134#define SWAP_FAIL 2 146#define SWAP_FAIL 2
147#define SWAP_MLOCK 3
135 148
136#endif /* _LINUX_RMAP_H */ 149#endif /* _LINUX_RMAP_H */
diff --git a/include/linux/rtc.h b/include/linux/rtc.h
index f2d0d1527721..91f597ad6acc 100644
--- a/include/linux/rtc.h
+++ b/include/linux/rtc.h
@@ -115,6 +115,23 @@ extern void rtc_time_to_tm(unsigned long time, struct rtc_time *tm);
115 115
116extern struct class *rtc_class; 116extern struct class *rtc_class;
117 117
118/*
119 * For these RTC methods the device parameter is the physical device
120 * on whatever bus holds the hardware (I2C, Platform, SPI, etc), which
121 * was passed to rtc_device_register(). Its driver_data normally holds
122 * device state, including the rtc_device pointer for the RTC.
123 *
124 * Most of these methods are called with rtc_device.ops_lock held,
125 * through the rtc_*(struct rtc_device *, ...) calls.
126 *
127 * The (current) exceptions are mostly filesystem hooks:
128 * - the proc() hook for procfs
129 * - non-ioctl() chardev hooks: open(), release(), read_callback()
130 * - periodic irq calls: irq_set_state(), irq_set_freq()
131 *
132 * REVISIT those periodic irq calls *do* have ops_lock when they're
133 * issued through ioctl() ...
134 */
118struct rtc_class_ops { 135struct rtc_class_ops {
119 int (*open)(struct device *); 136 int (*open)(struct device *);
120 void (*release)(struct device *); 137 void (*release)(struct device *);
@@ -208,8 +225,6 @@ typedef struct rtc_task {
208int rtc_register(rtc_task_t *task); 225int rtc_register(rtc_task_t *task);
209int rtc_unregister(rtc_task_t *task); 226int rtc_unregister(rtc_task_t *task);
210int rtc_control(rtc_task_t *t, unsigned int cmd, unsigned long arg); 227int rtc_control(rtc_task_t *t, unsigned int cmd, unsigned long arg);
211void rtc_get_rtc_time(struct rtc_time *rtc_tm);
212irqreturn_t rtc_interrupt(int irq, void *dev_id);
213 228
214#endif /* __KERNEL__ */ 229#endif /* __KERNEL__ */
215 230
diff --git a/include/linux/rtc/m48t59.h b/include/linux/rtc/m48t59.h
index e8c7c21ceb1f..6fc961459b4a 100644
--- a/include/linux/rtc/m48t59.h
+++ b/include/linux/rtc/m48t59.h
@@ -18,40 +18,47 @@
18/* 18/*
19 * M48T59 Register Offset 19 * M48T59 Register Offset
20 */ 20 */
21#define M48T59_YEAR 0x1fff 21#define M48T59_YEAR 0xf
22#define M48T59_MONTH 0x1ffe 22#define M48T59_MONTH 0xe
23#define M48T59_MDAY 0x1ffd /* Day of Month */ 23#define M48T59_MDAY 0xd /* Day of Month */
24#define M48T59_WDAY 0x1ffc /* Day of Week */ 24#define M48T59_WDAY 0xc /* Day of Week */
25#define M48T59_WDAY_CB 0x20 /* Century Bit */ 25#define M48T59_WDAY_CB 0x20 /* Century Bit */
26#define M48T59_WDAY_CEB 0x10 /* Century Enable Bit */ 26#define M48T59_WDAY_CEB 0x10 /* Century Enable Bit */
27#define M48T59_HOUR 0x1ffb 27#define M48T59_HOUR 0xb
28#define M48T59_MIN 0x1ffa 28#define M48T59_MIN 0xa
29#define M48T59_SEC 0x1ff9 29#define M48T59_SEC 0x9
30#define M48T59_CNTL 0x1ff8 30#define M48T59_CNTL 0x8
31#define M48T59_CNTL_READ 0x40 31#define M48T59_CNTL_READ 0x40
32#define M48T59_CNTL_WRITE 0x80 32#define M48T59_CNTL_WRITE 0x80
33#define M48T59_WATCHDOG 0x1ff7 33#define M48T59_WATCHDOG 0x7
34#define M48T59_INTR 0x1ff6 34#define M48T59_INTR 0x6
35#define M48T59_INTR_AFE 0x80 /* Alarm Interrupt Enable */ 35#define M48T59_INTR_AFE 0x80 /* Alarm Interrupt Enable */
36#define M48T59_INTR_ABE 0x20 36#define M48T59_INTR_ABE 0x20
37#define M48T59_ALARM_DATE 0x1ff5 37#define M48T59_ALARM_DATE 0x5
38#define M48T59_ALARM_HOUR 0x1ff4 38#define M48T59_ALARM_HOUR 0x4
39#define M48T59_ALARM_MIN 0x1ff3 39#define M48T59_ALARM_MIN 0x3
40#define M48T59_ALARM_SEC 0x1ff2 40#define M48T59_ALARM_SEC 0x2
41#define M48T59_UNUSED 0x1ff1 41#define M48T59_UNUSED 0x1
42#define M48T59_FLAGS 0x1ff0 42#define M48T59_FLAGS 0x0
43#define M48T59_FLAGS_WDT 0x80 /* watchdog timer expired */ 43#define M48T59_FLAGS_WDT 0x80 /* watchdog timer expired */
44#define M48T59_FLAGS_AF 0x40 /* alarm */ 44#define M48T59_FLAGS_AF 0x40 /* alarm */
45#define M48T59_FLAGS_BF 0x10 /* low battery */ 45#define M48T59_FLAGS_BF 0x10 /* low battery */
46 46
47#define M48T59_NVRAM_SIZE 0x1ff0 47#define M48T59RTC_TYPE_M48T59 0 /* to keep compatibility */
48#define M48T59RTC_TYPE_M48T02 1
49#define M48T59RTC_TYPE_M48T08 2
48 50
49struct m48t59_plat_data { 51struct m48t59_plat_data {
50 /* The method to access M48T59 registers, 52 /* The method to access M48T59 registers */
51 * NOTE: The 'ofs' should be 0x00~0x1fff
52 */
53 void (*write_byte)(struct device *dev, u32 ofs, u8 val); 53 void (*write_byte)(struct device *dev, u32 ofs, u8 val);
54 unsigned char (*read_byte)(struct device *dev, u32 ofs); 54 unsigned char (*read_byte)(struct device *dev, u32 ofs);
55
56 int type; /* RTC model */
57
58 /* ioaddr mapped externally */
59 void __iomem *ioaddr;
60 /* offset to RTC registers, automatically set according to the type */
61 unsigned int offset;
55}; 62};
56 63
57#endif /* _LINUX_RTC_M48T59_H_ */ 64#endif /* _LINUX_RTC_M48T59_H_ */
diff --git a/include/linux/rtmutex.h b/include/linux/rtmutex.h
index 382bb7951166..f19b00b7d530 100644
--- a/include/linux/rtmutex.h
+++ b/include/linux/rtmutex.h
@@ -54,7 +54,7 @@ struct hrtimer_sleeper;
54#ifdef CONFIG_DEBUG_RT_MUTEXES 54#ifdef CONFIG_DEBUG_RT_MUTEXES
55# define __DEBUG_RT_MUTEX_INITIALIZER(mutexname) \ 55# define __DEBUG_RT_MUTEX_INITIALIZER(mutexname) \
56 , .name = #mutexname, .file = __FILE__, .line = __LINE__ 56 , .name = #mutexname, .file = __FILE__, .line = __LINE__
57# define rt_mutex_init(mutex) __rt_mutex_init(mutex, __FUNCTION__) 57# define rt_mutex_init(mutex) __rt_mutex_init(mutex, __func__)
58 extern void rt_mutex_debug_task_free(struct task_struct *tsk); 58 extern void rt_mutex_debug_task_free(struct task_struct *tsk);
59#else 59#else
60# define __DEBUG_RT_MUTEX_INITIALIZER(mutexname) 60# define __DEBUG_RT_MUTEX_INITIALIZER(mutexname)
diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h
index b358c704d102..2b3d51c6ec9c 100644
--- a/include/linux/rtnetlink.h
+++ b/include/linux/rtnetlink.h
@@ -482,6 +482,7 @@ enum
482 TCA_RATE, 482 TCA_RATE,
483 TCA_FCNT, 483 TCA_FCNT,
484 TCA_STATS2, 484 TCA_STATS2,
485 TCA_STAB,
485 __TCA_MAX 486 __TCA_MAX
486}; 487};
487 488
@@ -581,6 +582,10 @@ enum rtnetlink_groups {
581#define RTNLGRP_IPV6_RULE RTNLGRP_IPV6_RULE 582#define RTNLGRP_IPV6_RULE RTNLGRP_IPV6_RULE
582 RTNLGRP_ND_USEROPT, 583 RTNLGRP_ND_USEROPT,
583#define RTNLGRP_ND_USEROPT RTNLGRP_ND_USEROPT 584#define RTNLGRP_ND_USEROPT RTNLGRP_ND_USEROPT
585 RTNLGRP_PHONET_IFADDR,
586#define RTNLGRP_PHONET_IFADDR RTNLGRP_PHONET_IFADDR
587 RTNLGRP_PHONET_ROUTE,
588#define RTNLGRP_PHONET_ROUTE RTNLGRP_PHONET_ROUTE
584 __RTNLGRP_MAX 589 __RTNLGRP_MAX
585}; 590};
586#define RTNLGRP_MAX (__RTNLGRP_MAX - 1) 591#define RTNLGRP_MAX (__RTNLGRP_MAX - 1)
@@ -754,13 +759,6 @@ extern void __rtnl_unlock(void);
754 } \ 759 } \
755} while(0) 760} while(0)
756 761
757#define BUG_TRAP(x) do { \
758 if (unlikely(!(x))) { \
759 printk(KERN_ERR "KERNEL: assertion (%s) failed at %s (%d)\n", \
760 #x, __FILE__ , __LINE__); \
761 } \
762} while(0)
763
764static inline u32 rtm_get_table(struct rtattr **rta, u8 table) 762static inline u32 rtm_get_table(struct rtattr **rta, u8 table)
765{ 763{
766 return RTA_GET_U32(rta[RTA_TABLE-1]); 764 return RTA_GET_U32(rta[RTA_TABLE-1]);
diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h
index 71fc81360048..e5996984ddd0 100644
--- a/include/linux/scatterlist.h
+++ b/include/linux/scatterlist.h
@@ -224,4 +224,42 @@ size_t sg_copy_to_buffer(struct scatterlist *sgl, unsigned int nents,
224 */ 224 */
225#define SG_MAX_SINGLE_ALLOC (PAGE_SIZE / sizeof(struct scatterlist)) 225#define SG_MAX_SINGLE_ALLOC (PAGE_SIZE / sizeof(struct scatterlist))
226 226
227
228/*
229 * Mapping sg iterator
230 *
231 * Iterates over sg entries mapping page-by-page. On each successful
232 * iteration, @miter->page points to the mapped page and
233 * @miter->length bytes of data can be accessed at @miter->addr. As
234 * long as an interation is enclosed between start and stop, the user
235 * is free to choose control structure and when to stop.
236 *
237 * @miter->consumed is set to @miter->length on each iteration. It
238 * can be adjusted if the user can't consume all the bytes in one go.
239 * Also, a stopped iteration can be resumed by calling next on it.
240 * This is useful when iteration needs to release all resources and
241 * continue later (e.g. at the next interrupt).
242 */
243
244#define SG_MITER_ATOMIC (1 << 0) /* use kmap_atomic */
245
246struct sg_mapping_iter {
247 /* the following three fields can be accessed directly */
248 struct page *page; /* currently mapped page */
249 void *addr; /* pointer to the mapped area */
250 size_t length; /* length of the mapped area */
251 size_t consumed; /* number of consumed bytes */
252
253 /* these are internal states, keep away */
254 struct scatterlist *__sg; /* current entry */
255 unsigned int __nents; /* nr of remaining entries */
256 unsigned int __offset; /* offset within sg */
257 unsigned int __flags;
258};
259
260void sg_miter_start(struct sg_mapping_iter *miter, struct scatterlist *sgl,
261 unsigned int nents, unsigned int flags);
262bool sg_miter_next(struct sg_mapping_iter *miter);
263void sg_miter_stop(struct sg_mapping_iter *miter);
264
227#endif /* _LINUX_SCATTERLIST_H */ 265#endif /* _LINUX_SCATTERLIST_H */
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 1941d8b5cf11..8478f334d732 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -87,6 +87,7 @@ struct sched_param {
87#include <linux/task_io_accounting.h> 87#include <linux/task_io_accounting.h>
88#include <linux/kobject.h> 88#include <linux/kobject.h>
89#include <linux/latencytop.h> 89#include <linux/latencytop.h>
90#include <linux/cred.h>
90 91
91#include <asm/processor.h> 92#include <asm/processor.h>
92 93
@@ -286,19 +287,18 @@ extern void trap_init(void);
286extern void account_process_tick(struct task_struct *task, int user); 287extern void account_process_tick(struct task_struct *task, int user);
287extern void update_process_times(int user); 288extern void update_process_times(int user);
288extern void scheduler_tick(void); 289extern void scheduler_tick(void);
289extern void hrtick_resched(void);
290 290
291extern void sched_show_task(struct task_struct *p); 291extern void sched_show_task(struct task_struct *p);
292 292
293#ifdef CONFIG_DETECT_SOFTLOCKUP 293#ifdef CONFIG_DETECT_SOFTLOCKUP
294extern void softlockup_tick(void); 294extern void softlockup_tick(void);
295extern void spawn_softlockup_task(void);
296extern void touch_softlockup_watchdog(void); 295extern void touch_softlockup_watchdog(void);
297extern void touch_all_softlockup_watchdogs(void); 296extern void touch_all_softlockup_watchdogs(void);
298extern unsigned long softlockup_thresh; 297extern unsigned int softlockup_panic;
299extern unsigned long sysctl_hung_task_check_count; 298extern unsigned long sysctl_hung_task_check_count;
300extern unsigned long sysctl_hung_task_timeout_secs; 299extern unsigned long sysctl_hung_task_timeout_secs;
301extern unsigned long sysctl_hung_task_warnings; 300extern unsigned long sysctl_hung_task_warnings;
301extern int softlockup_thresh;
302#else 302#else
303static inline void softlockup_tick(void) 303static inline void softlockup_tick(void)
304{ 304{
@@ -351,7 +351,7 @@ arch_get_unmapped_area_topdown(struct file *filp, unsigned long addr,
351extern void arch_unmap_area(struct mm_struct *, unsigned long); 351extern void arch_unmap_area(struct mm_struct *, unsigned long);
352extern void arch_unmap_area_topdown(struct mm_struct *, unsigned long); 352extern void arch_unmap_area_topdown(struct mm_struct *, unsigned long);
353 353
354#if NR_CPUS >= CONFIG_SPLIT_PTLOCK_CPUS 354#if USE_SPLIT_PTLOCKS
355/* 355/*
356 * The mm counters are not protected by its page_table_lock, 356 * The mm counters are not protected by its page_table_lock,
357 * so must be incremented atomically. 357 * so must be incremented atomically.
@@ -362,7 +362,7 @@ extern void arch_unmap_area_topdown(struct mm_struct *, unsigned long);
362#define inc_mm_counter(mm, member) atomic_long_inc(&(mm)->_##member) 362#define inc_mm_counter(mm, member) atomic_long_inc(&(mm)->_##member)
363#define dec_mm_counter(mm, member) atomic_long_dec(&(mm)->_##member) 363#define dec_mm_counter(mm, member) atomic_long_dec(&(mm)->_##member)
364 364
365#else /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */ 365#else /* !USE_SPLIT_PTLOCKS */
366/* 366/*
367 * The mm counters are protected by its page_table_lock, 367 * The mm counters are protected by its page_table_lock,
368 * so can be incremented directly. 368 * so can be incremented directly.
@@ -373,7 +373,7 @@ extern void arch_unmap_area_topdown(struct mm_struct *, unsigned long);
373#define inc_mm_counter(mm, member) (mm)->_##member++ 373#define inc_mm_counter(mm, member) (mm)->_##member++
374#define dec_mm_counter(mm, member) (mm)->_##member-- 374#define dec_mm_counter(mm, member) (mm)->_##member--
375 375
376#endif /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */ 376#endif /* !USE_SPLIT_PTLOCKS */
377 377
378#define get_mm_rss(mm) \ 378#define get_mm_rss(mm) \
379 (get_mm_counter(mm, file_rss) + get_mm_counter(mm, anon_rss)) 379 (get_mm_counter(mm, file_rss) + get_mm_counter(mm, anon_rss))
@@ -402,12 +402,21 @@ extern int get_dumpable(struct mm_struct *mm);
402#define MMF_DUMP_MAPPED_PRIVATE 4 402#define MMF_DUMP_MAPPED_PRIVATE 4
403#define MMF_DUMP_MAPPED_SHARED 5 403#define MMF_DUMP_MAPPED_SHARED 5
404#define MMF_DUMP_ELF_HEADERS 6 404#define MMF_DUMP_ELF_HEADERS 6
405#define MMF_DUMP_HUGETLB_PRIVATE 7
406#define MMF_DUMP_HUGETLB_SHARED 8
405#define MMF_DUMP_FILTER_SHIFT MMF_DUMPABLE_BITS 407#define MMF_DUMP_FILTER_SHIFT MMF_DUMPABLE_BITS
406#define MMF_DUMP_FILTER_BITS 5 408#define MMF_DUMP_FILTER_BITS 7
407#define MMF_DUMP_FILTER_MASK \ 409#define MMF_DUMP_FILTER_MASK \
408 (((1 << MMF_DUMP_FILTER_BITS) - 1) << MMF_DUMP_FILTER_SHIFT) 410 (((1 << MMF_DUMP_FILTER_BITS) - 1) << MMF_DUMP_FILTER_SHIFT)
409#define MMF_DUMP_FILTER_DEFAULT \ 411#define MMF_DUMP_FILTER_DEFAULT \
410 ((1 << MMF_DUMP_ANON_PRIVATE) | (1 << MMF_DUMP_ANON_SHARED)) 412 ((1 << MMF_DUMP_ANON_PRIVATE) | (1 << MMF_DUMP_ANON_SHARED) |\
413 (1 << MMF_DUMP_HUGETLB_PRIVATE) | MMF_DUMP_MASK_DEFAULT_ELF)
414
415#ifdef CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS
416# define MMF_DUMP_MASK_DEFAULT_ELF (1 << MMF_DUMP_ELF_HEADERS)
417#else
418# define MMF_DUMP_MASK_DEFAULT_ELF 0
419#endif
411 420
412struct sighand_struct { 421struct sighand_struct {
413 atomic_t count; 422 atomic_t count;
@@ -424,6 +433,39 @@ struct pacct_struct {
424 unsigned long ac_minflt, ac_majflt; 433 unsigned long ac_minflt, ac_majflt;
425}; 434};
426 435
436/**
437 * struct task_cputime - collected CPU time counts
438 * @utime: time spent in user mode, in &cputime_t units
439 * @stime: time spent in kernel mode, in &cputime_t units
440 * @sum_exec_runtime: total time spent on the CPU, in nanoseconds
441 *
442 * This structure groups together three kinds of CPU time that are
443 * tracked for threads and thread groups. Most things considering
444 * CPU time want to group these counts together and treat all three
445 * of them in parallel.
446 */
447struct task_cputime {
448 cputime_t utime;
449 cputime_t stime;
450 unsigned long long sum_exec_runtime;
451};
452/* Alternate field names when used to cache expirations. */
453#define prof_exp stime
454#define virt_exp utime
455#define sched_exp sum_exec_runtime
456
457/**
458 * struct thread_group_cputime - thread group interval timer counts
459 * @totals: thread group interval timers; substructure for
460 * uniprocessor kernel, per-cpu for SMP kernel.
461 *
462 * This structure contains the version of task_cputime, above, that is
463 * used for thread group CPU clock calculations.
464 */
465struct thread_group_cputime {
466 struct task_cputime *totals;
467};
468
427/* 469/*
428 * NOTE! "signal_struct" does not have it's own 470 * NOTE! "signal_struct" does not have it's own
429 * locking, because a shared signal_struct always 471 * locking, because a shared signal_struct always
@@ -450,8 +492,8 @@ struct signal_struct {
450 * - everyone except group_exit_task is stopped during signal delivery 492 * - everyone except group_exit_task is stopped during signal delivery
451 * of fatal signals, group_exit_task processes the signal. 493 * of fatal signals, group_exit_task processes the signal.
452 */ 494 */
453 struct task_struct *group_exit_task;
454 int notify_count; 495 int notify_count;
496 struct task_struct *group_exit_task;
455 497
456 /* thread group stop support, overloads group_exit_code too */ 498 /* thread group stop support, overloads group_exit_code too */
457 int group_stop_count; 499 int group_stop_count;
@@ -469,6 +511,17 @@ struct signal_struct {
469 cputime_t it_prof_expires, it_virt_expires; 511 cputime_t it_prof_expires, it_virt_expires;
470 cputime_t it_prof_incr, it_virt_incr; 512 cputime_t it_prof_incr, it_virt_incr;
471 513
514 /*
515 * Thread group totals for process CPU clocks.
516 * See thread_group_cputime(), et al, for details.
517 */
518 struct thread_group_cputime cputime;
519
520 /* Earliest-expiration cache. */
521 struct task_cputime cputime_expires;
522
523 struct list_head cpu_timers[3];
524
472 /* job control IDs */ 525 /* job control IDs */
473 526
474 /* 527 /*
@@ -499,20 +552,13 @@ struct signal_struct {
499 * Live threads maintain their own counters and add to these 552 * Live threads maintain their own counters and add to these
500 * in __exit_signal, except for the group leader. 553 * in __exit_signal, except for the group leader.
501 */ 554 */
502 cputime_t utime, stime, cutime, cstime; 555 cputime_t cutime, cstime;
503 cputime_t gtime; 556 cputime_t gtime;
504 cputime_t cgtime; 557 cputime_t cgtime;
505 unsigned long nvcsw, nivcsw, cnvcsw, cnivcsw; 558 unsigned long nvcsw, nivcsw, cnvcsw, cnivcsw;
506 unsigned long min_flt, maj_flt, cmin_flt, cmaj_flt; 559 unsigned long min_flt, maj_flt, cmin_flt, cmaj_flt;
507 unsigned long inblock, oublock, cinblock, coublock; 560 unsigned long inblock, oublock, cinblock, coublock;
508 561 struct task_io_accounting ioac;
509 /*
510 * Cumulative ns of scheduled CPU time for dead threads in the
511 * group, not including a zombie group leader. (This only differs
512 * from jiffies_to_ns(utime + stime) if sched_clock uses something
513 * other than jiffies.)
514 */
515 unsigned long long sum_sched_runtime;
516 562
517 /* 563 /*
518 * We don't bother to synchronize most readers of this at all, 564 * We don't bother to synchronize most readers of this at all,
@@ -525,8 +571,6 @@ struct signal_struct {
525 */ 571 */
526 struct rlimit rlim[RLIM_NLIMITS]; 572 struct rlimit rlim[RLIM_NLIMITS];
527 573
528 struct list_head cpu_timers[3];
529
530 /* keep the process-shared keyrings here so that they do the right 574 /* keep the process-shared keyrings here so that they do the right
531 * thing in threads created with CLONE_THREAD */ 575 * thing in threads created with CLONE_THREAD */
532#ifdef CONFIG_KEYS 576#ifdef CONFIG_KEYS
@@ -636,10 +680,6 @@ struct sched_info {
636}; 680};
637#endif /* defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT) */ 681#endif /* defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT) */
638 682
639#ifdef CONFIG_SCHEDSTATS
640extern const struct file_operations proc_schedstat_operations;
641#endif /* CONFIG_SCHEDSTATS */
642
643#ifdef CONFIG_TASK_DELAY_ACCT 683#ifdef CONFIG_TASK_DELAY_ACCT
644struct task_delay_info { 684struct task_delay_info {
645 spinlock_t lock; 685 spinlock_t lock;
@@ -667,6 +707,10 @@ struct task_delay_info {
667 /* io operations performed */ 707 /* io operations performed */
668 u32 swapin_count; /* total count of the number of swapin block */ 708 u32 swapin_count; /* total count of the number of swapin block */
669 /* io operations performed */ 709 /* io operations performed */
710
711 struct timespec freepages_start, freepages_end;
712 u64 freepages_delay; /* wait for memory reclaim */
713 u32 freepages_count; /* total count of memory reclaim */
670}; 714};
671#endif /* CONFIG_TASK_DELAY_ACCT */ 715#endif /* CONFIG_TASK_DELAY_ACCT */
672 716
@@ -818,13 +862,25 @@ struct sched_domain {
818 unsigned int ttwu_move_affine; 862 unsigned int ttwu_move_affine;
819 unsigned int ttwu_move_balance; 863 unsigned int ttwu_move_balance;
820#endif 864#endif
865#ifdef CONFIG_SCHED_DEBUG
866 char *name;
867#endif
821}; 868};
822 869
823extern void partition_sched_domains(int ndoms_new, cpumask_t *doms_new, 870extern void partition_sched_domains(int ndoms_new, cpumask_t *doms_new,
824 struct sched_domain_attr *dattr_new); 871 struct sched_domain_attr *dattr_new);
825extern int arch_reinit_sched_domains(void); 872extern int arch_reinit_sched_domains(void);
826 873
827#endif /* CONFIG_SMP */ 874#else /* CONFIG_SMP */
875
876struct sched_domain_attr;
877
878static inline void
879partition_sched_domains(int ndoms_new, cpumask_t *doms_new,
880 struct sched_domain_attr *dattr_new)
881{
882}
883#endif /* !CONFIG_SMP */
828 884
829struct io_context; /* See blkdev.h */ 885struct io_context; /* See blkdev.h */
830#define NGROUPS_SMALL 32 886#define NGROUPS_SMALL 32
@@ -882,7 +938,7 @@ struct sched_class {
882 void (*yield_task) (struct rq *rq); 938 void (*yield_task) (struct rq *rq);
883 int (*select_task_rq)(struct task_struct *p, int sync); 939 int (*select_task_rq)(struct task_struct *p, int sync);
884 940
885 void (*check_preempt_curr) (struct rq *rq, struct task_struct *p); 941 void (*check_preempt_curr) (struct rq *rq, struct task_struct *p, int sync);
886 942
887 struct task_struct * (*pick_next_task) (struct rq *rq); 943 struct task_struct * (*pick_next_task) (struct rq *rq);
888 void (*put_prev_task) (struct rq *rq, struct task_struct *p); 944 void (*put_prev_task) (struct rq *rq, struct task_struct *p);
@@ -995,8 +1051,8 @@ struct sched_entity {
995 1051
996struct sched_rt_entity { 1052struct sched_rt_entity {
997 struct list_head run_list; 1053 struct list_head run_list;
998 unsigned int time_slice;
999 unsigned long timeout; 1054 unsigned long timeout;
1055 unsigned int time_slice;
1000 int nr_cpus_allowed; 1056 int nr_cpus_allowed;
1001 1057
1002 struct sched_rt_entity *back; 1058 struct sched_rt_entity *back;
@@ -1119,8 +1175,7 @@ struct task_struct {
1119/* mm fault and swap info: this can arguably be seen as either mm-specific or thread-specific */ 1175/* mm fault and swap info: this can arguably be seen as either mm-specific or thread-specific */
1120 unsigned long min_flt, maj_flt; 1176 unsigned long min_flt, maj_flt;
1121 1177
1122 cputime_t it_prof_expires, it_virt_expires; 1178 struct task_cputime cputime_expires;
1123 unsigned long long it_sched_expires;
1124 struct list_head cpu_timers[3]; 1179 struct list_head cpu_timers[3];
1125 1180
1126/* process credentials */ 1181/* process credentials */
@@ -1239,15 +1294,11 @@ struct task_struct {
1239 1294
1240 unsigned long ptrace_message; 1295 unsigned long ptrace_message;
1241 siginfo_t *last_siginfo; /* For ptrace use. */ 1296 siginfo_t *last_siginfo; /* For ptrace use. */
1242#ifdef CONFIG_TASK_XACCT
1243/* i/o counters(bytes read/written, #syscalls */
1244 u64 rchar, wchar, syscr, syscw;
1245#endif
1246 struct task_io_accounting ioac; 1297 struct task_io_accounting ioac;
1247#if defined(CONFIG_TASK_XACCT) 1298#if defined(CONFIG_TASK_XACCT)
1248 u64 acct_rss_mem1; /* accumulated rss usage */ 1299 u64 acct_rss_mem1; /* accumulated rss usage */
1249 u64 acct_vm_mem1; /* accumulated virtual memory usage */ 1300 u64 acct_vm_mem1; /* accumulated virtual memory usage */
1250 cputime_t acct_stimexpd;/* stime since last update */ 1301 cputime_t acct_timexpd; /* stime + utime since last update */
1251#endif 1302#endif
1252#ifdef CONFIG_CPUSETS 1303#ifdef CONFIG_CPUSETS
1253 nodemask_t mems_allowed; 1304 nodemask_t mems_allowed;
@@ -1290,6 +1341,12 @@ struct task_struct {
1290 int latency_record_count; 1341 int latency_record_count;
1291 struct latency_record latency_record[LT_SAVECOUNT]; 1342 struct latency_record latency_record[LT_SAVECOUNT];
1292#endif 1343#endif
1344 /*
1345 * time slack values; these are used to round up poll() and
1346 * select() etc timeout values. These are in nanoseconds.
1347 */
1348 unsigned long timer_slack_ns;
1349 unsigned long default_timer_slack_ns;
1293}; 1350};
1294 1351
1295/* 1352/*
@@ -1464,6 +1521,10 @@ static inline void put_task_struct(struct task_struct *t)
1464 __put_task_struct(t); 1521 __put_task_struct(t);
1465} 1522}
1466 1523
1524extern cputime_t task_utime(struct task_struct *p);
1525extern cputime_t task_stime(struct task_struct *p);
1526extern cputime_t task_gtime(struct task_struct *p);
1527
1467/* 1528/*
1468 * Per process flags 1529 * Per process flags
1469 */ 1530 */
@@ -1486,7 +1547,7 @@ static inline void put_task_struct(struct task_struct *t)
1486#define PF_KSWAPD 0x00040000 /* I am kswapd */ 1547#define PF_KSWAPD 0x00040000 /* I am kswapd */
1487#define PF_SWAPOFF 0x00080000 /* I am in swapoff */ 1548#define PF_SWAPOFF 0x00080000 /* I am in swapoff */
1488#define PF_LESS_THROTTLE 0x00100000 /* Throttle me less: I clean memory */ 1549#define PF_LESS_THROTTLE 0x00100000 /* Throttle me less: I clean memory */
1489#define PF_BORROWED_MM 0x00200000 /* I am a kthread doing use_mm */ 1550#define PF_KTHREAD 0x00200000 /* I am a kernel thread */
1490#define PF_RANDOMIZE 0x00400000 /* randomize virtual address space */ 1551#define PF_RANDOMIZE 0x00400000 /* randomize virtual address space */
1491#define PF_SWAPWRITE 0x00800000 /* Allowed to write to swap */ 1552#define PF_SWAPWRITE 0x00800000 /* Allowed to write to swap */
1492#define PF_SPREAD_PAGE 0x01000000 /* Spread page cache over cpuset */ 1553#define PF_SPREAD_PAGE 0x01000000 /* Spread page cache over cpuset */
@@ -1541,16 +1602,10 @@ static inline int set_cpus_allowed(struct task_struct *p, cpumask_t new_mask)
1541 1602
1542extern unsigned long long sched_clock(void); 1603extern unsigned long long sched_clock(void);
1543 1604
1544#ifndef CONFIG_HAVE_UNSTABLE_SCHED_CLOCK 1605extern void sched_clock_init(void);
1545static inline void sched_clock_init(void) 1606extern u64 sched_clock_cpu(int cpu);
1546{
1547}
1548
1549static inline u64 sched_clock_cpu(int cpu)
1550{
1551 return sched_clock();
1552}
1553 1607
1608#ifndef CONFIG_HAVE_UNSTABLE_SCHED_CLOCK
1554static inline void sched_clock_tick(void) 1609static inline void sched_clock_tick(void)
1555{ 1610{
1556} 1611}
@@ -1562,28 +1617,11 @@ static inline void sched_clock_idle_sleep_event(void)
1562static inline void sched_clock_idle_wakeup_event(u64 delta_ns) 1617static inline void sched_clock_idle_wakeup_event(u64 delta_ns)
1563{ 1618{
1564} 1619}
1565 1620#else
1566#ifdef CONFIG_NO_HZ
1567static inline void sched_clock_tick_stop(int cpu)
1568{
1569}
1570
1571static inline void sched_clock_tick_start(int cpu)
1572{
1573}
1574#endif
1575
1576#else /* CONFIG_HAVE_UNSTABLE_SCHED_CLOCK */
1577extern void sched_clock_init(void);
1578extern u64 sched_clock_cpu(int cpu);
1579extern void sched_clock_tick(void); 1621extern void sched_clock_tick(void);
1580extern void sched_clock_idle_sleep_event(void); 1622extern void sched_clock_idle_sleep_event(void);
1581extern void sched_clock_idle_wakeup_event(u64 delta_ns); 1623extern void sched_clock_idle_wakeup_event(u64 delta_ns);
1582#ifdef CONFIG_NO_HZ
1583extern void sched_clock_tick_stop(int cpu);
1584extern void sched_clock_tick_start(int cpu);
1585#endif 1624#endif
1586#endif /* CONFIG_HAVE_UNSTABLE_SCHED_CLOCK */
1587 1625
1588/* 1626/*
1589 * For kernel-internal use: high-speed (but slightly incorrect) per-cpu 1627 * For kernel-internal use: high-speed (but slightly incorrect) per-cpu
@@ -1593,6 +1631,7 @@ extern unsigned long long cpu_clock(int cpu);
1593 1631
1594extern unsigned long long 1632extern unsigned long long
1595task_sched_runtime(struct task_struct *task); 1633task_sched_runtime(struct task_struct *task);
1634extern unsigned long long thread_group_sched_runtime(struct task_struct *task);
1596 1635
1597/* sched_exec is called by processes performing an exec */ 1636/* sched_exec is called by processes performing an exec */
1598#ifdef CONFIG_SMP 1637#ifdef CONFIG_SMP
@@ -1627,6 +1666,7 @@ extern unsigned int sysctl_sched_features;
1627extern unsigned int sysctl_sched_migration_cost; 1666extern unsigned int sysctl_sched_migration_cost;
1628extern unsigned int sysctl_sched_nr_migrate; 1667extern unsigned int sysctl_sched_nr_migrate;
1629extern unsigned int sysctl_sched_shares_ratelimit; 1668extern unsigned int sysctl_sched_shares_ratelimit;
1669extern unsigned int sysctl_sched_shares_thresh;
1630 1670
1631int sched_nr_latency_handler(struct ctl_table *table, int write, 1671int sched_nr_latency_handler(struct ctl_table *table, int write,
1632 struct file *file, void __user *buffer, size_t *length, 1672 struct file *file, void __user *buffer, size_t *length,
@@ -1705,19 +1745,13 @@ extern struct pid_namespace init_pid_ns;
1705 * finds a task by its pid in the specified namespace 1745 * finds a task by its pid in the specified namespace
1706 * find_task_by_vpid(): 1746 * find_task_by_vpid():
1707 * finds a task by its virtual pid 1747 * finds a task by its virtual pid
1708 * find_task_by_pid():
1709 * finds a task by its global pid
1710 * 1748 *
1711 * see also find_pid() etc in include/linux/pid.h 1749 * see also find_vpid() etc in include/linux/pid.h
1712 */ 1750 */
1713 1751
1714extern struct task_struct *find_task_by_pid_type_ns(int type, int pid, 1752extern struct task_struct *find_task_by_pid_type_ns(int type, int pid,
1715 struct pid_namespace *ns); 1753 struct pid_namespace *ns);
1716 1754
1717static inline struct task_struct *__deprecated find_task_by_pid(pid_t nr)
1718{
1719 return find_task_by_pid_type_ns(PIDTYPE_PID, nr, &init_pid_ns);
1720}
1721extern struct task_struct *find_task_by_vpid(pid_t nr); 1755extern struct task_struct *find_task_by_vpid(pid_t nr);
1722extern struct task_struct *find_task_by_pid_ns(pid_t nr, 1756extern struct task_struct *find_task_by_pid_ns(pid_t nr,
1723 struct pid_namespace *ns); 1757 struct pid_namespace *ns);
@@ -1785,12 +1819,11 @@ extern int kill_pid_info_as_uid(int, struct siginfo *, struct pid *, uid_t, uid_
1785extern int kill_pgrp(struct pid *pid, int sig, int priv); 1819extern int kill_pgrp(struct pid *pid, int sig, int priv);
1786extern int kill_pid(struct pid *pid, int sig, int priv); 1820extern int kill_pid(struct pid *pid, int sig, int priv);
1787extern int kill_proc_info(int, struct siginfo *, pid_t); 1821extern int kill_proc_info(int, struct siginfo *, pid_t);
1788extern void do_notify_parent(struct task_struct *, int); 1822extern int do_notify_parent(struct task_struct *, int);
1789extern void force_sig(int, struct task_struct *); 1823extern void force_sig(int, struct task_struct *);
1790extern void force_sig_specific(int, struct task_struct *); 1824extern void force_sig_specific(int, struct task_struct *);
1791extern int send_sig(int, struct task_struct *, int); 1825extern int send_sig(int, struct task_struct *, int);
1792extern void zap_other_threads(struct task_struct *p); 1826extern void zap_other_threads(struct task_struct *p);
1793extern int kill_proc(pid_t, int, int);
1794extern struct sigqueue *sigqueue_alloc(void); 1827extern struct sigqueue *sigqueue_alloc(void);
1795extern void sigqueue_free(struct sigqueue *); 1828extern void sigqueue_free(struct sigqueue *);
1796extern int send_sigqueue(struct sigqueue *, struct task_struct *, int group); 1829extern int send_sigqueue(struct sigqueue *, struct task_struct *, int group);
@@ -1872,9 +1905,13 @@ extern void set_task_comm(struct task_struct *tsk, char *from);
1872extern char *get_task_comm(char *to, struct task_struct *tsk); 1905extern char *get_task_comm(char *to, struct task_struct *tsk);
1873 1906
1874#ifdef CONFIG_SMP 1907#ifdef CONFIG_SMP
1875extern void wait_task_inactive(struct task_struct * p); 1908extern unsigned long wait_task_inactive(struct task_struct *, long match_state);
1876#else 1909#else
1877#define wait_task_inactive(p) do { } while (0) 1910static inline unsigned long wait_task_inactive(struct task_struct *p,
1911 long match_state)
1912{
1913 return 1;
1914}
1878#endif 1915#endif
1879 1916
1880#define next_task(p) list_entry(rcu_dereference((p)->tasks.next), struct task_struct, tasks) 1917#define next_task(p) list_entry(rcu_dereference((p)->tasks.next), struct task_struct, tasks)
@@ -1973,6 +2010,13 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
1973 2010
1974#endif 2011#endif
1975 2012
2013static inline int object_is_on_stack(void *obj)
2014{
2015 void *stack = task_stack_page(current);
2016
2017 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
2018}
2019
1976extern void thread_info_cache_init(void); 2020extern void thread_info_cache_init(void);
1977 2021
1978/* set thread flags in other task's structures 2022/* set thread flags in other task's structures
@@ -2037,9 +2081,6 @@ static inline int signal_pending_state(long state, struct task_struct *p)
2037 if (!signal_pending(p)) 2081 if (!signal_pending(p))
2038 return 0; 2082 return 0;
2039 2083
2040 if (state & (__TASK_STOPPED | __TASK_TRACED))
2041 return 0;
2042
2043 return (state & TASK_INTERRUPTIBLE) || __fatal_signal_pending(p); 2084 return (state & TASK_INTERRUPTIBLE) || __fatal_signal_pending(p);
2044} 2085}
2045 2086
@@ -2089,6 +2130,30 @@ static inline int spin_needbreak(spinlock_t *lock)
2089} 2130}
2090 2131
2091/* 2132/*
2133 * Thread group CPU time accounting.
2134 */
2135
2136extern int thread_group_cputime_alloc(struct task_struct *);
2137extern void thread_group_cputime(struct task_struct *, struct task_cputime *);
2138
2139static inline void thread_group_cputime_init(struct signal_struct *sig)
2140{
2141 sig->cputime.totals = NULL;
2142}
2143
2144static inline int thread_group_cputime_clone_thread(struct task_struct *curr)
2145{
2146 if (curr->signal->cputime.totals)
2147 return 0;
2148 return thread_group_cputime_alloc(curr);
2149}
2150
2151static inline void thread_group_cputime_free(struct signal_struct *sig)
2152{
2153 free_percpu(sig->cputime.totals);
2154}
2155
2156/*
2092 * Reevaluate whether the task has signals pending delivery. 2157 * Reevaluate whether the task has signals pending delivery.
2093 * Wake the task if so. 2158 * Wake the task if so.
2094 * This is required every time the blocked sigset_t changes. 2159 * This is required every time the blocked sigset_t changes.
@@ -2124,16 +2189,7 @@ static inline void set_task_cpu(struct task_struct *p, unsigned int cpu)
2124 2189
2125#endif /* CONFIG_SMP */ 2190#endif /* CONFIG_SMP */
2126 2191
2127#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
2128extern void arch_pick_mmap_layout(struct mm_struct *mm); 2192extern void arch_pick_mmap_layout(struct mm_struct *mm);
2129#else
2130static inline void arch_pick_mmap_layout(struct mm_struct *mm)
2131{
2132 mm->mmap_base = TASK_UNMAPPED_BASE;
2133 mm->get_unmapped_area = arch_get_unmapped_area;
2134 mm->unmap_area = arch_unmap_area;
2135}
2136#endif
2137 2193
2138#ifdef CONFIG_TRACING 2194#ifdef CONFIG_TRACING
2139extern void 2195extern void
@@ -2181,22 +2237,22 @@ extern long sched_group_rt_period(struct task_group *tg);
2181#ifdef CONFIG_TASK_XACCT 2237#ifdef CONFIG_TASK_XACCT
2182static inline void add_rchar(struct task_struct *tsk, ssize_t amt) 2238static inline void add_rchar(struct task_struct *tsk, ssize_t amt)
2183{ 2239{
2184 tsk->rchar += amt; 2240 tsk->ioac.rchar += amt;
2185} 2241}
2186 2242
2187static inline void add_wchar(struct task_struct *tsk, ssize_t amt) 2243static inline void add_wchar(struct task_struct *tsk, ssize_t amt)
2188{ 2244{
2189 tsk->wchar += amt; 2245 tsk->ioac.wchar += amt;
2190} 2246}
2191 2247
2192static inline void inc_syscr(struct task_struct *tsk) 2248static inline void inc_syscr(struct task_struct *tsk)
2193{ 2249{
2194 tsk->syscr++; 2250 tsk->ioac.syscr++;
2195} 2251}
2196 2252
2197static inline void inc_syscw(struct task_struct *tsk) 2253static inline void inc_syscw(struct task_struct *tsk)
2198{ 2254{
2199 tsk->syscw++; 2255 tsk->ioac.syscw++;
2200} 2256}
2201#else 2257#else
2202static inline void add_rchar(struct task_struct *tsk, ssize_t amt) 2258static inline void add_rchar(struct task_struct *tsk, ssize_t amt)
@@ -2216,14 +2272,6 @@ static inline void inc_syscw(struct task_struct *tsk)
2216} 2272}
2217#endif 2273#endif
2218 2274
2219#ifdef CONFIG_SMP
2220void migration_init(void);
2221#else
2222static inline void migration_init(void)
2223{
2224}
2225#endif
2226
2227#ifndef TASK_SIZE_OF 2275#ifndef TASK_SIZE_OF
2228#define TASK_SIZE_OF(tsk) TASK_SIZE 2276#define TASK_SIZE_OF(tsk) TASK_SIZE
2229#endif 2277#endif
diff --git a/include/linux/security.h b/include/linux/security.h
index 31c8851ec5d0..f5c4a51eb42e 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -46,8 +46,8 @@ struct audit_krule;
46 */ 46 */
47extern int cap_capable(struct task_struct *tsk, int cap); 47extern int cap_capable(struct task_struct *tsk, int cap);
48extern int cap_settime(struct timespec *ts, struct timezone *tz); 48extern int cap_settime(struct timespec *ts, struct timezone *tz);
49extern int cap_ptrace(struct task_struct *parent, struct task_struct *child, 49extern int cap_ptrace_may_access(struct task_struct *child, unsigned int mode);
50 unsigned int mode); 50extern int cap_ptrace_traceme(struct task_struct *parent);
51extern int cap_capget(struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted); 51extern int cap_capget(struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
52extern int cap_capset_check(struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted); 52extern int cap_capset_check(struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
53extern void cap_capset_set(struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted); 53extern void cap_capset_set(struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
@@ -102,9 +102,7 @@ extern unsigned long mmap_min_addr;
102#define LSM_SETID_FS 8 102#define LSM_SETID_FS 8
103 103
104/* forward declares to avoid warnings */ 104/* forward declares to avoid warnings */
105struct nfsctl_arg;
106struct sched_param; 105struct sched_param;
107struct swap_info_struct;
108struct request_sock; 106struct request_sock;
109 107
110/* bprm_apply_creds unsafe reasons */ 108/* bprm_apply_creds unsafe reasons */
@@ -1159,17 +1157,24 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
1159 * @alter contains the flag indicating whether changes are to be made. 1157 * @alter contains the flag indicating whether changes are to be made.
1160 * Return 0 if permission is granted. 1158 * Return 0 if permission is granted.
1161 * 1159 *
1162 * @ptrace: 1160 * @ptrace_may_access:
1163 * Check permission before allowing the @parent process to trace the 1161 * Check permission before allowing the current process to trace the
1164 * @child process. 1162 * @child process.
1165 * Security modules may also want to perform a process tracing check 1163 * Security modules may also want to perform a process tracing check
1166 * during an execve in the set_security or apply_creds hooks of 1164 * during an execve in the set_security or apply_creds hooks of
1167 * binprm_security_ops if the process is being traced and its security 1165 * binprm_security_ops if the process is being traced and its security
1168 * attributes would be changed by the execve. 1166 * attributes would be changed by the execve.
1169 * @parent contains the task_struct structure for parent process. 1167 * @child contains the task_struct structure for the target process.
1170 * @child contains the task_struct structure for child process.
1171 * @mode contains the PTRACE_MODE flags indicating the form of access. 1168 * @mode contains the PTRACE_MODE flags indicating the form of access.
1172 * Return 0 if permission is granted. 1169 * Return 0 if permission is granted.
1170 * @ptrace_traceme:
1171 * Check that the @parent process has sufficient permission to trace the
1172 * current process before allowing the current process to present itself
1173 * to the @parent process for tracing.
1174 * The parent process will still have to undergo the ptrace_may_access
1175 * checks before it is allowed to trace this one.
1176 * @parent contains the task_struct structure for debugger process.
1177 * Return 0 if permission is granted.
1173 * @capget: 1178 * @capget:
1174 * Get the @effective, @inheritable, and @permitted capability sets for 1179 * Get the @effective, @inheritable, and @permitted capability sets for
1175 * the @target process. The hook may also perform permission checking to 1180 * the @target process. The hook may also perform permission checking to
@@ -1289,8 +1294,8 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
1289struct security_operations { 1294struct security_operations {
1290 char name[SECURITY_NAME_MAX + 1]; 1295 char name[SECURITY_NAME_MAX + 1];
1291 1296
1292 int (*ptrace) (struct task_struct *parent, struct task_struct *child, 1297 int (*ptrace_may_access) (struct task_struct *child, unsigned int mode);
1293 unsigned int mode); 1298 int (*ptrace_traceme) (struct task_struct *parent);
1294 int (*capget) (struct task_struct *target, 1299 int (*capget) (struct task_struct *target,
1295 kernel_cap_t *effective, 1300 kernel_cap_t *effective,
1296 kernel_cap_t *inheritable, kernel_cap_t *permitted); 1301 kernel_cap_t *inheritable, kernel_cap_t *permitted);
@@ -1364,7 +1369,7 @@ struct security_operations {
1364 struct inode *new_dir, struct dentry *new_dentry); 1369 struct inode *new_dir, struct dentry *new_dentry);
1365 int (*inode_readlink) (struct dentry *dentry); 1370 int (*inode_readlink) (struct dentry *dentry);
1366 int (*inode_follow_link) (struct dentry *dentry, struct nameidata *nd); 1371 int (*inode_follow_link) (struct dentry *dentry, struct nameidata *nd);
1367 int (*inode_permission) (struct inode *inode, int mask, struct nameidata *nd); 1372 int (*inode_permission) (struct inode *inode, int mask);
1368 int (*inode_setattr) (struct dentry *dentry, struct iattr *attr); 1373 int (*inode_setattr) (struct dentry *dentry, struct iattr *attr);
1369 int (*inode_getattr) (struct vfsmount *mnt, struct dentry *dentry); 1374 int (*inode_getattr) (struct vfsmount *mnt, struct dentry *dentry);
1370 void (*inode_delete) (struct inode *inode); 1375 void (*inode_delete) (struct inode *inode);
@@ -1555,15 +1560,10 @@ struct security_operations {
1555extern int security_init(void); 1560extern int security_init(void);
1556extern int security_module_enable(struct security_operations *ops); 1561extern int security_module_enable(struct security_operations *ops);
1557extern int register_security(struct security_operations *ops); 1562extern int register_security(struct security_operations *ops);
1558extern struct dentry *securityfs_create_file(const char *name, mode_t mode,
1559 struct dentry *parent, void *data,
1560 const struct file_operations *fops);
1561extern struct dentry *securityfs_create_dir(const char *name, struct dentry *parent);
1562extern void securityfs_remove(struct dentry *dentry);
1563 1563
1564/* Security operations */ 1564/* Security operations */
1565int security_ptrace(struct task_struct *parent, struct task_struct *child, 1565int security_ptrace_may_access(struct task_struct *child, unsigned int mode);
1566 unsigned int mode); 1566int security_ptrace_traceme(struct task_struct *parent);
1567int security_capget(struct task_struct *target, 1567int security_capget(struct task_struct *target,
1568 kernel_cap_t *effective, 1568 kernel_cap_t *effective,
1569 kernel_cap_t *inheritable, 1569 kernel_cap_t *inheritable,
@@ -1630,7 +1630,7 @@ int security_inode_rename(struct inode *old_dir, struct dentry *old_dentry,
1630 struct inode *new_dir, struct dentry *new_dentry); 1630 struct inode *new_dir, struct dentry *new_dentry);
1631int security_inode_readlink(struct dentry *dentry); 1631int security_inode_readlink(struct dentry *dentry);
1632int security_inode_follow_link(struct dentry *dentry, struct nameidata *nd); 1632int security_inode_follow_link(struct dentry *dentry, struct nameidata *nd);
1633int security_inode_permission(struct inode *inode, int mask, struct nameidata *nd); 1633int security_inode_permission(struct inode *inode, int mask);
1634int security_inode_setattr(struct dentry *dentry, struct iattr *attr); 1634int security_inode_setattr(struct dentry *dentry, struct iattr *attr);
1635int security_inode_getattr(struct vfsmount *mnt, struct dentry *dentry); 1635int security_inode_getattr(struct vfsmount *mnt, struct dentry *dentry);
1636void security_inode_delete(struct inode *inode); 1636void security_inode_delete(struct inode *inode);
@@ -1744,11 +1744,15 @@ static inline int security_init(void)
1744 return 0; 1744 return 0;
1745} 1745}
1746 1746
1747static inline int security_ptrace(struct task_struct *parent, 1747static inline int security_ptrace_may_access(struct task_struct *child,
1748 struct task_struct *child, 1748 unsigned int mode)
1749 unsigned int mode)
1750{ 1749{
1751 return cap_ptrace(parent, child, mode); 1750 return cap_ptrace_may_access(child, mode);
1751}
1752
1753static inline int security_ptrace_traceme(struct task_struct *parent)
1754{
1755 return cap_ptrace_traceme(parent);
1752} 1756}
1753 1757
1754static inline int security_capget(struct task_struct *target, 1758static inline int security_capget(struct task_struct *target,
@@ -2023,8 +2027,7 @@ static inline int security_inode_follow_link(struct dentry *dentry,
2023 return 0; 2027 return 0;
2024} 2028}
2025 2029
2026static inline int security_inode_permission(struct inode *inode, int mask, 2030static inline int security_inode_permission(struct inode *inode, int mask)
2027 struct nameidata *nd)
2028{ 2031{
2029 return 0; 2032 return 0;
2030} 2033}
@@ -2416,25 +2419,6 @@ static inline int security_netlink_recv(struct sk_buff *skb, int cap)
2416 return cap_netlink_recv(skb, cap); 2419 return cap_netlink_recv(skb, cap);
2417} 2420}
2418 2421
2419static inline struct dentry *securityfs_create_dir(const char *name,
2420 struct dentry *parent)
2421{
2422 return ERR_PTR(-ENODEV);
2423}
2424
2425static inline struct dentry *securityfs_create_file(const char *name,
2426 mode_t mode,
2427 struct dentry *parent,
2428 void *data,
2429 const struct file_operations *fops)
2430{
2431 return ERR_PTR(-ENODEV);
2432}
2433
2434static inline void securityfs_remove(struct dentry *dentry)
2435{
2436}
2437
2438static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen) 2422static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
2439{ 2423{
2440 return -EOPNOTSUPP; 2424 return -EOPNOTSUPP;
@@ -2798,5 +2782,35 @@ static inline void security_audit_rule_free(void *lsmrule)
2798#endif /* CONFIG_SECURITY */ 2782#endif /* CONFIG_SECURITY */
2799#endif /* CONFIG_AUDIT */ 2783#endif /* CONFIG_AUDIT */
2800 2784
2785#ifdef CONFIG_SECURITYFS
2786
2787extern struct dentry *securityfs_create_file(const char *name, mode_t mode,
2788 struct dentry *parent, void *data,
2789 const struct file_operations *fops);
2790extern struct dentry *securityfs_create_dir(const char *name, struct dentry *parent);
2791extern void securityfs_remove(struct dentry *dentry);
2792
2793#else /* CONFIG_SECURITYFS */
2794
2795static inline struct dentry *securityfs_create_dir(const char *name,
2796 struct dentry *parent)
2797{
2798 return ERR_PTR(-ENODEV);
2799}
2800
2801static inline struct dentry *securityfs_create_file(const char *name,
2802 mode_t mode,
2803 struct dentry *parent,
2804 void *data,
2805 const struct file_operations *fops)
2806{
2807 return ERR_PTR(-ENODEV);
2808}
2809
2810static inline void securityfs_remove(struct dentry *dentry)
2811{}
2812
2813#endif
2814
2801#endif /* ! __LINUX_SECURITY_H */ 2815#endif /* ! __LINUX_SECURITY_H */
2802 2816
diff --git a/include/linux/sem.h b/include/linux/sem.h
index c8eaad9e4b72..1b191c176bcd 100644
--- a/include/linux/sem.h
+++ b/include/linux/sem.h
@@ -78,6 +78,7 @@ struct seminfo {
78 78
79#ifdef __KERNEL__ 79#ifdef __KERNEL__
80#include <asm/atomic.h> 80#include <asm/atomic.h>
81#include <linux/rcupdate.h>
81 82
82struct task_struct; 83struct task_struct;
83 84
@@ -93,23 +94,19 @@ struct sem_array {
93 time_t sem_otime; /* last semop time */ 94 time_t sem_otime; /* last semop time */
94 time_t sem_ctime; /* last change time */ 95 time_t sem_ctime; /* last change time */
95 struct sem *sem_base; /* ptr to first semaphore in array */ 96 struct sem *sem_base; /* ptr to first semaphore in array */
96 struct sem_queue *sem_pending; /* pending operations to be processed */ 97 struct list_head sem_pending; /* pending operations to be processed */
97 struct sem_queue **sem_pending_last; /* last pending operation */ 98 struct list_head list_id; /* undo requests on this array */
98 struct sem_undo *undo; /* undo requests on this array */
99 unsigned long sem_nsems; /* no. of semaphores in array */ 99 unsigned long sem_nsems; /* no. of semaphores in array */
100}; 100};
101 101
102/* One queue for each sleeping process in the system. */ 102/* One queue for each sleeping process in the system. */
103struct sem_queue { 103struct sem_queue {
104 struct sem_queue * next; /* next entry in the queue */ 104 struct list_head list; /* queue of pending operations */
105 struct sem_queue ** prev; /* previous entry in the queue, *(q->prev) == q */ 105 struct task_struct *sleeper; /* this process */
106 struct task_struct* sleeper; /* this process */ 106 struct sem_undo *undo; /* undo structure */
107 struct sem_undo * undo; /* undo structure */
108 int pid; /* process id of requesting process */ 107 int pid; /* process id of requesting process */
109 int status; /* completion status of operation */ 108 int status; /* completion status of operation */
110 struct sem_array * sma; /* semaphore array for operations */ 109 struct sembuf *sops; /* array of pending operations */
111 int id; /* internal sem id */
112 struct sembuf * sops; /* array of pending operations */
113 int nsops; /* number of operations */ 110 int nsops; /* number of operations */
114 int alter; /* does the operation alter the array? */ 111 int alter; /* does the operation alter the array? */
115}; 112};
@@ -118,8 +115,11 @@ struct sem_queue {
118 * when the process exits. 115 * when the process exits.
119 */ 116 */
120struct sem_undo { 117struct sem_undo {
121 struct sem_undo * proc_next; /* next entry on this process */ 118 struct list_head list_proc; /* per-process list: all undos from one process. */
122 struct sem_undo * id_next; /* next entry on this semaphore set */ 119 /* rcu protected */
120 struct rcu_head rcu; /* rcu struct for sem_undo() */
121 struct sem_undo_list *ulp; /* sem_undo_list for the process */
122 struct list_head list_id; /* per semaphore array list: all undos for one array */
123 int semid; /* semaphore set identifier */ 123 int semid; /* semaphore set identifier */
124 short * semadj; /* array of adjustments, one per semaphore */ 124 short * semadj; /* array of adjustments, one per semaphore */
125}; 125};
@@ -128,9 +128,9 @@ struct sem_undo {
128 * that may be shared among all a CLONE_SYSVSEM task group. 128 * that may be shared among all a CLONE_SYSVSEM task group.
129 */ 129 */
130struct sem_undo_list { 130struct sem_undo_list {
131 atomic_t refcnt; 131 atomic_t refcnt;
132 spinlock_t lock; 132 spinlock_t lock;
133 struct sem_undo *proc_list; 133 struct list_head list_proc;
134}; 134};
135 135
136struct sysv_sem { 136struct sysv_sem {
diff --git a/include/linux/semaphore.h b/include/linux/semaphore.h
index 9cae64b00d6b..7415839ac890 100644
--- a/include/linux/semaphore.h
+++ b/include/linux/semaphore.h
@@ -26,10 +26,8 @@ struct semaphore {
26 .wait_list = LIST_HEAD_INIT((name).wait_list), \ 26 .wait_list = LIST_HEAD_INIT((name).wait_list), \
27} 27}
28 28
29#define __DECLARE_SEMAPHORE_GENERIC(name, count) \ 29#define DECLARE_MUTEX(name) \
30 struct semaphore name = __SEMAPHORE_INITIALIZER(name, count) 30 struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1)
31
32#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name, 1)
33 31
34static inline void sema_init(struct semaphore *sem, int val) 32static inline void sema_init(struct semaphore *sem, int val)
35{ 33{
diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
index a66304a09955..dc50bcc282a8 100644
--- a/include/linux/seq_file.h
+++ b/include/linux/seq_file.h
@@ -4,6 +4,8 @@
4#include <linux/types.h> 4#include <linux/types.h>
5#include <linux/string.h> 5#include <linux/string.h>
6#include <linux/mutex.h> 6#include <linux/mutex.h>
7#include <linux/cpumask.h>
8#include <linux/nodemask.h>
7 9
8struct seq_operations; 10struct seq_operations;
9struct file; 11struct file;
@@ -47,6 +49,29 @@ int seq_path(struct seq_file *, struct path *, char *);
47int seq_dentry(struct seq_file *, struct dentry *, char *); 49int seq_dentry(struct seq_file *, struct dentry *, char *);
48int seq_path_root(struct seq_file *m, struct path *path, struct path *root, 50int seq_path_root(struct seq_file *m, struct path *path, struct path *root,
49 char *esc); 51 char *esc);
52int seq_bitmap(struct seq_file *m, unsigned long *bits, unsigned int nr_bits);
53static inline int seq_cpumask(struct seq_file *m, cpumask_t *mask)
54{
55 return seq_bitmap(m, mask->bits, NR_CPUS);
56}
57
58static inline int seq_nodemask(struct seq_file *m, nodemask_t *mask)
59{
60 return seq_bitmap(m, mask->bits, MAX_NUMNODES);
61}
62
63int seq_bitmap_list(struct seq_file *m, unsigned long *bits,
64 unsigned int nr_bits);
65
66static inline int seq_cpumask_list(struct seq_file *m, cpumask_t *mask)
67{
68 return seq_bitmap_list(m, mask->bits, NR_CPUS);
69}
70
71static inline int seq_nodemask_list(struct seq_file *m, nodemask_t *mask)
72{
73 return seq_bitmap_list(m, mask->bits, MAX_NUMNODES);
74}
50 75
51int single_open(struct file *, int (*)(struct seq_file *, void *), void *); 76int single_open(struct file *, int (*)(struct seq_file *, void *), void *);
52int single_release(struct inode *, struct file *); 77int single_release(struct inode *, struct file *);
diff --git a/include/linux/seq_file_net.h b/include/linux/seq_file_net.h
index 4ac52542a563..32c89bbe24a2 100644
--- a/include/linux/seq_file_net.h
+++ b/include/linux/seq_file_net.h
@@ -14,7 +14,10 @@ struct seq_net_private {
14 14
15int seq_open_net(struct inode *, struct file *, 15int seq_open_net(struct inode *, struct file *,
16 const struct seq_operations *, int); 16 const struct seq_operations *, int);
17int single_open_net(struct inode *, struct file *file,
18 int (*show)(struct seq_file *, void *));
17int seq_release_net(struct inode *, struct file *); 19int seq_release_net(struct inode *, struct file *);
20int single_release_net(struct inode *, struct file *);
18static inline struct net *seq_file_net(struct seq_file *seq) 21static inline struct net *seq_file_net(struct seq_file *seq)
19{ 22{
20#ifdef CONFIG_NET_NS 23#ifdef CONFIG_NET_NS
diff --git a/include/linux/serial.h b/include/linux/serial.h
index deb714314fb1..1ea8d9265bf6 100644
--- a/include/linux/serial.h
+++ b/include/linux/serial.h
@@ -173,6 +173,22 @@ struct serial_icounter_struct {
173 int reserved[9]; 173 int reserved[9];
174}; 174};
175 175
176/*
177 * Serial interface for controlling RS485 settings on chips with suitable
178 * support. Set with TIOCSRS485 and get with TIOCGRS485 if supported by your
179 * platform. The set function returns the new state, with any unsupported bits
180 * reverted appropriately.
181 */
182
183struct serial_rs485 {
184 __u32 flags; /* RS485 feature flags */
185#define SER_RS485_ENABLED (1 << 0)
186#define SER_RS485_RTS_ON_SEND (1 << 1)
187#define SER_RS485_RTS_AFTER_SEND (1 << 2)
188 __u32 delay_rts_before_send; /* Milliseconds */
189 __u32 padding[6]; /* Memory is cheap, new structs
190 are a royal PITA .. */
191};
176 192
177#ifdef __KERNEL__ 193#ifdef __KERNEL__
178#include <linux/compiler.h> 194#include <linux/compiler.h>
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index d8f31de632c5..e27f216361fc 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -59,9 +59,6 @@
59#define PORT_SUNZILOG 38 59#define PORT_SUNZILOG 38
60#define PORT_SUNSAB 39 60#define PORT_SUNSAB 39
61 61
62/* NEC v850. */
63#define PORT_V850E_UART 40
64
65/* DEC */ 62/* DEC */
66#define PORT_DZ 46 63#define PORT_DZ 46
67#define PORT_ZS 47 64#define PORT_ZS 47
@@ -190,6 +187,7 @@ struct uart_ops {
190 void (*break_ctl)(struct uart_port *, int ctl); 187 void (*break_ctl)(struct uart_port *, int ctl);
191 int (*startup)(struct uart_port *); 188 int (*startup)(struct uart_port *);
192 void (*shutdown)(struct uart_port *); 189 void (*shutdown)(struct uart_port *);
190 void (*flush_buffer)(struct uart_port *);
193 void (*set_termios)(struct uart_port *, struct ktermios *new, 191 void (*set_termios)(struct uart_port *, struct ktermios *new,
194 struct ktermios *old); 192 struct ktermios *old);
195 void (*set_ldisc)(struct uart_port *); 193 void (*set_ldisc)(struct uart_port *);
@@ -243,7 +241,7 @@ typedef unsigned int __bitwise__ upf_t;
243 241
244struct uart_port { 242struct uart_port {
245 spinlock_t lock; /* port lock */ 243 spinlock_t lock; /* port lock */
246 unsigned int iobase; /* in/out[bwl] */ 244 unsigned long iobase; /* in/out[bwl] */
247 unsigned char __iomem *membase; /* read/write[bwl] */ 245 unsigned char __iomem *membase; /* read/write[bwl] */
248 unsigned int irq; /* irq number */ 246 unsigned int irq; /* irq number */
249 unsigned int uartclk; /* base uart clock */ 247 unsigned int uartclk; /* base uart clock */
@@ -343,13 +341,15 @@ typedef unsigned int __bitwise__ uif_t;
343 * stuff here. 341 * stuff here.
344 */ 342 */
345struct uart_info { 343struct uart_info {
346 struct tty_struct *tty; 344 struct tty_port port;
347 struct circ_buf xmit; 345 struct circ_buf xmit;
348 uif_t flags; 346 uif_t flags;
349 347
350/* 348/*
351 * Definitions for info->flags. These are _private_ to serial_core, and 349 * Definitions for info->flags. These are _private_ to serial_core, and
352 * are specific to this structure. They may be queried by low level drivers. 350 * are specific to this structure. They may be queried by low level drivers.
351 *
352 * FIXME: use the ASY_ definitions
353 */ 353 */
354#define UIF_CHECK_CD ((__force uif_t) (1 << 25)) 354#define UIF_CHECK_CD ((__force uif_t) (1 << 25))
355#define UIF_CTS_FLOW ((__force uif_t) (1 << 26)) 355#define UIF_CTS_FLOW ((__force uif_t) (1 << 26))
@@ -357,11 +357,7 @@ struct uart_info {
357#define UIF_INITIALIZED ((__force uif_t) (1 << 31)) 357#define UIF_INITIALIZED ((__force uif_t) (1 << 31))
358#define UIF_SUSPENDED ((__force uif_t) (1 << 30)) 358#define UIF_SUSPENDED ((__force uif_t) (1 << 30))
359 359
360 int blocked_open;
361
362 struct tasklet_struct tlet; 360 struct tasklet_struct tlet;
363
364 wait_queue_head_t open_wait;
365 wait_queue_head_t delta_msr_wait; 361 wait_queue_head_t delta_msr_wait;
366}; 362};
367 363
@@ -438,8 +434,8 @@ int uart_resume_port(struct uart_driver *reg, struct uart_port *port);
438#define uart_circ_chars_free(circ) \ 434#define uart_circ_chars_free(circ) \
439 (CIRC_SPACE((circ)->head, (circ)->tail, UART_XMIT_SIZE)) 435 (CIRC_SPACE((circ)->head, (circ)->tail, UART_XMIT_SIZE))
440 436
441#define uart_tx_stopped(port) \ 437#define uart_tx_stopped(portp) \
442 ((port)->info->tty->stopped || (port)->info->tty->hw_stopped) 438 ((portp)->info->port.tty->stopped || (portp)->info->port.tty->hw_stopped)
443 439
444/* 440/*
445 * The following are helper functions for the low level drivers. 441 * The following are helper functions for the low level drivers.
@@ -450,7 +446,7 @@ uart_handle_sysrq_char(struct uart_port *port, unsigned int ch)
450#ifdef SUPPORT_SYSRQ 446#ifdef SUPPORT_SYSRQ
451 if (port->sysrq) { 447 if (port->sysrq) {
452 if (ch && time_before(jiffies, port->sysrq)) { 448 if (ch && time_before(jiffies, port->sysrq)) {
453 handle_sysrq(ch, port->info ? port->info->tty : NULL); 449 handle_sysrq(ch, port->info ? port->info->port.tty : NULL);
454 port->sysrq = 0; 450 port->sysrq = 0;
455 return 1; 451 return 1;
456 } 452 }
@@ -479,7 +475,7 @@ static inline int uart_handle_break(struct uart_port *port)
479 } 475 }
480#endif 476#endif
481 if (port->flags & UPF_SAK) 477 if (port->flags & UPF_SAK)
482 do_SAK(info->tty); 478 do_SAK(info->port.tty);
483 return 0; 479 return 0;
484} 480}
485 481
@@ -502,9 +498,9 @@ uart_handle_dcd_change(struct uart_port *port, unsigned int status)
502 498
503 if (info->flags & UIF_CHECK_CD) { 499 if (info->flags & UIF_CHECK_CD) {
504 if (status) 500 if (status)
505 wake_up_interruptible(&info->open_wait); 501 wake_up_interruptible(&info->port.open_wait);
506 else if (info->tty) 502 else if (info->port.tty)
507 tty_hangup(info->tty); 503 tty_hangup(info->port.tty);
508 } 504 }
509} 505}
510 506
@@ -517,7 +513,7 @@ static inline void
517uart_handle_cts_change(struct uart_port *port, unsigned int status) 513uart_handle_cts_change(struct uart_port *port, unsigned int status)
518{ 514{
519 struct uart_info *info = port->info; 515 struct uart_info *info = port->info;
520 struct tty_struct *tty = info->tty; 516 struct tty_struct *tty = info->port.tty;
521 517
522 port->icount.cts++; 518 port->icount.cts++;
523 519
@@ -543,7 +539,7 @@ static inline void
543uart_insert_char(struct uart_port *port, unsigned int status, 539uart_insert_char(struct uart_port *port, unsigned int status,
544 unsigned int overrun, unsigned int ch, unsigned int flag) 540 unsigned int overrun, unsigned int ch, unsigned int flag)
545{ 541{
546 struct tty_struct *tty = port->info->tty; 542 struct tty_struct *tty = port->info->port.tty;
547 543
548 if ((status & port->ignore_status_mask & ~overrun) == 0) 544 if ((status & port->ignore_status_mask & ~overrun) == 0)
549 tty_insert_flip_char(tty, ch, flag); 545 tty_insert_flip_char(tty, ch, flag);
diff --git a/include/linux/serio.h b/include/linux/serio.h
index 95674d97dabd..25641d9e0ea8 100644
--- a/include/linux/serio.h
+++ b/include/linux/serio.h
@@ -87,11 +87,10 @@ void serio_unregister_port(struct serio *serio);
87void serio_unregister_child_port(struct serio *serio); 87void serio_unregister_child_port(struct serio *serio);
88 88
89int __serio_register_driver(struct serio_driver *drv, struct module *owner, const char *mod_name); 89int __serio_register_driver(struct serio_driver *drv, struct module *owner, const char *mod_name);
90static inline int serio_register_driver(struct serio_driver *drv) 90static inline int __must_check serio_register_driver(struct serio_driver *drv)
91{ 91{
92 return __serio_register_driver(drv, THIS_MODULE, KBUILD_MODNAME); 92 return __serio_register_driver(drv, THIS_MODULE, KBUILD_MODNAME);
93} 93}
94int serio_register_driver(struct serio_driver *drv);
95void serio_unregister_driver(struct serio_driver *drv); 94void serio_unregister_driver(struct serio_driver *drv);
96 95
97static inline int serio_write(struct serio *serio, unsigned char data) 96static inline int serio_write(struct serio *serio, unsigned char data)
@@ -175,7 +174,7 @@ static inline void serio_unpin_driver(struct serio *serio)
175#define SERIO_8042_XL 0x06 174#define SERIO_8042_XL 0x06
176 175
177/* 176/*
178 * Serio types 177 * Serio protocols
179 */ 178 */
180#define SERIO_UNKNOWN 0x00 179#define SERIO_UNKNOWN 0x00
181#define SERIO_MSC 0x01 180#define SERIO_MSC 0x01
@@ -212,5 +211,7 @@ static inline void serio_unpin_driver(struct serio *serio)
212#define SERIO_TAOSEVM 0x34 211#define SERIO_TAOSEVM 0x34
213#define SERIO_FUJITSU 0x35 212#define SERIO_FUJITSU 0x35
214#define SERIO_ZHENHUA 0x36 213#define SERIO_ZHENHUA 0x36
214#define SERIO_INEXIO 0x37
215#define SERIO_TOUCHIT213 0x37
215 216
216#endif 217#endif
diff --git a/include/linux/sh_intc.h b/include/linux/sh_intc.h
new file mode 100644
index 000000000000..68e212ff9dde
--- /dev/null
+++ b/include/linux/sh_intc.h
@@ -0,0 +1,91 @@
1#ifndef __SH_INTC_H
2#define __SH_INTC_H
3
4typedef unsigned char intc_enum;
5
6struct intc_vect {
7 intc_enum enum_id;
8 unsigned short vect;
9};
10
11#define INTC_VECT(enum_id, vect) { enum_id, vect }
12#define INTC_IRQ(enum_id, irq) INTC_VECT(enum_id, irq2evt(irq))
13
14struct intc_group {
15 intc_enum enum_id;
16 intc_enum enum_ids[32];
17};
18
19#define INTC_GROUP(enum_id, ids...) { enum_id, { ids } }
20
21struct intc_mask_reg {
22 unsigned long set_reg, clr_reg, reg_width;
23 intc_enum enum_ids[32];
24#ifdef CONFIG_SMP
25 unsigned long smp;
26#endif
27};
28
29struct intc_prio_reg {
30 unsigned long set_reg, clr_reg, reg_width, field_width;
31 intc_enum enum_ids[16];
32#ifdef CONFIG_SMP
33 unsigned long smp;
34#endif
35};
36
37struct intc_sense_reg {
38 unsigned long reg, reg_width, field_width;
39 intc_enum enum_ids[16];
40};
41
42#ifdef CONFIG_SMP
43#define INTC_SMP(stride, nr) .smp = (stride) | ((nr) << 8)
44#else
45#define INTC_SMP(stride, nr)
46#endif
47
48struct intc_desc {
49 struct intc_vect *vectors;
50 unsigned int nr_vectors;
51 struct intc_group *groups;
52 unsigned int nr_groups;
53 struct intc_mask_reg *mask_regs;
54 unsigned int nr_mask_regs;
55 struct intc_prio_reg *prio_regs;
56 unsigned int nr_prio_regs;
57 struct intc_sense_reg *sense_regs;
58 unsigned int nr_sense_regs;
59 char *name;
60#if defined(CONFIG_CPU_SH3) || defined(CONFIG_CPU_SH4A)
61 struct intc_mask_reg *ack_regs;
62 unsigned int nr_ack_regs;
63#endif
64};
65
66#define _INTC_ARRAY(a) a, sizeof(a)/sizeof(*a)
67#define DECLARE_INTC_DESC(symbol, chipname, vectors, groups, \
68 mask_regs, prio_regs, sense_regs) \
69struct intc_desc symbol __initdata = { \
70 _INTC_ARRAY(vectors), _INTC_ARRAY(groups), \
71 _INTC_ARRAY(mask_regs), _INTC_ARRAY(prio_regs), \
72 _INTC_ARRAY(sense_regs), \
73 chipname, \
74}
75
76#if defined(CONFIG_CPU_SH3) || defined(CONFIG_CPU_SH4A)
77#define DECLARE_INTC_DESC_ACK(symbol, chipname, vectors, groups, \
78 mask_regs, prio_regs, sense_regs, ack_regs) \
79struct intc_desc symbol __initdata = { \
80 _INTC_ARRAY(vectors), _INTC_ARRAY(groups), \
81 _INTC_ARRAY(mask_regs), _INTC_ARRAY(prio_regs), \
82 _INTC_ARRAY(sense_regs), \
83 chipname, \
84 _INTC_ARRAY(ack_regs), \
85}
86#endif
87
88void __init register_intc_controller(struct intc_desc *desc);
89int intc_set_priority(unsigned int irq, unsigned int prio);
90
91#endif /* __SH_INTC_H */
diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h
index f2d12d5a21b8..fd83f2584b15 100644
--- a/include/linux/shmem_fs.h
+++ b/include/linux/shmem_fs.h
@@ -43,7 +43,7 @@ static inline struct shmem_inode_info *SHMEM_I(struct inode *inode)
43} 43}
44 44
45#ifdef CONFIG_TMPFS_POSIX_ACL 45#ifdef CONFIG_TMPFS_POSIX_ACL
46int shmem_permission(struct inode *, int, struct nameidata *); 46int shmem_permission(struct inode *, int);
47int shmem_acl_init(struct inode *, struct inode *); 47int shmem_acl_init(struct inode *, struct inode *);
48void shmem_acl_destroy_inode(struct inode *); 48void shmem_acl_destroy_inode(struct inode *);
49 49
diff --git a/include/linux/signalfd.h b/include/linux/signalfd.h
index ea037f28df91..bef0c46d4713 100644
--- a/include/linux/signalfd.h
+++ b/include/linux/signalfd.h
@@ -8,6 +8,12 @@
8#ifndef _LINUX_SIGNALFD_H 8#ifndef _LINUX_SIGNALFD_H
9#define _LINUX_SIGNALFD_H 9#define _LINUX_SIGNALFD_H
10 10
11/* For O_CLOEXEC and O_NONBLOCK */
12#include <linux/fcntl.h>
13
14/* Flags for signalfd4. */
15#define SFD_CLOEXEC O_CLOEXEC
16#define SFD_NONBLOCK O_NONBLOCK
11 17
12struct signalfd_siginfo { 18struct signalfd_siginfo {
13 __u32 ssi_signo; 19 __u32 ssi_signo;
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 299ec4b31412..2725f4e5a9bf 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -146,8 +146,14 @@ struct skb_shared_info {
146 unsigned short gso_segs; 146 unsigned short gso_segs;
147 unsigned short gso_type; 147 unsigned short gso_type;
148 __be32 ip6_frag_id; 148 __be32 ip6_frag_id;
149#ifdef CONFIG_HAS_DMA
150 unsigned int num_dma_maps;
151#endif
149 struct sk_buff *frag_list; 152 struct sk_buff *frag_list;
150 skb_frag_t frags[MAX_SKB_FRAGS]; 153 skb_frag_t frags[MAX_SKB_FRAGS];
154#ifdef CONFIG_HAS_DMA
155 dma_addr_t dma_maps[MAX_SKB_FRAGS + 1];
156#endif
151}; 157};
152 158
153/* We divide dataref into two halves. The higher 16 bits hold references 159/* We divide dataref into two halves. The higher 16 bits hold references
@@ -243,9 +249,11 @@ typedef unsigned char *sk_buff_data_t;
243 * @tc_index: Traffic control index 249 * @tc_index: Traffic control index
244 * @tc_verd: traffic control verdict 250 * @tc_verd: traffic control verdict
245 * @ndisc_nodetype: router type (from link layer) 251 * @ndisc_nodetype: router type (from link layer)
252 * @do_not_encrypt: set to prevent encryption of this frame
246 * @dma_cookie: a cookie to one of several possible DMA operations 253 * @dma_cookie: a cookie to one of several possible DMA operations
247 * done by skb DMA functions 254 * done by skb DMA functions
248 * @secmark: security marking 255 * @secmark: security marking
256 * @vlan_tci: vlan tag control information
249 */ 257 */
250 258
251struct sk_buff { 259struct sk_buff {
@@ -305,9 +313,7 @@ struct sk_buff {
305#endif 313#endif
306 314
307 int iif; 315 int iif;
308#ifdef CONFIG_NETDEVICES_MULTIQUEUE
309 __u16 queue_mapping; 316 __u16 queue_mapping;
310#endif
311#ifdef CONFIG_NET_SCHED 317#ifdef CONFIG_NET_SCHED
312 __u16 tc_index; /* traffic control index */ 318 __u16 tc_index; /* traffic control index */
313#ifdef CONFIG_NET_CLS_ACT 319#ifdef CONFIG_NET_CLS_ACT
@@ -317,7 +323,10 @@ struct sk_buff {
317#ifdef CONFIG_IPV6_NDISC_NODETYPE 323#ifdef CONFIG_IPV6_NDISC_NODETYPE
318 __u8 ndisc_nodetype:2; 324 __u8 ndisc_nodetype:2;
319#endif 325#endif
320 /* 14 bit hole */ 326#if defined(CONFIG_MAC80211) || defined(CONFIG_MAC80211_MODULE)
327 __u8 do_not_encrypt:1;
328#endif
329 /* 0/13/14 bit hole */
321 330
322#ifdef CONFIG_NET_DMA 331#ifdef CONFIG_NET_DMA
323 dma_cookie_t dma_cookie; 332 dma_cookie_t dma_cookie;
@@ -328,6 +337,8 @@ struct sk_buff {
328 337
329 __u32 mark; 338 __u32 mark;
330 339
340 __u16 vlan_tci;
341
331 sk_buff_data_t transport_header; 342 sk_buff_data_t transport_header;
332 sk_buff_data_t network_header; 343 sk_buff_data_t network_header;
333 sk_buff_data_t mac_header; 344 sk_buff_data_t mac_header;
@@ -348,6 +359,14 @@ struct sk_buff {
348 359
349#include <asm/system.h> 360#include <asm/system.h>
350 361
362#ifdef CONFIG_HAS_DMA
363#include <linux/dma-mapping.h>
364extern int skb_dma_map(struct device *dev, struct sk_buff *skb,
365 enum dma_data_direction dir);
366extern void skb_dma_unmap(struct device *dev, struct sk_buff *skb,
367 enum dma_data_direction dir);
368#endif
369
351extern void kfree_skb(struct sk_buff *skb); 370extern void kfree_skb(struct sk_buff *skb);
352extern void __kfree_skb(struct sk_buff *skb); 371extern void __kfree_skb(struct sk_buff *skb);
353extern struct sk_buff *__alloc_skb(unsigned int size, 372extern struct sk_buff *__alloc_skb(unsigned int size,
@@ -364,6 +383,8 @@ static inline struct sk_buff *alloc_skb_fclone(unsigned int size,
364 return __alloc_skb(size, priority, 1, -1); 383 return __alloc_skb(size, priority, 1, -1);
365} 384}
366 385
386extern int skb_recycle_check(struct sk_buff *skb, int skb_size);
387
367extern struct sk_buff *skb_morph(struct sk_buff *dst, struct sk_buff *src); 388extern struct sk_buff *skb_morph(struct sk_buff *dst, struct sk_buff *src);
368extern struct sk_buff *skb_clone(struct sk_buff *skb, 389extern struct sk_buff *skb_clone(struct sk_buff *skb,
369 gfp_t priority); 390 gfp_t priority);
@@ -454,6 +475,37 @@ static inline int skb_queue_empty(const struct sk_buff_head *list)
454} 475}
455 476
456/** 477/**
478 * skb_queue_is_last - check if skb is the last entry in the queue
479 * @list: queue head
480 * @skb: buffer
481 *
482 * Returns true if @skb is the last buffer on the list.
483 */
484static inline bool skb_queue_is_last(const struct sk_buff_head *list,
485 const struct sk_buff *skb)
486{
487 return (skb->next == (struct sk_buff *) list);
488}
489
490/**
491 * skb_queue_next - return the next packet in the queue
492 * @list: queue head
493 * @skb: current buffer
494 *
495 * Return the next packet in @list after @skb. It is only valid to
496 * call this if skb_queue_is_last() evaluates to false.
497 */
498static inline struct sk_buff *skb_queue_next(const struct sk_buff_head *list,
499 const struct sk_buff *skb)
500{
501 /* This BUG_ON may seem severe, but if we just return then we
502 * are going to dereference garbage.
503 */
504 BUG_ON(skb_queue_is_last(list, skb));
505 return skb->next;
506}
507
508/**
457 * skb_get - reference buffer 509 * skb_get - reference buffer
458 * @skb: buffer to reference 510 * @skb: buffer to reference
459 * 511 *
@@ -641,6 +693,22 @@ static inline __u32 skb_queue_len(const struct sk_buff_head *list_)
641 return list_->qlen; 693 return list_->qlen;
642} 694}
643 695
696/**
697 * __skb_queue_head_init - initialize non-spinlock portions of sk_buff_head
698 * @list: queue to initialize
699 *
700 * This initializes only the list and queue length aspects of
701 * an sk_buff_head object. This allows to initialize the list
702 * aspects of an sk_buff_head without reinitializing things like
703 * the spinlock. It can also be used for on-stack sk_buff_head
704 * objects where the spinlock is known to not be used.
705 */
706static inline void __skb_queue_head_init(struct sk_buff_head *list)
707{
708 list->prev = list->next = (struct sk_buff *)list;
709 list->qlen = 0;
710}
711
644/* 712/*
645 * This function creates a split out lock class for each invocation; 713 * This function creates a split out lock class for each invocation;
646 * this is needed for now since a whole lot of users of the skb-queue 714 * this is needed for now since a whole lot of users of the skb-queue
@@ -652,8 +720,7 @@ static inline __u32 skb_queue_len(const struct sk_buff_head *list_)
652static inline void skb_queue_head_init(struct sk_buff_head *list) 720static inline void skb_queue_head_init(struct sk_buff_head *list)
653{ 721{
654 spin_lock_init(&list->lock); 722 spin_lock_init(&list->lock);
655 list->prev = list->next = (struct sk_buff *)list; 723 __skb_queue_head_init(list);
656 list->qlen = 0;
657} 724}
658 725
659static inline void skb_queue_head_init_class(struct sk_buff_head *list, 726static inline void skb_queue_head_init_class(struct sk_buff_head *list,
@@ -680,6 +747,83 @@ static inline void __skb_insert(struct sk_buff *newsk,
680 list->qlen++; 747 list->qlen++;
681} 748}
682 749
750static inline void __skb_queue_splice(const struct sk_buff_head *list,
751 struct sk_buff *prev,
752 struct sk_buff *next)
753{
754 struct sk_buff *first = list->next;
755 struct sk_buff *last = list->prev;
756
757 first->prev = prev;
758 prev->next = first;
759
760 last->next = next;
761 next->prev = last;
762}
763
764/**
765 * skb_queue_splice - join two skb lists, this is designed for stacks
766 * @list: the new list to add
767 * @head: the place to add it in the first list
768 */
769static inline void skb_queue_splice(const struct sk_buff_head *list,
770 struct sk_buff_head *head)
771{
772 if (!skb_queue_empty(list)) {
773 __skb_queue_splice(list, (struct sk_buff *) head, head->next);
774 head->qlen += list->qlen;
775 }
776}
777
778/**
779 * skb_queue_splice - join two skb lists and reinitialise the emptied list
780 * @list: the new list to add
781 * @head: the place to add it in the first list
782 *
783 * The list at @list is reinitialised
784 */
785static inline void skb_queue_splice_init(struct sk_buff_head *list,
786 struct sk_buff_head *head)
787{
788 if (!skb_queue_empty(list)) {
789 __skb_queue_splice(list, (struct sk_buff *) head, head->next);
790 head->qlen += list->qlen;
791 __skb_queue_head_init(list);
792 }
793}
794
795/**
796 * skb_queue_splice_tail - join two skb lists, each list being a queue
797 * @list: the new list to add
798 * @head: the place to add it in the first list
799 */
800static inline void skb_queue_splice_tail(const struct sk_buff_head *list,
801 struct sk_buff_head *head)
802{
803 if (!skb_queue_empty(list)) {
804 __skb_queue_splice(list, head->prev, (struct sk_buff *) head);
805 head->qlen += list->qlen;
806 }
807}
808
809/**
810 * skb_queue_splice_tail - join two skb lists and reinitialise the emptied list
811 * @list: the new list to add
812 * @head: the place to add it in the first list
813 *
814 * Each of the lists is a queue.
815 * The list at @list is reinitialised
816 */
817static inline void skb_queue_splice_tail_init(struct sk_buff_head *list,
818 struct sk_buff_head *head)
819{
820 if (!skb_queue_empty(list)) {
821 __skb_queue_splice(list, head->prev, (struct sk_buff *) head);
822 head->qlen += list->qlen;
823 __skb_queue_head_init(list);
824 }
825}
826
683/** 827/**
684 * __skb_queue_after - queue a buffer at the list head 828 * __skb_queue_after - queue a buffer at the list head
685 * @list: list to use 829 * @list: list to use
@@ -824,6 +968,9 @@ static inline void skb_fill_page_desc(struct sk_buff *skb, int i,
824 skb_shinfo(skb)->nr_frags = i + 1; 968 skb_shinfo(skb)->nr_frags = i + 1;
825} 969}
826 970
971extern void skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page,
972 int off, int size);
973
827#define SKB_PAGE_ASSERT(skb) BUG_ON(skb_shinfo(skb)->nr_frags) 974#define SKB_PAGE_ASSERT(skb) BUG_ON(skb_shinfo(skb)->nr_frags)
828#define SKB_FRAG_ASSERT(skb) BUG_ON(skb_shinfo(skb)->frag_list) 975#define SKB_FRAG_ASSERT(skb) BUG_ON(skb_shinfo(skb)->frag_list)
829#define SKB_LINEAR_ASSERT(skb) BUG_ON(skb_is_nonlinear(skb)) 976#define SKB_LINEAR_ASSERT(skb) BUG_ON(skb_is_nonlinear(skb))
@@ -896,7 +1043,7 @@ extern unsigned char *__pskb_pull_tail(struct sk_buff *skb, int delta);
896static inline unsigned char *__pskb_pull(struct sk_buff *skb, unsigned int len) 1043static inline unsigned char *__pskb_pull(struct sk_buff *skb, unsigned int len)
897{ 1044{
898 if (len > skb_headlen(skb) && 1045 if (len > skb_headlen(skb) &&
899 !__pskb_pull_tail(skb, len-skb_headlen(skb))) 1046 !__pskb_pull_tail(skb, len - skb_headlen(skb)))
900 return NULL; 1047 return NULL;
901 skb->len -= len; 1048 skb->len -= len;
902 return skb->data += len; 1049 return skb->data += len;
@@ -913,7 +1060,7 @@ static inline int pskb_may_pull(struct sk_buff *skb, unsigned int len)
913 return 1; 1060 return 1;
914 if (unlikely(len > skb->len)) 1061 if (unlikely(len > skb->len))
915 return 0; 1062 return 0;
916 return __pskb_pull_tail(skb, len-skb_headlen(skb)) != NULL; 1063 return __pskb_pull_tail(skb, len - skb_headlen(skb)) != NULL;
917} 1064}
918 1065
919/** 1066/**
@@ -1238,6 +1385,26 @@ static inline struct sk_buff *netdev_alloc_skb(struct net_device *dev,
1238 return __netdev_alloc_skb(dev, length, GFP_ATOMIC); 1385 return __netdev_alloc_skb(dev, length, GFP_ATOMIC);
1239} 1386}
1240 1387
1388extern struct page *__netdev_alloc_page(struct net_device *dev, gfp_t gfp_mask);
1389
1390/**
1391 * netdev_alloc_page - allocate a page for ps-rx on a specific device
1392 * @dev: network device to receive on
1393 *
1394 * Allocate a new page node local to the specified device.
1395 *
1396 * %NULL is returned if there is no free memory.
1397 */
1398static inline struct page *netdev_alloc_page(struct net_device *dev)
1399{
1400 return __netdev_alloc_page(dev, GFP_ATOMIC);
1401}
1402
1403static inline void netdev_free_page(struct net_device *dev, struct page *page)
1404{
1405 __free_page(page);
1406}
1407
1241/** 1408/**
1242 * skb_clone_writable - is the header of a clone writable 1409 * skb_clone_writable - is the header of a clone writable
1243 * @skb: buffer to check 1410 * @skb: buffer to check
@@ -1316,7 +1483,7 @@ static inline int skb_padto(struct sk_buff *skb, unsigned int len)
1316 unsigned int size = skb->len; 1483 unsigned int size = skb->len;
1317 if (likely(size >= len)) 1484 if (likely(size >= len))
1318 return 0; 1485 return 0;
1319 return skb_pad(skb, len-size); 1486 return skb_pad(skb, len - size);
1320} 1487}
1321 1488
1322static inline int skb_add_data(struct sk_buff *skb, 1489static inline int skb_add_data(struct sk_buff *skb,
@@ -1429,6 +1596,15 @@ static inline int pskb_trim_rcsum(struct sk_buff *skb, unsigned int len)
1429 skb != (struct sk_buff *)(queue); \ 1596 skb != (struct sk_buff *)(queue); \
1430 skb = tmp, tmp = skb->next) 1597 skb = tmp, tmp = skb->next)
1431 1598
1599#define skb_queue_walk_from(queue, skb) \
1600 for (; prefetch(skb->next), (skb != (struct sk_buff *)(queue)); \
1601 skb = skb->next)
1602
1603#define skb_queue_walk_from_safe(queue, skb, tmp) \
1604 for (tmp = skb->next; \
1605 skb != (struct sk_buff *)(queue); \
1606 skb = tmp, tmp = skb->next)
1607
1432#define skb_queue_reverse_walk(queue, skb) \ 1608#define skb_queue_reverse_walk(queue, skb) \
1433 for (skb = (queue)->prev; \ 1609 for (skb = (queue)->prev; \
1434 prefetch(skb->prev), (skb != (struct sk_buff *)(queue)); \ 1610 prefetch(skb->prev), (skb != (struct sk_buff *)(queue)); \
@@ -1447,6 +1623,10 @@ extern int skb_copy_datagram_iovec(const struct sk_buff *from,
1447extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb, 1623extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
1448 int hlen, 1624 int hlen,
1449 struct iovec *iov); 1625 struct iovec *iov);
1626extern int skb_copy_datagram_from_iovec(struct sk_buff *skb,
1627 int offset,
1628 struct iovec *from,
1629 int len);
1450extern void skb_free_datagram(struct sock *sk, struct sk_buff *skb); 1630extern void skb_free_datagram(struct sock *sk, struct sk_buff *skb);
1451extern int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, 1631extern int skb_kill_datagram(struct sock *sk, struct sk_buff *skb,
1452 unsigned int flags); 1632 unsigned int flags);
@@ -1671,25 +1851,17 @@ static inline void skb_init_secmark(struct sk_buff *skb)
1671 1851
1672static inline void skb_set_queue_mapping(struct sk_buff *skb, u16 queue_mapping) 1852static inline void skb_set_queue_mapping(struct sk_buff *skb, u16 queue_mapping)
1673{ 1853{
1674#ifdef CONFIG_NETDEVICES_MULTIQUEUE
1675 skb->queue_mapping = queue_mapping; 1854 skb->queue_mapping = queue_mapping;
1676#endif
1677} 1855}
1678 1856
1679static inline u16 skb_get_queue_mapping(struct sk_buff *skb) 1857static inline u16 skb_get_queue_mapping(struct sk_buff *skb)
1680{ 1858{
1681#ifdef CONFIG_NETDEVICES_MULTIQUEUE
1682 return skb->queue_mapping; 1859 return skb->queue_mapping;
1683#else
1684 return 0;
1685#endif
1686} 1860}
1687 1861
1688static inline void skb_copy_queue_mapping(struct sk_buff *to, const struct sk_buff *from) 1862static inline void skb_copy_queue_mapping(struct sk_buff *to, const struct sk_buff *from)
1689{ 1863{
1690#ifdef CONFIG_NETDEVICES_MULTIQUEUE
1691 to->queue_mapping = from->queue_mapping; 1864 to->queue_mapping = from->queue_mapping;
1692#endif
1693} 1865}
1694 1866
1695static inline int skb_is_gso(const struct sk_buff *skb) 1867static inline int skb_is_gso(const struct sk_buff *skb)
@@ -1702,6 +1874,20 @@ static inline int skb_is_gso_v6(const struct sk_buff *skb)
1702 return skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6; 1874 return skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6;
1703} 1875}
1704 1876
1877extern void __skb_warn_lro_forwarding(const struct sk_buff *skb);
1878
1879static inline bool skb_warn_if_lro(const struct sk_buff *skb)
1880{
1881 /* LRO sets gso_size but not gso_type, whereas if GSO is really
1882 * wanted then gso_type will be set. */
1883 struct skb_shared_info *shinfo = skb_shinfo(skb);
1884 if (shinfo->gso_size != 0 && unlikely(shinfo->gso_type == 0)) {
1885 __skb_warn_lro_forwarding(skb);
1886 return true;
1887 }
1888 return false;
1889}
1890
1705static inline void skb_forward_csum(struct sk_buff *skb) 1891static inline void skb_forward_csum(struct sk_buff *skb)
1706{ 1892{
1707 /* Unfortunately we don't support this one. Any brave souls? */ 1893 /* Unfortunately we don't support this one. Any brave souls? */
diff --git a/include/linux/slab.h b/include/linux/slab.h
index 9aa90a6f20e0..ba965c84ae06 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -58,7 +58,7 @@ int slab_is_available(void);
58 58
59struct kmem_cache *kmem_cache_create(const char *, size_t, size_t, 59struct kmem_cache *kmem_cache_create(const char *, size_t, size_t,
60 unsigned long, 60 unsigned long,
61 void (*)(struct kmem_cache *, void *)); 61 void (*)(void *));
62void kmem_cache_destroy(struct kmem_cache *); 62void kmem_cache_destroy(struct kmem_cache *);
63int kmem_cache_shrink(struct kmem_cache *); 63int kmem_cache_shrink(struct kmem_cache *);
64void kmem_cache_free(struct kmem_cache *, void *); 64void kmem_cache_free(struct kmem_cache *, void *);
@@ -96,6 +96,7 @@ int kmem_ptr_validate(struct kmem_cache *cachep, const void *ptr);
96/* 96/*
97 * Common kmalloc functions provided by all allocators 97 * Common kmalloc functions provided by all allocators
98 */ 98 */
99void * __must_check __krealloc(const void *, size_t, gfp_t);
99void * __must_check krealloc(const void *, size_t, gfp_t); 100void * __must_check krealloc(const void *, size_t, gfp_t);
100void kfree(const void *); 101void kfree(const void *);
101size_t ksize(const void *); 102size_t ksize(const void *);
@@ -180,7 +181,7 @@ size_t ksize(const void *);
180 */ 181 */
181static inline void *kcalloc(size_t n, size_t size, gfp_t flags) 182static inline void *kcalloc(size_t n, size_t size, gfp_t flags)
182{ 183{
183 if (n != 0 && size > ULONG_MAX / n) 184 if (size != 0 && n > ULONG_MAX / size)
184 return NULL; 185 return NULL;
185 return __kmalloc(n * size, flags | __GFP_ZERO); 186 return __kmalloc(n * size, flags | __GFP_ZERO);
186} 187}
@@ -287,9 +288,4 @@ static inline void *kzalloc_node(size_t size, gfp_t flags, int node)
287 return kmalloc_node(size, flags | __GFP_ZERO, node); 288 return kmalloc_node(size, flags | __GFP_ZERO, node);
288} 289}
289 290
290#ifdef CONFIG_SLABINFO
291extern const struct seq_operations slabinfo_op;
292ssize_t slabinfo_write(struct file *, const char __user *, size_t, loff_t *);
293#endif
294
295#endif /* _LINUX_SLAB_H */ 291#endif /* _LINUX_SLAB_H */
diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
index d117ea2825a9..2f5c16b1aacd 100644
--- a/include/linux/slub_def.h
+++ b/include/linux/slub_def.h
@@ -46,6 +46,7 @@ struct kmem_cache_cpu {
46struct kmem_cache_node { 46struct kmem_cache_node {
47 spinlock_t list_lock; /* Protect partial list and nr_partial */ 47 spinlock_t list_lock; /* Protect partial list and nr_partial */
48 unsigned long nr_partial; 48 unsigned long nr_partial;
49 unsigned long min_partial;
49 struct list_head partial; 50 struct list_head partial;
50#ifdef CONFIG_SLUB_DEBUG 51#ifdef CONFIG_SLUB_DEBUG
51 atomic_long_t nr_slabs; 52 atomic_long_t nr_slabs;
@@ -85,7 +86,7 @@ struct kmem_cache {
85 struct kmem_cache_order_objects min; 86 struct kmem_cache_order_objects min;
86 gfp_t allocflags; /* gfp flags to use on each alloc */ 87 gfp_t allocflags; /* gfp flags to use on each alloc */
87 int refcount; /* Refcount for slab cache destroy */ 88 int refcount; /* Refcount for slab cache destroy */
88 void (*ctor)(struct kmem_cache *, void *); 89 void (*ctor)(void *);
89 int inuse; /* Offset to metadata */ 90 int inuse; /* Offset to metadata */
90 int align; /* Alignment */ 91 int align; /* Alignment */
91 const char *name; /* Name (only for display!) */ 92 const char *name; /* Name (only for display!) */
diff --git a/include/linux/sm501.h b/include/linux/sm501.h
index 95c1c39ba445..214f93209b8c 100644
--- a/include/linux/sm501.h
+++ b/include/linux/sm501.h
@@ -46,24 +46,6 @@ extern unsigned long sm501_modify_reg(struct device *dev,
46 unsigned long set, 46 unsigned long set,
47 unsigned long clear); 47 unsigned long clear);
48 48
49/* sm501_gpio_set
50 *
51 * set the state of the given GPIO line
52*/
53
54extern void sm501_gpio_set(struct device *dev,
55 unsigned long gpio,
56 unsigned int to,
57 unsigned int dir);
58
59/* sm501_gpio_get
60 *
61 * get the state of the given GPIO line
62*/
63
64extern unsigned long sm501_gpio_get(struct device *dev,
65 unsigned long gpio);
66
67 49
68/* Platform data definitions */ 50/* Platform data definitions */
69 51
@@ -73,6 +55,8 @@ extern unsigned long sm501_gpio_get(struct device *dev,
73#define SM501FB_FLAG_USE_HWACCEL (1<<3) 55#define SM501FB_FLAG_USE_HWACCEL (1<<3)
74#define SM501FB_FLAG_PANEL_NO_FPEN (1<<4) 56#define SM501FB_FLAG_PANEL_NO_FPEN (1<<4)
75#define SM501FB_FLAG_PANEL_NO_VBIASEN (1<<5) 57#define SM501FB_FLAG_PANEL_NO_VBIASEN (1<<5)
58#define SM501FB_FLAG_PANEL_INV_FPEN (1<<6)
59#define SM501FB_FLAG_PANEL_INV_VBIASEN (1<<7)
76 60
77struct sm501_platdata_fbsub { 61struct sm501_platdata_fbsub {
78 struct fb_videomode *def_mode; 62 struct fb_videomode *def_mode;
@@ -102,11 +86,19 @@ struct sm501_platdata_fb {
102 struct sm501_platdata_fbsub *fb_pnl; 86 struct sm501_platdata_fbsub *fb_pnl;
103}; 87};
104 88
105/* gpio i2c */ 89/* gpio i2c
90 *
91 * Note, we have to pass in the bus number, as the number used will be
92 * passed to the i2c-gpio driver's platform_device.id, subsequently used
93 * to register the i2c bus.
94*/
106 95
107struct sm501_platdata_gpio_i2c { 96struct sm501_platdata_gpio_i2c {
97 unsigned int bus_num;
108 unsigned int pin_sda; 98 unsigned int pin_sda;
109 unsigned int pin_scl; 99 unsigned int pin_scl;
100 int udelay;
101 int timeout;
110}; 102};
111 103
112/* sm501_initdata 104/* sm501_initdata
@@ -129,6 +121,7 @@ struct sm501_reg_init {
129#define SM501_USE_FBACCEL (1<<6) 121#define SM501_USE_FBACCEL (1<<6)
130#define SM501_USE_AC97 (1<<7) 122#define SM501_USE_AC97 (1<<7)
131#define SM501_USE_I2S (1<<8) 123#define SM501_USE_I2S (1<<8)
124#define SM501_USE_GPIO (1<<9)
132 125
133#define SM501_USE_ALL (0xffffffff) 126#define SM501_USE_ALL (0xffffffff)
134 127
@@ -155,6 +148,8 @@ struct sm501_init_gpio {
155 struct sm501_reg_init gpio_ddr_high; 148 struct sm501_reg_init gpio_ddr_high;
156}; 149};
157 150
151#define SM501_FLAG_SUSPEND_OFF (1<<4)
152
158/* sm501_platdata 153/* sm501_platdata
159 * 154 *
160 * This is passed with the platform device to allow the board 155 * This is passed with the platform device to allow the board
@@ -168,6 +163,12 @@ struct sm501_platdata {
168 struct sm501_init_gpio *init_gpiop; 163 struct sm501_init_gpio *init_gpiop;
169 struct sm501_platdata_fb *fb; 164 struct sm501_platdata_fb *fb;
170 165
166 int flags;
167 int gpio_base;
168
169 int (*get_power)(struct device *dev);
170 int (*set_power)(struct device *dev, unsigned int on);
171
171 struct sm501_platdata_gpio_i2c *gpio_i2c; 172 struct sm501_platdata_gpio_i2c *gpio_i2c;
172 unsigned int gpio_i2c_nr; 173 unsigned int gpio_i2c_nr;
173}; 174};
diff --git a/include/linux/smb.h b/include/linux/smb.h
index caa43b2370cb..82fefddc5987 100644
--- a/include/linux/smb.h
+++ b/include/linux/smb.h
@@ -11,7 +11,9 @@
11 11
12#include <linux/types.h> 12#include <linux/types.h>
13#include <linux/magic.h> 13#include <linux/magic.h>
14#ifdef __KERNEL__
14#include <linux/time.h> 15#include <linux/time.h>
16#endif
15 17
16enum smb_protocol { 18enum smb_protocol {
17 SMB_PROTOCOL_NONE, 19 SMB_PROTOCOL_NONE,
diff --git a/include/linux/smb_fs.h b/include/linux/smb_fs.h
index 2c5cd55f44ff..923cd8a247b1 100644
--- a/include/linux/smb_fs.h
+++ b/include/linux/smb_fs.h
@@ -43,18 +43,13 @@ static inline struct smb_inode_info *SMB_I(struct inode *inode)
43} 43}
44 44
45/* macro names are short for word, double-word, long value (?) */ 45/* macro names are short for word, double-word, long value (?) */
46#define WVAL(buf,pos) \ 46#define WVAL(buf, pos) (get_unaligned_le16((u8 *)(buf) + (pos)))
47 (le16_to_cpu(get_unaligned((__le16 *)((u8 *)(buf) + (pos))))) 47#define DVAL(buf, pos) (get_unaligned_le32((u8 *)(buf) + (pos)))
48#define DVAL(buf,pos) \ 48#define LVAL(buf, pos) (get_unaligned_le64((u8 *)(buf) + (pos)))
49 (le32_to_cpu(get_unaligned((__le32 *)((u8 *)(buf) + (pos))))) 49
50#define LVAL(buf,pos) \ 50#define WSET(buf, pos, val) put_unaligned_le16((val), (u8 *)(buf) + (pos))
51 (le64_to_cpu(get_unaligned((__le64 *)((u8 *)(buf) + (pos))))) 51#define DSET(buf, pos, val) put_unaligned_le32((val), (u8 *)(buf) + (pos))
52#define WSET(buf,pos,val) \ 52#define LSET(buf, pos, val) put_unaligned_le64((val), (u8 *)(buf) + (pos))
53 put_unaligned(cpu_to_le16((u16)(val)), (__le16 *)((u8 *)(buf) + (pos)))
54#define DSET(buf,pos,val) \
55 put_unaligned(cpu_to_le32((u32)(val)), (__le32 *)((u8 *)(buf) + (pos)))
56#define LSET(buf,pos,val) \
57 put_unaligned(cpu_to_le64((u64)(val)), (__le64 *)((u8 *)(buf) + (pos)))
58 53
59/* where to find the base of the SMB packet proper */ 54/* where to find the base of the SMB packet proper */
60#define smb_base(buf) ((u8 *)(((u8 *)(buf))+4)) 55#define smb_base(buf) ((u8 *)(((u8 *)(buf))+4))
diff --git a/include/linux/smc911x.h b/include/linux/smc911x.h
new file mode 100644
index 000000000000..521f37143fae
--- /dev/null
+++ b/include/linux/smc911x.h
@@ -0,0 +1,13 @@
1#ifndef __SMC911X_H__
2#define __SMC911X_H__
3
4#define SMC911X_USE_16BIT (1 << 0)
5#define SMC911X_USE_32BIT (1 << 1)
6
7struct smc911x_platdata {
8 unsigned long flags;
9 unsigned long irq_flags; /* IRQF_... */
10 int irq_polarity;
11};
12
13#endif /* __SMC911X_H__ */
diff --git a/include/linux/smc91x.h b/include/linux/smc91x.h
index 8e0556b8781c..bc21db598c06 100644
--- a/include/linux/smc91x.h
+++ b/include/linux/smc91x.h
@@ -5,9 +5,30 @@
5#define SMC91X_USE_16BIT (1 << 1) 5#define SMC91X_USE_16BIT (1 << 1)
6#define SMC91X_USE_32BIT (1 << 2) 6#define SMC91X_USE_32BIT (1 << 2)
7 7
8#define SMC91X_NOWAIT (1 << 3)
9
10/* two bits for IO_SHIFT, let's hope later designs will keep this sane */
11#define SMC91X_IO_SHIFT_0 (0 << 4)
12#define SMC91X_IO_SHIFT_1 (1 << 4)
13#define SMC91X_IO_SHIFT_2 (2 << 4)
14#define SMC91X_IO_SHIFT_3 (3 << 4)
15#define SMC91X_IO_SHIFT(x) (((x) >> 4) & 0x3)
16
17#define SMC91X_USE_DMA (1 << 6)
18
19#define RPC_LED_100_10 (0x00) /* LED = 100Mbps OR's with 10Mbps link detect */
20#define RPC_LED_RES (0x01) /* LED = Reserved */
21#define RPC_LED_10 (0x02) /* LED = 10Mbps link detect */
22#define RPC_LED_FD (0x03) /* LED = Full Duplex Mode */
23#define RPC_LED_TX_RX (0x04) /* LED = TX or RX packet occurred */
24#define RPC_LED_100 (0x05) /* LED = 100Mbps link dectect */
25#define RPC_LED_TX (0x06) /* LED = TX packet occurred */
26#define RPC_LED_RX (0x07) /* LED = RX packet occurred */
27
8struct smc91x_platdata { 28struct smc91x_platdata {
9 unsigned long flags; 29 unsigned long flags;
10 unsigned long irq_flags; /* IRQF_... */ 30 unsigned char leda;
31 unsigned char ledb;
11}; 32};
12 33
13#endif /* __SMC91X_H__ */ 34#endif /* __SMC91X_H__ */
diff --git a/include/linux/smp.h b/include/linux/smp.h
index 48262f86c969..2e4d58b26c06 100644
--- a/include/linux/smp.h
+++ b/include/linux/smp.h
@@ -7,6 +7,7 @@
7 */ 7 */
8 8
9#include <linux/errno.h> 9#include <linux/errno.h>
10#include <linux/types.h>
10#include <linux/list.h> 11#include <linux/list.h>
11#include <linux/cpumask.h> 12#include <linux/cpumask.h>
12 13
@@ -16,7 +17,8 @@ struct call_single_data {
16 struct list_head list; 17 struct list_head list;
17 void (*func) (void *info); 18 void (*func) (void *info);
18 void *info; 19 void *info;
19 unsigned int flags; 20 u16 flags;
21 u16 priv;
20}; 22};
21 23
22#ifdef CONFIG_SMP 24#ifdef CONFIG_SMP
@@ -74,15 +76,10 @@ void __smp_call_function_single(int cpuid, struct call_single_data *data);
74#ifdef CONFIG_USE_GENERIC_SMP_HELPERS 76#ifdef CONFIG_USE_GENERIC_SMP_HELPERS
75void generic_smp_call_function_single_interrupt(void); 77void generic_smp_call_function_single_interrupt(void);
76void generic_smp_call_function_interrupt(void); 78void generic_smp_call_function_interrupt(void);
77void init_call_single_data(void);
78void ipi_call_lock(void); 79void ipi_call_lock(void);
79void ipi_call_unlock(void); 80void ipi_call_unlock(void);
80void ipi_call_lock_irq(void); 81void ipi_call_lock_irq(void);
81void ipi_call_unlock_irq(void); 82void ipi_call_unlock_irq(void);
82#else
83static inline void init_call_single_data(void)
84{
85}
86#endif 83#endif
87 84
88/* 85/*
diff --git a/include/linux/snmp.h b/include/linux/snmp.h
index 5df62ef1280c..7a6e6bba4a71 100644
--- a/include/linux/snmp.h
+++ b/include/linux/snmp.h
@@ -214,6 +214,8 @@ enum
214 LINUX_MIB_TCPDSACKIGNOREDOLD, /* TCPSACKIgnoredOld */ 214 LINUX_MIB_TCPDSACKIGNOREDOLD, /* TCPSACKIgnoredOld */
215 LINUX_MIB_TCPDSACKIGNOREDNOUNDO, /* TCPSACKIgnoredNoUndo */ 215 LINUX_MIB_TCPDSACKIGNOREDNOUNDO, /* TCPSACKIgnoredNoUndo */
216 LINUX_MIB_TCPSPURIOUSRTOS, /* TCPSpuriousRTOs */ 216 LINUX_MIB_TCPSPURIOUSRTOS, /* TCPSpuriousRTOs */
217 LINUX_MIB_TCPMD5NOTFOUND, /* TCPMD5NotFound */
218 LINUX_MIB_TCPMD5UNEXPECTED, /* TCPMD5Unexpected */
217 __LINUX_MIB_MAX 219 __LINUX_MIB_MAX
218}; 220};
219 221
diff --git a/include/linux/socket.h b/include/linux/socket.h
index bd2b30a74e76..20fc4bbfca42 100644
--- a/include/linux/socket.h
+++ b/include/linux/socket.h
@@ -189,7 +189,9 @@ struct ucred {
189#define AF_BLUETOOTH 31 /* Bluetooth sockets */ 189#define AF_BLUETOOTH 31 /* Bluetooth sockets */
190#define AF_IUCV 32 /* IUCV sockets */ 190#define AF_IUCV 32 /* IUCV sockets */
191#define AF_RXRPC 33 /* RxRPC sockets */ 191#define AF_RXRPC 33 /* RxRPC sockets */
192#define AF_MAX 34 /* For now.. */ 192#define AF_ISDN 34 /* mISDN sockets */
193#define AF_PHONET 35 /* Phonet sockets */
194#define AF_MAX 36 /* For now.. */
193 195
194/* Protocol families, same as address families. */ 196/* Protocol families, same as address families. */
195#define PF_UNSPEC AF_UNSPEC 197#define PF_UNSPEC AF_UNSPEC
@@ -225,6 +227,8 @@ struct ucred {
225#define PF_BLUETOOTH AF_BLUETOOTH 227#define PF_BLUETOOTH AF_BLUETOOTH
226#define PF_IUCV AF_IUCV 228#define PF_IUCV AF_IUCV
227#define PF_RXRPC AF_RXRPC 229#define PF_RXRPC AF_RXRPC
230#define PF_ISDN AF_ISDN
231#define PF_PHONET AF_PHONET
228#define PF_MAX AF_MAX 232#define PF_MAX AF_MAX
229 233
230/* Maximum queue length specifiable by listen. */ 234/* Maximum queue length specifiable by listen. */
@@ -293,6 +297,7 @@ struct ucred {
293#define SOL_RXRPC 272 297#define SOL_RXRPC 272
294#define SOL_PPPOL2TP 273 298#define SOL_PPPOL2TP 273
295#define SOL_BLUETOOTH 274 299#define SOL_BLUETOOTH 274
300#define SOL_PNPIPE 275
296 301
297/* IPX options */ 302/* IPX options */
298#define IPX_TYPE 1 303#define IPX_TYPE 1
@@ -306,10 +311,10 @@ extern int csum_partial_copy_fromiovecend(unsigned char *kdata,
306 int offset, 311 int offset,
307 unsigned int len, __wsum *csump); 312 unsigned int len, __wsum *csump);
308 313
309extern int verify_iovec(struct msghdr *m, struct iovec *iov, char *address, int mode); 314extern int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr *address, int mode);
310extern int memcpy_toiovec(struct iovec *v, unsigned char *kdata, int len); 315extern int memcpy_toiovec(struct iovec *v, unsigned char *kdata, int len);
311extern int move_addr_to_user(void *kaddr, int klen, void __user *uaddr, int __user *ulen); 316extern int move_addr_to_user(struct sockaddr *kaddr, int klen, void __user *uaddr, int __user *ulen);
312extern int move_addr_to_kernel(void __user *uaddr, int ulen, void *kaddr); 317extern int move_addr_to_kernel(void __user *uaddr, int ulen, struct sockaddr *kaddr);
313extern int put_cmsg(struct msghdr*, int level, int type, int len, void *data); 318extern int put_cmsg(struct msghdr*, int level, int type, int len, void *data);
314 319
315#endif 320#endif
diff --git a/include/linux/sonet.h b/include/linux/sonet.h
index 753680296e17..67ad11fcf88b 100644
--- a/include/linux/sonet.h
+++ b/include/linux/sonet.h
@@ -34,7 +34,7 @@ struct sonet_stats {
34 /* clear error insertion */ 34 /* clear error insertion */
35#define SONET_GETDIAG _IOR('a',ATMIOC_PHYTYP+4,int) 35#define SONET_GETDIAG _IOR('a',ATMIOC_PHYTYP+4,int)
36 /* query error insertion */ 36 /* query error insertion */
37#define SONET_SETFRAMING _IO('a',ATMIOC_PHYTYP+5) 37#define SONET_SETFRAMING _IOW('a',ATMIOC_PHYTYP+5,int)
38 /* set framing mode (SONET/SDH) */ 38 /* set framing mode (SONET/SDH) */
39#define SONET_GETFRAMING _IOR('a',ATMIOC_PHYTYP+6,int) 39#define SONET_GETFRAMING _IOR('a',ATMIOC_PHYTYP+6,int)
40 /* get framing mode */ 40 /* get framing mode */
diff --git a/include/linux/spi/ads7846.h b/include/linux/spi/ads7846.h
index daf744017a31..05eab2f11e63 100644
--- a/include/linux/spi/ads7846.h
+++ b/include/linux/spi/ads7846.h
@@ -43,6 +43,9 @@ struct ads7846_platform_data {
43 u16 debounce_tol; /* tolerance used for filtering */ 43 u16 debounce_tol; /* tolerance used for filtering */
44 u16 debounce_rep; /* additional consecutive good readings 44 u16 debounce_rep; /* additional consecutive good readings
45 * required after the first two */ 45 * required after the first two */
46 int gpio_pendown; /* the GPIO used to decide the pendown
47 * state if get_pendown_state == NULL
48 */
46 int (*get_pendown_state)(void); 49 int (*get_pendown_state)(void);
47 int (*filter_init) (struct ads7846_platform_data *pdata, 50 int (*filter_init) (struct ads7846_platform_data *pdata,
48 void **filter_data); 51 void **filter_data);
diff --git a/include/linux/spi/corgi_lcd.h b/include/linux/spi/corgi_lcd.h
new file mode 100644
index 000000000000..6692b3418ccf
--- /dev/null
+++ b/include/linux/spi/corgi_lcd.h
@@ -0,0 +1,20 @@
1#ifndef __LINUX_SPI_CORGI_LCD_H
2#define __LINUX_SPI_CORGI_LCD_H
3
4#define CORGI_LCD_MODE_QVGA 1
5#define CORGI_LCD_MODE_VGA 2
6
7struct corgi_lcd_platform_data {
8 int init_mode;
9 int max_intensity;
10 int default_intensity;
11 int limit_mask;
12
13 int gpio_backlight_on; /* -1 if n/a */
14 int gpio_backlight_cont; /* -1 if n/a */
15
16 void (*notify)(int intensity);
17 void (*kick_battery)(void);
18};
19
20#endif /* __LINUX_SPI_CORGI_LCD_H */
diff --git a/include/linux/spi/ds1305.h b/include/linux/spi/ds1305.h
new file mode 100644
index 000000000000..287ec830eab7
--- /dev/null
+++ b/include/linux/spi/ds1305.h
@@ -0,0 +1,35 @@
1#ifndef __LINUX_SPI_DS1305_H
2#define __LINUX_SPI_DS1305_H
3
4/*
5 * One-time configuration for ds1305 and ds1306 RTC chips.
6 *
7 * Put a pointer to this in spi_board_info.platform_data if you want to
8 * be sure that Linux (re)initializes this as needed ... after losing
9 * backup power, and potentially on the first boot.
10 */
11struct ds1305_platform_data {
12
13 /* Trickle charge configuration: it's OK to leave out the MAGIC
14 * bitmask; mask in either DS1 or DS2, and then one of 2K/4k/8K.
15 */
16#define DS1305_TRICKLE_MAGIC 0xa0
17#define DS1305_TRICKLE_DS2 0x08 /* two diodes */
18#define DS1305_TRICKLE_DS1 0x04 /* one diode */
19#define DS1305_TRICKLE_2K 0x01 /* 2 KOhm resistance */
20#define DS1305_TRICKLE_4K 0x02 /* 4 KOhm resistance */
21#define DS1305_TRICKLE_8K 0x03 /* 8 KOhm resistance */
22 u8 trickle;
23
24 /* set only on ds1306 parts */
25 bool is_ds1306;
26
27 /* ds1306 only: enable 1 Hz output */
28 bool en_1hz;
29
30 /* REVISIT: the driver currently expects nINT0 to be wired
31 * as the alarm IRQ. ALM1 may also need to be set up ...
32 */
33};
34
35#endif /* __LINUX_SPI_DS1305_H */
diff --git a/include/linux/spi/max7301.h b/include/linux/spi/max7301.h
new file mode 100644
index 000000000000..6dfd83f19b4b
--- /dev/null
+++ b/include/linux/spi/max7301.h
@@ -0,0 +1,9 @@
1#ifndef LINUX_SPI_MAX7301_H
2#define LINUX_SPI_MAX7301_H
3
4struct max7301_platform_data {
5 /* number assigned to the first GPIO */
6 unsigned base;
7};
8
9#endif
diff --git a/include/linux/spi/mcp23s08.h b/include/linux/spi/mcp23s08.h
index 835ddf47d45c..22ef107d7704 100644
--- a/include/linux/spi/mcp23s08.h
+++ b/include/linux/spi/mcp23s08.h
@@ -1,18 +1,25 @@
1 1
2/* FIXME driver should be able to handle all four slaves that 2/* FIXME driver should be able to handle IRQs... */
3 * can be hooked up to each chipselect, as well as IRQs... 3
4 */ 4struct mcp23s08_chip_info {
5 bool is_present; /* true iff populated */
6 u8 pullups; /* BIT(x) means enable pullup x */
7};
5 8
6struct mcp23s08_platform_data { 9struct mcp23s08_platform_data {
7 /* four slaves can share one SPI chipselect */ 10 /* Four slaves (numbered 0..3) can share one SPI chipselect, and
8 u8 slave; 11 * will provide 8..32 GPIOs using 1..4 gpio_chip instances.
12 */
13 struct mcp23s08_chip_info chip[4];
9 14
10 /* number assigned to the first GPIO */ 15 /* "base" is the number of the first GPIO. Dynamic assignment is
16 * not currently supported, and even if there are gaps in chip
17 * addressing the GPIO numbers are sequential .. so for example
18 * if only slaves 0 and 3 are present, their GPIOs range from
19 * base to base+15.
20 */
11 unsigned base; 21 unsigned base;
12 22
13 /* pins with pullups */
14 u8 pullups;
15
16 void *context; /* param to setup/teardown */ 23 void *context; /* param to setup/teardown */
17 24
18 int (*setup)(struct spi_device *spi, 25 int (*setup)(struct spi_device *spi,
diff --git a/include/linux/spi/orion_spi.h b/include/linux/spi/orion_spi.h
new file mode 100644
index 000000000000..decf6d8c77b7
--- /dev/null
+++ b/include/linux/spi/orion_spi.h
@@ -0,0 +1,18 @@
1/*
2 * orion_spi.h
3 *
4 * This file is licensed under the terms of the GNU General Public
5 * License version 2. This program is licensed "as is" without any
6 * warranty of any kind, whether express or implied.
7 */
8
9#ifndef __LINUX_SPI_ORION_SPI_H
10#define __LINUX_SPI_ORION_SPI_H
11
12struct orion_spi_info {
13 u32 tclk; /* no <linux/clk.h> support yet */
14 u32 enable_clock_fix;
15};
16
17
18#endif
diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
index 387e428f1cdf..4be01bb44377 100644
--- a/include/linux/spi/spi.h
+++ b/include/linux/spi/spi.h
@@ -82,7 +82,7 @@ struct spi_device {
82 int irq; 82 int irq;
83 void *controller_state; 83 void *controller_state;
84 void *controller_data; 84 void *controller_data;
85 const char *modalias; 85 char modalias[32];
86 86
87 /* 87 /*
88 * likely need more hooks for more protocol options affecting how 88 * likely need more hooks for more protocol options affecting how
@@ -733,7 +733,7 @@ struct spi_board_info {
733 * controller_data goes to spi_device.controller_data, 733 * controller_data goes to spi_device.controller_data,
734 * irq is copied too 734 * irq is copied too
735 */ 735 */
736 char modalias[KOBJ_NAME_LEN]; 736 char modalias[32];
737 const void *platform_data; 737 const void *platform_data;
738 void *controller_data; 738 void *controller_data;
739 int irq; 739 int irq;
@@ -778,8 +778,20 @@ spi_register_board_info(struct spi_board_info const *info, unsigned n)
778 * use spi_new_device() to describe each device. You can also call 778 * use spi_new_device() to describe each device. You can also call
779 * spi_unregister_device() to start making that device vanish, but 779 * spi_unregister_device() to start making that device vanish, but
780 * normally that would be handled by spi_unregister_master(). 780 * normally that would be handled by spi_unregister_master().
781 *
782 * You can also use spi_alloc_device() and spi_add_device() to use a two
783 * stage registration sequence for each spi_device. This gives the caller
784 * some more control over the spi_device structure before it is registered,
785 * but requires that caller to initialize fields that would otherwise
786 * be defined using the board info.
781 */ 787 */
782extern struct spi_device * 788extern struct spi_device *
789spi_alloc_device(struct spi_master *master);
790
791extern int
792spi_add_device(struct spi_device *spi);
793
794extern struct spi_device *
783spi_new_device(struct spi_master *, struct spi_board_info *); 795spi_new_device(struct spi_master *, struct spi_board_info *);
784 796
785static inline void 797static inline void
diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h
index d311a090fae7..e0c0fccced46 100644
--- a/include/linux/spinlock.h
+++ b/include/linux/spinlock.h
@@ -46,6 +46,7 @@
46 * linux/spinlock.h: builds the final spin_*() APIs. 46 * linux/spinlock.h: builds the final spin_*() APIs.
47 */ 47 */
48 48
49#include <linux/typecheck.h>
49#include <linux/preempt.h> 50#include <linux/preempt.h>
50#include <linux/linkage.h> 51#include <linux/linkage.h>
51#include <linux/compiler.h> 52#include <linux/compiler.h>
@@ -182,8 +183,14 @@ do { \
182 183
183#ifdef CONFIG_DEBUG_LOCK_ALLOC 184#ifdef CONFIG_DEBUG_LOCK_ALLOC
184# define spin_lock_nested(lock, subclass) _spin_lock_nested(lock, subclass) 185# define spin_lock_nested(lock, subclass) _spin_lock_nested(lock, subclass)
186# define spin_lock_nest_lock(lock, nest_lock) \
187 do { \
188 typecheck(struct lockdep_map *, &(nest_lock)->dep_map);\
189 _spin_lock_nest_lock(lock, &(nest_lock)->dep_map); \
190 } while (0)
185#else 191#else
186# define spin_lock_nested(lock, subclass) _spin_lock(lock) 192# define spin_lock_nested(lock, subclass) _spin_lock(lock)
193# define spin_lock_nest_lock(lock, nest_lock) _spin_lock(lock)
187#endif 194#endif
188 195
189#define write_lock(lock) _write_lock(lock) 196#define write_lock(lock) _write_lock(lock)
@@ -191,23 +198,53 @@ do { \
191 198
192#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) 199#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
193 200
194#define spin_lock_irqsave(lock, flags) flags = _spin_lock_irqsave(lock) 201#define spin_lock_irqsave(lock, flags) \
195#define read_lock_irqsave(lock, flags) flags = _read_lock_irqsave(lock) 202 do { \
196#define write_lock_irqsave(lock, flags) flags = _write_lock_irqsave(lock) 203 typecheck(unsigned long, flags); \
204 flags = _spin_lock_irqsave(lock); \
205 } while (0)
206#define read_lock_irqsave(lock, flags) \
207 do { \
208 typecheck(unsigned long, flags); \
209 flags = _read_lock_irqsave(lock); \
210 } while (0)
211#define write_lock_irqsave(lock, flags) \
212 do { \
213 typecheck(unsigned long, flags); \
214 flags = _write_lock_irqsave(lock); \
215 } while (0)
197 216
198#ifdef CONFIG_DEBUG_LOCK_ALLOC 217#ifdef CONFIG_DEBUG_LOCK_ALLOC
199#define spin_lock_irqsave_nested(lock, flags, subclass) \ 218#define spin_lock_irqsave_nested(lock, flags, subclass) \
200 flags = _spin_lock_irqsave_nested(lock, subclass) 219 do { \
220 typecheck(unsigned long, flags); \
221 flags = _spin_lock_irqsave_nested(lock, subclass); \
222 } while (0)
201#else 223#else
202#define spin_lock_irqsave_nested(lock, flags, subclass) \ 224#define spin_lock_irqsave_nested(lock, flags, subclass) \
203 flags = _spin_lock_irqsave(lock) 225 do { \
226 typecheck(unsigned long, flags); \
227 flags = _spin_lock_irqsave(lock); \
228 } while (0)
204#endif 229#endif
205 230
206#else 231#else
207 232
208#define spin_lock_irqsave(lock, flags) _spin_lock_irqsave(lock, flags) 233#define spin_lock_irqsave(lock, flags) \
209#define read_lock_irqsave(lock, flags) _read_lock_irqsave(lock, flags) 234 do { \
210#define write_lock_irqsave(lock, flags) _write_lock_irqsave(lock, flags) 235 typecheck(unsigned long, flags); \
236 _spin_lock_irqsave(lock, flags); \
237 } while (0)
238#define read_lock_irqsave(lock, flags) \
239 do { \
240 typecheck(unsigned long, flags); \
241 _read_lock_irqsave(lock, flags); \
242 } while (0)
243#define write_lock_irqsave(lock, flags) \
244 do { \
245 typecheck(unsigned long, flags); \
246 _write_lock_irqsave(lock, flags); \
247 } while (0)
211#define spin_lock_irqsave_nested(lock, flags, subclass) \ 248#define spin_lock_irqsave_nested(lock, flags, subclass) \
212 spin_lock_irqsave(lock, flags) 249 spin_lock_irqsave(lock, flags)
213 250
@@ -260,16 +297,25 @@ do { \
260} while (0) 297} while (0)
261#endif 298#endif
262 299
263#define spin_unlock_irqrestore(lock, flags) \ 300#define spin_unlock_irqrestore(lock, flags) \
264 _spin_unlock_irqrestore(lock, flags) 301 do { \
302 typecheck(unsigned long, flags); \
303 _spin_unlock_irqrestore(lock, flags); \
304 } while (0)
265#define spin_unlock_bh(lock) _spin_unlock_bh(lock) 305#define spin_unlock_bh(lock) _spin_unlock_bh(lock)
266 306
267#define read_unlock_irqrestore(lock, flags) \ 307#define read_unlock_irqrestore(lock, flags) \
268 _read_unlock_irqrestore(lock, flags) 308 do { \
309 typecheck(unsigned long, flags); \
310 _read_unlock_irqrestore(lock, flags); \
311 } while (0)
269#define read_unlock_bh(lock) _read_unlock_bh(lock) 312#define read_unlock_bh(lock) _read_unlock_bh(lock)
270 313
271#define write_unlock_irqrestore(lock, flags) \ 314#define write_unlock_irqrestore(lock, flags) \
272 _write_unlock_irqrestore(lock, flags) 315 do { \
316 typecheck(unsigned long, flags); \
317 _write_unlock_irqrestore(lock, flags); \
318 } while (0)
273#define write_unlock_bh(lock) _write_unlock_bh(lock) 319#define write_unlock_bh(lock) _write_unlock_bh(lock)
274 320
275#define spin_trylock_bh(lock) __cond_lock(lock, _spin_trylock_bh(lock)) 321#define spin_trylock_bh(lock) __cond_lock(lock, _spin_trylock_bh(lock))
diff --git a/include/linux/spinlock_api_smp.h b/include/linux/spinlock_api_smp.h
index 8a2307ce7296..d79845d034b5 100644
--- a/include/linux/spinlock_api_smp.h
+++ b/include/linux/spinlock_api_smp.h
@@ -22,6 +22,8 @@ int in_lock_functions(unsigned long addr);
22void __lockfunc _spin_lock(spinlock_t *lock) __acquires(lock); 22void __lockfunc _spin_lock(spinlock_t *lock) __acquires(lock);
23void __lockfunc _spin_lock_nested(spinlock_t *lock, int subclass) 23void __lockfunc _spin_lock_nested(spinlock_t *lock, int subclass)
24 __acquires(lock); 24 __acquires(lock);
25void __lockfunc _spin_lock_nest_lock(spinlock_t *lock, struct lockdep_map *map)
26 __acquires(lock);
25void __lockfunc _read_lock(rwlock_t *lock) __acquires(lock); 27void __lockfunc _read_lock(rwlock_t *lock) __acquires(lock);
26void __lockfunc _write_lock(rwlock_t *lock) __acquires(lock); 28void __lockfunc _write_lock(rwlock_t *lock) __acquires(lock);
27void __lockfunc _spin_lock_bh(spinlock_t *lock) __acquires(lock); 29void __lockfunc _spin_lock_bh(spinlock_t *lock) __acquires(lock);
diff --git a/include/linux/ssb/ssb.h b/include/linux/ssb/ssb.h
index 50dfd0dc4093..e530026eedf7 100644
--- a/include/linux/ssb/ssb.h
+++ b/include/linux/ssb/ssb.h
@@ -7,6 +7,7 @@
7#include <linux/spinlock.h> 7#include <linux/spinlock.h>
8#include <linux/pci.h> 8#include <linux/pci.h>
9#include <linux/mod_devicetable.h> 9#include <linux/mod_devicetable.h>
10#include <linux/dma-mapping.h>
10 11
11#include <linux/ssb/ssb_regs.h> 12#include <linux/ssb/ssb_regs.h>
12 13
@@ -137,9 +138,6 @@ struct ssb_device {
137 const struct ssb_bus_ops *ops; 138 const struct ssb_bus_ops *ops;
138 139
139 struct device *dev; 140 struct device *dev;
140 /* Pointer to the device that has to be used for
141 * any DMA related operation. */
142 struct device *dma_dev;
143 141
144 struct ssb_bus *bus; 142 struct ssb_bus *bus;
145 struct ssb_device_id id; 143 struct ssb_device_id id;
@@ -399,13 +397,151 @@ static inline void ssb_block_write(struct ssb_device *dev, const void *buffer,
399#endif /* CONFIG_SSB_BLOCKIO */ 397#endif /* CONFIG_SSB_BLOCKIO */
400 398
401 399
400/* The SSB DMA API. Use this API for any DMA operation on the device.
401 * This API basically is a wrapper that calls the correct DMA API for
402 * the host device type the SSB device is attached to. */
403
402/* Translation (routing) bits that need to be ORed to DMA 404/* Translation (routing) bits that need to be ORed to DMA
403 * addresses before they are given to a device. */ 405 * addresses before they are given to a device. */
404extern u32 ssb_dma_translation(struct ssb_device *dev); 406extern u32 ssb_dma_translation(struct ssb_device *dev);
405#define SSB_DMA_TRANSLATION_MASK 0xC0000000 407#define SSB_DMA_TRANSLATION_MASK 0xC0000000
406#define SSB_DMA_TRANSLATION_SHIFT 30 408#define SSB_DMA_TRANSLATION_SHIFT 30
407 409
408extern int ssb_dma_set_mask(struct ssb_device *ssb_dev, u64 mask); 410extern int ssb_dma_set_mask(struct ssb_device *dev, u64 mask);
411
412extern void * ssb_dma_alloc_consistent(struct ssb_device *dev, size_t size,
413 dma_addr_t *dma_handle, gfp_t gfp_flags);
414extern void ssb_dma_free_consistent(struct ssb_device *dev, size_t size,
415 void *vaddr, dma_addr_t dma_handle,
416 gfp_t gfp_flags);
417
418static inline void __cold __ssb_dma_not_implemented(struct ssb_device *dev)
419{
420#ifdef CONFIG_SSB_DEBUG
421 printk(KERN_ERR "SSB: BUG! Calling DMA API for "
422 "unsupported bustype %d\n", dev->bus->bustype);
423#endif /* DEBUG */
424}
425
426static inline int ssb_dma_mapping_error(struct ssb_device *dev, dma_addr_t addr)
427{
428 switch (dev->bus->bustype) {
429 case SSB_BUSTYPE_PCI:
430 return pci_dma_mapping_error(dev->bus->host_pci, addr);
431 case SSB_BUSTYPE_SSB:
432 return dma_mapping_error(dev->dev, addr);
433 default:
434 __ssb_dma_not_implemented(dev);
435 }
436 return -ENOSYS;
437}
438
439static inline dma_addr_t ssb_dma_map_single(struct ssb_device *dev, void *p,
440 size_t size, enum dma_data_direction dir)
441{
442 switch (dev->bus->bustype) {
443 case SSB_BUSTYPE_PCI:
444 return pci_map_single(dev->bus->host_pci, p, size, dir);
445 case SSB_BUSTYPE_SSB:
446 return dma_map_single(dev->dev, p, size, dir);
447 default:
448 __ssb_dma_not_implemented(dev);
449 }
450 return 0;
451}
452
453static inline void ssb_dma_unmap_single(struct ssb_device *dev, dma_addr_t dma_addr,
454 size_t size, enum dma_data_direction dir)
455{
456 switch (dev->bus->bustype) {
457 case SSB_BUSTYPE_PCI:
458 pci_unmap_single(dev->bus->host_pci, dma_addr, size, dir);
459 return;
460 case SSB_BUSTYPE_SSB:
461 dma_unmap_single(dev->dev, dma_addr, size, dir);
462 return;
463 default:
464 __ssb_dma_not_implemented(dev);
465 }
466}
467
468static inline void ssb_dma_sync_single_for_cpu(struct ssb_device *dev,
469 dma_addr_t dma_addr,
470 size_t size,
471 enum dma_data_direction dir)
472{
473 switch (dev->bus->bustype) {
474 case SSB_BUSTYPE_PCI:
475 pci_dma_sync_single_for_cpu(dev->bus->host_pci, dma_addr,
476 size, dir);
477 return;
478 case SSB_BUSTYPE_SSB:
479 dma_sync_single_for_cpu(dev->dev, dma_addr, size, dir);
480 return;
481 default:
482 __ssb_dma_not_implemented(dev);
483 }
484}
485
486static inline void ssb_dma_sync_single_for_device(struct ssb_device *dev,
487 dma_addr_t dma_addr,
488 size_t size,
489 enum dma_data_direction dir)
490{
491 switch (dev->bus->bustype) {
492 case SSB_BUSTYPE_PCI:
493 pci_dma_sync_single_for_device(dev->bus->host_pci, dma_addr,
494 size, dir);
495 return;
496 case SSB_BUSTYPE_SSB:
497 dma_sync_single_for_device(dev->dev, dma_addr, size, dir);
498 return;
499 default:
500 __ssb_dma_not_implemented(dev);
501 }
502}
503
504static inline void ssb_dma_sync_single_range_for_cpu(struct ssb_device *dev,
505 dma_addr_t dma_addr,
506 unsigned long offset,
507 size_t size,
508 enum dma_data_direction dir)
509{
510 switch (dev->bus->bustype) {
511 case SSB_BUSTYPE_PCI:
512 /* Just sync everything. That's all the PCI API can do. */
513 pci_dma_sync_single_for_cpu(dev->bus->host_pci, dma_addr,
514 offset + size, dir);
515 return;
516 case SSB_BUSTYPE_SSB:
517 dma_sync_single_range_for_cpu(dev->dev, dma_addr, offset,
518 size, dir);
519 return;
520 default:
521 __ssb_dma_not_implemented(dev);
522 }
523}
524
525static inline void ssb_dma_sync_single_range_for_device(struct ssb_device *dev,
526 dma_addr_t dma_addr,
527 unsigned long offset,
528 size_t size,
529 enum dma_data_direction dir)
530{
531 switch (dev->bus->bustype) {
532 case SSB_BUSTYPE_PCI:
533 /* Just sync everything. That's all the PCI API can do. */
534 pci_dma_sync_single_for_device(dev->bus->host_pci, dma_addr,
535 offset + size, dir);
536 return;
537 case SSB_BUSTYPE_SSB:
538 dma_sync_single_range_for_device(dev->dev, dma_addr, offset,
539 size, dir);
540 return;
541 default:
542 __ssb_dma_not_implemented(dev);
543 }
544}
409 545
410 546
411#ifdef CONFIG_SSB_PCIHOST 547#ifdef CONFIG_SSB_PCIHOST
diff --git a/include/linux/ssb/ssb_regs.h b/include/linux/ssb/ssb_regs.h
index ebad0bac9801..99a0f991e850 100644
--- a/include/linux/ssb/ssb_regs.h
+++ b/include/linux/ssb/ssb_regs.h
@@ -245,8 +245,6 @@
245 245
246/* SPROM Revision 3 (inherits most data from rev 2) */ 246/* SPROM Revision 3 (inherits most data from rev 2) */
247#define SSB_SPROM3_IL0MAC 0x104A /* 6 bytes MAC address for 802.11b/g */ 247#define SSB_SPROM3_IL0MAC 0x104A /* 6 bytes MAC address for 802.11b/g */
248#define SSB_SPROM3_ET0MAC 0x1050 /* 6 bytes MAC address for Ethernet ?? */
249#define SSB_SPROM3_ET1MAC 0x1050 /* 6 bytes MAC address for 802.11a ?? */
250#define SSB_SPROM3_OFDMAPO 0x102C /* A-PHY OFDM Mid Power Offset (4 bytes, BigEndian) */ 248#define SSB_SPROM3_OFDMAPO 0x102C /* A-PHY OFDM Mid Power Offset (4 bytes, BigEndian) */
251#define SSB_SPROM3_OFDMALPO 0x1030 /* A-PHY OFDM Low Power Offset (4 bytes, BigEndian) */ 249#define SSB_SPROM3_OFDMALPO 0x1030 /* A-PHY OFDM Low Power Offset (4 bytes, BigEndian) */
252#define SSB_SPROM3_OFDMAHPO 0x1034 /* A-PHY OFDM High Power Offset (4 bytes, BigEndian) */ 250#define SSB_SPROM3_OFDMAHPO 0x1034 /* A-PHY OFDM High Power Offset (4 bytes, BigEndian) */
@@ -267,8 +265,6 @@
267 265
268/* SPROM Revision 4 */ 266/* SPROM Revision 4 */
269#define SSB_SPROM4_IL0MAC 0x104C /* 6 byte MAC address for a/b/g/n */ 267#define SSB_SPROM4_IL0MAC 0x104C /* 6 byte MAC address for a/b/g/n */
270#define SSB_SPROM4_ET0MAC 0x1018 /* 6 bytes MAC address for Ethernet ?? */
271#define SSB_SPROM4_ET1MAC 0x1018 /* 6 bytes MAC address for 802.11a ?? */
272#define SSB_SPROM4_ETHPHY 0x105A /* Ethernet PHY settings ?? */ 268#define SSB_SPROM4_ETHPHY 0x105A /* Ethernet PHY settings ?? */
273#define SSB_SPROM4_ETHPHY_ET0A 0x001F /* MII Address for enet0 */ 269#define SSB_SPROM4_ETHPHY_ET0A 0x001F /* MII Address for enet0 */
274#define SSB_SPROM4_ETHPHY_ET1A 0x03E0 /* MII Address for enet1 */ 270#define SSB_SPROM4_ETHPHY_ET1A 0x03E0 /* MII Address for enet1 */
@@ -316,6 +312,21 @@
316#define SSB_SPROM4_PA1B1 0x1090 312#define SSB_SPROM4_PA1B1 0x1090
317#define SSB_SPROM4_PA1B2 0x1092 313#define SSB_SPROM4_PA1B2 0x1092
318 314
315/* SPROM Revision 5 (inherits most data from rev 4) */
316#define SSB_SPROM5_BFLLO 0x104A /* Boardflags (low 16 bits) */
317#define SSB_SPROM5_BFLHI 0x104C /* Board Flags Hi */
318#define SSB_SPROM5_IL0MAC 0x1052 /* 6 byte MAC address for a/b/g/n */
319#define SSB_SPROM5_CCODE 0x1044 /* Country Code (2 bytes) */
320#define SSB_SPROM5_GPIOA 0x1076 /* Gen. Purpose IO # 0 and 1 */
321#define SSB_SPROM5_GPIOA_P0 0x00FF /* Pin 0 */
322#define SSB_SPROM5_GPIOA_P1 0xFF00 /* Pin 1 */
323#define SSB_SPROM5_GPIOA_P1_SHIFT 8
324#define SSB_SPROM5_GPIOB 0x1078 /* Gen. Purpose IO # 2 and 3 */
325#define SSB_SPROM5_GPIOB_P2 0x00FF /* Pin 2 */
326#define SSB_SPROM5_GPIOB_P3 0xFF00 /* Pin 3 */
327#define SSB_SPROM5_GPIOB_P3_SHIFT 8
328
329
319/* Values for SSB_SPROM1_BINF_CCODE */ 330/* Values for SSB_SPROM1_BINF_CCODE */
320enum { 331enum {
321 SSB_SPROM1CCODE_WORLD = 0, 332 SSB_SPROM1CCODE_WORLD = 0,
diff --git a/include/linux/stacktrace.h b/include/linux/stacktrace.h
index 5da9794b2d78..b106fd8e0d5c 100644
--- a/include/linux/stacktrace.h
+++ b/include/linux/stacktrace.h
@@ -1,6 +1,8 @@
1#ifndef __LINUX_STACKTRACE_H 1#ifndef __LINUX_STACKTRACE_H
2#define __LINUX_STACKTRACE_H 2#define __LINUX_STACKTRACE_H
3 3
4struct task_struct;
5
4#ifdef CONFIG_STACKTRACE 6#ifdef CONFIG_STACKTRACE
5struct stack_trace { 7struct stack_trace {
6 unsigned int nr_entries, max_entries; 8 unsigned int nr_entries, max_entries;
diff --git a/include/linux/stallion.h b/include/linux/stallion.h
index 0424d75a5aaa..336af33c6ea4 100644
--- a/include/linux/stallion.h
+++ b/include/linux/stallion.h
@@ -69,6 +69,7 @@ struct stlrq {
69 */ 69 */
70struct stlport { 70struct stlport {
71 unsigned long magic; 71 unsigned long magic;
72 struct tty_port port;
72 unsigned int portnr; 73 unsigned int portnr;
73 unsigned int panelnr; 74 unsigned int panelnr;
74 unsigned int brdnr; 75 unsigned int brdnr;
@@ -76,12 +77,10 @@ struct stlport {
76 int uartaddr; 77 int uartaddr;
77 unsigned int pagenr; 78 unsigned int pagenr;
78 unsigned long istate; 79 unsigned long istate;
79 int flags;
80 int baud_base; 80 int baud_base;
81 int custom_divisor; 81 int custom_divisor;
82 int close_delay; 82 int close_delay;
83 int closing_wait; 83 int closing_wait;
84 int refcount;
85 int openwaitcnt; 84 int openwaitcnt;
86 int brklen; 85 int brklen;
87 unsigned int sigs; 86 unsigned int sigs;
@@ -92,9 +91,6 @@ struct stlport {
92 unsigned long clk; 91 unsigned long clk;
93 unsigned long hwid; 92 unsigned long hwid;
94 void *uartp; 93 void *uartp;
95 struct tty_struct *tty;
96 wait_queue_head_t open_wait;
97 wait_queue_head_t close_wait;
98 comstats_t stats; 94 comstats_t stats;
99 struct stlrq tx; 95 struct stlrq tx;
100}; 96};
diff --git a/include/linux/stop_machine.h b/include/linux/stop_machine.h
index 5bfc553bdb21..faf1519b5adc 100644
--- a/include/linux/stop_machine.h
+++ b/include/linux/stop_machine.h
@@ -3,43 +3,42 @@
3/* "Bogolock": stop the entire machine, disable interrupts. This is a 3/* "Bogolock": stop the entire machine, disable interrupts. This is a
4 very heavy lock, which is equivalent to grabbing every spinlock 4 very heavy lock, which is equivalent to grabbing every spinlock
5 (and more). So the "read" side to such a lock is anything which 5 (and more). So the "read" side to such a lock is anything which
6 diables preeempt. */ 6 disables preeempt. */
7#include <linux/cpu.h> 7#include <linux/cpu.h>
8#include <linux/cpumask.h>
8#include <asm/system.h> 9#include <asm/system.h>
9 10
10#if defined(CONFIG_STOP_MACHINE) && defined(CONFIG_SMP) 11#if defined(CONFIG_STOP_MACHINE) && defined(CONFIG_SMP)
12
11/** 13/**
12 * stop_machine_run: freeze the machine on all CPUs and run this function 14 * stop_machine: freeze the machine on all CPUs and run this function
13 * @fn: the function to run 15 * @fn: the function to run
14 * @data: the data ptr for the @fn() 16 * @data: the data ptr for the @fn()
15 * @cpu: the cpu to run @fn() on (or any, if @cpu == NR_CPUS. 17 * @cpus: the cpus to run the @fn() on (NULL = any online cpu)
16 * 18 *
17 * Description: This causes a thread to be scheduled on every other cpu, 19 * Description: This causes a thread to be scheduled on every cpu,
18 * each of which disables interrupts, and finally interrupts are disabled 20 * each of which disables interrupts. The result is that noone is
19 * on the current CPU. The result is that noone is holding a spinlock 21 * holding a spinlock or inside any other preempt-disabled region when
20 * or inside any other preempt-disabled region when @fn() runs. 22 * @fn() runs.
21 * 23 *
22 * This can be thought of as a very heavy write lock, equivalent to 24 * This can be thought of as a very heavy write lock, equivalent to
23 * grabbing every spinlock in the kernel. */ 25 * grabbing every spinlock in the kernel. */
24int stop_machine_run(int (*fn)(void *), void *data, unsigned int cpu); 26int stop_machine(int (*fn)(void *), void *data, const cpumask_t *cpus);
25 27
26/** 28/**
27 * __stop_machine_run: freeze the machine on all CPUs and run this function 29 * __stop_machine: freeze the machine on all CPUs and run this function
28 * @fn: the function to run 30 * @fn: the function to run
29 * @data: the data ptr for the @fn 31 * @data: the data ptr for the @fn
30 * @cpu: the cpu to run @fn on (or any, if @cpu == NR_CPUS. 32 * @cpus: the cpus to run the @fn() on (NULL = any online cpu)
31 * 33 *
32 * Description: This is a special version of the above, which returns the 34 * Description: This is a special version of the above, which assumes cpus
33 * thread which has run @fn(): kthread_stop will return the return value 35 * won't come or go while it's being called. Used by hotplug cpu.
34 * of @fn(). Used by hotplug cpu.
35 */ 36 */
36struct task_struct *__stop_machine_run(int (*fn)(void *), void *data, 37int __stop_machine(int (*fn)(void *), void *data, const cpumask_t *cpus);
37 unsigned int cpu);
38
39#else 38#else
40 39
41static inline int stop_machine_run(int (*fn)(void *), void *data, 40static inline int stop_machine(int (*fn)(void *), void *data,
42 unsigned int cpu) 41 const cpumask_t *cpus)
43{ 42{
44 int ret; 43 int ret;
45 local_irq_disable(); 44 local_irq_disable();
diff --git a/include/linux/string.h b/include/linux/string.h
index efdc44593b52..810d80df0a1d 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -111,5 +111,8 @@ extern void argv_free(char **argv);
111 111
112extern bool sysfs_streq(const char *s1, const char *s2); 112extern bool sysfs_streq(const char *s1, const char *s2);
113 113
114extern ssize_t memory_read_from_buffer(void *to, size_t count, loff_t *ppos,
115 const void *from, size_t available);
116
114#endif 117#endif
115#endif /* _LINUX_STRING_H_ */ 118#endif /* _LINUX_STRING_H_ */
diff --git a/include/linux/string_helpers.h b/include/linux/string_helpers.h
new file mode 100644
index 000000000000..a3eb2f65b656
--- /dev/null
+++ b/include/linux/string_helpers.h
@@ -0,0 +1,16 @@
1#ifndef _LINUX_STRING_HELPERS_H_
2#define _LINUX_STRING_HELPERS_H_
3
4#include <linux/types.h>
5
6/* Descriptions of the types of units to
7 * print in */
8enum string_size_units {
9 STRING_UNITS_10, /* use powers of 10^3 (standard SI) */
10 STRING_UNITS_2, /* use binary powers of 2^10 */
11};
12
13int string_get_size(u64 size, enum string_size_units units,
14 char *buf, int len);
15
16#endif
diff --git a/include/linux/sunrpc/auth_gss.h b/include/linux/sunrpc/auth_gss.h
index fec6899bf355..d48d4e605f74 100644
--- a/include/linux/sunrpc/auth_gss.h
+++ b/include/linux/sunrpc/auth_gss.h
@@ -7,8 +7,6 @@
7 * Andy Adamson <andros@umich.edu> 7 * Andy Adamson <andros@umich.edu>
8 * Bruce Fields <bfields@umich.edu> 8 * Bruce Fields <bfields@umich.edu>
9 * Copyright (c) 2000 The Regents of the University of Michigan 9 * Copyright (c) 2000 The Regents of the University of Michigan
10 *
11 * $Id$
12 */ 10 */
13 11
14#ifndef _LINUX_SUNRPC_AUTH_GSS_H 12#ifndef _LINUX_SUNRPC_AUTH_GSS_H
diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
index e5bfe01ee305..6f0ee1b84a4f 100644
--- a/include/linux/sunrpc/clnt.h
+++ b/include/linux/sunrpc/clnt.h
@@ -104,6 +104,7 @@ struct rpc_create_args {
104 const struct rpc_timeout *timeout; 104 const struct rpc_timeout *timeout;
105 char *servername; 105 char *servername;
106 struct rpc_program *program; 106 struct rpc_program *program;
107 u32 prognumber; /* overrides program->number */
107 u32 version; 108 u32 version;
108 rpc_authflavor_t authflavor; 109 rpc_authflavor_t authflavor;
109 unsigned long flags; 110 unsigned long flags;
@@ -124,10 +125,10 @@ struct rpc_clnt *rpc_clone_client(struct rpc_clnt *);
124void rpc_shutdown_client(struct rpc_clnt *); 125void rpc_shutdown_client(struct rpc_clnt *);
125void rpc_release_client(struct rpc_clnt *); 126void rpc_release_client(struct rpc_clnt *);
126 127
127int rpcb_register(u32, u32, int, unsigned short, int *); 128int rpcb_register(u32, u32, int, unsigned short);
128int rpcb_v4_register(const u32 program, const u32 version, 129int rpcb_v4_register(const u32 program, const u32 version,
129 const struct sockaddr *address, 130 const struct sockaddr *address,
130 const char *netid, int *result); 131 const char *netid);
131int rpcb_getport_sync(struct sockaddr_in *, u32, u32, int); 132int rpcb_getport_sync(struct sockaddr_in *, u32, u32, int);
132void rpcb_getport_async(struct rpc_task *); 133void rpcb_getport_async(struct rpc_task *);
133 134
diff --git a/include/linux/sunrpc/gss_api.h b/include/linux/sunrpc/gss_api.h
index 459c5fc11d51..03f33330ece2 100644
--- a/include/linux/sunrpc/gss_api.h
+++ b/include/linux/sunrpc/gss_api.h
@@ -7,8 +7,6 @@
7 * Andy Adamson <andros@umich.edu> 7 * Andy Adamson <andros@umich.edu>
8 * Bruce Fields <bfields@umich.edu> 8 * Bruce Fields <bfields@umich.edu>
9 * Copyright (c) 2000 The Regents of the University of Michigan 9 * Copyright (c) 2000 The Regents of the University of Michigan
10 *
11 * $Id$
12 */ 10 */
13 11
14#ifndef _LINUX_SUNRPC_GSS_API_H 12#ifndef _LINUX_SUNRPC_GSS_API_H
diff --git a/include/linux/sunrpc/gss_krb5.h b/include/linux/sunrpc/gss_krb5.h
index a10f1fb0bf7c..e7bbdba474d5 100644
--- a/include/linux/sunrpc/gss_krb5.h
+++ b/include/linux/sunrpc/gss_krb5.h
@@ -51,6 +51,9 @@ struct krb5_ctx {
51 51
52extern spinlock_t krb5_seq_lock; 52extern spinlock_t krb5_seq_lock;
53 53
54/* The length of the Kerberos GSS token header */
55#define GSS_KRB5_TOK_HDR_LEN (16)
56
54#define KG_TOK_MIC_MSG 0x0101 57#define KG_TOK_MIC_MSG 0x0101
55#define KG_TOK_WRAP_MSG 0x0201 58#define KG_TOK_WRAP_MSG 0x0201
56 59
diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
index 4b54c5fdcfd9..3afe7fb403b2 100644
--- a/include/linux/sunrpc/svc.h
+++ b/include/linux/sunrpc/svc.h
@@ -22,7 +22,7 @@
22/* 22/*
23 * This is the RPC server thread function prototype 23 * This is the RPC server thread function prototype
24 */ 24 */
25typedef void (*svc_thread_fn)(struct svc_rqst *); 25typedef int (*svc_thread_fn)(void *);
26 26
27/* 27/*
28 * 28 *
@@ -66,6 +66,7 @@ struct svc_serv {
66 struct list_head sv_tempsocks; /* all temporary sockets */ 66 struct list_head sv_tempsocks; /* all temporary sockets */
67 int sv_tmpcnt; /* count of temporary sockets */ 67 int sv_tmpcnt; /* count of temporary sockets */
68 struct timer_list sv_temptimer; /* timer for aging temporary sockets */ 68 struct timer_list sv_temptimer; /* timer for aging temporary sockets */
69 sa_family_t sv_family; /* listener's address family */
69 70
70 char * sv_name; /* service name */ 71 char * sv_name; /* service name */
71 72
@@ -80,7 +81,6 @@ struct svc_serv {
80 struct module * sv_module; /* optional module to count when 81 struct module * sv_module; /* optional module to count when
81 * adding threads */ 82 * adding threads */
82 svc_thread_fn sv_function; /* main function for threads */ 83 svc_thread_fn sv_function; /* main function for threads */
83 int sv_kill_signal; /* signal to kill threads */
84}; 84};
85 85
86/* 86/*
@@ -266,17 +266,17 @@ struct svc_rqst {
266/* 266/*
267 * Rigorous type checking on sockaddr type conversions 267 * Rigorous type checking on sockaddr type conversions
268 */ 268 */
269static inline struct sockaddr_in *svc_addr_in(struct svc_rqst *rqst) 269static inline struct sockaddr_in *svc_addr_in(const struct svc_rqst *rqst)
270{ 270{
271 return (struct sockaddr_in *) &rqst->rq_addr; 271 return (struct sockaddr_in *) &rqst->rq_addr;
272} 272}
273 273
274static inline struct sockaddr_in6 *svc_addr_in6(struct svc_rqst *rqst) 274static inline struct sockaddr_in6 *svc_addr_in6(const struct svc_rqst *rqst)
275{ 275{
276 return (struct sockaddr_in6 *) &rqst->rq_addr; 276 return (struct sockaddr_in6 *) &rqst->rq_addr;
277} 277}
278 278
279static inline struct sockaddr *svc_addr(struct svc_rqst *rqst) 279static inline struct sockaddr *svc_addr(const struct svc_rqst *rqst)
280{ 280{
281 return (struct sockaddr *) &rqst->rq_addr; 281 return (struct sockaddr *) &rqst->rq_addr;
282} 282}
@@ -382,18 +382,20 @@ struct svc_procedure {
382/* 382/*
383 * Function prototypes. 383 * Function prototypes.
384 */ 384 */
385struct svc_serv * svc_create(struct svc_program *, unsigned int, 385struct svc_serv *svc_create(struct svc_program *, unsigned int, sa_family_t,
386 void (*shutdown)(struct svc_serv*)); 386 void (*shutdown)(struct svc_serv *));
387struct svc_rqst *svc_prepare_thread(struct svc_serv *serv, 387struct svc_rqst *svc_prepare_thread(struct svc_serv *serv,
388 struct svc_pool *pool); 388 struct svc_pool *pool);
389void svc_exit_thread(struct svc_rqst *); 389void svc_exit_thread(struct svc_rqst *);
390struct svc_serv * svc_create_pooled(struct svc_program *, unsigned int, 390struct svc_serv * svc_create_pooled(struct svc_program *, unsigned int,
391 void (*shutdown)(struct svc_serv*), 391 sa_family_t, void (*shutdown)(struct svc_serv *),
392 svc_thread_fn, int sig, struct module *); 392 svc_thread_fn, struct module *);
393int svc_set_num_threads(struct svc_serv *, struct svc_pool *, int); 393int svc_set_num_threads(struct svc_serv *, struct svc_pool *, int);
394void svc_destroy(struct svc_serv *); 394void svc_destroy(struct svc_serv *);
395int svc_process(struct svc_rqst *); 395int svc_process(struct svc_rqst *);
396int svc_register(struct svc_serv *, int, unsigned short); 396int svc_register(const struct svc_serv *, const unsigned short,
397 const unsigned short);
398
397void svc_wake_up(struct svc_serv *); 399void svc_wake_up(struct svc_serv *);
398void svc_reserve(struct svc_rqst *rqstp, int space); 400void svc_reserve(struct svc_rqst *rqstp, int space);
399struct svc_pool * svc_pool_for_cpu(struct svc_serv *serv, int cpu); 401struct svc_pool * svc_pool_for_cpu(struct svc_serv *serv, int cpu);
diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
index 05eb4664d0dd..c14fe86dac59 100644
--- a/include/linux/sunrpc/svc_rdma.h
+++ b/include/linux/sunrpc/svc_rdma.h
@@ -72,7 +72,8 @@ extern atomic_t rdma_stat_sq_prod;
72 */ 72 */
73struct svc_rdma_op_ctxt { 73struct svc_rdma_op_ctxt {
74 struct svc_rdma_op_ctxt *read_hdr; 74 struct svc_rdma_op_ctxt *read_hdr;
75 struct list_head free_list; 75 struct svc_rdma_fastreg_mr *frmr;
76 int hdr_count;
76 struct xdr_buf arg; 77 struct xdr_buf arg;
77 struct list_head dto_q; 78 struct list_head dto_q;
78 enum ib_wr_opcode wr_op; 79 enum ib_wr_opcode wr_op;
@@ -86,14 +87,52 @@ struct svc_rdma_op_ctxt {
86 struct page *pages[RPCSVC_MAXPAGES]; 87 struct page *pages[RPCSVC_MAXPAGES];
87}; 88};
88 89
90/*
91 * NFS_ requests are mapped on the client side by the chunk lists in
92 * the RPCRDMA header. During the fetching of the RPC from the client
93 * and the writing of the reply to the client, the memory in the
94 * client and the memory in the server must be mapped as contiguous
95 * vaddr/len for access by the hardware. These data strucures keep
96 * these mappings.
97 *
98 * For an RDMA_WRITE, the 'sge' maps the RPC REPLY. For RDMA_READ, the
99 * 'sge' in the svc_rdma_req_map maps the server side RPC reply and the
100 * 'ch' field maps the read-list of the RPCRDMA header to the 'sge'
101 * mapping of the reply.
102 */
103struct svc_rdma_chunk_sge {
104 int start; /* sge no for this chunk */
105 int count; /* sge count for this chunk */
106};
107struct svc_rdma_fastreg_mr {
108 struct ib_mr *mr;
109 void *kva;
110 struct ib_fast_reg_page_list *page_list;
111 int page_list_len;
112 unsigned long access_flags;
113 unsigned long map_len;
114 enum dma_data_direction direction;
115 struct list_head frmr_list;
116};
117struct svc_rdma_req_map {
118 struct svc_rdma_fastreg_mr *frmr;
119 unsigned long count;
120 union {
121 struct kvec sge[RPCSVC_MAXPAGES];
122 struct svc_rdma_chunk_sge ch[RPCSVC_MAXPAGES];
123 };
124};
125#define RDMACTXT_F_FAST_UNREG 1
89#define RDMACTXT_F_LAST_CTXT 2 126#define RDMACTXT_F_LAST_CTXT 2
90 127
128#define SVCRDMA_DEVCAP_FAST_REG 1 /* fast mr registration */
129#define SVCRDMA_DEVCAP_READ_W_INV 2 /* read w/ invalidate */
130
91struct svcxprt_rdma { 131struct svcxprt_rdma {
92 struct svc_xprt sc_xprt; /* SVC transport structure */ 132 struct svc_xprt sc_xprt; /* SVC transport structure */
93 struct rdma_cm_id *sc_cm_id; /* RDMA connection id */ 133 struct rdma_cm_id *sc_cm_id; /* RDMA connection id */
94 struct list_head sc_accept_q; /* Conn. waiting accept */ 134 struct list_head sc_accept_q; /* Conn. waiting accept */
95 int sc_ord; /* RDMA read limit */ 135 int sc_ord; /* RDMA read limit */
96 wait_queue_head_t sc_read_wait;
97 int sc_max_sge; 136 int sc_max_sge;
98 137
99 int sc_sq_depth; /* Depth of SQ */ 138 int sc_sq_depth; /* Depth of SQ */
@@ -104,18 +143,19 @@ struct svcxprt_rdma {
104 143
105 struct ib_pd *sc_pd; 144 struct ib_pd *sc_pd;
106 145
146 atomic_t sc_dma_used;
107 atomic_t sc_ctxt_used; 147 atomic_t sc_ctxt_used;
108 struct list_head sc_ctxt_free;
109 int sc_ctxt_cnt;
110 int sc_ctxt_bump;
111 int sc_ctxt_max;
112 spinlock_t sc_ctxt_lock;
113 struct list_head sc_rq_dto_q; 148 struct list_head sc_rq_dto_q;
114 spinlock_t sc_rq_dto_lock; 149 spinlock_t sc_rq_dto_lock;
115 struct ib_qp *sc_qp; 150 struct ib_qp *sc_qp;
116 struct ib_cq *sc_rq_cq; 151 struct ib_cq *sc_rq_cq;
117 struct ib_cq *sc_sq_cq; 152 struct ib_cq *sc_sq_cq;
118 struct ib_mr *sc_phys_mr; /* MR for server memory */ 153 struct ib_mr *sc_phys_mr; /* MR for server memory */
154 u32 sc_dev_caps; /* distilled device caps */
155 u32 sc_dma_lkey; /* local dma key */
156 unsigned int sc_frmr_pg_list_len;
157 struct list_head sc_frmr_q;
158 spinlock_t sc_frmr_q_lock;
119 159
120 spinlock_t sc_lock; /* transport lock */ 160 spinlock_t sc_lock; /* transport lock */
121 161
@@ -123,7 +163,6 @@ struct svcxprt_rdma {
123 unsigned long sc_flags; 163 unsigned long sc_flags;
124 struct list_head sc_dto_q; /* DTO tasklet I/O pending Q */ 164 struct list_head sc_dto_q; /* DTO tasklet I/O pending Q */
125 struct list_head sc_read_complete_q; 165 struct list_head sc_read_complete_q;
126 spinlock_t sc_read_complete_lock;
127 struct work_struct sc_work; 166 struct work_struct sc_work;
128}; 167};
129/* sc_flags */ 168/* sc_flags */
@@ -173,6 +212,13 @@ extern int svc_rdma_post_recv(struct svcxprt_rdma *);
173extern int svc_rdma_create_listen(struct svc_serv *, int, struct sockaddr *); 212extern int svc_rdma_create_listen(struct svc_serv *, int, struct sockaddr *);
174extern struct svc_rdma_op_ctxt *svc_rdma_get_context(struct svcxprt_rdma *); 213extern struct svc_rdma_op_ctxt *svc_rdma_get_context(struct svcxprt_rdma *);
175extern void svc_rdma_put_context(struct svc_rdma_op_ctxt *, int); 214extern void svc_rdma_put_context(struct svc_rdma_op_ctxt *, int);
215extern void svc_rdma_unmap_dma(struct svc_rdma_op_ctxt *ctxt);
216extern struct svc_rdma_req_map *svc_rdma_get_req_map(void);
217extern void svc_rdma_put_req_map(struct svc_rdma_req_map *);
218extern int svc_rdma_fastreg(struct svcxprt_rdma *, struct svc_rdma_fastreg_mr *);
219extern struct svc_rdma_fastreg_mr *svc_rdma_get_frmr(struct svcxprt_rdma *);
220extern void svc_rdma_put_frmr(struct svcxprt_rdma *,
221 struct svc_rdma_fastreg_mr *);
176extern void svc_sq_reap(struct svcxprt_rdma *); 222extern void svc_sq_reap(struct svcxprt_rdma *);
177extern void svc_rq_reap(struct svcxprt_rdma *); 223extern void svc_rq_reap(struct svcxprt_rdma *);
178extern struct svc_xprt_class svc_rdma_class; 224extern struct svc_xprt_class svc_rdma_class;
diff --git a/include/linux/sunrpc/svcauth_gss.h b/include/linux/sunrpc/svcauth_gss.h
index 417a1def56db..c9165d9771a8 100644
--- a/include/linux/sunrpc/svcauth_gss.h
+++ b/include/linux/sunrpc/svcauth_gss.h
@@ -3,9 +3,6 @@
3 * 3 *
4 * Bruce Fields <bfields@umich.edu> 4 * Bruce Fields <bfields@umich.edu>
5 * Copyright (c) 2002 The Regents of the Unviersity of Michigan 5 * Copyright (c) 2002 The Regents of the Unviersity of Michigan
6 *
7 * $Id$
8 *
9 */ 6 */
10 7
11#ifndef _LINUX_SUNRPC_SVCAUTH_GSS_H 8#ifndef _LINUX_SUNRPC_SVCAUTH_GSS_H
diff --git a/include/linux/sunrpc/svcsock.h b/include/linux/sunrpc/svcsock.h
index 8cff696dedf5..483e10380aae 100644
--- a/include/linux/sunrpc/svcsock.h
+++ b/include/linux/sunrpc/svcsock.h
@@ -39,10 +39,7 @@ int svc_send(struct svc_rqst *);
39void svc_drop(struct svc_rqst *); 39void svc_drop(struct svc_rqst *);
40void svc_sock_update_bufs(struct svc_serv *serv); 40void svc_sock_update_bufs(struct svc_serv *serv);
41int svc_sock_names(char *buf, struct svc_serv *serv, char *toclose); 41int svc_sock_names(char *buf, struct svc_serv *serv, char *toclose);
42int svc_addsock(struct svc_serv *serv, 42int svc_addsock(struct svc_serv *serv, int fd, char *name_return);
43 int fd,
44 char *name_return,
45 int *proto);
46void svc_init_xprt_sock(void); 43void svc_init_xprt_sock(void);
47void svc_cleanup_xprt_sock(void); 44void svc_cleanup_xprt_sock(void);
48 45
diff --git a/include/linux/sunrpc/xprtrdma.h b/include/linux/sunrpc/xprtrdma.h
index 4de56b1d372b..54a379c9e8eb 100644
--- a/include/linux/sunrpc/xprtrdma.h
+++ b/include/linux/sunrpc/xprtrdma.h
@@ -66,9 +66,6 @@
66 66
67#define RPCRDMA_INLINE_PAD_THRESH (512)/* payload threshold to pad (bytes) */ 67#define RPCRDMA_INLINE_PAD_THRESH (512)/* payload threshold to pad (bytes) */
68 68
69#define RDMA_RESOLVE_TIMEOUT (5*HZ) /* TBD 5 seconds */
70#define RDMA_CONNECT_RETRY_MAX (2) /* retries if no listener backlog */
71
72/* memory registration strategies */ 69/* memory registration strategies */
73#define RPCRDMA_PERSISTENT_REGISTRATION (1) 70#define RPCRDMA_PERSISTENT_REGISTRATION (1)
74 71
@@ -78,6 +75,7 @@ enum rpcrdma_memreg {
78 RPCRDMA_MEMWINDOWS, 75 RPCRDMA_MEMWINDOWS,
79 RPCRDMA_MEMWINDOWS_ASYNC, 76 RPCRDMA_MEMWINDOWS_ASYNC,
80 RPCRDMA_MTHCAFMR, 77 RPCRDMA_MTHCAFMR,
78 RPCRDMA_FRMR,
81 RPCRDMA_ALLPHYSICAL, 79 RPCRDMA_ALLPHYSICAL,
82 RPCRDMA_LAST 80 RPCRDMA_LAST
83}; 81};
diff --git a/include/linux/suspend.h b/include/linux/suspend.h
index e8e69159af71..2ce8207686e2 100644
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -217,11 +217,11 @@ struct platform_hibernation_ops {
217#ifdef CONFIG_HIBERNATION 217#ifdef CONFIG_HIBERNATION
218/* kernel/power/snapshot.c */ 218/* kernel/power/snapshot.c */
219extern void __register_nosave_region(unsigned long b, unsigned long e, int km); 219extern void __register_nosave_region(unsigned long b, unsigned long e, int km);
220static inline void register_nosave_region(unsigned long b, unsigned long e) 220static inline void __init register_nosave_region(unsigned long b, unsigned long e)
221{ 221{
222 __register_nosave_region(b, e, 0); 222 __register_nosave_region(b, e, 0);
223} 223}
224static inline void register_nosave_region_late(unsigned long b, unsigned long e) 224static inline void __init register_nosave_region_late(unsigned long b, unsigned long e)
225{ 225{
226 __register_nosave_region(b, e, 1); 226 __register_nosave_region(b, e, 1);
227} 227}
@@ -278,4 +278,6 @@ static inline void register_nosave_region_late(unsigned long b, unsigned long e)
278} 278}
279#endif 279#endif
280 280
281extern struct mutex pm_mutex;
282
281#endif /* _LINUX_SUSPEND_H */ 283#endif /* _LINUX_SUSPEND_H */
diff --git a/include/linux/swab.h b/include/linux/swab.h
new file mode 100644
index 000000000000..bbed279f3b32
--- /dev/null
+++ b/include/linux/swab.h
@@ -0,0 +1,299 @@
1#ifndef _LINUX_SWAB_H
2#define _LINUX_SWAB_H
3
4#include <linux/types.h>
5#include <linux/compiler.h>
6#include <asm/byteorder.h>
7
8/*
9 * casts are necessary for constants, because we never know how for sure
10 * how U/UL/ULL map to __u16, __u32, __u64. At least not in a portable way.
11 */
12#define __const_swab16(x) ((__u16)( \
13 (((__u16)(x) & (__u16)0x00ffU) << 8) | \
14 (((__u16)(x) & (__u16)0xff00U) >> 8)))
15
16#define __const_swab32(x) ((__u32)( \
17 (((__u32)(x) & (__u32)0x000000ffUL) << 24) | \
18 (((__u32)(x) & (__u32)0x0000ff00UL) << 8) | \
19 (((__u32)(x) & (__u32)0x00ff0000UL) >> 8) | \
20 (((__u32)(x) & (__u32)0xff000000UL) >> 24)))
21
22#define __const_swab64(x) ((__u64)( \
23 (((__u64)(x) & (__u64)0x00000000000000ffULL) << 56) | \
24 (((__u64)(x) & (__u64)0x000000000000ff00ULL) << 40) | \
25 (((__u64)(x) & (__u64)0x0000000000ff0000ULL) << 24) | \
26 (((__u64)(x) & (__u64)0x00000000ff000000ULL) << 8) | \
27 (((__u64)(x) & (__u64)0x000000ff00000000ULL) >> 8) | \
28 (((__u64)(x) & (__u64)0x0000ff0000000000ULL) >> 24) | \
29 (((__u64)(x) & (__u64)0x00ff000000000000ULL) >> 40) | \
30 (((__u64)(x) & (__u64)0xff00000000000000ULL) >> 56)))
31
32#define __const_swahw32(x) ((__u32)( \
33 (((__u32)(x) & (__u32)0x0000ffffUL) << 16) | \
34 (((__u32)(x) & (__u32)0xffff0000UL) >> 16)))
35
36#define __const_swahb32(x) ((__u32)( \
37 (((__u32)(x) & (__u32)0x00ff00ffUL) << 8) | \
38 (((__u32)(x) & (__u32)0xff00ff00UL) >> 8)))
39
40/*
41 * Implement the following as inlines, but define the interface using
42 * macros to allow constant folding when possible:
43 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
44 */
45
46static inline __attribute_const__ __u16 ___swab16(__u16 val)
47{
48#ifdef __arch_swab16
49 return __arch_swab16(val);
50#else
51 return __const_swab16(val);
52#endif
53}
54
55static inline __attribute_const__ __u32 ___swab32(__u32 val)
56{
57#ifdef __arch_swab32
58 return __arch_swab32(val);
59#else
60 return __const_swab32(val);
61#endif
62}
63
64static inline __attribute_const__ __u64 ___swab64(__u64 val)
65{
66#ifdef __arch_swab64
67 return __arch_swab64(val);
68#elif defined(__SWAB_64_THRU_32__)
69 __u32 h = val >> 32;
70 __u32 l = val & ((1ULL << 32) - 1);
71 return (((__u64)___swab32(l)) << 32) | ((__u64)(___swab32(h)));
72#else
73 return __const_swab64(val);
74#endif
75}
76
77static inline __attribute_const__ __u32 ___swahw32(__u32 val)
78{
79#ifdef __arch_swahw32
80 return __arch_swahw32(val);
81#else
82 return __const_swahw32(val);
83#endif
84}
85
86static inline __attribute_const__ __u32 ___swahb32(__u32 val)
87{
88#ifdef __arch_swahb32
89 return __arch_swahb32(val);
90#else
91 return __const_swahb32(val);
92#endif
93}
94
95/**
96 * __swab16 - return a byteswapped 16-bit value
97 * @x: value to byteswap
98 */
99#define __swab16(x) \
100 (__builtin_constant_p((__u16)(x)) ? \
101 __const_swab16((x)) : \
102 ___swab16((x)))
103
104/**
105 * __swab32 - return a byteswapped 32-bit value
106 * @x: value to byteswap
107 */
108#define __swab32(x) \
109 (__builtin_constant_p((__u32)(x)) ? \
110 __const_swab32((x)) : \
111 ___swab32((x)))
112
113/**
114 * __swab64 - return a byteswapped 64-bit value
115 * @x: value to byteswap
116 */
117#define __swab64(x) \
118 (__builtin_constant_p((__u64)(x)) ? \
119 __const_swab64((x)) : \
120 ___swab64((x)))
121
122/**
123 * __swahw32 - return a word-swapped 32-bit value
124 * @x: value to wordswap
125 *
126 * __swahw32(0x12340000) is 0x00001234
127 */
128#define __swahw32(x) \
129 (__builtin_constant_p((__u32)(x)) ? \
130 __const_swahw32((x)) : \
131 ___swahw32((x)))
132
133/**
134 * __swahb32 - return a high and low byte-swapped 32-bit value
135 * @x: value to byteswap
136 *
137 * __swahb32(0x12345678) is 0x34127856
138 */
139#define __swahb32(x) \
140 (__builtin_constant_p((__u32)(x)) ? \
141 __const_swahb32((x)) : \
142 ___swahb32((x)))
143
144/**
145 * __swab16p - return a byteswapped 16-bit value from a pointer
146 * @p: pointer to a naturally-aligned 16-bit value
147 */
148static inline __u16 __swab16p(const __u16 *p)
149{
150#ifdef __arch_swab16p
151 return __arch_swab16p(p);
152#else
153 return __swab16(*p);
154#endif
155}
156
157/**
158 * __swab32p - return a byteswapped 32-bit value from a pointer
159 * @p: pointer to a naturally-aligned 32-bit value
160 */
161static inline __u32 __swab32p(const __u32 *p)
162{
163#ifdef __arch_swab32p
164 return __arch_swab32p(p);
165#else
166 return __swab32(*p);
167#endif
168}
169
170/**
171 * __swab64p - return a byteswapped 64-bit value from a pointer
172 * @p: pointer to a naturally-aligned 64-bit value
173 */
174static inline __u64 __swab64p(const __u64 *p)
175{
176#ifdef __arch_swab64p
177 return __arch_swab64p(p);
178#else
179 return __swab64(*p);
180#endif
181}
182
183/**
184 * __swahw32p - return a wordswapped 32-bit value from a pointer
185 * @p: pointer to a naturally-aligned 32-bit value
186 *
187 * See __swahw32() for details of wordswapping.
188 */
189static inline __u32 __swahw32p(const __u32 *p)
190{
191#ifdef __arch_swahw32p
192 return __arch_swahw32p(p);
193#else
194 return __swahw32(*p);
195#endif
196}
197
198/**
199 * __swahb32p - return a high and low byteswapped 32-bit value from a pointer
200 * @p: pointer to a naturally-aligned 32-bit value
201 *
202 * See __swahb32() for details of high/low byteswapping.
203 */
204static inline __u32 __swahb32p(const __u32 *p)
205{
206#ifdef __arch_swahb32p
207 return __arch_swahb32p(p);
208#else
209 return __swahb32(*p);
210#endif
211}
212
213/**
214 * __swab16s - byteswap a 16-bit value in-place
215 * @p: pointer to a naturally-aligned 16-bit value
216 */
217static inline void __swab16s(__u16 *p)
218{
219#ifdef __arch_swab16s
220 __arch_swab16s(p);
221#else
222 *p = __swab16p(p);
223#endif
224}
225/**
226 * __swab32s - byteswap a 32-bit value in-place
227 * @p: pointer to a naturally-aligned 32-bit value
228 */
229static inline void __swab32s(__u32 *p)
230{
231#ifdef __arch_swab32s
232 __arch_swab32s(p);
233#else
234 *p = __swab32p(p);
235#endif
236}
237
238/**
239 * __swab64s - byteswap a 64-bit value in-place
240 * @p: pointer to a naturally-aligned 64-bit value
241 */
242static inline void __swab64s(__u64 *p)
243{
244#ifdef __arch_swab64s
245 __arch_swab64s(p);
246#else
247 *p = __swab64p(p);
248#endif
249}
250
251/**
252 * __swahw32s - wordswap a 32-bit value in-place
253 * @p: pointer to a naturally-aligned 32-bit value
254 *
255 * See __swahw32() for details of wordswapping
256 */
257static inline void __swahw32s(__u32 *p)
258{
259#ifdef __arch_swahw32s
260 __arch_swahw32s(p);
261#else
262 *p = __swahw32p(p);
263#endif
264}
265
266/**
267 * __swahb32s - high and low byteswap a 32-bit value in-place
268 * @p: pointer to a naturally-aligned 32-bit value
269 *
270 * See __swahb32() for details of high and low byte swapping
271 */
272static inline void __swahb32s(__u32 *p)
273{
274#ifdef __arch_swahb32s
275 __arch_swahb32s(p);
276#else
277 *p = __swahb32p(p);
278#endif
279}
280
281#ifdef __KERNEL__
282# define swab16 __swab16
283# define swab32 __swab32
284# define swab64 __swab64
285# define swahw32 __swahw32
286# define swahb32 __swahb32
287# define swab16p __swab16p
288# define swab32p __swab32p
289# define swab64p __swab64p
290# define swahw32p __swahw32p
291# define swahb32p __swahb32p
292# define swab16s __swab16s
293# define swab32s __swab32s
294# define swab64s __swab64s
295# define swahw32s __swahw32s
296# define swahb32s __swahb32s
297#endif /* __KERNEL__ */
298
299#endif /* _LINUX_SWAB_H */
diff --git a/include/linux/swap.h b/include/linux/swap.h
index 0b3377650c85..a3af95b2cb6d 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -7,6 +7,7 @@
7#include <linux/list.h> 7#include <linux/list.h>
8#include <linux/memcontrol.h> 8#include <linux/memcontrol.h>
9#include <linux/sched.h> 9#include <linux/sched.h>
10#include <linux/node.h>
10 11
11#include <asm/atomic.h> 12#include <asm/atomic.h>
12#include <asm/page.h> 13#include <asm/page.h>
@@ -171,8 +172,10 @@ extern unsigned int nr_free_pagecache_pages(void);
171 172
172 173
173/* linux/mm/swap.c */ 174/* linux/mm/swap.c */
174extern void lru_cache_add(struct page *); 175extern void __lru_cache_add(struct page *, enum lru_list lru);
175extern void lru_cache_add_active(struct page *); 176extern void lru_cache_add_lru(struct page *, enum lru_list lru);
177extern void lru_cache_add_active_or_unevictable(struct page *,
178 struct vm_area_struct *);
176extern void activate_page(struct page *); 179extern void activate_page(struct page *);
177extern void mark_page_accessed(struct page *); 180extern void mark_page_accessed(struct page *);
178extern void lru_add_drain(void); 181extern void lru_add_drain(void);
@@ -180,12 +183,38 @@ extern int lru_add_drain_all(void);
180extern void rotate_reclaimable_page(struct page *page); 183extern void rotate_reclaimable_page(struct page *page);
181extern void swap_setup(void); 184extern void swap_setup(void);
182 185
186extern void add_page_to_unevictable_list(struct page *page);
187
188/**
189 * lru_cache_add: add a page to the page lists
190 * @page: the page to add
191 */
192static inline void lru_cache_add_anon(struct page *page)
193{
194 __lru_cache_add(page, LRU_INACTIVE_ANON);
195}
196
197static inline void lru_cache_add_active_anon(struct page *page)
198{
199 __lru_cache_add(page, LRU_ACTIVE_ANON);
200}
201
202static inline void lru_cache_add_file(struct page *page)
203{
204 __lru_cache_add(page, LRU_INACTIVE_FILE);
205}
206
207static inline void lru_cache_add_active_file(struct page *page)
208{
209 __lru_cache_add(page, LRU_ACTIVE_FILE);
210}
211
183/* linux/mm/vmscan.c */ 212/* linux/mm/vmscan.c */
184extern unsigned long try_to_free_pages(struct zonelist *zonelist, int order, 213extern unsigned long try_to_free_pages(struct zonelist *zonelist, int order,
185 gfp_t gfp_mask); 214 gfp_t gfp_mask);
186extern unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem, 215extern unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem,
187 gfp_t gfp_mask); 216 gfp_t gfp_mask);
188extern int __isolate_lru_page(struct page *page, int mode); 217extern int __isolate_lru_page(struct page *page, int mode, int file);
189extern unsigned long shrink_all_memory(unsigned long nr_pages); 218extern unsigned long shrink_all_memory(unsigned long nr_pages);
190extern int vm_swappiness; 219extern int vm_swappiness;
191extern int remove_mapping(struct address_space *mapping, struct page *page); 220extern int remove_mapping(struct address_space *mapping, struct page *page);
@@ -204,6 +233,34 @@ static inline int zone_reclaim(struct zone *z, gfp_t mask, unsigned int order)
204} 233}
205#endif 234#endif
206 235
236#ifdef CONFIG_UNEVICTABLE_LRU
237extern int page_evictable(struct page *page, struct vm_area_struct *vma);
238extern void scan_mapping_unevictable_pages(struct address_space *);
239
240extern unsigned long scan_unevictable_pages;
241extern int scan_unevictable_handler(struct ctl_table *, int, struct file *,
242 void __user *, size_t *, loff_t *);
243extern int scan_unevictable_register_node(struct node *node);
244extern void scan_unevictable_unregister_node(struct node *node);
245#else
246static inline int page_evictable(struct page *page,
247 struct vm_area_struct *vma)
248{
249 return 1;
250}
251
252static inline void scan_mapping_unevictable_pages(struct address_space *mapping)
253{
254}
255
256static inline int scan_unevictable_register_node(struct node *node)
257{
258 return 0;
259}
260
261static inline void scan_unevictable_unregister_node(struct node *node) { }
262#endif
263
207extern int kswapd_run(int nid); 264extern int kswapd_run(int nid);
208 265
209#ifdef CONFIG_MMU 266#ifdef CONFIG_MMU
@@ -237,7 +294,6 @@ extern struct page *swapin_readahead(swp_entry_t, gfp_t,
237 294
238/* linux/mm/swapfile.c */ 295/* linux/mm/swapfile.c */
239extern long total_swap_pages; 296extern long total_swap_pages;
240extern unsigned int nr_swapfiles;
241extern void si_swapinfo(struct sysinfo *); 297extern void si_swapinfo(struct sysinfo *);
242extern swp_entry_t get_swap_page(void); 298extern swp_entry_t get_swap_page(void);
243extern swp_entry_t get_swap_page_of_type(int); 299extern swp_entry_t get_swap_page_of_type(int);
@@ -252,10 +308,9 @@ extern sector_t swapdev_block(int, pgoff_t);
252extern struct swap_info_struct *get_swap_info_struct(unsigned); 308extern struct swap_info_struct *get_swap_info_struct(unsigned);
253extern int can_share_swap_page(struct page *); 309extern int can_share_swap_page(struct page *);
254extern int remove_exclusive_swap_page(struct page *); 310extern int remove_exclusive_swap_page(struct page *);
311extern int remove_exclusive_swap_page_ref(struct page *);
255struct backing_dev_info; 312struct backing_dev_info;
256 313
257extern spinlock_t swap_lock;
258
259/* linux/mm/thrash.c */ 314/* linux/mm/thrash.c */
260extern struct mm_struct * swap_token_mm; 315extern struct mm_struct * swap_token_mm;
261extern void grab_swap_token(void); 316extern void grab_swap_token(void);
@@ -342,6 +397,11 @@ static inline int remove_exclusive_swap_page(struct page *p)
342 return 0; 397 return 0;
343} 398}
344 399
400static inline int remove_exclusive_swap_page_ref(struct page *page)
401{
402 return 0;
403}
404
345static inline swp_entry_t get_swap_page(void) 405static inline swp_entry_t get_swap_page(void)
346{ 406{
347 swp_entry_t entry; 407 swp_entry_t entry;
diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
new file mode 100644
index 000000000000..b18ec5533e8c
--- /dev/null
+++ b/include/linux/swiotlb.h
@@ -0,0 +1,83 @@
1#ifndef __LINUX_SWIOTLB_H
2#define __LINUX_SWIOTLB_H
3
4#include <linux/types.h>
5
6struct device;
7struct dma_attrs;
8struct scatterlist;
9
10extern void
11swiotlb_init(void);
12
13extern void
14*swiotlb_alloc_coherent(struct device *hwdev, size_t size,
15 dma_addr_t *dma_handle, gfp_t flags);
16
17extern void
18swiotlb_free_coherent(struct device *hwdev, size_t size,
19 void *vaddr, dma_addr_t dma_handle);
20
21extern dma_addr_t
22swiotlb_map_single(struct device *hwdev, void *ptr, size_t size, int dir);
23
24extern void
25swiotlb_unmap_single(struct device *hwdev, dma_addr_t dev_addr,
26 size_t size, int dir);
27
28extern dma_addr_t
29swiotlb_map_single_attrs(struct device *hwdev, void *ptr, size_t size,
30 int dir, struct dma_attrs *attrs);
31
32extern void
33swiotlb_unmap_single_attrs(struct device *hwdev, dma_addr_t dev_addr,
34 size_t size, int dir, struct dma_attrs *attrs);
35
36extern int
37swiotlb_map_sg(struct device *hwdev, struct scatterlist *sg, int nents,
38 int direction);
39
40extern void
41swiotlb_unmap_sg(struct device *hwdev, struct scatterlist *sg, int nents,
42 int direction);
43
44extern int
45swiotlb_map_sg_attrs(struct device *hwdev, struct scatterlist *sgl, int nelems,
46 int dir, struct dma_attrs *attrs);
47
48extern void
49swiotlb_unmap_sg_attrs(struct device *hwdev, struct scatterlist *sgl,
50 int nelems, int dir, struct dma_attrs *attrs);
51
52extern void
53swiotlb_sync_single_for_cpu(struct device *hwdev, dma_addr_t dev_addr,
54 size_t size, int dir);
55
56extern void
57swiotlb_sync_sg_for_cpu(struct device *hwdev, struct scatterlist *sg,
58 int nelems, int dir);
59
60extern void
61swiotlb_sync_single_for_device(struct device *hwdev, dma_addr_t dev_addr,
62 size_t size, int dir);
63
64extern void
65swiotlb_sync_sg_for_device(struct device *hwdev, struct scatterlist *sg,
66 int nelems, int dir);
67
68extern void
69swiotlb_sync_single_range_for_cpu(struct device *hwdev, dma_addr_t dev_addr,
70 unsigned long offset, size_t size, int dir);
71
72extern void
73swiotlb_sync_single_range_for_device(struct device *hwdev, dma_addr_t dev_addr,
74 unsigned long offset, size_t size,
75 int dir);
76
77extern int
78swiotlb_dma_mapping_error(struct device *hwdev, dma_addr_t dma_addr);
79
80extern int
81swiotlb_dma_supported(struct device *hwdev, u64 mask);
82
83#endif /* __LINUX_SWIOTLB_H */
diff --git a/include/linux/synclink.h b/include/linux/synclink.h
index 45f6bc82d317..c844a229acc9 100644
--- a/include/linux/synclink.h
+++ b/include/linux/synclink.h
@@ -136,6 +136,7 @@
136#define MGSL_INTERFACE_RTS_EN 0x10 136#define MGSL_INTERFACE_RTS_EN 0x10
137#define MGSL_INTERFACE_LL 0x20 137#define MGSL_INTERFACE_LL 0x20
138#define MGSL_INTERFACE_RL 0x40 138#define MGSL_INTERFACE_RL 0x40
139#define MGSL_INTERFACE_MSB_FIRST 0x80
139 140
140typedef struct _MGSL_PARAMS 141typedef struct _MGSL_PARAMS
141{ 142{
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 0522f368f9d7..d6ff145919ca 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -305,6 +305,7 @@ asmlinkage long sys_fcntl64(unsigned int fd,
305#endif 305#endif
306asmlinkage long sys_dup(unsigned int fildes); 306asmlinkage long sys_dup(unsigned int fildes);
307asmlinkage long sys_dup2(unsigned int oldfd, unsigned int newfd); 307asmlinkage long sys_dup2(unsigned int oldfd, unsigned int newfd);
308asmlinkage long sys_dup3(unsigned int oldfd, unsigned int newfd, int flags);
308asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int on); 309asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int on);
309asmlinkage long sys_ioctl(unsigned int fd, unsigned int cmd, 310asmlinkage long sys_ioctl(unsigned int fd, unsigned int cmd,
310 unsigned long arg); 311 unsigned long arg);
@@ -409,6 +410,8 @@ asmlinkage long sys_getsockopt(int fd, int level, int optname,
409asmlinkage long sys_bind(int, struct sockaddr __user *, int); 410asmlinkage long sys_bind(int, struct sockaddr __user *, int);
410asmlinkage long sys_connect(int, struct sockaddr __user *, int); 411asmlinkage long sys_connect(int, struct sockaddr __user *, int);
411asmlinkage long sys_accept(int, struct sockaddr __user *, int __user *); 412asmlinkage long sys_accept(int, struct sockaddr __user *, int __user *);
413asmlinkage long sys_paccept(int, struct sockaddr __user *, int __user *,
414 const __user sigset_t *, size_t, int);
412asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *); 415asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
413asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *); 416asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
414asmlinkage long sys_send(int, void __user *, size_t, unsigned); 417asmlinkage long sys_send(int, void __user *, size_t, unsigned);
@@ -428,6 +431,7 @@ asmlinkage long sys_poll(struct pollfd __user *ufds, unsigned int nfds,
428asmlinkage long sys_select(int n, fd_set __user *inp, fd_set __user *outp, 431asmlinkage long sys_select(int n, fd_set __user *inp, fd_set __user *outp,
429 fd_set __user *exp, struct timeval __user *tvp); 432 fd_set __user *exp, struct timeval __user *tvp);
430asmlinkage long sys_epoll_create(int size); 433asmlinkage long sys_epoll_create(int size);
434asmlinkage long sys_epoll_create1(int flags);
431asmlinkage long sys_epoll_ctl(int epfd, int op, int fd, 435asmlinkage long sys_epoll_ctl(int epfd, int op, int fd,
432 struct epoll_event __user *event); 436 struct epoll_event __user *event);
433asmlinkage long sys_epoll_wait(int epfd, struct epoll_event __user *events, 437asmlinkage long sys_epoll_wait(int epfd, struct epoll_event __user *events,
@@ -443,7 +447,7 @@ asmlinkage long sys_newuname(struct new_utsname __user *name);
443 447
444asmlinkage long sys_getrlimit(unsigned int resource, 448asmlinkage long sys_getrlimit(unsigned int resource,
445 struct rlimit __user *rlim); 449 struct rlimit __user *rlim);
446#if defined(COMPAT_RLIM_OLD_INFINITY) || !(defined(CONFIG_IA64) || defined(CONFIG_V850)) 450#if defined(COMPAT_RLIM_OLD_INFINITY) || !(defined(CONFIG_IA64))
447asmlinkage long sys_old_getrlimit(unsigned int resource, struct rlimit __user *rlim); 451asmlinkage long sys_old_getrlimit(unsigned int resource, struct rlimit __user *rlim);
448#endif 452#endif
449asmlinkage long sys_setrlimit(unsigned int resource, 453asmlinkage long sys_setrlimit(unsigned int resource,
@@ -543,6 +547,7 @@ asmlinkage long sys_get_mempolicy(int __user *policy,
543 unsigned long addr, unsigned long flags); 547 unsigned long addr, unsigned long flags);
544 548
545asmlinkage long sys_inotify_init(void); 549asmlinkage long sys_inotify_init(void);
550asmlinkage long sys_inotify_init1(int flags);
546asmlinkage long sys_inotify_add_watch(int fd, const char __user *path, 551asmlinkage long sys_inotify_add_watch(int fd, const char __user *path,
547 u32 mask); 552 u32 mask);
548asmlinkage long sys_inotify_rm_watch(int fd, u32 wd); 553asmlinkage long sys_inotify_rm_watch(int fd, u32 wd);
@@ -608,12 +613,14 @@ asmlinkage long sys_set_robust_list(struct robust_list_head __user *head,
608 size_t len); 613 size_t len);
609asmlinkage long sys_getcpu(unsigned __user *cpu, unsigned __user *node, struct getcpu_cache __user *cache); 614asmlinkage long sys_getcpu(unsigned __user *cpu, unsigned __user *node, struct getcpu_cache __user *cache);
610asmlinkage long sys_signalfd(int ufd, sigset_t __user *user_mask, size_t sizemask); 615asmlinkage long sys_signalfd(int ufd, sigset_t __user *user_mask, size_t sizemask);
616asmlinkage long sys_signalfd4(int ufd, sigset_t __user *user_mask, size_t sizemask, int flags);
611asmlinkage long sys_timerfd_create(int clockid, int flags); 617asmlinkage long sys_timerfd_create(int clockid, int flags);
612asmlinkage long sys_timerfd_settime(int ufd, int flags, 618asmlinkage long sys_timerfd_settime(int ufd, int flags,
613 const struct itimerspec __user *utmr, 619 const struct itimerspec __user *utmr,
614 struct itimerspec __user *otmr); 620 struct itimerspec __user *otmr);
615asmlinkage long sys_timerfd_gettime(int ufd, struct itimerspec __user *otmr); 621asmlinkage long sys_timerfd_gettime(int ufd, struct itimerspec __user *otmr);
616asmlinkage long sys_eventfd(unsigned int count); 622asmlinkage long sys_eventfd(unsigned int count);
623asmlinkage long sys_eventfd2(unsigned int count, int flags);
617asmlinkage long sys_fallocate(int fd, int mode, loff_t offset, loff_t len); 624asmlinkage long sys_fallocate(int fd, int mode, loff_t offset, loff_t len);
618 625
619int kernel_execve(const char *filename, char *const argv[], char *const envp[]); 626int kernel_execve(const char *filename, char *const argv[], char *const envp[]);
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index 24141b4d1a11..39d471d1163b 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -947,6 +947,22 @@ struct ctl_table;
947struct nsproxy; 947struct nsproxy;
948struct ctl_table_root; 948struct ctl_table_root;
949 949
950struct ctl_table_set {
951 struct list_head list;
952 struct ctl_table_set *parent;
953 int (*is_seen)(struct ctl_table_set *);
954};
955
956extern void setup_sysctl_set(struct ctl_table_set *p,
957 struct ctl_table_set *parent,
958 int (*is_seen)(struct ctl_table_set *));
959
960struct ctl_table_header;
961
962extern void sysctl_head_get(struct ctl_table_header *);
963extern void sysctl_head_put(struct ctl_table_header *);
964extern int sysctl_is_seen(struct ctl_table_header *);
965extern struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *);
950extern struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev); 966extern struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev);
951extern struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces, 967extern struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces,
952 struct ctl_table_header *prev); 968 struct ctl_table_header *prev);
@@ -956,7 +972,7 @@ extern int sysctl_perm(struct ctl_table_root *root,
956 972
957typedef struct ctl_table ctl_table; 973typedef struct ctl_table ctl_table;
958 974
959typedef int ctl_handler (struct ctl_table *table, int __user *name, int nlen, 975typedef int ctl_handler (struct ctl_table *table,
960 void __user *oldval, size_t __user *oldlenp, 976 void __user *oldval, size_t __user *oldlenp,
961 void __user *newval, size_t newlen); 977 void __user *newval, size_t newlen);
962 978
@@ -1049,8 +1065,8 @@ struct ctl_table
1049 1065
1050struct ctl_table_root { 1066struct ctl_table_root {
1051 struct list_head root_list; 1067 struct list_head root_list;
1052 struct list_head header_list; 1068 struct ctl_table_set default_set;
1053 struct list_head *(*lookup)(struct ctl_table_root *root, 1069 struct ctl_table_set *(*lookup)(struct ctl_table_root *root,
1054 struct nsproxy *namespaces); 1070 struct nsproxy *namespaces);
1055 int (*permissions)(struct ctl_table_root *root, 1071 int (*permissions)(struct ctl_table_root *root,
1056 struct nsproxy *namespaces, struct ctl_table *table); 1072 struct nsproxy *namespaces, struct ctl_table *table);
@@ -1063,9 +1079,14 @@ struct ctl_table_header
1063 struct ctl_table *ctl_table; 1079 struct ctl_table *ctl_table;
1064 struct list_head ctl_entry; 1080 struct list_head ctl_entry;
1065 int used; 1081 int used;
1082 int count;
1066 struct completion *unregistering; 1083 struct completion *unregistering;
1067 struct ctl_table *ctl_table_arg; 1084 struct ctl_table *ctl_table_arg;
1068 struct ctl_table_root *root; 1085 struct ctl_table_root *root;
1086 struct ctl_table_set *set;
1087 struct ctl_table *attached_by;
1088 struct ctl_table *attached_to;
1089 struct ctl_table_header *parent;
1069}; 1090};
1070 1091
1071/* struct ctl_path describes where in the hierarchy a table is added */ 1092/* struct ctl_path describes where in the hierarchy a table is added */
diff --git a/include/linux/sysdev.h b/include/linux/sysdev.h
index f2767bc6b735..f395bb3fa2f2 100644
--- a/include/linux/sysdev.h
+++ b/include/linux/sysdev.h
@@ -99,8 +99,9 @@ extern void sysdev_unregister(struct sys_device *);
99 99
100struct sysdev_attribute { 100struct sysdev_attribute {
101 struct attribute attr; 101 struct attribute attr;
102 ssize_t (*show)(struct sys_device *, char *); 102 ssize_t (*show)(struct sys_device *, struct sysdev_attribute *, char *);
103 ssize_t (*store)(struct sys_device *, const char *, size_t); 103 ssize_t (*store)(struct sys_device *, struct sysdev_attribute *,
104 const char *, size_t);
104}; 105};
105 106
106 107
@@ -118,4 +119,38 @@ struct sysdev_attribute {
118extern int sysdev_create_file(struct sys_device *, struct sysdev_attribute *); 119extern int sysdev_create_file(struct sys_device *, struct sysdev_attribute *);
119extern void sysdev_remove_file(struct sys_device *, struct sysdev_attribute *); 120extern void sysdev_remove_file(struct sys_device *, struct sysdev_attribute *);
120 121
122struct sysdev_ext_attribute {
123 struct sysdev_attribute attr;
124 void *var;
125};
126
127/*
128 * Support for simple variable sysdev attributes.
129 * The pointer to the variable is stored in a sysdev_ext_attribute
130 */
131
132/* Add more types as needed */
133
134extern ssize_t sysdev_show_ulong(struct sys_device *, struct sysdev_attribute *,
135 char *);
136extern ssize_t sysdev_store_ulong(struct sys_device *,
137 struct sysdev_attribute *, const char *, size_t);
138extern ssize_t sysdev_show_int(struct sys_device *, struct sysdev_attribute *,
139 char *);
140extern ssize_t sysdev_store_int(struct sys_device *,
141 struct sysdev_attribute *, const char *, size_t);
142
143#define _SYSDEV_ULONG_ATTR(_name, _mode, _var) \
144 { _SYSDEV_ATTR(_name, _mode, sysdev_show_ulong, sysdev_store_ulong), \
145 &(_var) }
146#define SYSDEV_ULONG_ATTR(_name, _mode, _var) \
147 struct sysdev_ext_attribute attr_##_name = \
148 _SYSDEV_ULONG_ATTR(_name, _mode, _var);
149#define _SYSDEV_INT_ATTR(_name, _mode, _var) \
150 { _SYSDEV_ATTR(_name, _mode, sysdev_show_int, sysdev_store_int), \
151 &(_var) }
152#define SYSDEV_INT_ATTR(_name, _mode, _var) \
153 struct sysdev_ext_attribute attr_##_name = \
154 _SYSDEV_INT_ATTR(_name, _mode, _var);
155
121#endif /* _SYSDEV_H_ */ 156#endif /* _SYSDEV_H_ */
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
index 7858eac40aa7..9d68fed50f11 100644
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -21,8 +21,9 @@ struct kobject;
21struct module; 21struct module;
22 22
23/* FIXME 23/* FIXME
24 * The *owner field is no longer used, but leave around 24 * The *owner field is no longer used.
25 * until the tree gets cleaned up fully. 25 * x86 tree has been cleaned up. The owner
26 * attribute is still left for other arches.
26 */ 27 */
27struct attribute { 28struct attribute {
28 const char *name; 29 const char *name;
@@ -78,6 +79,8 @@ struct sysfs_ops {
78 ssize_t (*store)(struct kobject *,struct attribute *,const char *, size_t); 79 ssize_t (*store)(struct kobject *,struct attribute *,const char *, size_t);
79}; 80};
80 81
82struct sysfs_dirent;
83
81#ifdef CONFIG_SYSFS 84#ifdef CONFIG_SYSFS
82 85
83int sysfs_schedule_callback(struct kobject *kobj, void (*func)(void *), 86int sysfs_schedule_callback(struct kobject *kobj, void (*func)(void *),
@@ -101,6 +104,9 @@ void sysfs_remove_bin_file(struct kobject *kobj, struct bin_attribute *attr);
101 104
102int __must_check sysfs_create_link(struct kobject *kobj, struct kobject *target, 105int __must_check sysfs_create_link(struct kobject *kobj, struct kobject *target,
103 const char *name); 106 const char *name);
107int __must_check sysfs_create_link_nowarn(struct kobject *kobj,
108 struct kobject *target,
109 const char *name);
104void sysfs_remove_link(struct kobject *kobj, const char *name); 110void sysfs_remove_link(struct kobject *kobj, const char *name);
105 111
106int __must_check sysfs_create_group(struct kobject *kobj, 112int __must_check sysfs_create_group(struct kobject *kobj,
@@ -114,9 +120,14 @@ int sysfs_add_file_to_group(struct kobject *kobj,
114void sysfs_remove_file_from_group(struct kobject *kobj, 120void sysfs_remove_file_from_group(struct kobject *kobj,
115 const struct attribute *attr, const char *group); 121 const struct attribute *attr, const char *group);
116 122
117void sysfs_notify(struct kobject *kobj, char *dir, char *attr); 123void sysfs_notify(struct kobject *kobj, const char *dir, const char *attr);
118 124void sysfs_notify_dirent(struct sysfs_dirent *sd);
119extern int __must_check sysfs_init(void); 125struct sysfs_dirent *sysfs_get_dirent(struct sysfs_dirent *parent_sd,
126 const unsigned char *name);
127struct sysfs_dirent *sysfs_get(struct sysfs_dirent *sd);
128void sysfs_put(struct sysfs_dirent *sd);
129void sysfs_printk_last_file(void);
130int __must_check sysfs_init(void);
120 131
121#else /* CONFIG_SYSFS */ 132#else /* CONFIG_SYSFS */
122 133
@@ -180,6 +191,13 @@ static inline int sysfs_create_link(struct kobject *kobj,
180 return 0; 191 return 0;
181} 192}
182 193
194static inline int sysfs_create_link_nowarn(struct kobject *kobj,
195 struct kobject *target,
196 const char *name)
197{
198 return 0;
199}
200
183static inline void sysfs_remove_link(struct kobject *kobj, const char *name) 201static inline void sysfs_remove_link(struct kobject *kobj, const char *name)
184{ 202{
185} 203}
@@ -212,7 +230,24 @@ static inline void sysfs_remove_file_from_group(struct kobject *kobj,
212{ 230{
213} 231}
214 232
215static inline void sysfs_notify(struct kobject *kobj, char *dir, char *attr) 233static inline void sysfs_notify(struct kobject *kobj, const char *dir,
234 const char *attr)
235{
236}
237static inline void sysfs_notify_dirent(struct sysfs_dirent *sd)
238{
239}
240static inline
241struct sysfs_dirent *sysfs_get_dirent(struct sysfs_dirent *parent_sd,
242 const unsigned char *name)
243{
244 return NULL;
245}
246static inline struct sysfs_dirent *sysfs_get(struct sysfs_dirent *sd)
247{
248 return NULL;
249}
250static inline void sysfs_put(struct sysfs_dirent *sd)
216{ 251{
217} 252}
218 253
@@ -221,6 +256,10 @@ static inline int __must_check sysfs_init(void)
221 return 0; 256 return 0;
222} 257}
223 258
259static inline void sysfs_printk_last_file(void)
260{
261}
262
224#endif /* CONFIG_SYSFS */ 263#endif /* CONFIG_SYSFS */
225 264
226#endif /* _SYSFS_H_ */ 265#endif /* _SYSFS_H_ */
diff --git a/include/linux/task_io_accounting.h b/include/linux/task_io_accounting.h
index 44d00e9cceea..bdf855c2856f 100644
--- a/include/linux/task_io_accounting.h
+++ b/include/linux/task_io_accounting.h
@@ -5,11 +5,22 @@
5 * Don't include this header file directly - it is designed to be dragged in via 5 * Don't include this header file directly - it is designed to be dragged in via
6 * sched.h. 6 * sched.h.
7 * 7 *
8 * Blame akpm@osdl.org for all this. 8 * Blame Andrew Morton for all this.
9 */ 9 */
10 10
11#ifdef CONFIG_TASK_IO_ACCOUNTING
12struct task_io_accounting { 11struct task_io_accounting {
12#ifdef CONFIG_TASK_XACCT
13 /* bytes read */
14 u64 rchar;
15 /* bytes written */
16 u64 wchar;
17 /* # of read syscalls */
18 u64 syscr;
19 /* # of write syscalls */
20 u64 syscw;
21#endif /* CONFIG_TASK_XACCT */
22
23#ifdef CONFIG_TASK_IO_ACCOUNTING
13 /* 24 /*
14 * The number of bytes which this task has caused to be read from 25 * The number of bytes which this task has caused to be read from
15 * storage. 26 * storage.
@@ -30,8 +41,5 @@ struct task_io_accounting {
30 * information loss in doing that. 41 * information loss in doing that.
31 */ 42 */
32 u64 cancelled_write_bytes; 43 u64 cancelled_write_bytes;
44#endif /* CONFIG_TASK_IO_ACCOUNTING */
33}; 45};
34#else
35struct task_io_accounting {
36};
37#endif
diff --git a/include/linux/task_io_accounting_ops.h b/include/linux/task_io_accounting_ops.h
index ff46c6fad79d..4d090f9ee608 100644
--- a/include/linux/task_io_accounting_ops.h
+++ b/include/linux/task_io_accounting_ops.h
@@ -40,9 +40,17 @@ static inline void task_io_account_cancelled_write(size_t bytes)
40 current->ioac.cancelled_write_bytes += bytes; 40 current->ioac.cancelled_write_bytes += bytes;
41} 41}
42 42
43static inline void task_io_accounting_init(struct task_struct *tsk) 43static inline void task_io_accounting_init(struct task_io_accounting *ioac)
44{ 44{
45 memset(&tsk->ioac, 0, sizeof(tsk->ioac)); 45 memset(ioac, 0, sizeof(*ioac));
46}
47
48static inline void task_blk_io_accounting_add(struct task_io_accounting *dst,
49 struct task_io_accounting *src)
50{
51 dst->read_bytes += src->read_bytes;
52 dst->write_bytes += src->write_bytes;
53 dst->cancelled_write_bytes += src->cancelled_write_bytes;
46} 54}
47 55
48#else 56#else
@@ -69,9 +77,37 @@ static inline void task_io_account_cancelled_write(size_t bytes)
69{ 77{
70} 78}
71 79
72static inline void task_io_accounting_init(struct task_struct *tsk) 80static inline void task_io_accounting_init(struct task_io_accounting *ioac)
81{
82}
83
84static inline void task_blk_io_accounting_add(struct task_io_accounting *dst,
85 struct task_io_accounting *src)
73{ 86{
74} 87}
75 88
76#endif /* CONFIG_TASK_IO_ACCOUNTING */ 89#endif /* CONFIG_TASK_IO_ACCOUNTING */
77#endif /* __TASK_IO_ACCOUNTING_OPS_INCLUDED */ 90
91#ifdef CONFIG_TASK_XACCT
92static inline void task_chr_io_accounting_add(struct task_io_accounting *dst,
93 struct task_io_accounting *src)
94{
95 dst->rchar += src->rchar;
96 dst->wchar += src->wchar;
97 dst->syscr += src->syscr;
98 dst->syscw += src->syscw;
99}
100#else
101static inline void task_chr_io_accounting_add(struct task_io_accounting *dst,
102 struct task_io_accounting *src)
103{
104}
105#endif /* CONFIG_TASK_XACCT */
106
107static inline void task_io_accounting_add(struct task_io_accounting *dst,
108 struct task_io_accounting *src)
109{
110 task_chr_io_accounting_add(dst, src);
111 task_blk_io_accounting_add(dst, src);
112}
113#endif /* __TASK_IO_ACCOUNTING_OPS_INCLUDED */
diff --git a/include/linux/taskstats.h b/include/linux/taskstats.h
index 5d69c0744fff..18269e956a71 100644
--- a/include/linux/taskstats.h
+++ b/include/linux/taskstats.h
@@ -31,7 +31,7 @@
31 */ 31 */
32 32
33 33
34#define TASKSTATS_VERSION 6 34#define TASKSTATS_VERSION 7
35#define TS_COMM_LEN 32 /* should be >= TASK_COMM_LEN 35#define TS_COMM_LEN 32 /* should be >= TASK_COMM_LEN
36 * in linux/sched.h */ 36 * in linux/sched.h */
37 37
@@ -157,6 +157,10 @@ struct taskstats {
157 __u64 ac_utimescaled; /* utime scaled on frequency etc */ 157 __u64 ac_utimescaled; /* utime scaled on frequency etc */
158 __u64 ac_stimescaled; /* stime scaled on frequency etc */ 158 __u64 ac_stimescaled; /* stime scaled on frequency etc */
159 __u64 cpu_scaled_run_real_total; /* scaled cpu_run_real_total */ 159 __u64 cpu_scaled_run_real_total; /* scaled cpu_run_real_total */
160
161 /* Delay waiting for memory reclaim */
162 __u64 freepages_count;
163 __u64 freepages_delay_total;
160}; 164};
161 165
162 166
diff --git a/include/linux/tc_act/Kbuild b/include/linux/tc_act/Kbuild
index 6dac0d7365cc..76990937f4c9 100644
--- a/include/linux/tc_act/Kbuild
+++ b/include/linux/tc_act/Kbuild
@@ -3,3 +3,4 @@ header-y += tc_ipt.h
3header-y += tc_mirred.h 3header-y += tc_mirred.h
4header-y += tc_pedit.h 4header-y += tc_pedit.h
5header-y += tc_nat.h 5header-y += tc_nat.h
6header-y += tc_skbedit.h
diff --git a/include/linux/tc_act/tc_skbedit.h b/include/linux/tc_act/tc_skbedit.h
new file mode 100644
index 000000000000..a14e461a7af7
--- /dev/null
+++ b/include/linux/tc_act/tc_skbedit.h
@@ -0,0 +1,44 @@
1/*
2 * Copyright (c) 2008, Intel Corporation.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
15 * Place - Suite 330, Boston, MA 02111-1307 USA.
16 *
17 * Author: Alexander Duyck <alexander.h.duyck@intel.com>
18 */
19
20#ifndef __LINUX_TC_SKBEDIT_H
21#define __LINUX_TC_SKBEDIT_H
22
23#include <linux/pkt_cls.h>
24
25#define TCA_ACT_SKBEDIT 11
26
27#define SKBEDIT_F_PRIORITY 0x1
28#define SKBEDIT_F_QUEUE_MAPPING 0x2
29
30struct tc_skbedit {
31 tc_gen;
32};
33
34enum {
35 TCA_SKBEDIT_UNSPEC,
36 TCA_SKBEDIT_TM,
37 TCA_SKBEDIT_PARMS,
38 TCA_SKBEDIT_PRIORITY,
39 TCA_SKBEDIT_QUEUE_MAPPING,
40 __TCA_SKBEDIT_MAX
41};
42#define TCA_SKBEDIT_MAX (__TCA_SKBEDIT_MAX - 1)
43
44#endif
diff --git a/include/linux/tcp.h b/include/linux/tcp.h
index b31b6b74aa28..fe77e1499ab7 100644
--- a/include/linux/tcp.h
+++ b/include/linux/tcp.h
@@ -224,6 +224,12 @@ struct tcp_options_received {
224 u16 mss_clamp; /* Maximal mss, negotiated at connection setup */ 224 u16 mss_clamp; /* Maximal mss, negotiated at connection setup */
225}; 225};
226 226
227/* This is the max number of SACKS that we'll generate and process. It's safe
228 * to increse this, although since:
229 * size = TCPOLEN_SACK_BASE_ALIGNED (4) + n * TCPOLEN_SACK_PERBLOCK (8)
230 * only four options will fit in a standard TCP header */
231#define TCP_NUM_SACKS 4
232
227struct tcp_request_sock { 233struct tcp_request_sock {
228 struct inet_request_sock req; 234 struct inet_request_sock req;
229#ifdef CONFIG_TCP_MD5SIG 235#ifdef CONFIG_TCP_MD5SIG
@@ -291,10 +297,9 @@ struct tcp_sock {
291 u32 rcv_ssthresh; /* Current window clamp */ 297 u32 rcv_ssthresh; /* Current window clamp */
292 298
293 u32 frto_highmark; /* snd_nxt when RTO occurred */ 299 u32 frto_highmark; /* snd_nxt when RTO occurred */
294 u8 reordering; /* Packet reordering metric. */ 300 u16 advmss; /* Advertised MSS */
295 u8 frto_counter; /* Number of new acks after RTO */ 301 u8 frto_counter; /* Number of new acks after RTO */
296 u8 nonagle; /* Disable Nagle algorithm? */ 302 u8 nonagle; /* Disable Nagle algorithm? */
297 u8 keepalive_probes; /* num of allowed keep alive probes */
298 303
299/* RTT measurement */ 304/* RTT measurement */
300 u32 srtt; /* smoothed round trip time << 3 */ 305 u32 srtt; /* smoothed round trip time << 3 */
@@ -305,6 +310,13 @@ struct tcp_sock {
305 310
306 u32 packets_out; /* Packets which are "in flight" */ 311 u32 packets_out; /* Packets which are "in flight" */
307 u32 retrans_out; /* Retransmitted packets out */ 312 u32 retrans_out; /* Retransmitted packets out */
313
314 u16 urg_data; /* Saved octet of OOB data and control flags */
315 u8 ecn_flags; /* ECN status bits. */
316 u8 reordering; /* Packet reordering metric. */
317 u32 snd_up; /* Urgent pointer */
318
319 u8 keepalive_probes; /* num of allowed keep alive probes */
308/* 320/*
309 * Options received (usually on last packet, some only on SYN packets). 321 * Options received (usually on last packet, some only on SYN packets).
310 */ 322 */
@@ -320,13 +332,23 @@ struct tcp_sock {
320 u32 snd_cwnd_used; 332 u32 snd_cwnd_used;
321 u32 snd_cwnd_stamp; 333 u32 snd_cwnd_stamp;
322 334
323 struct sk_buff_head out_of_order_queue; /* Out of order segments go here */
324
325 u32 rcv_wnd; /* Current receiver window */ 335 u32 rcv_wnd; /* Current receiver window */
326 u32 write_seq; /* Tail(+1) of data held in tcp send buffer */ 336 u32 write_seq; /* Tail(+1) of data held in tcp send buffer */
327 u32 pushed_seq; /* Last pushed seq, required to talk to windows */ 337 u32 pushed_seq; /* Last pushed seq, required to talk to windows */
338 u32 lost_out; /* Lost packets */
339 u32 sacked_out; /* SACK'd packets */
340 u32 fackets_out; /* FACK'd packets */
341 u32 tso_deferred;
342 u32 bytes_acked; /* Appropriate Byte Counting - RFC3465 */
328 343
329/* SACKs data */ 344 /* from STCP, retrans queue hinting */
345 struct sk_buff* lost_skb_hint;
346 struct sk_buff *scoreboard_skb_hint;
347 struct sk_buff *retransmit_skb_hint;
348
349 struct sk_buff_head out_of_order_queue; /* Out of order segments go here */
350
351 /* SACKs data, these 2 need to be together (see tcp_build_and_update_options) */
330 struct tcp_sack_block duplicate_sack[1]; /* D-SACK block */ 352 struct tcp_sack_block duplicate_sack[1]; /* D-SACK block */
331 struct tcp_sack_block selective_acks[4]; /* The SACKS themselves*/ 353 struct tcp_sack_block selective_acks[4]; /* The SACKS themselves*/
332 354
@@ -337,23 +359,12 @@ struct tcp_sock {
337 * sacked_out > 0) 359 * sacked_out > 0)
338 */ 360 */
339 361
340 /* from STCP, retrans queue hinting */
341 struct sk_buff* lost_skb_hint;
342
343 struct sk_buff *scoreboard_skb_hint;
344 struct sk_buff *retransmit_skb_hint;
345 struct sk_buff *forward_skb_hint;
346
347 int lost_cnt_hint; 362 int lost_cnt_hint;
348 int retransmit_cnt_hint; 363 u32 retransmit_high; /* L-bits may be on up to this seqno */
349 364
350 u32 lost_retrans_low; /* Sent seq after any rxmit (lowest) */ 365 u32 lost_retrans_low; /* Sent seq after any rxmit (lowest) */
351 366
352 u16 advmss; /* Advertised MSS */
353 u32 prior_ssthresh; /* ssthresh saved at recovery start */ 367 u32 prior_ssthresh; /* ssthresh saved at recovery start */
354 u32 lost_out; /* Lost packets */
355 u32 sacked_out; /* SACK'd packets */
356 u32 fackets_out; /* FACK'd packets */
357 u32 high_seq; /* snd_nxt at onset of congestion */ 368 u32 high_seq; /* snd_nxt at onset of congestion */
358 369
359 u32 retrans_stamp; /* Timestamp of the last retransmit, 370 u32 retrans_stamp; /* Timestamp of the last retransmit,
@@ -361,23 +372,14 @@ struct tcp_sock {
361 * the first SYN. */ 372 * the first SYN. */
362 u32 undo_marker; /* tracking retrans started here. */ 373 u32 undo_marker; /* tracking retrans started here. */
363 int undo_retrans; /* number of undoable retransmissions. */ 374 int undo_retrans; /* number of undoable retransmissions. */
364 u32 urg_seq; /* Seq of received urgent pointer */
365 u16 urg_data; /* Saved octet of OOB data and control flags */
366 u8 urg_mode; /* In urgent mode */
367 u8 ecn_flags; /* ECN status bits. */
368 u32 snd_up; /* Urgent pointer */
369
370 u32 total_retrans; /* Total retransmits for entire connection */ 375 u32 total_retrans; /* Total retransmits for entire connection */
371 u32 bytes_acked; /* Appropriate Byte Counting - RFC3465 */
372 376
377 u32 urg_seq; /* Seq of received urgent pointer */
373 unsigned int keepalive_time; /* time before keep alive takes place */ 378 unsigned int keepalive_time; /* time before keep alive takes place */
374 unsigned int keepalive_intvl; /* time interval between keep alive probes */ 379 unsigned int keepalive_intvl; /* time interval between keep alive probes */
375 int linger2;
376 380
377 unsigned long last_synq_overflow; 381 unsigned long last_synq_overflow;
378 382
379 u32 tso_deferred;
380
381/* Receiver side RTT estimation */ 383/* Receiver side RTT estimation */
382 struct { 384 struct {
383 u32 rtt; 385 u32 rtt;
@@ -405,6 +407,8 @@ struct tcp_sock {
405/* TCP MD5 Signagure Option information */ 407/* TCP MD5 Signagure Option information */
406 struct tcp_md5sig_info *md5sig_info; 408 struct tcp_md5sig_info *md5sig_info;
407#endif 409#endif
410
411 int linger2;
408}; 412};
409 413
410static inline struct tcp_sock *tcp_sk(const struct sock *sk) 414static inline struct tcp_sock *tcp_sk(const struct sock *sk)
diff --git a/include/linux/telephony.h b/include/linux/telephony.h
index 0d0cf2a1e7bc..5b2b6261f193 100644
--- a/include/linux/telephony.h
+++ b/include/linux/telephony.h
@@ -28,10 +28,6 @@
28 * ON AN "AS IS" BASIS, AND QUICKNET TECHNOLOGIES, INC. HAS NO OBLIGATION 28 * ON AN "AS IS" BASIS, AND QUICKNET TECHNOLOGIES, INC. HAS NO OBLIGATION
29 * TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 29 * TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
30 * 30 *
31 * Version: $Revision: 4.2 $
32 *
33 * $Id: telephony.h,v 4.2 2001/08/06 07:09:43 craigs Exp $
34 *
35 *****************************************************************************/ 31 *****************************************************************************/
36 32
37#ifndef TELEPHONY_H 33#ifndef TELEPHONY_H
diff --git a/include/linux/termios.h b/include/linux/termios.h
index 478662889f48..2acd0c1f8a2a 100644
--- a/include/linux/termios.h
+++ b/include/linux/termios.h
@@ -4,4 +4,19 @@
4#include <linux/types.h> 4#include <linux/types.h>
5#include <asm/termios.h> 5#include <asm/termios.h>
6 6
7#define NFF 5
8
9struct termiox
10{
11 __u16 x_hflag;
12 __u16 x_cflag;
13 __u16 x_rflag[NFF];
14 __u16 x_sflag;
15};
16
17#define RTSXOFF 0x0001 /* RTS flow control on input */
18#define CTSXON 0x0002 /* CTS flow control on output */
19#define DTRXOFF 0x0004 /* DTR flow control on input */
20#define DSRXON 0x0008 /* DCD flow control on output */
21
7#endif 22#endif
diff --git a/include/linux/textsearch.h b/include/linux/textsearch.h
index 6f371f24160b..d9a85d616385 100644
--- a/include/linux/textsearch.h
+++ b/include/linux/textsearch.h
@@ -10,10 +10,8 @@
10 10
11struct ts_config; 11struct ts_config;
12 12
13/** 13#define TS_AUTOLOAD 1 /* Automatically load textsearch modules when needed */
14 * TS_AUTOLOAD - Automatically load textsearch modules when needed 14#define TS_IGNORECASE 2 /* Searches string case insensitively */
15 */
16#define TS_AUTOLOAD 1
17 15
18/** 16/**
19 * struct ts_state - search state 17 * struct ts_state - search state
@@ -39,7 +37,7 @@ struct ts_state
39struct ts_ops 37struct ts_ops
40{ 38{
41 const char *name; 39 const char *name;
42 struct ts_config * (*init)(const void *, unsigned int, gfp_t); 40 struct ts_config * (*init)(const void *, unsigned int, gfp_t, int);
43 unsigned int (*find)(struct ts_config *, 41 unsigned int (*find)(struct ts_config *,
44 struct ts_state *); 42 struct ts_state *);
45 void (*destroy)(struct ts_config *); 43 void (*destroy)(struct ts_config *);
@@ -52,12 +50,14 @@ struct ts_ops
52/** 50/**
53 * struct ts_config - search configuration 51 * struct ts_config - search configuration
54 * @ops: operations of chosen algorithm 52 * @ops: operations of chosen algorithm
53 * @flags: flags
55 * @get_next_block: callback to fetch the next block to search in 54 * @get_next_block: callback to fetch the next block to search in
56 * @finish: callback to finalize a search 55 * @finish: callback to finalize a search
57 */ 56 */
58struct ts_config 57struct ts_config
59{ 58{
60 struct ts_ops *ops; 59 struct ts_ops *ops;
60 int flags;
61 61
62 /** 62 /**
63 * get_next_block - fetch next block of data 63 * get_next_block - fetch next block of data
@@ -162,11 +162,10 @@ static inline struct ts_config *alloc_ts_config(size_t payload,
162{ 162{
163 struct ts_config *conf; 163 struct ts_config *conf;
164 164
165 conf = kmalloc(TS_PRIV_ALIGN(sizeof(*conf)) + payload, gfp_mask); 165 conf = kzalloc(TS_PRIV_ALIGN(sizeof(*conf)) + payload, gfp_mask);
166 if (conf == NULL) 166 if (conf == NULL)
167 return ERR_PTR(-ENOMEM); 167 return ERR_PTR(-ENOMEM);
168 168
169 memset(conf, 0, TS_PRIV_ALIGN(sizeof(*conf)) + payload);
170 return conf; 169 return conf;
171} 170}
172 171
diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
index 38a56477f27a..e6b820f8b56b 100644
--- a/include/linux/thread_info.h
+++ b/include/linux/thread_info.h
@@ -38,6 +38,14 @@ struct restart_block {
38#endif 38#endif
39 u64 expires; 39 u64 expires;
40 } nanosleep; 40 } nanosleep;
41 /* For poll */
42 struct {
43 struct pollfd __user *ufds;
44 int nfds;
45 int has_timeout;
46 unsigned long tv_sec;
47 unsigned long tv_nsec;
48 } poll;
41 }; 49 };
42}; 50};
43 51
diff --git a/include/linux/tick.h b/include/linux/tick.h
index a881c652f7e9..b6ec8189ac0c 100644
--- a/include/linux/tick.h
+++ b/include/linux/tick.h
@@ -49,6 +49,7 @@ struct tick_sched {
49 unsigned long check_clocks; 49 unsigned long check_clocks;
50 enum tick_nohz_mode nohz_mode; 50 enum tick_nohz_mode nohz_mode;
51 ktime_t idle_tick; 51 ktime_t idle_tick;
52 int inidle;
52 int tick_stopped; 53 int tick_stopped;
53 unsigned long idle_jiffies; 54 unsigned long idle_jiffies;
54 unsigned long idle_calls; 55 unsigned long idle_calls;
@@ -73,10 +74,13 @@ extern struct tick_device *tick_get_device(int cpu);
73extern int tick_init_highres(void); 74extern int tick_init_highres(void);
74extern int tick_program_event(ktime_t expires, int force); 75extern int tick_program_event(ktime_t expires, int force);
75extern void tick_setup_sched_timer(void); 76extern void tick_setup_sched_timer(void);
77# endif
78
79# if defined CONFIG_NO_HZ || defined CONFIG_HIGH_RES_TIMERS
76extern void tick_cancel_sched_timer(int cpu); 80extern void tick_cancel_sched_timer(int cpu);
77# else 81# else
78static inline void tick_cancel_sched_timer(int cpu) { } 82static inline void tick_cancel_sched_timer(int cpu) { }
79# endif /* HIGHRES */ 83# endif
80 84
81# ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST 85# ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
82extern struct tick_device *tick_get_broadcast_device(void); 86extern struct tick_device *tick_get_broadcast_device(void);
@@ -92,9 +96,11 @@ extern cpumask_t *tick_get_broadcast_oneshot_mask(void);
92extern void tick_clock_notify(void); 96extern void tick_clock_notify(void);
93extern int tick_check_oneshot_change(int allow_nohz); 97extern int tick_check_oneshot_change(int allow_nohz);
94extern struct tick_sched *tick_get_tick_sched(int cpu); 98extern struct tick_sched *tick_get_tick_sched(int cpu);
99extern void tick_check_idle(int cpu);
95# else 100# else
96static inline void tick_clock_notify(void) { } 101static inline void tick_clock_notify(void) { }
97static inline int tick_check_oneshot_change(int allow_nohz) { return 0; } 102static inline int tick_check_oneshot_change(int allow_nohz) { return 0; }
103static inline void tick_check_idle(int cpu) { }
98# endif 104# endif
99 105
100#else /* CONFIG_GENERIC_CLOCKEVENTS */ 106#else /* CONFIG_GENERIC_CLOCKEVENTS */
@@ -102,27 +108,24 @@ static inline void tick_init(void) { }
102static inline void tick_cancel_sched_timer(int cpu) { } 108static inline void tick_cancel_sched_timer(int cpu) { }
103static inline void tick_clock_notify(void) { } 109static inline void tick_clock_notify(void) { }
104static inline int tick_check_oneshot_change(int allow_nohz) { return 0; } 110static inline int tick_check_oneshot_change(int allow_nohz) { return 0; }
111static inline void tick_check_idle(int cpu) { }
105#endif /* !CONFIG_GENERIC_CLOCKEVENTS */ 112#endif /* !CONFIG_GENERIC_CLOCKEVENTS */
106 113
107# ifdef CONFIG_NO_HZ 114# ifdef CONFIG_NO_HZ
108extern void tick_nohz_stop_sched_tick(void); 115extern void tick_nohz_stop_sched_tick(int inidle);
109extern void tick_nohz_restart_sched_tick(void); 116extern void tick_nohz_restart_sched_tick(void);
110extern void tick_nohz_update_jiffies(void);
111extern ktime_t tick_nohz_get_sleep_length(void); 117extern ktime_t tick_nohz_get_sleep_length(void);
112extern void tick_nohz_stop_idle(int cpu);
113extern u64 get_cpu_idle_time_us(int cpu, u64 *last_update_time); 118extern u64 get_cpu_idle_time_us(int cpu, u64 *last_update_time);
114# else 119# else
115static inline void tick_nohz_stop_sched_tick(void) { } 120static inline void tick_nohz_stop_sched_tick(int inidle) { }
116static inline void tick_nohz_restart_sched_tick(void) { } 121static inline void tick_nohz_restart_sched_tick(void) { }
117static inline void tick_nohz_update_jiffies(void) { }
118static inline ktime_t tick_nohz_get_sleep_length(void) 122static inline ktime_t tick_nohz_get_sleep_length(void)
119{ 123{
120 ktime_t len = { .tv64 = NSEC_PER_SEC/HZ }; 124 ktime_t len = { .tv64 = NSEC_PER_SEC/HZ };
121 125
122 return len; 126 return len;
123} 127}
124static inline void tick_nohz_stop_idle(int cpu) { } 128static inline u64 get_cpu_idle_time_us(int cpu, u64 *unused) { return -1; }
125static inline u64 get_cpu_idle_time_us(int cpu, u64 *unused) { return 0; }
126# endif /* !NO_HZ */ 129# endif /* !NO_HZ */
127 130
128#endif 131#endif
diff --git a/include/linux/time.h b/include/linux/time.h
index e15206a7e82e..ce321ac5c8f8 100644
--- a/include/linux/time.h
+++ b/include/linux/time.h
@@ -29,6 +29,8 @@ struct timezone {
29 29
30#ifdef __KERNEL__ 30#ifdef __KERNEL__
31 31
32extern struct timezone sys_tz;
33
32/* Parameters used to convert the timespec values: */ 34/* Parameters used to convert the timespec values: */
33#define MSEC_PER_SEC 1000L 35#define MSEC_PER_SEC 1000L
34#define USEC_PER_MSEC 1000L 36#define USEC_PER_MSEC 1000L
@@ -38,6 +40,8 @@ struct timezone {
38#define NSEC_PER_SEC 1000000000L 40#define NSEC_PER_SEC 1000000000L
39#define FSEC_PER_SEC 1000000000000000L 41#define FSEC_PER_SEC 1000000000000000L
40 42
43#define TIME_T_MAX (time_t)((1UL << ((sizeof(time_t) << 3) - 1)) - 1)
44
41static inline int timespec_equal(const struct timespec *a, 45static inline int timespec_equal(const struct timespec *a,
42 const struct timespec *b) 46 const struct timespec *b)
43{ 47{
@@ -72,6 +76,8 @@ extern unsigned long mktime(const unsigned int year, const unsigned int mon,
72 const unsigned int min, const unsigned int sec); 76 const unsigned int min, const unsigned int sec);
73 77
74extern void set_normalized_timespec(struct timespec *ts, time_t sec, long nsec); 78extern void set_normalized_timespec(struct timespec *ts, time_t sec, long nsec);
79extern struct timespec timespec_add_safe(const struct timespec lhs,
80 const struct timespec rhs);
75 81
76/* 82/*
77 * sub = lhs - rhs, in normalized form 83 * sub = lhs - rhs, in normalized form
@@ -117,6 +123,7 @@ extern int do_setitimer(int which, struct itimerval *value,
117extern unsigned int alarm_setitimer(unsigned int seconds); 123extern unsigned int alarm_setitimer(unsigned int seconds);
118extern int do_getitimer(int which, struct itimerval *value); 124extern int do_getitimer(int which, struct itimerval *value);
119extern void getnstimeofday(struct timespec *tv); 125extern void getnstimeofday(struct timespec *tv);
126extern void getrawmonotonic(struct timespec *ts);
120extern void getboottime(struct timespec *ts); 127extern void getboottime(struct timespec *ts);
121extern void monotonic_to_bootbased(struct timespec *ts); 128extern void monotonic_to_bootbased(struct timespec *ts);
122 129
@@ -125,6 +132,9 @@ extern int timekeeping_valid_for_hres(void);
125extern void update_wall_time(void); 132extern void update_wall_time(void);
126extern void update_xtime_cache(u64 nsec); 133extern void update_xtime_cache(u64 nsec);
127 134
135struct tms;
136extern void do_sys_times(struct tms *);
137
128/** 138/**
129 * timespec_to_ns - Convert timespec to nanoseconds 139 * timespec_to_ns - Convert timespec to nanoseconds
130 * @ts: pointer to the timespec variable to be converted 140 * @ts: pointer to the timespec variable to be converted
@@ -214,6 +224,7 @@ struct itimerval {
214#define CLOCK_MONOTONIC 1 224#define CLOCK_MONOTONIC 1
215#define CLOCK_PROCESS_CPUTIME_ID 2 225#define CLOCK_PROCESS_CPUTIME_ID 2
216#define CLOCK_THREAD_CPUTIME_ID 3 226#define CLOCK_THREAD_CPUTIME_ID 3
227#define CLOCK_MONOTONIC_RAW 4
217 228
218/* 229/*
219 * The IDs of various hardware clocks: 230 * The IDs of various hardware clocks:
diff --git a/include/linux/timerfd.h b/include/linux/timerfd.h
index cf2b10d75731..86cb0501d3e2 100644
--- a/include/linux/timerfd.h
+++ b/include/linux/timerfd.h
@@ -8,9 +8,15 @@
8#ifndef _LINUX_TIMERFD_H 8#ifndef _LINUX_TIMERFD_H
9#define _LINUX_TIMERFD_H 9#define _LINUX_TIMERFD_H
10 10
11/* For O_CLOEXEC and O_NONBLOCK */
12#include <linux/fcntl.h>
11 13
14/* Flags for timerfd_settime. */
12#define TFD_TIMER_ABSTIME (1 << 0) 15#define TFD_TIMER_ABSTIME (1 << 0)
13 16
17/* Flags for timerfd_create. */
18#define TFD_CLOEXEC O_CLOEXEC
19#define TFD_NONBLOCK O_NONBLOCK
14 20
15 21
16#endif /* _LINUX_TIMERFD_H */ 22#endif /* _LINUX_TIMERFD_H */
diff --git a/include/linux/timex.h b/include/linux/timex.h
index fc6035d29d56..9007313b5b71 100644
--- a/include/linux/timex.h
+++ b/include/linux/timex.h
@@ -82,7 +82,7 @@
82 */ 82 */
83#define SHIFT_USEC 16 /* frequency offset scale (shift) */ 83#define SHIFT_USEC 16 /* frequency offset scale (shift) */
84#define PPM_SCALE (NSEC_PER_USEC << (NTP_SCALE_SHIFT - SHIFT_USEC)) 84#define PPM_SCALE (NSEC_PER_USEC << (NTP_SCALE_SHIFT - SHIFT_USEC))
85#define PPM_SCALE_INV_SHIFT 20 85#define PPM_SCALE_INV_SHIFT 19
86#define PPM_SCALE_INV ((1ll << (PPM_SCALE_INV_SHIFT + NTP_SCALE_SHIFT)) / \ 86#define PPM_SCALE_INV ((1ll << (PPM_SCALE_INV_SHIFT + NTP_SCALE_SHIFT)) / \
87 PPM_SCALE + 1) 87 PPM_SCALE + 1)
88 88
@@ -141,8 +141,15 @@ struct timex {
141#define ADJ_MICRO 0x1000 /* select microsecond resolution */ 141#define ADJ_MICRO 0x1000 /* select microsecond resolution */
142#define ADJ_NANO 0x2000 /* select nanosecond resolution */ 142#define ADJ_NANO 0x2000 /* select nanosecond resolution */
143#define ADJ_TICK 0x4000 /* tick value */ 143#define ADJ_TICK 0x4000 /* tick value */
144
145#ifdef __KERNEL__
146#define ADJ_ADJTIME 0x8000 /* switch between adjtime/adjtimex modes */
147#define ADJ_OFFSET_SINGLESHOT 0x0001 /* old-fashioned adjtime */
148#define ADJ_OFFSET_READONLY 0x2000 /* read-only adjtime */
149#else
144#define ADJ_OFFSET_SINGLESHOT 0x8001 /* old-fashioned adjtime */ 150#define ADJ_OFFSET_SINGLESHOT 0x8001 /* old-fashioned adjtime */
145#define ADJ_OFFSET_SS_READ 0xa001 /* read-only adjtime */ 151#define ADJ_OFFSET_SS_READ 0xa001 /* read-only adjtime */
152#endif
146 153
147/* xntp 3.4 compatibility names */ 154/* xntp 3.4 compatibility names */
148#define MOD_OFFSET ADJ_OFFSET 155#define MOD_OFFSET ADJ_OFFSET
diff --git a/include/linux/tipc_config.h b/include/linux/tipc_config.h
index b0c916d1f375..2bc6fa4adeb5 100644
--- a/include/linux/tipc_config.h
+++ b/include/linux/tipc_config.h
@@ -2,7 +2,7 @@
2 * include/linux/tipc_config.h: Include file for TIPC configuration interface 2 * include/linux/tipc_config.h: Include file for TIPC configuration interface
3 * 3 *
4 * Copyright (c) 2003-2006, Ericsson AB 4 * Copyright (c) 2003-2006, Ericsson AB
5 * Copyright (c) 2005, Wind River Systems 5 * Copyright (c) 2005-2007, Wind River Systems
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
@@ -136,6 +136,14 @@
136#define TIPC_CMD_SET_NETID 0x800B /* tx unsigned, rx none */ 136#define TIPC_CMD_SET_NETID 0x800B /* tx unsigned, rx none */
137 137
138/* 138/*
139 * Reserved commands:
140 * May not be issued by any process.
141 * Used internally by TIPC.
142 */
143
144#define TIPC_CMD_NOT_NET_ADMIN 0xC001 /* tx none, rx none */
145
146/*
139 * TLV types defined for TIPC 147 * TLV types defined for TIPC
140 */ 148 */
141 149
diff --git a/include/linux/tracehook.h b/include/linux/tracehook.h
new file mode 100644
index 000000000000..6186a789d6c7
--- /dev/null
+++ b/include/linux/tracehook.h
@@ -0,0 +1,582 @@
1/*
2 * Tracing hooks
3 *
4 * Copyright (C) 2008 Red Hat, Inc. All rights reserved.
5 *
6 * This copyrighted material is made available to anyone wishing to use,
7 * modify, copy, or redistribute it subject to the terms and conditions
8 * of the GNU General Public License v.2.
9 *
10 * This file defines hook entry points called by core code where
11 * user tracing/debugging support might need to do something. These
12 * entry points are called tracehook_*(). Each hook declared below
13 * has a detailed kerneldoc comment giving the context (locking et
14 * al) from which it is called, and the meaning of its return value.
15 *
16 * Each function here typically has only one call site, so it is ok
17 * to have some nontrivial tracehook_*() inlines. In all cases, the
18 * fast path when no tracing is enabled should be very short.
19 *
20 * The purpose of this file and the tracehook_* layer is to consolidate
21 * the interface that the kernel core and arch code uses to enable any
22 * user debugging or tracing facility (such as ptrace). The interfaces
23 * here are carefully documented so that maintainers of core and arch
24 * code do not need to think about the implementation details of the
25 * tracing facilities. Likewise, maintainers of the tracing code do not
26 * need to understand all the calling core or arch code in detail, just
27 * documented circumstances of each call, such as locking conditions.
28 *
29 * If the calling core code changes so that locking is different, then
30 * it is ok to change the interface documented here. The maintainer of
31 * core code changing should notify the maintainers of the tracing code
32 * that they need to work out the change.
33 *
34 * Some tracehook_*() inlines take arguments that the current tracing
35 * implementations might not necessarily use. These function signatures
36 * are chosen to pass in all the information that is on hand in the
37 * caller and might conceivably be relevant to a tracer, so that the
38 * core code won't have to be updated when tracing adds more features.
39 * If a call site changes so that some of those parameters are no longer
40 * already on hand without extra work, then the tracehook_* interface
41 * can change so there is no make-work burden on the core code. The
42 * maintainer of core code changing should notify the maintainers of the
43 * tracing code that they need to work out the change.
44 */
45
46#ifndef _LINUX_TRACEHOOK_H
47#define _LINUX_TRACEHOOK_H 1
48
49#include <linux/sched.h>
50#include <linux/ptrace.h>
51#include <linux/security.h>
52struct linux_binprm;
53
54/**
55 * tracehook_expect_breakpoints - guess if task memory might be touched
56 * @task: current task, making a new mapping
57 *
58 * Return nonzero if @task is expected to want breakpoint insertion in
59 * its memory at some point. A zero return is no guarantee it won't
60 * be done, but this is a hint that it's known to be likely.
61 *
62 * May be called with @task->mm->mmap_sem held for writing.
63 */
64static inline int tracehook_expect_breakpoints(struct task_struct *task)
65{
66 return (task_ptrace(task) & PT_PTRACED) != 0;
67}
68
69/*
70 * ptrace report for syscall entry and exit looks identical.
71 */
72static inline void ptrace_report_syscall(struct pt_regs *regs)
73{
74 int ptrace = task_ptrace(current);
75
76 if (!(ptrace & PT_PTRACED))
77 return;
78
79 ptrace_notify(SIGTRAP | ((ptrace & PT_TRACESYSGOOD) ? 0x80 : 0));
80
81 /*
82 * this isn't the same as continuing with a signal, but it will do
83 * for normal use. strace only continues with a signal if the
84 * stopping signal is not SIGTRAP. -brl
85 */
86 if (current->exit_code) {
87 send_sig(current->exit_code, current, 1);
88 current->exit_code = 0;
89 }
90}
91
92/**
93 * tracehook_report_syscall_entry - task is about to attempt a system call
94 * @regs: user register state of current task
95 *
96 * This will be called if %TIF_SYSCALL_TRACE has been set, when the
97 * current task has just entered the kernel for a system call.
98 * Full user register state is available here. Changing the values
99 * in @regs can affect the system call number and arguments to be tried.
100 * It is safe to block here, preventing the system call from beginning.
101 *
102 * Returns zero normally, or nonzero if the calling arch code should abort
103 * the system call. That must prevent normal entry so no system call is
104 * made. If @task ever returns to user mode after this, its register state
105 * is unspecified, but should be something harmless like an %ENOSYS error
106 * return. It should preserve enough information so that syscall_rollback()
107 * can work (see asm-generic/syscall.h).
108 *
109 * Called without locks, just after entering kernel mode.
110 */
111static inline __must_check int tracehook_report_syscall_entry(
112 struct pt_regs *regs)
113{
114 ptrace_report_syscall(regs);
115 return 0;
116}
117
118/**
119 * tracehook_report_syscall_exit - task has just finished a system call
120 * @regs: user register state of current task
121 * @step: nonzero if simulating single-step or block-step
122 *
123 * This will be called if %TIF_SYSCALL_TRACE has been set, when the
124 * current task has just finished an attempted system call. Full
125 * user register state is available here. It is safe to block here,
126 * preventing signals from being processed.
127 *
128 * If @step is nonzero, this report is also in lieu of the normal
129 * trap that would follow the system call instruction because
130 * user_enable_block_step() or user_enable_single_step() was used.
131 * In this case, %TIF_SYSCALL_TRACE might not be set.
132 *
133 * Called without locks, just before checking for pending signals.
134 */
135static inline void tracehook_report_syscall_exit(struct pt_regs *regs, int step)
136{
137 ptrace_report_syscall(regs);
138}
139
140/**
141 * tracehook_unsafe_exec - check for exec declared unsafe due to tracing
142 * @task: current task doing exec
143 *
144 * Return %LSM_UNSAFE_* bits applied to an exec because of tracing.
145 *
146 * Called with task_lock() held on @task.
147 */
148static inline int tracehook_unsafe_exec(struct task_struct *task)
149{
150 int unsafe = 0;
151 int ptrace = task_ptrace(task);
152 if (ptrace & PT_PTRACED) {
153 if (ptrace & PT_PTRACE_CAP)
154 unsafe |= LSM_UNSAFE_PTRACE_CAP;
155 else
156 unsafe |= LSM_UNSAFE_PTRACE;
157 }
158 return unsafe;
159}
160
161/**
162 * tracehook_tracer_task - return the task that is tracing the given task
163 * @tsk: task to consider
164 *
165 * Returns NULL if noone is tracing @task, or the &struct task_struct
166 * pointer to its tracer.
167 *
168 * Must called under rcu_read_lock(). The pointer returned might be kept
169 * live only by RCU. During exec, this may be called with task_lock()
170 * held on @task, still held from when tracehook_unsafe_exec() was called.
171 */
172static inline struct task_struct *tracehook_tracer_task(struct task_struct *tsk)
173{
174 if (task_ptrace(tsk) & PT_PTRACED)
175 return rcu_dereference(tsk->parent);
176 return NULL;
177}
178
179/**
180 * tracehook_report_exec - a successful exec was completed
181 * @fmt: &struct linux_binfmt that performed the exec
182 * @bprm: &struct linux_binprm containing exec details
183 * @regs: user-mode register state
184 *
185 * An exec just completed, we are shortly going to return to user mode.
186 * The freshly initialized register state can be seen and changed in @regs.
187 * The name, file and other pointers in @bprm are still on hand to be
188 * inspected, but will be freed as soon as this returns.
189 *
190 * Called with no locks, but with some kernel resources held live
191 * and a reference on @fmt->module.
192 */
193static inline void tracehook_report_exec(struct linux_binfmt *fmt,
194 struct linux_binprm *bprm,
195 struct pt_regs *regs)
196{
197 if (!ptrace_event(PT_TRACE_EXEC, PTRACE_EVENT_EXEC, 0) &&
198 unlikely(task_ptrace(current) & PT_PTRACED))
199 send_sig(SIGTRAP, current, 0);
200}
201
202/**
203 * tracehook_report_exit - task has begun to exit
204 * @exit_code: pointer to value destined for @current->exit_code
205 *
206 * @exit_code points to the value passed to do_exit(), which tracing
207 * might change here. This is almost the first thing in do_exit(),
208 * before freeing any resources or setting the %PF_EXITING flag.
209 *
210 * Called with no locks held.
211 */
212static inline void tracehook_report_exit(long *exit_code)
213{
214 ptrace_event(PT_TRACE_EXIT, PTRACE_EVENT_EXIT, *exit_code);
215}
216
217/**
218 * tracehook_prepare_clone - prepare for new child to be cloned
219 * @clone_flags: %CLONE_* flags from clone/fork/vfork system call
220 *
221 * This is called before a new user task is to be cloned.
222 * Its return value will be passed to tracehook_finish_clone().
223 *
224 * Called with no locks held.
225 */
226static inline int tracehook_prepare_clone(unsigned clone_flags)
227{
228 if (clone_flags & CLONE_UNTRACED)
229 return 0;
230
231 if (clone_flags & CLONE_VFORK) {
232 if (current->ptrace & PT_TRACE_VFORK)
233 return PTRACE_EVENT_VFORK;
234 } else if ((clone_flags & CSIGNAL) != SIGCHLD) {
235 if (current->ptrace & PT_TRACE_CLONE)
236 return PTRACE_EVENT_CLONE;
237 } else if (current->ptrace & PT_TRACE_FORK)
238 return PTRACE_EVENT_FORK;
239
240 return 0;
241}
242
243/**
244 * tracehook_finish_clone - new child created and being attached
245 * @child: new child task
246 * @clone_flags: %CLONE_* flags from clone/fork/vfork system call
247 * @trace: return value from tracehook_prepare_clone()
248 *
249 * This is called immediately after adding @child to its parent's children list.
250 * The @trace value is that returned by tracehook_prepare_clone().
251 *
252 * Called with current's siglock and write_lock_irq(&tasklist_lock) held.
253 */
254static inline void tracehook_finish_clone(struct task_struct *child,
255 unsigned long clone_flags, int trace)
256{
257 ptrace_init_task(child, (clone_flags & CLONE_PTRACE) || trace);
258}
259
260/**
261 * tracehook_report_clone - in parent, new child is about to start running
262 * @trace: return value from tracehook_prepare_clone()
263 * @regs: parent's user register state
264 * @clone_flags: flags from parent's system call
265 * @pid: new child's PID in the parent's namespace
266 * @child: new child task
267 *
268 * Called after a child is set up, but before it has been started
269 * running. @trace is the value returned by tracehook_prepare_clone().
270 * This is not a good place to block, because the child has not started
271 * yet. Suspend the child here if desired, and then block in
272 * tracehook_report_clone_complete(). This must prevent the child from
273 * self-reaping if tracehook_report_clone_complete() uses the @child
274 * pointer; otherwise it might have died and been released by the time
275 * tracehook_report_clone_complete() is called.
276 *
277 * Called with no locks held, but the child cannot run until this returns.
278 */
279static inline void tracehook_report_clone(int trace, struct pt_regs *regs,
280 unsigned long clone_flags,
281 pid_t pid, struct task_struct *child)
282{
283 if (unlikely(trace) || unlikely(clone_flags & CLONE_PTRACE)) {
284 /*
285 * The child starts up with an immediate SIGSTOP.
286 */
287 sigaddset(&child->pending.signal, SIGSTOP);
288 set_tsk_thread_flag(child, TIF_SIGPENDING);
289 }
290}
291
292/**
293 * tracehook_report_clone_complete - new child is running
294 * @trace: return value from tracehook_prepare_clone()
295 * @regs: parent's user register state
296 * @clone_flags: flags from parent's system call
297 * @pid: new child's PID in the parent's namespace
298 * @child: child task, already running
299 *
300 * This is called just after the child has started running. This is
301 * just before the clone/fork syscall returns, or blocks for vfork
302 * child completion if @clone_flags has the %CLONE_VFORK bit set.
303 * The @child pointer may be invalid if a self-reaping child died and
304 * tracehook_report_clone() took no action to prevent it from self-reaping.
305 *
306 * Called with no locks held.
307 */
308static inline void tracehook_report_clone_complete(int trace,
309 struct pt_regs *regs,
310 unsigned long clone_flags,
311 pid_t pid,
312 struct task_struct *child)
313{
314 if (unlikely(trace))
315 ptrace_event(0, trace, pid);
316}
317
318/**
319 * tracehook_report_vfork_done - vfork parent's child has exited or exec'd
320 * @child: child task, already running
321 * @pid: new child's PID in the parent's namespace
322 *
323 * Called after a %CLONE_VFORK parent has waited for the child to complete.
324 * The clone/vfork system call will return immediately after this.
325 * The @child pointer may be invalid if a self-reaping child died and
326 * tracehook_report_clone() took no action to prevent it from self-reaping.
327 *
328 * Called with no locks held.
329 */
330static inline void tracehook_report_vfork_done(struct task_struct *child,
331 pid_t pid)
332{
333 ptrace_event(PT_TRACE_VFORK_DONE, PTRACE_EVENT_VFORK_DONE, pid);
334}
335
336/**
337 * tracehook_prepare_release_task - task is being reaped, clean up tracing
338 * @task: task in %EXIT_DEAD state
339 *
340 * This is called in release_task() just before @task gets finally reaped
341 * and freed. This would be the ideal place to remove and clean up any
342 * tracing-related state for @task.
343 *
344 * Called with no locks held.
345 */
346static inline void tracehook_prepare_release_task(struct task_struct *task)
347{
348}
349
350/**
351 * tracehook_finish_release_task - final tracing clean-up
352 * @task: task in %EXIT_DEAD state
353 *
354 * This is called in release_task() when @task is being in the middle of
355 * being reaped. After this, there must be no tracing entanglements.
356 *
357 * Called with write_lock_irq(&tasklist_lock) held.
358 */
359static inline void tracehook_finish_release_task(struct task_struct *task)
360{
361 ptrace_release_task(task);
362}
363
364/**
365 * tracehook_signal_handler - signal handler setup is complete
366 * @sig: number of signal being delivered
367 * @info: siginfo_t of signal being delivered
368 * @ka: sigaction setting that chose the handler
369 * @regs: user register state
370 * @stepping: nonzero if debugger single-step or block-step in use
371 *
372 * Called by the arch code after a signal handler has been set up.
373 * Register and stack state reflects the user handler about to run.
374 * Signal mask changes have already been made.
375 *
376 * Called without locks, shortly before returning to user mode
377 * (or handling more signals).
378 */
379static inline void tracehook_signal_handler(int sig, siginfo_t *info,
380 const struct k_sigaction *ka,
381 struct pt_regs *regs, int stepping)
382{
383 if (stepping)
384 ptrace_notify(SIGTRAP);
385}
386
387/**
388 * tracehook_consider_ignored_signal - suppress short-circuit of ignored signal
389 * @task: task receiving the signal
390 * @sig: signal number being sent
391 * @handler: %SIG_IGN or %SIG_DFL
392 *
393 * Return zero iff tracing doesn't care to examine this ignored signal,
394 * so it can short-circuit normal delivery and never even get queued.
395 * Either @handler is %SIG_DFL and @sig's default is ignore, or it's %SIG_IGN.
396 *
397 * Called with @task->sighand->siglock held.
398 */
399static inline int tracehook_consider_ignored_signal(struct task_struct *task,
400 int sig,
401 void __user *handler)
402{
403 return (task_ptrace(task) & PT_PTRACED) != 0;
404}
405
406/**
407 * tracehook_consider_fatal_signal - suppress special handling of fatal signal
408 * @task: task receiving the signal
409 * @sig: signal number being sent
410 * @handler: %SIG_DFL or %SIG_IGN
411 *
412 * Return nonzero to prevent special handling of this termination signal.
413 * Normally @handler is %SIG_DFL. It can be %SIG_IGN if @sig is ignored,
414 * in which case force_sig() is about to reset it to %SIG_DFL.
415 * When this returns zero, this signal might cause a quick termination
416 * that does not give the debugger a chance to intercept the signal.
417 *
418 * Called with or without @task->sighand->siglock held.
419 */
420static inline int tracehook_consider_fatal_signal(struct task_struct *task,
421 int sig,
422 void __user *handler)
423{
424 return (task_ptrace(task) & PT_PTRACED) != 0;
425}
426
427/**
428 * tracehook_force_sigpending - let tracing force signal_pending(current) on
429 *
430 * Called when recomputing our signal_pending() flag. Return nonzero
431 * to force the signal_pending() flag on, so that tracehook_get_signal()
432 * will be called before the next return to user mode.
433 *
434 * Called with @current->sighand->siglock held.
435 */
436static inline int tracehook_force_sigpending(void)
437{
438 return 0;
439}
440
441/**
442 * tracehook_get_signal - deliver synthetic signal to traced task
443 * @task: @current
444 * @regs: task_pt_regs(@current)
445 * @info: details of synthetic signal
446 * @return_ka: sigaction for synthetic signal
447 *
448 * Return zero to check for a real pending signal normally.
449 * Return -1 after releasing the siglock to repeat the check.
450 * Return a signal number to induce an artifical signal delivery,
451 * setting *@info and *@return_ka to specify its details and behavior.
452 *
453 * The @return_ka->sa_handler value controls the disposition of the
454 * signal, no matter the signal number. For %SIG_DFL, the return value
455 * is a representative signal to indicate the behavior (e.g. %SIGTERM
456 * for death, %SIGQUIT for core dump, %SIGSTOP for job control stop,
457 * %SIGTSTP for stop unless in an orphaned pgrp), but the signal number
458 * reported will be @info->si_signo instead.
459 *
460 * Called with @task->sighand->siglock held, before dequeuing pending signals.
461 */
462static inline int tracehook_get_signal(struct task_struct *task,
463 struct pt_regs *regs,
464 siginfo_t *info,
465 struct k_sigaction *return_ka)
466{
467 return 0;
468}
469
470/**
471 * tracehook_notify_jctl - report about job control stop/continue
472 * @notify: nonzero if this is the last thread in the group to stop
473 * @why: %CLD_STOPPED or %CLD_CONTINUED
474 *
475 * This is called when we might call do_notify_parent_cldstop().
476 * It's called when about to stop for job control; we are already in
477 * %TASK_STOPPED state, about to call schedule(). It's also called when
478 * a delayed %CLD_STOPPED or %CLD_CONTINUED report is ready to be made.
479 *
480 * Return nonzero to generate a %SIGCHLD with @why, which is
481 * normal if @notify is nonzero.
482 *
483 * Called with no locks held.
484 */
485static inline int tracehook_notify_jctl(int notify, int why)
486{
487 return notify || (current->ptrace & PT_PTRACED);
488}
489
490#define DEATH_REAP -1
491#define DEATH_DELAYED_GROUP_LEADER -2
492
493/**
494 * tracehook_notify_death - task is dead, ready to notify parent
495 * @task: @current task now exiting
496 * @death_cookie: value to pass to tracehook_report_death()
497 * @group_dead: nonzero if this was the last thread in the group to die
498 *
499 * A return value >= 0 means call do_notify_parent() with that signal
500 * number. Negative return value can be %DEATH_REAP to self-reap right
501 * now, or %DEATH_DELAYED_GROUP_LEADER to a zombie without notifying our
502 * parent. Note that a return value of 0 means a do_notify_parent() call
503 * that sends no signal, but still wakes up a parent blocked in wait*().
504 *
505 * Called with write_lock_irq(&tasklist_lock) held.
506 */
507static inline int tracehook_notify_death(struct task_struct *task,
508 void **death_cookie, int group_dead)
509{
510 if (task->exit_signal == -1)
511 return task->ptrace ? SIGCHLD : DEATH_REAP;
512
513 /*
514 * If something other than our normal parent is ptracing us, then
515 * send it a SIGCHLD instead of honoring exit_signal. exit_signal
516 * only has special meaning to our real parent.
517 */
518 if (thread_group_empty(task) && !ptrace_reparented(task))
519 return task->exit_signal;
520
521 return task->ptrace ? SIGCHLD : DEATH_DELAYED_GROUP_LEADER;
522}
523
524/**
525 * tracehook_report_death - task is dead and ready to be reaped
526 * @task: @current task now exiting
527 * @signal: return value from tracheook_notify_death()
528 * @death_cookie: value passed back from tracehook_notify_death()
529 * @group_dead: nonzero if this was the last thread in the group to die
530 *
531 * Thread has just become a zombie or is about to self-reap. If positive,
532 * @signal is the signal number just sent to the parent (usually %SIGCHLD).
533 * If @signal is %DEATH_REAP, this thread will self-reap. If @signal is
534 * %DEATH_DELAYED_GROUP_LEADER, this is a delayed_group_leader() zombie.
535 * The @death_cookie was passed back by tracehook_notify_death().
536 *
537 * If normal reaping is not inhibited, @task->exit_state might be changing
538 * in parallel.
539 *
540 * Called without locks.
541 */
542static inline void tracehook_report_death(struct task_struct *task,
543 int signal, void *death_cookie,
544 int group_dead)
545{
546}
547
548#ifdef TIF_NOTIFY_RESUME
549/**
550 * set_notify_resume - cause tracehook_notify_resume() to be called
551 * @task: task that will call tracehook_notify_resume()
552 *
553 * Calling this arranges that @task will call tracehook_notify_resume()
554 * before returning to user mode. If it's already running in user mode,
555 * it will enter the kernel and call tracehook_notify_resume() soon.
556 * If it's blocked, it will not be woken.
557 */
558static inline void set_notify_resume(struct task_struct *task)
559{
560 if (!test_and_set_tsk_thread_flag(task, TIF_NOTIFY_RESUME))
561 kick_process(task);
562}
563
564/**
565 * tracehook_notify_resume - report when about to return to user mode
566 * @regs: user-mode registers of @current task
567 *
568 * This is called when %TIF_NOTIFY_RESUME has been set. Now we are
569 * about to return to user mode, and the user state in @regs can be
570 * inspected or adjusted. The caller in arch code has cleared
571 * %TIF_NOTIFY_RESUME before the call. If the flag gets set again
572 * asynchronously, this will be called again before we return to
573 * user mode.
574 *
575 * Called without locks.
576 */
577static inline void tracehook_notify_resume(struct pt_regs *regs)
578{
579}
580#endif /* TIF_NOTIFY_RESUME */
581
582#endif /* <linux/tracehook.h> */
diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
new file mode 100644
index 000000000000..c5bb39c7a770
--- /dev/null
+++ b/include/linux/tracepoint.h
@@ -0,0 +1,137 @@
1#ifndef _LINUX_TRACEPOINT_H
2#define _LINUX_TRACEPOINT_H
3
4/*
5 * Kernel Tracepoint API.
6 *
7 * See Documentation/tracepoint.txt.
8 *
9 * (C) Copyright 2008 Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
10 *
11 * Heavily inspired from the Linux Kernel Markers.
12 *
13 * This file is released under the GPLv2.
14 * See the file COPYING for more details.
15 */
16
17#include <linux/types.h>
18#include <linux/rcupdate.h>
19
20struct module;
21struct tracepoint;
22
23struct tracepoint {
24 const char *name; /* Tracepoint name */
25 int state; /* State. */
26 void **funcs;
27} __attribute__((aligned(8)));
28
29
30#define TPPROTO(args...) args
31#define TPARGS(args...) args
32
33#ifdef CONFIG_TRACEPOINTS
34
35/*
36 * it_func[0] is never NULL because there is at least one element in the array
37 * when the array itself is non NULL.
38 */
39#define __DO_TRACE(tp, proto, args) \
40 do { \
41 void **it_func; \
42 \
43 rcu_read_lock_sched(); \
44 it_func = rcu_dereference((tp)->funcs); \
45 if (it_func) { \
46 do { \
47 ((void(*)(proto))(*it_func))(args); \
48 } while (*(++it_func)); \
49 } \
50 rcu_read_unlock_sched(); \
51 } while (0)
52
53/*
54 * Make sure the alignment of the structure in the __tracepoints section will
55 * not add unwanted padding between the beginning of the section and the
56 * structure. Force alignment to the same alignment as the section start.
57 */
58#define DEFINE_TRACE(name, proto, args) \
59 static inline void trace_##name(proto) \
60 { \
61 static const char __tpstrtab_##name[] \
62 __attribute__((section("__tracepoints_strings"))) \
63 = #name ":" #proto; \
64 static struct tracepoint __tracepoint_##name \
65 __attribute__((section("__tracepoints"), aligned(8))) = \
66 { __tpstrtab_##name, 0, NULL }; \
67 if (unlikely(__tracepoint_##name.state)) \
68 __DO_TRACE(&__tracepoint_##name, \
69 TPPROTO(proto), TPARGS(args)); \
70 } \
71 static inline int register_trace_##name(void (*probe)(proto)) \
72 { \
73 return tracepoint_probe_register(#name ":" #proto, \
74 (void *)probe); \
75 } \
76 static inline void unregister_trace_##name(void (*probe)(proto))\
77 { \
78 tracepoint_probe_unregister(#name ":" #proto, \
79 (void *)probe); \
80 }
81
82extern void tracepoint_update_probe_range(struct tracepoint *begin,
83 struct tracepoint *end);
84
85#else /* !CONFIG_TRACEPOINTS */
86#define DEFINE_TRACE(name, proto, args) \
87 static inline void _do_trace_##name(struct tracepoint *tp, proto) \
88 { } \
89 static inline void trace_##name(proto) \
90 { } \
91 static inline int register_trace_##name(void (*probe)(proto)) \
92 { \
93 return -ENOSYS; \
94 } \
95 static inline void unregister_trace_##name(void (*probe)(proto))\
96 { }
97
98static inline void tracepoint_update_probe_range(struct tracepoint *begin,
99 struct tracepoint *end)
100{ }
101#endif /* CONFIG_TRACEPOINTS */
102
103/*
104 * Connect a probe to a tracepoint.
105 * Internal API, should not be used directly.
106 */
107extern int tracepoint_probe_register(const char *name, void *probe);
108
109/*
110 * Disconnect a probe from a tracepoint.
111 * Internal API, should not be used directly.
112 */
113extern int tracepoint_probe_unregister(const char *name, void *probe);
114
115struct tracepoint_iter {
116 struct module *module;
117 struct tracepoint *tracepoint;
118};
119
120extern void tracepoint_iter_start(struct tracepoint_iter *iter);
121extern void tracepoint_iter_next(struct tracepoint_iter *iter);
122extern void tracepoint_iter_stop(struct tracepoint_iter *iter);
123extern void tracepoint_iter_reset(struct tracepoint_iter *iter);
124extern int tracepoint_get_iter_range(struct tracepoint **tracepoint,
125 struct tracepoint *begin, struct tracepoint *end);
126
127/*
128 * tracepoint_synchronize_unregister must be called between the last tracepoint
129 * probe unregistration and the end of module exit to make sure there is no
130 * caller executing a probe when it is freed.
131 */
132static inline void tracepoint_synchronize_unregister(void)
133{
134 synchronize_sched();
135}
136
137#endif
diff --git a/include/linux/tty.h b/include/linux/tty.h
index 324a3b231d40..3b8121d4e36f 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -23,7 +23,7 @@
23 */ 23 */
24#define NR_UNIX98_PTY_DEFAULT 4096 /* Default maximum for Unix98 ptys */ 24#define NR_UNIX98_PTY_DEFAULT 4096 /* Default maximum for Unix98 ptys */
25#define NR_UNIX98_PTY_MAX (1 << MINORBITS) /* Absolute limit */ 25#define NR_UNIX98_PTY_MAX (1 << MINORBITS) /* Absolute limit */
26#define NR_LDISCS 18 26#define NR_LDISCS 19
27 27
28/* line disciplines */ 28/* line disciplines */
29#define N_TTY 0 29#define N_TTY 0
@@ -45,6 +45,7 @@
45#define N_HCI 15 /* Bluetooth HCI UART */ 45#define N_HCI 15 /* Bluetooth HCI UART */
46#define N_GIGASET_M101 16 /* Siemens Gigaset M101 serial DECT adapter */ 46#define N_GIGASET_M101 16 /* Siemens Gigaset M101 serial DECT adapter */
47#define N_SLCAN 17 /* Serial / USB serial CAN Adaptors */ 47#define N_SLCAN 17 /* Serial / USB serial CAN Adaptors */
48#define N_PPS 18 /* Pulse per Second */
48 49
49/* 50/*
50 * This character is the same as _POSIX_VDISABLE: it cannot be used as 51 * This character is the same as _POSIX_VDISABLE: it cannot be used as
@@ -71,7 +72,8 @@ struct tty_bufhead {
71 struct tty_buffer *head; /* Queue head */ 72 struct tty_buffer *head; /* Queue head */
72 struct tty_buffer *tail; /* Active buffer */ 73 struct tty_buffer *tail; /* Active buffer */
73 struct tty_buffer *free; /* Free queue head */ 74 struct tty_buffer *free; /* Free queue head */
74 int memory_used; /* Buffer space used excluding free queue */ 75 int memory_used; /* Buffer space used excluding
76 free queue */
75}; 77};
76/* 78/*
77 * When a break, frame error, or parity error happens, these codes are 79 * When a break, frame error, or parity error happens, these codes are
@@ -101,71 +103,97 @@ struct tty_bufhead {
101#define LNEXT_CHAR(tty) ((tty)->termios->c_cc[VLNEXT]) 103#define LNEXT_CHAR(tty) ((tty)->termios->c_cc[VLNEXT])
102#define EOL2_CHAR(tty) ((tty)->termios->c_cc[VEOL2]) 104#define EOL2_CHAR(tty) ((tty)->termios->c_cc[VEOL2])
103 105
104#define _I_FLAG(tty,f) ((tty)->termios->c_iflag & (f)) 106#define _I_FLAG(tty, f) ((tty)->termios->c_iflag & (f))
105#define _O_FLAG(tty,f) ((tty)->termios->c_oflag & (f)) 107#define _O_FLAG(tty, f) ((tty)->termios->c_oflag & (f))
106#define _C_FLAG(tty,f) ((tty)->termios->c_cflag & (f)) 108#define _C_FLAG(tty, f) ((tty)->termios->c_cflag & (f))
107#define _L_FLAG(tty,f) ((tty)->termios->c_lflag & (f)) 109#define _L_FLAG(tty, f) ((tty)->termios->c_lflag & (f))
108 110
109#define I_IGNBRK(tty) _I_FLAG((tty),IGNBRK) 111#define I_IGNBRK(tty) _I_FLAG((tty), IGNBRK)
110#define I_BRKINT(tty) _I_FLAG((tty),BRKINT) 112#define I_BRKINT(tty) _I_FLAG((tty), BRKINT)
111#define I_IGNPAR(tty) _I_FLAG((tty),IGNPAR) 113#define I_IGNPAR(tty) _I_FLAG((tty), IGNPAR)
112#define I_PARMRK(tty) _I_FLAG((tty),PARMRK) 114#define I_PARMRK(tty) _I_FLAG((tty), PARMRK)
113#define I_INPCK(tty) _I_FLAG((tty),INPCK) 115#define I_INPCK(tty) _I_FLAG((tty), INPCK)
114#define I_ISTRIP(tty) _I_FLAG((tty),ISTRIP) 116#define I_ISTRIP(tty) _I_FLAG((tty), ISTRIP)
115#define I_INLCR(tty) _I_FLAG((tty),INLCR) 117#define I_INLCR(tty) _I_FLAG((tty), INLCR)
116#define I_IGNCR(tty) _I_FLAG((tty),IGNCR) 118#define I_IGNCR(tty) _I_FLAG((tty), IGNCR)
117#define I_ICRNL(tty) _I_FLAG((tty),ICRNL) 119#define I_ICRNL(tty) _I_FLAG((tty), ICRNL)
118#define I_IUCLC(tty) _I_FLAG((tty),IUCLC) 120#define I_IUCLC(tty) _I_FLAG((tty), IUCLC)
119#define I_IXON(tty) _I_FLAG((tty),IXON) 121#define I_IXON(tty) _I_FLAG((tty), IXON)
120#define I_IXANY(tty) _I_FLAG((tty),IXANY) 122#define I_IXANY(tty) _I_FLAG((tty), IXANY)
121#define I_IXOFF(tty) _I_FLAG((tty),IXOFF) 123#define I_IXOFF(tty) _I_FLAG((tty), IXOFF)
122#define I_IMAXBEL(tty) _I_FLAG((tty),IMAXBEL) 124#define I_IMAXBEL(tty) _I_FLAG((tty), IMAXBEL)
123#define I_IUTF8(tty) _I_FLAG((tty),IUTF8) 125#define I_IUTF8(tty) _I_FLAG((tty), IUTF8)
124 126
125#define O_OPOST(tty) _O_FLAG((tty),OPOST) 127#define O_OPOST(tty) _O_FLAG((tty), OPOST)
126#define O_OLCUC(tty) _O_FLAG((tty),OLCUC) 128#define O_OLCUC(tty) _O_FLAG((tty), OLCUC)
127#define O_ONLCR(tty) _O_FLAG((tty),ONLCR) 129#define O_ONLCR(tty) _O_FLAG((tty), ONLCR)
128#define O_OCRNL(tty) _O_FLAG((tty),OCRNL) 130#define O_OCRNL(tty) _O_FLAG((tty), OCRNL)
129#define O_ONOCR(tty) _O_FLAG((tty),ONOCR) 131#define O_ONOCR(tty) _O_FLAG((tty), ONOCR)
130#define O_ONLRET(tty) _O_FLAG((tty),ONLRET) 132#define O_ONLRET(tty) _O_FLAG((tty), ONLRET)
131#define O_OFILL(tty) _O_FLAG((tty),OFILL) 133#define O_OFILL(tty) _O_FLAG((tty), OFILL)
132#define O_OFDEL(tty) _O_FLAG((tty),OFDEL) 134#define O_OFDEL(tty) _O_FLAG((tty), OFDEL)
133#define O_NLDLY(tty) _O_FLAG((tty),NLDLY) 135#define O_NLDLY(tty) _O_FLAG((tty), NLDLY)
134#define O_CRDLY(tty) _O_FLAG((tty),CRDLY) 136#define O_CRDLY(tty) _O_FLAG((tty), CRDLY)
135#define O_TABDLY(tty) _O_FLAG((tty),TABDLY) 137#define O_TABDLY(tty) _O_FLAG((tty), TABDLY)
136#define O_BSDLY(tty) _O_FLAG((tty),BSDLY) 138#define O_BSDLY(tty) _O_FLAG((tty), BSDLY)
137#define O_VTDLY(tty) _O_FLAG((tty),VTDLY) 139#define O_VTDLY(tty) _O_FLAG((tty), VTDLY)
138#define O_FFDLY(tty) _O_FLAG((tty),FFDLY) 140#define O_FFDLY(tty) _O_FLAG((tty), FFDLY)
139 141
140#define C_BAUD(tty) _C_FLAG((tty),CBAUD) 142#define C_BAUD(tty) _C_FLAG((tty), CBAUD)
141#define C_CSIZE(tty) _C_FLAG((tty),CSIZE) 143#define C_CSIZE(tty) _C_FLAG((tty), CSIZE)
142#define C_CSTOPB(tty) _C_FLAG((tty),CSTOPB) 144#define C_CSTOPB(tty) _C_FLAG((tty), CSTOPB)
143#define C_CREAD(tty) _C_FLAG((tty),CREAD) 145#define C_CREAD(tty) _C_FLAG((tty), CREAD)
144#define C_PARENB(tty) _C_FLAG((tty),PARENB) 146#define C_PARENB(tty) _C_FLAG((tty), PARENB)
145#define C_PARODD(tty) _C_FLAG((tty),PARODD) 147#define C_PARODD(tty) _C_FLAG((tty), PARODD)
146#define C_HUPCL(tty) _C_FLAG((tty),HUPCL) 148#define C_HUPCL(tty) _C_FLAG((tty), HUPCL)
147#define C_CLOCAL(tty) _C_FLAG((tty),CLOCAL) 149#define C_CLOCAL(tty) _C_FLAG((tty), CLOCAL)
148#define C_CIBAUD(tty) _C_FLAG((tty),CIBAUD) 150#define C_CIBAUD(tty) _C_FLAG((tty), CIBAUD)
149#define C_CRTSCTS(tty) _C_FLAG((tty),CRTSCTS) 151#define C_CRTSCTS(tty) _C_FLAG((tty), CRTSCTS)
150 152
151#define L_ISIG(tty) _L_FLAG((tty),ISIG) 153#define L_ISIG(tty) _L_FLAG((tty), ISIG)
152#define L_ICANON(tty) _L_FLAG((tty),ICANON) 154#define L_ICANON(tty) _L_FLAG((tty), ICANON)
153#define L_XCASE(tty) _L_FLAG((tty),XCASE) 155#define L_XCASE(tty) _L_FLAG((tty), XCASE)
154#define L_ECHO(tty) _L_FLAG((tty),ECHO) 156#define L_ECHO(tty) _L_FLAG((tty), ECHO)
155#define L_ECHOE(tty) _L_FLAG((tty),ECHOE) 157#define L_ECHOE(tty) _L_FLAG((tty), ECHOE)
156#define L_ECHOK(tty) _L_FLAG((tty),ECHOK) 158#define L_ECHOK(tty) _L_FLAG((tty), ECHOK)
157#define L_ECHONL(tty) _L_FLAG((tty),ECHONL) 159#define L_ECHONL(tty) _L_FLAG((tty), ECHONL)
158#define L_NOFLSH(tty) _L_FLAG((tty),NOFLSH) 160#define L_NOFLSH(tty) _L_FLAG((tty), NOFLSH)
159#define L_TOSTOP(tty) _L_FLAG((tty),TOSTOP) 161#define L_TOSTOP(tty) _L_FLAG((tty), TOSTOP)
160#define L_ECHOCTL(tty) _L_FLAG((tty),ECHOCTL) 162#define L_ECHOCTL(tty) _L_FLAG((tty), ECHOCTL)
161#define L_ECHOPRT(tty) _L_FLAG((tty),ECHOPRT) 163#define L_ECHOPRT(tty) _L_FLAG((tty), ECHOPRT)
162#define L_ECHOKE(tty) _L_FLAG((tty),ECHOKE) 164#define L_ECHOKE(tty) _L_FLAG((tty), ECHOKE)
163#define L_FLUSHO(tty) _L_FLAG((tty),FLUSHO) 165#define L_FLUSHO(tty) _L_FLAG((tty), FLUSHO)
164#define L_PENDIN(tty) _L_FLAG((tty),PENDIN) 166#define L_PENDIN(tty) _L_FLAG((tty), PENDIN)
165#define L_IEXTEN(tty) _L_FLAG((tty),IEXTEN) 167#define L_IEXTEN(tty) _L_FLAG((tty), IEXTEN)
166 168
167struct device; 169struct device;
168struct signal_struct; 170struct signal_struct;
171
172/*
173 * Port level information. Each device keeps its own port level information
174 * so provide a common structure for those ports wanting to use common support
175 * routines.
176 *
177 * The tty port has a different lifetime to the tty so must be kept apart.
178 * In addition be careful as tty -> port mappings are valid for the life
179 * of the tty object but in many cases port -> tty mappings are valid only
180 * until a hangup so don't use the wrong path.
181 */
182
183struct tty_port {
184 struct tty_struct *tty; /* Back pointer */
185 spinlock_t lock; /* Lock protecting tty field */
186 int blocked_open; /* Waiting to open */
187 int count; /* Usage count */
188 wait_queue_head_t open_wait; /* Open waiters */
189 wait_queue_head_t close_wait; /* Close waiters */
190 unsigned long flags; /* TTY flags ASY_*/
191 struct mutex mutex; /* Locking */
192 unsigned char *xmit_buf; /* Optional buffer */
193 int close_delay; /* Close port delay */
194 int closing_wait; /* Delay for output */
195};
196
169/* 197/*
170 * Where all of the state associated with a tty is kept while the tty 198 * Where all of the state associated with a tty is kept while the tty
171 * is open. Since the termios state should be kept even if the tty 199 * is open. Since the termios state should be kept even if the tty
@@ -182,14 +210,17 @@ struct tty_operations;
182 210
183struct tty_struct { 211struct tty_struct {
184 int magic; 212 int magic;
213 struct kref kref;
185 struct tty_driver *driver; 214 struct tty_driver *driver;
186 const struct tty_operations *ops; 215 const struct tty_operations *ops;
187 int index; 216 int index;
217 /* The ldisc objects are protected by tty_ldisc_lock at the moment */
188 struct tty_ldisc ldisc; 218 struct tty_ldisc ldisc;
189 struct mutex termios_mutex; 219 struct mutex termios_mutex;
190 spinlock_t ctrl_lock; 220 spinlock_t ctrl_lock;
191 /* Termios values are protected by the termios mutex */ 221 /* Termios values are protected by the termios mutex */
192 struct ktermios *termios, *termios_locked; 222 struct ktermios *termios, *termios_locked;
223 struct termiox *termiox; /* May be NULL for unsupported */
193 char name[64]; 224 char name[64];
194 struct pid *pgrp; /* Protected by ctrl lock */ 225 struct pid *pgrp; /* Protected by ctrl lock */
195 struct pid *session; 226 struct pid *session;
@@ -213,7 +244,7 @@ struct tty_struct {
213 struct list_head tty_files; 244 struct list_head tty_files;
214 245
215#define N_TTY_BUF_SIZE 4096 246#define N_TTY_BUF_SIZE 4096
216 247
217 /* 248 /*
218 * The following is data for the N_TTY line discipline. For 249 * The following is data for the N_TTY line discipline. For
219 * historical reasons, this is included in the tty structure. 250 * historical reasons, this is included in the tty structure.
@@ -241,6 +272,7 @@ struct tty_struct {
241 spinlock_t read_lock; 272 spinlock_t read_lock;
242 /* If the tty has a pending do_SAK, queue it here - akpm */ 273 /* If the tty has a pending do_SAK, queue it here - akpm */
243 struct work_struct SAK_work; 274 struct work_struct SAK_work;
275 struct tty_port *port;
244}; 276};
245 277
246/* tty magic number */ 278/* tty magic number */
@@ -248,14 +280,14 @@ struct tty_struct {
248 280
249/* 281/*
250 * These bits are used in the flags field of the tty structure. 282 * These bits are used in the flags field of the tty structure.
251 * 283 *
252 * So that interrupts won't be able to mess up the queues, 284 * So that interrupts won't be able to mess up the queues,
253 * copy_to_cooked must be atomic with respect to itself, as must 285 * copy_to_cooked must be atomic with respect to itself, as must
254 * tty->write. Thus, you must use the inline functions set_bit() and 286 * tty->write. Thus, you must use the inline functions set_bit() and
255 * clear_bit() to make things atomic. 287 * clear_bit() to make things atomic.
256 */ 288 */
257#define TTY_THROTTLED 0 /* Call unthrottle() at threshold min */ 289#define TTY_THROTTLED 0 /* Call unthrottle() at threshold min */
258#define TTY_IO_ERROR 1 /* Canse an I/O error (may be no ldisc too) */ 290#define TTY_IO_ERROR 1 /* Cause an I/O error (may be no ldisc too) */
259#define TTY_OTHER_CLOSED 2 /* Other side (if any) has closed */ 291#define TTY_OTHER_CLOSED 2 /* Other side (if any) has closed */
260#define TTY_EXCLUSIVE 3 /* Exclusive open mode */ 292#define TTY_EXCLUSIVE 3 /* Exclusive open mode */
261#define TTY_DEBUG 4 /* Debugging */ 293#define TTY_DEBUG 4 /* Debugging */
@@ -282,15 +314,32 @@ extern int kmsg_redirect;
282extern void console_init(void); 314extern void console_init(void);
283extern int vcs_init(void); 315extern int vcs_init(void);
284 316
317extern struct class *tty_class;
318
319/**
320 * tty_kref_get - get a tty reference
321 * @tty: tty device
322 *
323 * Return a new reference to a tty object. The caller must hold
324 * sufficient locks/counts to ensure that their existing reference cannot
325 * go away
326 */
327
328extern inline struct tty_struct *tty_kref_get(struct tty_struct *tty)
329{
330 if (tty)
331 kref_get(&tty->kref);
332 return tty;
333}
334extern void tty_kref_put(struct tty_struct *tty);
335
285extern int tty_paranoia_check(struct tty_struct *tty, struct inode *inode, 336extern int tty_paranoia_check(struct tty_struct *tty, struct inode *inode,
286 const char *routine); 337 const char *routine);
287extern char *tty_name(struct tty_struct *tty, char *buf); 338extern char *tty_name(struct tty_struct *tty, char *buf);
288extern void tty_wait_until_sent(struct tty_struct * tty, long timeout); 339extern void tty_wait_until_sent(struct tty_struct *tty, long timeout);
289extern int tty_check_change(struct tty_struct * tty); 340extern int tty_check_change(struct tty_struct *tty);
290extern void stop_tty(struct tty_struct * tty); 341extern void stop_tty(struct tty_struct *tty);
291extern void start_tty(struct tty_struct * tty); 342extern void start_tty(struct tty_struct *tty);
292extern int tty_register_ldisc(int disc, struct tty_ldisc *new_ldisc);
293extern int tty_unregister_ldisc(int disc);
294extern int tty_register_driver(struct tty_driver *driver); 343extern int tty_register_driver(struct tty_driver *driver);
295extern int tty_unregister_driver(struct tty_driver *driver); 344extern int tty_unregister_driver(struct tty_driver *driver);
296extern struct device *tty_register_device(struct tty_driver *driver, 345extern struct device *tty_register_device(struct tty_driver *driver,
@@ -305,34 +354,41 @@ extern int tty_write_room(struct tty_struct *tty);
305extern void tty_driver_flush_buffer(struct tty_struct *tty); 354extern void tty_driver_flush_buffer(struct tty_struct *tty);
306extern void tty_throttle(struct tty_struct *tty); 355extern void tty_throttle(struct tty_struct *tty);
307extern void tty_unthrottle(struct tty_struct *tty); 356extern void tty_unthrottle(struct tty_struct *tty);
308 357extern int tty_do_resize(struct tty_struct *tty, struct tty_struct *real_tty,
358 struct winsize *ws);
359extern void tty_shutdown(struct tty_struct *tty);
360extern void tty_free_termios(struct tty_struct *tty);
309extern int is_current_pgrp_orphaned(void); 361extern int is_current_pgrp_orphaned(void);
310extern struct pid *tty_get_pgrp(struct tty_struct *tty); 362extern struct pid *tty_get_pgrp(struct tty_struct *tty);
311extern int is_ignored(int sig); 363extern int is_ignored(int sig);
312extern int tty_signal(int sig, struct tty_struct *tty); 364extern int tty_signal(int sig, struct tty_struct *tty);
313extern void tty_hangup(struct tty_struct * tty); 365extern void tty_hangup(struct tty_struct *tty);
314extern void tty_vhangup(struct tty_struct * tty); 366extern void tty_vhangup(struct tty_struct *tty);
367extern void tty_vhangup_self(void);
315extern void tty_unhangup(struct file *filp); 368extern void tty_unhangup(struct file *filp);
316extern int tty_hung_up_p(struct file * filp); 369extern int tty_hung_up_p(struct file *filp);
317extern void do_SAK(struct tty_struct *tty); 370extern void do_SAK(struct tty_struct *tty);
318extern void __do_SAK(struct tty_struct *tty); 371extern void __do_SAK(struct tty_struct *tty);
319extern void disassociate_ctty(int priv); 372extern void disassociate_ctty(int priv);
320extern void no_tty(void); 373extern void no_tty(void);
321extern void tty_flip_buffer_push(struct tty_struct *tty); 374extern void tty_flip_buffer_push(struct tty_struct *tty);
375extern void tty_buffer_free_all(struct tty_struct *tty);
376extern void tty_buffer_flush(struct tty_struct *tty);
377extern void tty_buffer_init(struct tty_struct *tty);
322extern speed_t tty_get_baud_rate(struct tty_struct *tty); 378extern speed_t tty_get_baud_rate(struct tty_struct *tty);
323extern speed_t tty_termios_baud_rate(struct ktermios *termios); 379extern speed_t tty_termios_baud_rate(struct ktermios *termios);
324extern speed_t tty_termios_input_baud_rate(struct ktermios *termios); 380extern speed_t tty_termios_input_baud_rate(struct ktermios *termios);
325extern void tty_termios_encode_baud_rate(struct ktermios *termios, speed_t ibaud, speed_t obaud); 381extern void tty_termios_encode_baud_rate(struct ktermios *termios,
326extern void tty_encode_baud_rate(struct tty_struct *tty, speed_t ibaud, speed_t obaud); 382 speed_t ibaud, speed_t obaud);
383extern void tty_encode_baud_rate(struct tty_struct *tty,
384 speed_t ibaud, speed_t obaud);
327extern void tty_termios_copy_hw(struct ktermios *new, struct ktermios *old); 385extern void tty_termios_copy_hw(struct ktermios *new, struct ktermios *old);
328extern int tty_termios_hw_change(struct ktermios *a, struct ktermios *b); 386extern int tty_termios_hw_change(struct ktermios *a, struct ktermios *b);
329 387
330extern struct tty_ldisc *tty_ldisc_ref(struct tty_struct *); 388extern struct tty_ldisc *tty_ldisc_ref(struct tty_struct *);
331extern void tty_ldisc_deref(struct tty_ldisc *); 389extern void tty_ldisc_deref(struct tty_ldisc *);
332extern struct tty_ldisc *tty_ldisc_ref_wait(struct tty_struct *); 390extern struct tty_ldisc *tty_ldisc_ref_wait(struct tty_struct *);
333 391extern const struct file_operations tty_ldiscs_proc_fops;
334extern struct tty_ldisc *tty_ldisc_get(int);
335extern void tty_ldisc_put(int);
336 392
337extern void tty_wakeup(struct tty_struct *tty); 393extern void tty_wakeup(struct tty_struct *tty);
338extern void tty_ldisc_flush(struct tty_struct *tty); 394extern void tty_ldisc_flush(struct tty_struct *tty);
@@ -344,6 +400,15 @@ extern int tty_perform_flush(struct tty_struct *tty, unsigned long arg);
344extern dev_t tty_devnum(struct tty_struct *tty); 400extern dev_t tty_devnum(struct tty_struct *tty);
345extern void proc_clear_tty(struct task_struct *p); 401extern void proc_clear_tty(struct task_struct *p);
346extern struct tty_struct *get_current_tty(void); 402extern struct tty_struct *get_current_tty(void);
403extern void tty_default_fops(struct file_operations *fops);
404extern struct tty_struct *alloc_tty_struct(void);
405extern void free_tty_struct(struct tty_struct *tty);
406extern void initialize_tty_struct(struct tty_struct *tty,
407 struct tty_driver *driver, int idx);
408extern struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx,
409 int first_ok);
410extern void tty_release_dev(struct file *filp);
411extern int tty_init_termios(struct tty_struct *tty);
347 412
348extern struct mutex tty_mutex; 413extern struct mutex tty_mutex;
349 414
@@ -351,10 +416,25 @@ extern void tty_write_unlock(struct tty_struct *tty);
351extern int tty_write_lock(struct tty_struct *tty, int ndelay); 416extern int tty_write_lock(struct tty_struct *tty, int ndelay);
352#define tty_is_writelocked(tty) (mutex_is_locked(&tty->atomic_write_lock)) 417#define tty_is_writelocked(tty) (mutex_is_locked(&tty->atomic_write_lock))
353 418
419extern void tty_port_init(struct tty_port *port);
420extern int tty_port_alloc_xmit_buf(struct tty_port *port);
421extern void tty_port_free_xmit_buf(struct tty_port *port);
422extern struct tty_struct *tty_port_tty_get(struct tty_port *port);
423extern void tty_port_tty_set(struct tty_port *port, struct tty_struct *tty);
424
425extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
426extern int tty_unregister_ldisc(int disc);
427extern int tty_set_ldisc(struct tty_struct *tty, int ldisc);
428extern int tty_ldisc_setup(struct tty_struct *tty, struct tty_struct *o_tty);
429extern void tty_ldisc_release(struct tty_struct *tty, struct tty_struct *o_tty);
430extern void tty_ldisc_init(struct tty_struct *tty);
431extern void tty_ldisc_begin(void);
432/* This last one is just for the tty layer internals and shouldn't be used elsewhere */
433extern void tty_ldisc_enable(struct tty_struct *tty);
354 434
355 435
356/* n_tty.c */ 436/* n_tty.c */
357extern struct tty_ldisc tty_ldisc_N_TTY; 437extern struct tty_ldisc_ops tty_ldisc_N_TTY;
358 438
359/* tty_audit.c */ 439/* tty_audit.c */
360#ifdef CONFIG_AUDIT 440#ifdef CONFIG_AUDIT
@@ -363,7 +443,8 @@ extern void tty_audit_add_data(struct tty_struct *tty, unsigned char *data,
363extern void tty_audit_exit(void); 443extern void tty_audit_exit(void);
364extern void tty_audit_fork(struct signal_struct *sig); 444extern void tty_audit_fork(struct signal_struct *sig);
365extern void tty_audit_push(struct tty_struct *tty); 445extern void tty_audit_push(struct tty_struct *tty);
366extern void tty_audit_push_task(struct task_struct *tsk, uid_t loginuid, u32 sessionid); 446extern void tty_audit_push_task(struct task_struct *tsk,
447 uid_t loginuid, u32 sessionid);
367#else 448#else
368static inline void tty_audit_add_data(struct tty_struct *tty, 449static inline void tty_audit_add_data(struct tty_struct *tty,
369 unsigned char *data, size_t size) 450 unsigned char *data, size_t size)
@@ -378,19 +459,20 @@ static inline void tty_audit_fork(struct signal_struct *sig)
378static inline void tty_audit_push(struct tty_struct *tty) 459static inline void tty_audit_push(struct tty_struct *tty)
379{ 460{
380} 461}
381static inline void tty_audit_push_task(struct task_struct *tsk, uid_t loginuid, u32 sessionid) 462static inline void tty_audit_push_task(struct task_struct *tsk,
463 uid_t loginuid, u32 sessionid)
382{ 464{
383} 465}
384#endif 466#endif
385 467
386/* tty_ioctl.c */ 468/* tty_ioctl.c */
387extern int n_tty_ioctl(struct tty_struct * tty, struct file * file, 469extern int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file,
388 unsigned int cmd, unsigned long arg); 470 unsigned int cmd, unsigned long arg);
389 471
390/* serial.c */ 472/* serial.c */
391 473
392extern void serial_console_init(void); 474extern void serial_console_init(void);
393 475
394/* pcxx.c */ 476/* pcxx.c */
395 477
396extern int pcxe_open(struct tty_struct *tty, struct file *filp); 478extern int pcxe_open(struct tty_struct *tty, struct file *filp);
@@ -401,7 +483,7 @@ extern void console_print(const char *);
401 483
402/* vt.c */ 484/* vt.c */
403 485
404extern int vt_ioctl(struct tty_struct *tty, struct file * file, 486extern int vt_ioctl(struct tty_struct *tty, struct file *file,
405 unsigned int cmd, unsigned long arg); 487 unsigned int cmd, unsigned long arg);
406 488
407#endif /* __KERNEL__ */ 489#endif /* __KERNEL__ */
diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
index d2a003586761..78416b901589 100644
--- a/include/linux/tty_driver.h
+++ b/include/linux/tty_driver.h
@@ -7,6 +7,28 @@
7 * defined; unless noted otherwise, they are optional, and can be 7 * defined; unless noted otherwise, they are optional, and can be
8 * filled in with a null pointer. 8 * filled in with a null pointer.
9 * 9 *
10 * struct tty_struct * (*lookup)(struct tty_driver *self, int idx)
11 *
12 * Return the tty device corresponding to idx, NULL if there is not
13 * one currently in use and an ERR_PTR value on error. Called under
14 * tty_mutex (for now!)
15 *
16 * Optional method. Default behaviour is to use the ttys array
17 *
18 * int (*install)(struct tty_driver *self, struct tty_struct *tty)
19 *
20 * Install a new tty into the tty driver internal tables. Used in
21 * conjunction with lookup and remove methods.
22 *
23 * Optional method. Default behaviour is to use the ttys array
24 *
25 * void (*remove)(struct tty_driver *self, struct tty_struct *tty)
26 *
27 * Remove a closed tty from the tty driver internal tables. Used in
28 * conjunction with lookup and remove methods.
29 *
30 * Optional method. Default behaviour is to use the ttys array
31 *
10 * int (*open)(struct tty_struct * tty, struct file * filp); 32 * int (*open)(struct tty_struct * tty, struct file * filp);
11 * 33 *
12 * This routine is called when a particular tty device is opened. 34 * This routine is called when a particular tty device is opened.
@@ -21,6 +43,11 @@
21 * 43 *
22 * Required method. 44 * Required method.
23 * 45 *
46 * void (*shutdown)(struct tty_struct * tty);
47 *
48 * This routine is called when a particular tty device is closed for
49 * the last time freeing up the resources.
50 *
24 * int (*write)(struct tty_struct * tty, 51 * int (*write)(struct tty_struct * tty,
25 * const unsigned char *buf, int count); 52 * const unsigned char *buf, int count);
26 * 53 *
@@ -135,7 +162,7 @@
135 * 162 *
136 * Optional: 163 * Optional:
137 * 164 *
138 * void (*break_ctl)(struct tty_stuct *tty, int state); 165 * int (*break_ctl)(struct tty_stuct *tty, int state);
139 * 166 *
140 * This optional routine requests the tty driver to turn on or 167 * This optional routine requests the tty driver to turn on or
141 * off BREAK status on the RS-232 port. If state is -1, 168 * off BREAK status on the RS-232 port. If state is -1,
@@ -146,6 +173,10 @@
146 * handle the following ioctls: TCSBRK, TCSBRKP, TIOCSBRK, 173 * handle the following ioctls: TCSBRK, TCSBRKP, TIOCSBRK,
147 * TIOCCBRK. 174 * TIOCCBRK.
148 * 175 *
176 * If the driver sets TTY_DRIVER_HARDWARE_BREAK then the interface
177 * will also be called with actual times and the hardware is expected
178 * to do the delay work itself. 0 and -1 are still used for on/off.
179 *
149 * Optional: Required for TCSBRK/BRKP/etc handling. 180 * Optional: Required for TCSBRK/BRKP/etc handling.
150 * 181 *
151 * void (*wait_until_sent)(struct tty_struct *tty, int timeout); 182 * void (*wait_until_sent)(struct tty_struct *tty, int timeout);
@@ -164,6 +195,26 @@
164 * 195 *
165 * Optional: If not provided then the write method is called under 196 * Optional: If not provided then the write method is called under
166 * the atomic write lock to keep it serialized with the ldisc. 197 * the atomic write lock to keep it serialized with the ldisc.
198 *
199 * int (*resize)(struct tty_struct *tty, struct tty_struct *real_tty,
200 * unsigned int rows, unsigned int cols);
201 *
202 * Called when a termios request is issued which changes the
203 * requested terminal geometry.
204 *
205 * Optional: the default action is to update the termios structure
206 * without error. This is usually the correct behaviour. Drivers should
207 * not force errors here if they are not resizable objects (eg a serial
208 * line). See tty_do_resize() if you need to wrap the standard method
209 * in your own logic - the usual case.
210 *
211 * void (*set_termiox)(struct tty_struct *tty, struct termiox *new);
212 *
213 * Called when the device receives a termiox based ioctl. Passes down
214 * the requested data from user space. This method will not be invoked
215 * unless the tty also has a valid tty->termiox pointer.
216 *
217 * Optional: Called under the termios lock
167 */ 218 */
168 219
169#include <linux/fs.h> 220#include <linux/fs.h>
@@ -174,8 +225,13 @@ struct tty_struct;
174struct tty_driver; 225struct tty_driver;
175 226
176struct tty_operations { 227struct tty_operations {
228 struct tty_struct * (*lookup)(struct tty_driver *driver,
229 struct inode *inode, int idx);
230 int (*install)(struct tty_driver *driver, struct tty_struct *tty);
231 void (*remove)(struct tty_driver *driver, struct tty_struct *tty);
177 int (*open)(struct tty_struct * tty, struct file * filp); 232 int (*open)(struct tty_struct * tty, struct file * filp);
178 void (*close)(struct tty_struct * tty, struct file * filp); 233 void (*close)(struct tty_struct * tty, struct file * filp);
234 void (*shutdown)(struct tty_struct *tty);
179 int (*write)(struct tty_struct * tty, 235 int (*write)(struct tty_struct * tty,
180 const unsigned char *buf, int count); 236 const unsigned char *buf, int count);
181 int (*put_char)(struct tty_struct *tty, unsigned char ch); 237 int (*put_char)(struct tty_struct *tty, unsigned char ch);
@@ -192,7 +248,7 @@ struct tty_operations {
192 void (*stop)(struct tty_struct *tty); 248 void (*stop)(struct tty_struct *tty);
193 void (*start)(struct tty_struct *tty); 249 void (*start)(struct tty_struct *tty);
194 void (*hangup)(struct tty_struct *tty); 250 void (*hangup)(struct tty_struct *tty);
195 void (*break_ctl)(struct tty_struct *tty, int state); 251 int (*break_ctl)(struct tty_struct *tty, int state);
196 void (*flush_buffer)(struct tty_struct *tty); 252 void (*flush_buffer)(struct tty_struct *tty);
197 void (*set_ldisc)(struct tty_struct *tty); 253 void (*set_ldisc)(struct tty_struct *tty);
198 void (*wait_until_sent)(struct tty_struct *tty, int timeout); 254 void (*wait_until_sent)(struct tty_struct *tty, int timeout);
@@ -202,6 +258,9 @@ struct tty_operations {
202 int (*tiocmget)(struct tty_struct *tty, struct file *file); 258 int (*tiocmget)(struct tty_struct *tty, struct file *file);
203 int (*tiocmset)(struct tty_struct *tty, struct file *file, 259 int (*tiocmset)(struct tty_struct *tty, struct file *file,
204 unsigned int set, unsigned int clear); 260 unsigned int set, unsigned int clear);
261 int (*resize)(struct tty_struct *tty, struct tty_struct *real_tty,
262 struct winsize *ws);
263 int (*set_termiox)(struct tty_struct *tty, struct termiox *tnew);
205#ifdef CONFIG_CONSOLE_POLL 264#ifdef CONFIG_CONSOLE_POLL
206 int (*poll_init)(struct tty_driver *driver, int line, char *options); 265 int (*poll_init)(struct tty_driver *driver, int line, char *options);
207 int (*poll_get_char)(struct tty_driver *driver, int line); 266 int (*poll_get_char)(struct tty_driver *driver, int line);
@@ -211,6 +270,7 @@ struct tty_operations {
211 270
212struct tty_driver { 271struct tty_driver {
213 int magic; /* magic number for this structure */ 272 int magic; /* magic number for this structure */
273 struct kref kref; /* Reference management */
214 struct cdev cdev; 274 struct cdev cdev;
215 struct module *owner; 275 struct module *owner;
216 const char *driver_name; 276 const char *driver_name;
@@ -224,7 +284,6 @@ struct tty_driver {
224 short subtype; /* subtype of tty driver */ 284 short subtype; /* subtype of tty driver */
225 struct ktermios init_termios; /* Initial termios */ 285 struct ktermios init_termios; /* Initial termios */
226 int flags; /* tty driver flags */ 286 int flags; /* tty driver flags */
227 int refcount; /* for loadable tty drivers */
228 struct proc_dir_entry *proc_entry; /* /proc fs entry */ 287 struct proc_dir_entry *proc_entry; /* /proc fs entry */
229 struct tty_driver *other; /* only used for the PTY driver */ 288 struct tty_driver *other; /* only used for the PTY driver */
230 289
@@ -246,12 +305,19 @@ struct tty_driver {
246 305
247extern struct list_head tty_drivers; 306extern struct list_head tty_drivers;
248 307
249struct tty_driver *alloc_tty_driver(int lines); 308extern struct tty_driver *alloc_tty_driver(int lines);
250void put_tty_driver(struct tty_driver *driver); 309extern void put_tty_driver(struct tty_driver *driver);
251void tty_set_operations(struct tty_driver *driver, 310extern void tty_set_operations(struct tty_driver *driver,
252 const struct tty_operations *op); 311 const struct tty_operations *op);
253extern struct tty_driver *tty_find_polling_driver(char *name, int *line); 312extern struct tty_driver *tty_find_polling_driver(char *name, int *line);
254 313
314extern void tty_driver_kref_put(struct tty_driver *driver);
315extern inline struct tty_driver *tty_driver_kref_get(struct tty_driver *d)
316{
317 kref_get(&d->kref);
318 return d;
319}
320
255/* tty driver magic number */ 321/* tty driver magic number */
256#define TTY_DRIVER_MAGIC 0x5402 322#define TTY_DRIVER_MAGIC 0x5402
257 323
@@ -285,12 +351,18 @@ extern struct tty_driver *tty_find_polling_driver(char *name, int *line);
285 * TTY_DRIVER_DEVPTS_MEM -- don't use the standard arrays, instead 351 * TTY_DRIVER_DEVPTS_MEM -- don't use the standard arrays, instead
286 * use dynamic memory keyed through the devpts filesystem. This 352 * use dynamic memory keyed through the devpts filesystem. This
287 * is only applicable to the pty driver. 353 * is only applicable to the pty driver.
354 *
355 * TTY_DRIVER_HARDWARE_BREAK -- hardware handles break signals. Pass
356 * the requested timeout to the caller instead of using a simple
357 * on/off interface.
358 *
288 */ 359 */
289#define TTY_DRIVER_INSTALLED 0x0001 360#define TTY_DRIVER_INSTALLED 0x0001
290#define TTY_DRIVER_RESET_TERMIOS 0x0002 361#define TTY_DRIVER_RESET_TERMIOS 0x0002
291#define TTY_DRIVER_REAL_RAW 0x0004 362#define TTY_DRIVER_REAL_RAW 0x0004
292#define TTY_DRIVER_DYNAMIC_DEV 0x0008 363#define TTY_DRIVER_DYNAMIC_DEV 0x0008
293#define TTY_DRIVER_DEVPTS_MEM 0x0010 364#define TTY_DRIVER_DEVPTS_MEM 0x0010
365#define TTY_DRIVER_HARDWARE_BREAK 0x0020
294 366
295/* tty driver types */ 367/* tty driver types */
296#define TTY_DRIVER_TYPE_SYSTEM 0x0001 368#define TTY_DRIVER_TYPE_SYSTEM 0x0001
diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
index 6226504d9108..40f38d896777 100644
--- a/include/linux/tty_ldisc.h
+++ b/include/linux/tty_ldisc.h
@@ -104,7 +104,7 @@
104#include <linux/fs.h> 104#include <linux/fs.h>
105#include <linux/wait.h> 105#include <linux/wait.h>
106 106
107struct tty_ldisc { 107struct tty_ldisc_ops {
108 int magic; 108 int magic;
109 char *name; 109 char *name;
110 int num; 110 int num;
@@ -142,6 +142,11 @@ struct tty_ldisc {
142 int refcount; 142 int refcount;
143}; 143};
144 144
145struct tty_ldisc {
146 struct tty_ldisc_ops *ops;
147 int refcount;
148};
149
145#define TTY_LDISC_MAGIC 0x5403 150#define TTY_LDISC_MAGIC 0x5403
146 151
147#define LDISC_FLAG_DEFINED 0x00000001 152#define LDISC_FLAG_DEFINED 0x00000001
diff --git a/include/linux/typecheck.h b/include/linux/typecheck.h
new file mode 100644
index 000000000000..eb5b74a575be
--- /dev/null
+++ b/include/linux/typecheck.h
@@ -0,0 +1,24 @@
1#ifndef TYPECHECK_H_INCLUDED
2#define TYPECHECK_H_INCLUDED
3
4/*
5 * Check at compile time that something is of a particular type.
6 * Always evaluates to 1 so you may use it easily in comparisons.
7 */
8#define typecheck(type,x) \
9({ type __dummy; \
10 typeof(x) __dummy2; \
11 (void)(&__dummy == &__dummy2); \
12 1; \
13})
14
15/*
16 * Check at compile time that 'function' is a certain type, or is a pointer
17 * to that type (needs to use typedef for the function type.)
18 */
19#define typecheck_fn(type,function) \
20({ typeof(type) __tmp = function; \
21 (void)__tmp; \
22})
23
24#endif /* TYPECHECK_H_INCLUDED */
diff --git a/include/linux/types.h b/include/linux/types.h
index d4a9ce6e2760..1d98330b1f2c 100644
--- a/include/linux/types.h
+++ b/include/linux/types.h
@@ -190,13 +190,16 @@ typedef __u32 __bitwise __wsum;
190 190
191#ifdef __KERNEL__ 191#ifdef __KERNEL__
192typedef unsigned __bitwise__ gfp_t; 192typedef unsigned __bitwise__ gfp_t;
193typedef unsigned __bitwise__ fmode_t;
193 194
194#ifdef CONFIG_RESOURCES_64BIT 195#ifdef CONFIG_PHYS_ADDR_T_64BIT
195typedef u64 resource_size_t; 196typedef u64 phys_addr_t;
196#else 197#else
197typedef u32 resource_size_t; 198typedef u32 phys_addr_t;
198#endif 199#endif
199 200
201typedef phys_addr_t resource_size_t;
202
200struct ustat { 203struct ustat {
201 __kernel_daddr_t f_tfree; 204 __kernel_daddr_t f_tfree;
202 __kernel_ino_t f_tinode; 205 __kernel_ino_t f_tinode;
diff --git a/include/linux/ucb1400.h b/include/linux/ucb1400.h
new file mode 100644
index 000000000000..970473bf8d5a
--- /dev/null
+++ b/include/linux/ucb1400.h
@@ -0,0 +1,161 @@
1/*
2 * Register definitions and functions for:
3 * Philips UCB1400 driver
4 *
5 * Based on ucb1400_ts:
6 * Author: Nicolas Pitre
7 * Created: September 25, 2006
8 * Copyright: MontaVista Software, Inc.
9 *
10 * Spliting done by: Marek Vasut <marek.vasut@gmail.com>
11 * If something doesnt work and it worked before spliting, e-mail me,
12 * dont bother Nicolas please ;-)
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License version 2 as
16 * published by the Free Software Foundation.
17 *
18 * This code is heavily based on ucb1x00-*.c copyrighted by Russell King
19 * covering the UCB1100, UCB1200 and UCB1300.. Support for the UCB1400 has
20 * been made separate from ucb1x00-core/ucb1x00-ts on Russell's request.
21 */
22
23#ifndef _LINUX__UCB1400_H
24#define _LINUX__UCB1400_H
25
26#include <sound/ac97_codec.h>
27#include <linux/mutex.h>
28#include <linux/platform_device.h>
29
30/*
31 * UCB1400 AC-link registers
32 */
33
34#define UCB_IO_DATA 0x5a
35#define UCB_IO_DIR 0x5c
36#define UCB_IE_RIS 0x5e
37#define UCB_IE_FAL 0x60
38#define UCB_IE_STATUS 0x62
39#define UCB_IE_CLEAR 0x62
40#define UCB_IE_ADC (1 << 11)
41#define UCB_IE_TSPX (1 << 12)
42
43#define UCB_TS_CR 0x64
44#define UCB_TS_CR_TSMX_POW (1 << 0)
45#define UCB_TS_CR_TSPX_POW (1 << 1)
46#define UCB_TS_CR_TSMY_POW (1 << 2)
47#define UCB_TS_CR_TSPY_POW (1 << 3)
48#define UCB_TS_CR_TSMX_GND (1 << 4)
49#define UCB_TS_CR_TSPX_GND (1 << 5)
50#define UCB_TS_CR_TSMY_GND (1 << 6)
51#define UCB_TS_CR_TSPY_GND (1 << 7)
52#define UCB_TS_CR_MODE_INT (0 << 8)
53#define UCB_TS_CR_MODE_PRES (1 << 8)
54#define UCB_TS_CR_MODE_POS (2 << 8)
55#define UCB_TS_CR_BIAS_ENA (1 << 11)
56#define UCB_TS_CR_TSPX_LOW (1 << 12)
57#define UCB_TS_CR_TSMX_LOW (1 << 13)
58
59#define UCB_ADC_CR 0x66
60#define UCB_ADC_SYNC_ENA (1 << 0)
61#define UCB_ADC_VREFBYP_CON (1 << 1)
62#define UCB_ADC_INP_TSPX (0 << 2)
63#define UCB_ADC_INP_TSMX (1 << 2)
64#define UCB_ADC_INP_TSPY (2 << 2)
65#define UCB_ADC_INP_TSMY (3 << 2)
66#define UCB_ADC_INP_AD0 (4 << 2)
67#define UCB_ADC_INP_AD1 (5 << 2)
68#define UCB_ADC_INP_AD2 (6 << 2)
69#define UCB_ADC_INP_AD3 (7 << 2)
70#define UCB_ADC_EXT_REF (1 << 5)
71#define UCB_ADC_START (1 << 7)
72#define UCB_ADC_ENA (1 << 15)
73
74#define UCB_ADC_DATA 0x68
75#define UCB_ADC_DAT_VALID (1 << 15)
76#define UCB_ADC_DAT_MASK 0x3ff
77
78#define UCB_ID 0x7e
79#define UCB_ID_1400 0x4304
80
81struct ucb1400_ts {
82 struct input_dev *ts_idev;
83 struct task_struct *ts_task;
84 int id;
85 wait_queue_head_t ts_wait;
86 unsigned int ts_restart:1;
87 int irq;
88 unsigned int irq_pending; /* not bit field shared */
89 struct snd_ac97 *ac97;
90};
91
92struct ucb1400 {
93 struct platform_device *ucb1400_ts;
94};
95
96static inline u16 ucb1400_reg_read(struct snd_ac97 *ac97, u16 reg)
97{
98 return ac97->bus->ops->read(ac97, reg);
99}
100
101static inline void ucb1400_reg_write(struct snd_ac97 *ac97, u16 reg, u16 val)
102{
103 ac97->bus->ops->write(ac97, reg, val);
104}
105
106static inline u16 ucb1400_gpio_get_value(struct snd_ac97 *ac97, u16 gpio)
107{
108 return ucb1400_reg_read(ac97, UCB_IO_DATA) & (1 << gpio);
109}
110
111static inline void ucb1400_gpio_set_value(struct snd_ac97 *ac97, u16 gpio,
112 u16 val)
113{
114 ucb1400_reg_write(ac97, UCB_IO_DATA, val ?
115 ucb1400_reg_read(ac97, UCB_IO_DATA) | (1 << gpio) :
116 ucb1400_reg_read(ac97, UCB_IO_DATA) & ~(1 << gpio));
117}
118
119static inline u16 ucb1400_gpio_get_direction(struct snd_ac97 *ac97, u16 gpio)
120{
121 return ucb1400_reg_read(ac97, UCB_IO_DIR) & (1 << gpio);
122}
123
124static inline void ucb1400_gpio_set_direction(struct snd_ac97 *ac97, u16 gpio,
125 u16 dir)
126{
127 ucb1400_reg_write(ac97, UCB_IO_DIR, dir ?
128 ucb1400_reg_read(ac97, UCB_IO_DIR) | (1 << gpio) :
129 ucb1400_reg_read(ac97, UCB_IO_DIR) & ~(1 << gpio));
130}
131
132static inline void ucb1400_adc_enable(struct snd_ac97 *ac97)
133{
134 ucb1400_reg_write(ac97, UCB_ADC_CR, UCB_ADC_ENA);
135}
136
137static unsigned int ucb1400_adc_read(struct snd_ac97 *ac97, u16 adc_channel,
138 int adcsync)
139{
140 unsigned int val;
141
142 if (adcsync)
143 adc_channel |= UCB_ADC_SYNC_ENA;
144
145 ucb1400_reg_write(ac97, UCB_ADC_CR, UCB_ADC_ENA | adc_channel);
146 ucb1400_reg_write(ac97, UCB_ADC_CR, UCB_ADC_ENA | adc_channel |
147 UCB_ADC_START);
148
149 while (!((val = ucb1400_reg_read(ac97, UCB_ADC_DATA))
150 & UCB_ADC_DAT_VALID))
151 schedule_timeout_uninterruptible(1);
152
153 return val & UCB_ADC_DAT_MASK;
154}
155
156static inline void ucb1400_adc_disable(struct snd_ac97 *ac97)
157{
158 ucb1400_reg_write(ac97, UCB_ADC_CR, 0);
159}
160
161#endif
diff --git a/include/linux/udp.h b/include/linux/udp.h
index 581ca2c14c52..0cf5c4c0ec81 100644
--- a/include/linux/udp.h
+++ b/include/linux/udp.h
@@ -38,6 +38,7 @@ struct udphdr {
38#ifdef __KERNEL__ 38#ifdef __KERNEL__
39#include <net/inet_sock.h> 39#include <net/inet_sock.h>
40#include <linux/skbuff.h> 40#include <linux/skbuff.h>
41#include <net/netns/hash.h>
41 42
42static inline struct udphdr *udp_hdr(const struct sk_buff *skb) 43static inline struct udphdr *udp_hdr(const struct sk_buff *skb)
43{ 44{
@@ -46,6 +47,11 @@ static inline struct udphdr *udp_hdr(const struct sk_buff *skb)
46 47
47#define UDP_HTABLE_SIZE 128 48#define UDP_HTABLE_SIZE 128
48 49
50static inline int udp_hashfn(struct net *net, const unsigned num)
51{
52 return (num + net_hash_mix(net)) & (UDP_HTABLE_SIZE - 1);
53}
54
49struct udp_sock { 55struct udp_sock {
50 /* inet_sock has to be the first member */ 56 /* inet_sock has to be the first member */
51 struct inet_sock inet; 57 struct inet_sock inet;
diff --git a/include/linux/uio_driver.h b/include/linux/uio_driver.h
index 973386d439da..cdf338d94b7f 100644
--- a/include/linux/uio_driver.h
+++ b/include/linux/uio_driver.h
@@ -36,7 +36,7 @@ struct uio_mem {
36 struct uio_map *map; 36 struct uio_map *map;
37}; 37};
38 38
39#define MAX_UIO_MAPS 5 39#define MAX_UIO_MAPS 5
40 40
41struct uio_device; 41struct uio_device;
42 42
@@ -53,6 +53,7 @@ struct uio_device;
53 * @mmap: mmap operation for this uio device 53 * @mmap: mmap operation for this uio device
54 * @open: open operation for this uio device 54 * @open: open operation for this uio device
55 * @release: release operation for this uio device 55 * @release: release operation for this uio device
56 * @irqcontrol: disable/enable irqs when 0/1 is written to /dev/uioX
56 */ 57 */
57struct uio_info { 58struct uio_info {
58 struct uio_device *uio_dev; 59 struct uio_device *uio_dev;
@@ -66,6 +67,7 @@ struct uio_info {
66 int (*mmap)(struct uio_info *info, struct vm_area_struct *vma); 67 int (*mmap)(struct uio_info *info, struct vm_area_struct *vma);
67 int (*open)(struct uio_info *info, struct inode *inode); 68 int (*open)(struct uio_info *info, struct inode *inode);
68 int (*release)(struct uio_info *info, struct inode *inode); 69 int (*release)(struct uio_info *info, struct inode *inode);
70 int (*irqcontrol)(struct uio_info *info, s32 irq_on);
69}; 71};
70 72
71extern int __must_check 73extern int __must_check
@@ -80,11 +82,11 @@ static inline int __must_check
80extern void uio_unregister_device(struct uio_info *info); 82extern void uio_unregister_device(struct uio_info *info);
81extern void uio_event_notify(struct uio_info *info); 83extern void uio_event_notify(struct uio_info *info);
82 84
83/* defines for uio_device->irq */ 85/* defines for uio_info->irq */
84#define UIO_IRQ_CUSTOM -1 86#define UIO_IRQ_CUSTOM -1
85#define UIO_IRQ_NONE -2 87#define UIO_IRQ_NONE -2
86 88
87/* defines for uio_device->memtype */ 89/* defines for uio_mem->memtype */
88#define UIO_MEM_NONE 0 90#define UIO_MEM_NONE 0
89#define UIO_MEM_PHYS 1 91#define UIO_MEM_PHYS 1
90#define UIO_MEM_LOGICAL 2 92#define UIO_MEM_LOGICAL 2
diff --git a/include/linux/usb.h b/include/linux/usb.h
index c08689ea9b4b..8fa973bede5e 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -110,6 +110,10 @@ enum usb_interface_condition {
110 * @sysfs_files_created: sysfs attributes exist 110 * @sysfs_files_created: sysfs attributes exist
111 * @needs_remote_wakeup: flag set when the driver requires remote-wakeup 111 * @needs_remote_wakeup: flag set when the driver requires remote-wakeup
112 * capability during autosuspend. 112 * capability during autosuspend.
113 * @needs_altsetting0: flag set when a set-interface request for altsetting 0
114 * has been deferred.
115 * @needs_binding: flag set when the driver should be re-probed or unbound
116 * following a reset or suspend operation it doesn't support.
113 * @dev: driver model's view of this device 117 * @dev: driver model's view of this device
114 * @usb_dev: if an interface is bound to the USB major, this will point 118 * @usb_dev: if an interface is bound to the USB major, this will point
115 * to the sysfs representation for that device. 119 * to the sysfs representation for that device.
@@ -160,6 +164,8 @@ struct usb_interface {
160 unsigned is_active:1; /* the interface is not suspended */ 164 unsigned is_active:1; /* the interface is not suspended */
161 unsigned sysfs_files_created:1; /* the sysfs attributes exist */ 165 unsigned sysfs_files_created:1; /* the sysfs attributes exist */
162 unsigned needs_remote_wakeup:1; /* driver requires remote wakeup */ 166 unsigned needs_remote_wakeup:1; /* driver requires remote wakeup */
167 unsigned needs_altsetting0:1; /* switch to altsetting 0 is pending */
168 unsigned needs_binding:1; /* needs delayed unbind/rebind */
163 169
164 struct device dev; /* interface specific device info */ 170 struct device dev; /* interface specific device info */
165 struct device *usb_dev; 171 struct device *usb_dev;
@@ -293,7 +299,7 @@ struct usb_devmap {
293struct usb_bus { 299struct usb_bus {
294 struct device *controller; /* host/master side hardware */ 300 struct device *controller; /* host/master side hardware */
295 int busnum; /* Bus number (in order of reg) */ 301 int busnum; /* Bus number (in order of reg) */
296 char *bus_name; /* stable id (PCI slot_name etc) */ 302 const char *bus_name; /* stable id (PCI slot_name etc) */
297 u8 uses_dma; /* Does the host controller use DMA? */ 303 u8 uses_dma; /* Does the host controller use DMA? */
298 u8 otg_port; /* 0, or number of OTG/HNP port */ 304 u8 otg_port; /* 0, or number of OTG/HNP port */
299 unsigned is_b_host:1; /* true during some HNP roleswitches */ 305 unsigned is_b_host:1; /* true during some HNP roleswitches */
@@ -497,8 +503,6 @@ extern int usb_lock_device_for_reset(struct usb_device *udev,
497 503
498/* USB port reset for device reinitialization */ 504/* USB port reset for device reinitialization */
499extern int usb_reset_device(struct usb_device *dev); 505extern int usb_reset_device(struct usb_device *dev);
500extern int usb_reset_composite_device(struct usb_device *dev,
501 struct usb_interface *iface);
502 506
503extern struct usb_device *usb_find_device(u16 vendor_id, u16 product_id); 507extern struct usb_device *usb_find_device(u16 vendor_id, u16 product_id);
504 508
@@ -958,9 +962,9 @@ struct usbdrv_wrap {
958 * @resume: Called when the device is being resumed by the system. 962 * @resume: Called when the device is being resumed by the system.
959 * @reset_resume: Called when the suspended device has been reset instead 963 * @reset_resume: Called when the suspended device has been reset instead
960 * of being resumed. 964 * of being resumed.
961 * @pre_reset: Called by usb_reset_composite_device() when the device 965 * @pre_reset: Called by usb_reset_device() when the device
962 * is about to be reset. 966 * is about to be reset.
963 * @post_reset: Called by usb_reset_composite_device() after the device 967 * @post_reset: Called by usb_reset_device() after the device
964 * has been reset 968 * has been reset
965 * @id_table: USB drivers use ID table to support hotplugging. 969 * @id_table: USB drivers use ID table to support hotplugging.
966 * Export this with MODULE_DEVICE_TABLE(usb,...). This must be set 970 * Export this with MODULE_DEVICE_TABLE(usb,...). This must be set
@@ -972,6 +976,8 @@ struct usbdrv_wrap {
972 * added to this driver by preventing the sysfs file from being created. 976 * added to this driver by preventing the sysfs file from being created.
973 * @supports_autosuspend: if set to 0, the USB core will not allow autosuspend 977 * @supports_autosuspend: if set to 0, the USB core will not allow autosuspend
974 * for interfaces bound to this driver. 978 * for interfaces bound to this driver.
979 * @soft_unbind: if set to 1, the USB core will not kill URBs and disable
980 * endpoints before calling the driver's disconnect method.
975 * 981 *
976 * USB interface drivers must provide a name, probe() and disconnect() 982 * USB interface drivers must provide a name, probe() and disconnect()
977 * methods, and an id_table. Other driver fields are optional. 983 * methods, and an id_table. Other driver fields are optional.
@@ -1012,6 +1018,7 @@ struct usb_driver {
1012 struct usbdrv_wrap drvwrap; 1018 struct usbdrv_wrap drvwrap;
1013 unsigned int no_dynamic_id:1; 1019 unsigned int no_dynamic_id:1;
1014 unsigned int supports_autosuspend:1; 1020 unsigned int supports_autosuspend:1;
1021 unsigned int soft_unbind:1;
1015}; 1022};
1016#define to_usb_driver(d) container_of(d, struct usb_driver, drvwrap.driver) 1023#define to_usb_driver(d) container_of(d, struct usb_driver, drvwrap.driver)
1017 1024
@@ -1128,6 +1135,7 @@ struct usb_anchor {
1128 struct list_head urb_list; 1135 struct list_head urb_list;
1129 wait_queue_head_t wait; 1136 wait_queue_head_t wait;
1130 spinlock_t lock; 1137 spinlock_t lock;
1138 unsigned int poisoned:1;
1131}; 1139};
1132 1140
1133static inline void init_usb_anchor(struct usb_anchor *anchor) 1141static inline void init_usb_anchor(struct usb_anchor *anchor)
@@ -1452,12 +1460,18 @@ extern struct urb *usb_get_urb(struct urb *urb);
1452extern int usb_submit_urb(struct urb *urb, gfp_t mem_flags); 1460extern int usb_submit_urb(struct urb *urb, gfp_t mem_flags);
1453extern int usb_unlink_urb(struct urb *urb); 1461extern int usb_unlink_urb(struct urb *urb);
1454extern void usb_kill_urb(struct urb *urb); 1462extern void usb_kill_urb(struct urb *urb);
1463extern void usb_poison_urb(struct urb *urb);
1464extern void usb_unpoison_urb(struct urb *urb);
1455extern void usb_kill_anchored_urbs(struct usb_anchor *anchor); 1465extern void usb_kill_anchored_urbs(struct usb_anchor *anchor);
1466extern void usb_poison_anchored_urbs(struct usb_anchor *anchor);
1456extern void usb_unlink_anchored_urbs(struct usb_anchor *anchor); 1467extern void usb_unlink_anchored_urbs(struct usb_anchor *anchor);
1457extern void usb_anchor_urb(struct urb *urb, struct usb_anchor *anchor); 1468extern void usb_anchor_urb(struct urb *urb, struct usb_anchor *anchor);
1458extern void usb_unanchor_urb(struct urb *urb); 1469extern void usb_unanchor_urb(struct urb *urb);
1459extern int usb_wait_anchor_empty_timeout(struct usb_anchor *anchor, 1470extern int usb_wait_anchor_empty_timeout(struct usb_anchor *anchor,
1460 unsigned int timeout); 1471 unsigned int timeout);
1472extern struct urb *usb_get_from_anchor(struct usb_anchor *anchor);
1473extern void usb_scuttle_anchored_urbs(struct usb_anchor *anchor);
1474extern int usb_anchor_empty(struct usb_anchor *anchor);
1461 1475
1462/** 1476/**
1463 * usb_urb_dir_in - check if an URB describes an IN transfer 1477 * usb_urb_dir_in - check if an URB describes an IN transfer
diff --git a/include/linux/usb/Kbuild b/include/linux/usb/Kbuild
index 42e84fc315e3..54c446309a2a 100644
--- a/include/linux/usb/Kbuild
+++ b/include/linux/usb/Kbuild
@@ -4,4 +4,5 @@ header-y += ch9.h
4header-y += gadgetfs.h 4header-y += gadgetfs.h
5header-y += midi.h 5header-y += midi.h
6header-y += g_printer.h 6header-y += g_printer.h
7 7header-y += tmc.h
8header-y += vstusb.h
diff --git a/include/linux/usb/cdc.h b/include/linux/usb/cdc.h
index ca228bb94218..18a729343ffa 100644
--- a/include/linux/usb/cdc.h
+++ b/include/linux/usb/cdc.h
@@ -160,6 +160,15 @@ struct usb_cdc_mdlm_detail_desc {
160 __u8 bDetailData[0]; 160 __u8 bDetailData[0];
161} __attribute__ ((packed)); 161} __attribute__ ((packed));
162 162
163/* "OBEX Control Model Functional Descriptor" */
164struct usb_cdc_obex_desc {
165 __u8 bLength;
166 __u8 bDescriptorType;
167 __u8 bDescriptorSubType;
168
169 __le16 bcdVersion;
170} __attribute__ ((packed));
171
163/*-------------------------------------------------------------------------*/ 172/*-------------------------------------------------------------------------*/
164 173
165/* 174/*
diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h
new file mode 100644
index 000000000000..935c380ffe47
--- /dev/null
+++ b/include/linux/usb/composite.h
@@ -0,0 +1,345 @@
1/*
2 * composite.h -- framework for usb gadgets which are composite devices
3 *
4 * Copyright (C) 2006-2008 David Brownell
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#ifndef __LINUX_USB_COMPOSITE_H
22#define __LINUX_USB_COMPOSITE_H
23
24/*
25 * This framework is an optional layer on top of the USB Gadget interface,
26 * making it easier to build (a) Composite devices, supporting multiple
27 * functions within any single configuration, and (b) Multi-configuration
28 * devices, also supporting multiple functions but without necessarily
29 * having more than one function per configuration.
30 *
31 * Example: a device with a single configuration supporting both network
32 * link and mass storage functions is a composite device. Those functions
33 * might alternatively be packaged in individual configurations, but in
34 * the composite model the host can use both functions at the same time.
35 */
36
37#include <linux/usb/ch9.h>
38#include <linux/usb/gadget.h>
39
40
41struct usb_configuration;
42
43/**
44 * struct usb_function - describes one function of a configuration
45 * @name: For diagnostics, identifies the function.
46 * @strings: tables of strings, keyed by identifiers assigned during bind()
47 * and by language IDs provided in control requests
48 * @descriptors: Table of full (or low) speed descriptors, using interface and
49 * string identifiers assigned during @bind(). If this pointer is null,
50 * the function will not be available at full speed (or at low speed).
51 * @hs_descriptors: Table of high speed descriptors, using interface and
52 * string identifiers assigned during @bind(). If this pointer is null,
53 * the function will not be available at high speed.
54 * @config: assigned when @usb_add_function() is called; this is the
55 * configuration with which this function is associated.
56 * @bind: Before the gadget can register, all of its functions bind() to the
57 * available resources including string and interface identifiers used
58 * in interface or class descriptors; endpoints; I/O buffers; and so on.
59 * @unbind: Reverses @bind; called as a side effect of unregistering the
60 * driver which added this function.
61 * @set_alt: (REQUIRED) Reconfigures altsettings; function drivers may
62 * initialize usb_ep.driver data at this time (when it is used).
63 * Note that setting an interface to its current altsetting resets
64 * interface state, and that all interfaces have a disabled state.
65 * @get_alt: Returns the active altsetting. If this is not provided,
66 * then only altsetting zero is supported.
67 * @disable: (REQUIRED) Indicates the function should be disabled. Reasons
68 * include host resetting or reconfiguring the gadget, and disconnection.
69 * @setup: Used for interface-specific control requests.
70 * @suspend: Notifies functions when the host stops sending USB traffic.
71 * @resume: Notifies functions when the host restarts USB traffic.
72 *
73 * A single USB function uses one or more interfaces, and should in most
74 * cases support operation at both full and high speeds. Each function is
75 * associated by @usb_add_function() with a one configuration; that function
76 * causes @bind() to be called so resources can be allocated as part of
77 * setting up a gadget driver. Those resources include endpoints, which
78 * should be allocated using @usb_ep_autoconfig().
79 *
80 * To support dual speed operation, a function driver provides descriptors
81 * for both high and full speed operation. Except in rare cases that don't
82 * involve bulk endpoints, each speed needs different endpoint descriptors.
83 *
84 * Function drivers choose their own strategies for managing instance data.
85 * The simplest strategy just declares it "static', which means the function
86 * can only be activated once. If the function needs to be exposed in more
87 * than one configuration at a given speed, it needs to support multiple
88 * usb_function structures (one for each configuration).
89 *
90 * A more complex strategy might encapsulate a @usb_function structure inside
91 * a driver-specific instance structure to allows multiple activations. An
92 * example of multiple activations might be a CDC ACM function that supports
93 * two or more distinct instances within the same configuration, providing
94 * several independent logical data links to a USB host.
95 */
96struct usb_function {
97 const char *name;
98 struct usb_gadget_strings **strings;
99 struct usb_descriptor_header **descriptors;
100 struct usb_descriptor_header **hs_descriptors;
101
102 struct usb_configuration *config;
103
104 /* REVISIT: bind() functions can be marked __init, which
105 * makes trouble for section mismatch analysis. See if
106 * we can't restructure things to avoid mismatching.
107 * Related: unbind() may kfree() but bind() won't...
108 */
109
110 /* configuration management: bind/unbind */
111 int (*bind)(struct usb_configuration *,
112 struct usb_function *);
113 void (*unbind)(struct usb_configuration *,
114 struct usb_function *);
115
116 /* runtime state management */
117 int (*set_alt)(struct usb_function *,
118 unsigned interface, unsigned alt);
119 int (*get_alt)(struct usb_function *,
120 unsigned interface);
121 void (*disable)(struct usb_function *);
122 int (*setup)(struct usb_function *,
123 const struct usb_ctrlrequest *);
124 void (*suspend)(struct usb_function *);
125 void (*resume)(struct usb_function *);
126
127 /* internals */
128 struct list_head list;
129};
130
131int usb_add_function(struct usb_configuration *, struct usb_function *);
132
133int usb_function_deactivate(struct usb_function *);
134int usb_function_activate(struct usb_function *);
135
136int usb_interface_id(struct usb_configuration *, struct usb_function *);
137
138/**
139 * ep_choose - select descriptor endpoint at current device speed
140 * @g: gadget, connected and running at some speed
141 * @hs: descriptor to use for high speed operation
142 * @fs: descriptor to use for full or low speed operation
143 */
144static inline struct usb_endpoint_descriptor *
145ep_choose(struct usb_gadget *g, struct usb_endpoint_descriptor *hs,
146 struct usb_endpoint_descriptor *fs)
147{
148 if (gadget_is_dualspeed(g) && g->speed == USB_SPEED_HIGH)
149 return hs;
150 return fs;
151}
152
153#define MAX_CONFIG_INTERFACES 16 /* arbitrary; max 255 */
154
155/**
156 * struct usb_configuration - represents one gadget configuration
157 * @label: For diagnostics, describes the configuration.
158 * @strings: Tables of strings, keyed by identifiers assigned during @bind()
159 * and by language IDs provided in control requests.
160 * @descriptors: Table of descriptors preceding all function descriptors.
161 * Examples include OTG and vendor-specific descriptors.
162 * @bind: Called from @usb_add_config() to allocate resources unique to this
163 * configuration and to call @usb_add_function() for each function used.
164 * @unbind: Reverses @bind; called as a side effect of unregistering the
165 * driver which added this configuration.
166 * @setup: Used to delegate control requests that aren't handled by standard
167 * device infrastructure or directed at a specific interface.
168 * @bConfigurationValue: Copied into configuration descriptor.
169 * @iConfiguration: Copied into configuration descriptor.
170 * @bmAttributes: Copied into configuration descriptor.
171 * @bMaxPower: Copied into configuration descriptor.
172 * @cdev: assigned by @usb_add_config() before calling @bind(); this is
173 * the device associated with this configuration.
174 *
175 * Configurations are building blocks for gadget drivers structured around
176 * function drivers. Simple USB gadgets require only one function and one
177 * configuration, and handle dual-speed hardware by always providing the same
178 * functionality. Slightly more complex gadgets may have more than one
179 * single-function configuration at a given speed; or have configurations
180 * that only work at one speed.
181 *
182 * Composite devices are, by definition, ones with configurations which
183 * include more than one function.
184 *
185 * The lifecycle of a usb_configuration includes allocation, initialization
186 * of the fields described above, and calling @usb_add_config() to set up
187 * internal data and bind it to a specific device. The configuration's
188 * @bind() method is then used to initialize all the functions and then
189 * call @usb_add_function() for them.
190 *
191 * Those functions would normally be independant of each other, but that's
192 * not mandatory. CDC WMC devices are an example where functions often
193 * depend on other functions, with some functions subsidiary to others.
194 * Such interdependency may be managed in any way, so long as all of the
195 * descriptors complete by the time the composite driver returns from
196 * its bind() routine.
197 */
198struct usb_configuration {
199 const char *label;
200 struct usb_gadget_strings **strings;
201 const struct usb_descriptor_header **descriptors;
202
203 /* REVISIT: bind() functions can be marked __init, which
204 * makes trouble for section mismatch analysis. See if
205 * we can't restructure things to avoid mismatching...
206 */
207
208 /* configuration management: bind/unbind */
209 int (*bind)(struct usb_configuration *);
210 void (*unbind)(struct usb_configuration *);
211 int (*setup)(struct usb_configuration *,
212 const struct usb_ctrlrequest *);
213
214 /* fields in the config descriptor */
215 u8 bConfigurationValue;
216 u8 iConfiguration;
217 u8 bmAttributes;
218 u8 bMaxPower;
219
220 struct usb_composite_dev *cdev;
221
222 /* internals */
223 struct list_head list;
224 struct list_head functions;
225 u8 next_interface_id;
226 unsigned highspeed:1;
227 unsigned fullspeed:1;
228 struct usb_function *interface[MAX_CONFIG_INTERFACES];
229};
230
231int usb_add_config(struct usb_composite_dev *,
232 struct usb_configuration *);
233
234/**
235 * struct usb_composite_driver - groups configurations into a gadget
236 * @name: For diagnostics, identifies the driver.
237 * @dev: Template descriptor for the device, including default device
238 * identifiers.
239 * @strings: tables of strings, keyed by identifiers assigned during bind()
240 * and language IDs provided in control requests
241 * @bind: (REQUIRED) Used to allocate resources that are shared across the
242 * whole device, such as string IDs, and add its configurations using
243 * @usb_add_config(). This may fail by returning a negative errno
244 * value; it should return zero on successful initialization.
245 * @unbind: Reverses @bind(); called as a side effect of unregistering
246 * this driver.
247 *
248 * Devices default to reporting self powered operation. Devices which rely
249 * on bus powered operation should report this in their @bind() method.
250 *
251 * Before returning from @bind, various fields in the template descriptor
252 * may be overridden. These include the idVendor/idProduct/bcdDevice values
253 * normally to bind the appropriate host side driver, and the three strings
254 * (iManufacturer, iProduct, iSerialNumber) normally used to provide user
255 * meaningful device identifiers. (The strings will not be defined unless
256 * they are defined in @dev and @strings.) The correct ep0 maxpacket size
257 * is also reported, as defined by the underlying controller driver.
258 */
259struct usb_composite_driver {
260 const char *name;
261 const struct usb_device_descriptor *dev;
262 struct usb_gadget_strings **strings;
263
264 /* REVISIT: bind() functions can be marked __init, which
265 * makes trouble for section mismatch analysis. See if
266 * we can't restructure things to avoid mismatching...
267 */
268
269 int (*bind)(struct usb_composite_dev *);
270 int (*unbind)(struct usb_composite_dev *);
271};
272
273extern int usb_composite_register(struct usb_composite_driver *);
274extern void usb_composite_unregister(struct usb_composite_driver *);
275
276
277/**
278 * struct usb_composite_device - represents one composite usb gadget
279 * @gadget: read-only, abstracts the gadget's usb peripheral controller
280 * @req: used for control responses; buffer is pre-allocated
281 * @bufsiz: size of buffer pre-allocated in @req
282 * @config: the currently active configuration
283 *
284 * One of these devices is allocated and initialized before the
285 * associated device driver's bind() is called.
286 *
287 * OPEN ISSUE: it appears that some WUSB devices will need to be
288 * built by combining a normal (wired) gadget with a wireless one.
289 * This revision of the gadget framework should probably try to make
290 * sure doing that won't hurt too much.
291 *
292 * One notion for how to handle Wireless USB devices involves:
293 * (a) a second gadget here, discovery mechanism TBD, but likely
294 * needing separate "register/unregister WUSB gadget" calls;
295 * (b) updates to usb_gadget to include flags "is it wireless",
296 * "is it wired", plus (presumably in a wrapper structure)
297 * bandgroup and PHY info;
298 * (c) presumably a wireless_ep wrapping a usb_ep, and reporting
299 * wireless-specific parameters like maxburst and maxsequence;
300 * (d) configurations that are specific to wireless links;
301 * (e) function drivers that understand wireless configs and will
302 * support wireless for (additional) function instances;
303 * (f) a function to support association setup (like CBAF), not
304 * necessarily requiring a wireless adapter;
305 * (g) composite device setup that can create one or more wireless
306 * configs, including appropriate association setup support;
307 * (h) more, TBD.
308 */
309struct usb_composite_dev {
310 struct usb_gadget *gadget;
311 struct usb_request *req;
312 unsigned bufsiz;
313
314 struct usb_configuration *config;
315
316 /* internals */
317 struct usb_device_descriptor desc;
318 struct list_head configs;
319 struct usb_composite_driver *driver;
320 u8 next_string_id;
321
322 /* the gadget driver won't enable the data pullup
323 * while the deactivation count is nonzero.
324 */
325 unsigned deactivations;
326
327 /* protects at least deactivation count */
328 spinlock_t lock;
329};
330
331extern int usb_string_id(struct usb_composite_dev *c);
332
333/* messaging utils */
334#define DBG(d, fmt, args...) \
335 dev_dbg(&(d)->gadget->dev , fmt , ## args)
336#define VDBG(d, fmt, args...) \
337 dev_vdbg(&(d)->gadget->dev , fmt , ## args)
338#define ERROR(d, fmt, args...) \
339 dev_err(&(d)->gadget->dev , fmt , ## args)
340#define WARNING(d, fmt, args...) \
341 dev_warn(&(d)->gadget->dev , fmt , ## args)
342#define INFO(d, fmt, args...) \
343 dev_info(&(d)->gadget->dev , fmt , ## args)
344
345#endif /* __LINUX_USB_COMPOSITE_H */
diff --git a/include/linux/usb/ehci_def.h b/include/linux/usb/ehci_def.h
new file mode 100644
index 000000000000..5b88e36c9103
--- /dev/null
+++ b/include/linux/usb/ehci_def.h
@@ -0,0 +1,160 @@
1/*
2 * Copyright (c) 2001-2002 by David Brownell
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */
18
19#ifndef __LINUX_USB_EHCI_DEF_H
20#define __LINUX_USB_EHCI_DEF_H
21
22/* EHCI register interface, corresponds to EHCI Revision 0.95 specification */
23
24/* Section 2.2 Host Controller Capability Registers */
25struct ehci_caps {
26 /* these fields are specified as 8 and 16 bit registers,
27 * but some hosts can't perform 8 or 16 bit PCI accesses.
28 */
29 u32 hc_capbase;
30#define HC_LENGTH(p) (((p)>>00)&0x00ff) /* bits 7:0 */
31#define HC_VERSION(p) (((p)>>16)&0xffff) /* bits 31:16 */
32 u32 hcs_params; /* HCSPARAMS - offset 0x4 */
33#define HCS_DEBUG_PORT(p) (((p)>>20)&0xf) /* bits 23:20, debug port? */
34#define HCS_INDICATOR(p) ((p)&(1 << 16)) /* true: has port indicators */
35#define HCS_N_CC(p) (((p)>>12)&0xf) /* bits 15:12, #companion HCs */
36#define HCS_N_PCC(p) (((p)>>8)&0xf) /* bits 11:8, ports per CC */
37#define HCS_PORTROUTED(p) ((p)&(1 << 7)) /* true: port routing */
38#define HCS_PPC(p) ((p)&(1 << 4)) /* true: port power control */
39#define HCS_N_PORTS(p) (((p)>>0)&0xf) /* bits 3:0, ports on HC */
40
41 u32 hcc_params; /* HCCPARAMS - offset 0x8 */
42#define HCC_EXT_CAPS(p) (((p)>>8)&0xff) /* for pci extended caps */
43#define HCC_ISOC_CACHE(p) ((p)&(1 << 7)) /* true: can cache isoc frame */
44#define HCC_ISOC_THRES(p) (((p)>>4)&0x7) /* bits 6:4, uframes cached */
45#define HCC_CANPARK(p) ((p)&(1 << 2)) /* true: can park on async qh */
46#define HCC_PGM_FRAMELISTLEN(p) ((p)&(1 << 1)) /* true: periodic_size changes*/
47#define HCC_64BIT_ADDR(p) ((p)&(1)) /* true: can use 64-bit addr */
48 u8 portroute [8]; /* nibbles for routing - offset 0xC */
49} __attribute__ ((packed));
50
51
52/* Section 2.3 Host Controller Operational Registers */
53struct ehci_regs {
54
55 /* USBCMD: offset 0x00 */
56 u32 command;
57/* 23:16 is r/w intr rate, in microframes; default "8" == 1/msec */
58#define CMD_PARK (1<<11) /* enable "park" on async qh */
59#define CMD_PARK_CNT(c) (((c)>>8)&3) /* how many transfers to park for */
60#define CMD_LRESET (1<<7) /* partial reset (no ports, etc) */
61#define CMD_IAAD (1<<6) /* "doorbell" interrupt async advance */
62#define CMD_ASE (1<<5) /* async schedule enable */
63#define CMD_PSE (1<<4) /* periodic schedule enable */
64/* 3:2 is periodic frame list size */
65#define CMD_RESET (1<<1) /* reset HC not bus */
66#define CMD_RUN (1<<0) /* start/stop HC */
67
68 /* USBSTS: offset 0x04 */
69 u32 status;
70#define STS_ASS (1<<15) /* Async Schedule Status */
71#define STS_PSS (1<<14) /* Periodic Schedule Status */
72#define STS_RECL (1<<13) /* Reclamation */
73#define STS_HALT (1<<12) /* Not running (any reason) */
74/* some bits reserved */
75 /* these STS_* flags are also intr_enable bits (USBINTR) */
76#define STS_IAA (1<<5) /* Interrupted on async advance */
77#define STS_FATAL (1<<4) /* such as some PCI access errors */
78#define STS_FLR (1<<3) /* frame list rolled over */
79#define STS_PCD (1<<2) /* port change detect */
80#define STS_ERR (1<<1) /* "error" completion (overflow, ...) */
81#define STS_INT (1<<0) /* "normal" completion (short, ...) */
82
83 /* USBINTR: offset 0x08 */
84 u32 intr_enable;
85
86 /* FRINDEX: offset 0x0C */
87 u32 frame_index; /* current microframe number */
88 /* CTRLDSSEGMENT: offset 0x10 */
89 u32 segment; /* address bits 63:32 if needed */
90 /* PERIODICLISTBASE: offset 0x14 */
91 u32 frame_list; /* points to periodic list */
92 /* ASYNCLISTADDR: offset 0x18 */
93 u32 async_next; /* address of next async queue head */
94
95 u32 reserved [9];
96
97 /* CONFIGFLAG: offset 0x40 */
98 u32 configured_flag;
99#define FLAG_CF (1<<0) /* true: we'll support "high speed" */
100
101 /* PORTSC: offset 0x44 */
102 u32 port_status [0]; /* up to N_PORTS */
103/* 31:23 reserved */
104#define PORT_WKOC_E (1<<22) /* wake on overcurrent (enable) */
105#define PORT_WKDISC_E (1<<21) /* wake on disconnect (enable) */
106#define PORT_WKCONN_E (1<<20) /* wake on connect (enable) */
107/* 19:16 for port testing */
108#define PORT_LED_OFF (0<<14)
109#define PORT_LED_AMBER (1<<14)
110#define PORT_LED_GREEN (2<<14)
111#define PORT_LED_MASK (3<<14)
112#define PORT_OWNER (1<<13) /* true: companion hc owns this port */
113#define PORT_POWER (1<<12) /* true: has power (see PPC) */
114#define PORT_USB11(x) (((x)&(3<<10)) == (1<<10)) /* USB 1.1 device */
115/* 11:10 for detecting lowspeed devices (reset vs release ownership) */
116/* 9 reserved */
117#define PORT_RESET (1<<8) /* reset port */
118#define PORT_SUSPEND (1<<7) /* suspend port */
119#define PORT_RESUME (1<<6) /* resume it */
120#define PORT_OCC (1<<5) /* over current change */
121#define PORT_OC (1<<4) /* over current active */
122#define PORT_PEC (1<<3) /* port enable change */
123#define PORT_PE (1<<2) /* port enable */
124#define PORT_CSC (1<<1) /* connect status change */
125#define PORT_CONNECT (1<<0) /* device connected */
126#define PORT_RWC_BITS (PORT_CSC | PORT_PEC | PORT_OCC)
127} __attribute__ ((packed));
128
129#define USBMODE 0x68 /* USB Device mode */
130#define USBMODE_SDIS (1<<3) /* Stream disable */
131#define USBMODE_BE (1<<2) /* BE/LE endianness select */
132#define USBMODE_CM_HC (3<<0) /* host controller mode */
133#define USBMODE_CM_IDLE (0<<0) /* idle state */
134
135/* Appendix C, Debug port ... intended for use with special "debug devices"
136 * that can help if there's no serial console. (nonstandard enumeration.)
137 */
138struct ehci_dbg_port {
139 u32 control;
140#define DBGP_OWNER (1<<30)
141#define DBGP_ENABLED (1<<28)
142#define DBGP_DONE (1<<16)
143#define DBGP_INUSE (1<<10)
144#define DBGP_ERRCODE(x) (((x)>>7)&0x07)
145# define DBGP_ERR_BAD 1
146# define DBGP_ERR_SIGNAL 2
147#define DBGP_ERROR (1<<6)
148#define DBGP_GO (1<<5)
149#define DBGP_OUT (1<<4)
150#define DBGP_LEN(x) (((x)>>0)&0x0f)
151 u32 pids;
152#define DBGP_PID_GET(x) (((x)>>16)&0xff)
153#define DBGP_PID_SET(data, tok) (((data)<<8)|(tok))
154 u32 data03;
155 u32 data47;
156 u32 address;
157#define DBGP_EPADDR(dev, ep) (((dev)<<8)|(ep))
158} __attribute__ ((packed));
159
160#endif /* __LINUX_USB_EHCI_DEF_H */
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index cf468fbdbf8e..0460a746480c 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -33,7 +33,8 @@ struct usb_ep;
33 * @short_not_ok: When reading data, makes short packets be 33 * @short_not_ok: When reading data, makes short packets be
34 * treated as errors (queue stops advancing till cleanup). 34 * treated as errors (queue stops advancing till cleanup).
35 * @complete: Function called when request completes, so this request and 35 * @complete: Function called when request completes, so this request and
36 * its buffer may be re-used. 36 * its buffer may be re-used. The function will always be called with
37 * interrupts disabled, and it must not sleep.
37 * Reads terminate with a short packet, or when the buffer fills, 38 * Reads terminate with a short packet, or when the buffer fills,
38 * whichever comes first. When writes terminate, some data bytes 39 * whichever comes first. When writes terminate, some data bytes
39 * will usually still be in flight (often in a hardware fifo). 40 * will usually still be in flight (often in a hardware fifo).
@@ -271,7 +272,10 @@ static inline void usb_ep_free_request(struct usb_ep *ep,
271 * (Note that some USB device controllers disallow protocol stall responses 272 * (Note that some USB device controllers disallow protocol stall responses
272 * in some cases.) When control responses are deferred (the response is 273 * in some cases.) When control responses are deferred (the response is
273 * written after the setup callback returns), then usb_ep_set_halt() may be 274 * written after the setup callback returns), then usb_ep_set_halt() may be
274 * used on ep0 to trigger protocol stalls. 275 * used on ep0 to trigger protocol stalls. Depending on the controller,
276 * it may not be possible to trigger a status-stage protocol stall when the
277 * data stage is over, that is, from within the response's completion
278 * routine.
275 * 279 *
276 * For periodic endpoints, like interrupt or isochronous ones, the usb host 280 * For periodic endpoints, like interrupt or isochronous ones, the usb host
277 * arranges to poll once per interval, and the gadget driver usually will 281 * arranges to poll once per interval, and the gadget driver usually will
@@ -858,6 +862,25 @@ int usb_descriptor_fillbuf(void *, unsigned,
858int usb_gadget_config_buf(const struct usb_config_descriptor *config, 862int usb_gadget_config_buf(const struct usb_config_descriptor *config,
859 void *buf, unsigned buflen, const struct usb_descriptor_header **desc); 863 void *buf, unsigned buflen, const struct usb_descriptor_header **desc);
860 864
865/* copy a NULL-terminated vector of descriptors */
866struct usb_descriptor_header **usb_copy_descriptors(
867 struct usb_descriptor_header **);
868
869/* return copy of endpoint descriptor given original descriptor set */
870struct usb_endpoint_descriptor *usb_find_endpoint(
871 struct usb_descriptor_header **src,
872 struct usb_descriptor_header **copy,
873 struct usb_endpoint_descriptor *match);
874
875/**
876 * usb_free_descriptors - free descriptors returned by usb_copy_descriptors()
877 * @v: vector of descriptors
878 */
879static inline void usb_free_descriptors(struct usb_descriptor_header **v)
880{
881 kfree(v);
882}
883
861/*-------------------------------------------------------------------------*/ 884/*-------------------------------------------------------------------------*/
862 885
863/* utility wrapping a simple endpoint selection policy */ 886/* utility wrapping a simple endpoint selection policy */
diff --git a/include/linux/usb/irda.h b/include/linux/usb/irda.h
new file mode 100644
index 000000000000..e345ceaf72d6
--- /dev/null
+++ b/include/linux/usb/irda.h
@@ -0,0 +1,151 @@
1/*
2 * USB IrDA Bridge Device Definition
3 */
4
5#ifndef __LINUX_USB_IRDA_H
6#define __LINUX_USB_IRDA_H
7
8/* This device should use Application-specific class */
9
10#define USB_SUBCLASS_IRDA 0x02
11
12/*-------------------------------------------------------------------------*/
13
14/* Class-Specific requests (bRequest field) */
15
16#define USB_REQ_CS_IRDA_RECEIVING 1
17#define USB_REQ_CS_IRDA_CHECK_MEDIA_BUSY 3
18#define USB_REQ_CS_IRDA_RATE_SNIFF 4
19#define USB_REQ_CS_IRDA_UNICAST_LIST 5
20#define USB_REQ_CS_IRDA_GET_CLASS_DESC 6
21
22/*-------------------------------------------------------------------------*/
23
24/* Class-Specific descriptor */
25
26#define USB_DT_CS_IRDA 0x21
27
28/*-------------------------------------------------------------------------*/
29
30/* Data sizes */
31
32#define USB_IRDA_DS_2048 (1 << 5)
33#define USB_IRDA_DS_1024 (1 << 4)
34#define USB_IRDA_DS_512 (1 << 3)
35#define USB_IRDA_DS_256 (1 << 2)
36#define USB_IRDA_DS_128 (1 << 1)
37#define USB_IRDA_DS_64 (1 << 0)
38
39/* Window sizes */
40
41#define USB_IRDA_WS_7 (1 << 6)
42#define USB_IRDA_WS_6 (1 << 5)
43#define USB_IRDA_WS_5 (1 << 4)
44#define USB_IRDA_WS_4 (1 << 3)
45#define USB_IRDA_WS_3 (1 << 2)
46#define USB_IRDA_WS_2 (1 << 1)
47#define USB_IRDA_WS_1 (1 << 0)
48
49/* Min turnaround times in usecs */
50
51#define USB_IRDA_MTT_0 (1 << 7)
52#define USB_IRDA_MTT_10 (1 << 6)
53#define USB_IRDA_MTT_50 (1 << 5)
54#define USB_IRDA_MTT_100 (1 << 4)
55#define USB_IRDA_MTT_500 (1 << 3)
56#define USB_IRDA_MTT_1000 (1 << 2)
57#define USB_IRDA_MTT_5000 (1 << 1)
58#define USB_IRDA_MTT_10000 (1 << 0)
59
60/* Baud rates */
61
62#define USB_IRDA_BR_4000000 (1 << 8)
63#define USB_IRDA_BR_1152000 (1 << 7)
64#define USB_IRDA_BR_576000 (1 << 6)
65#define USB_IRDA_BR_115200 (1 << 5)
66#define USB_IRDA_BR_57600 (1 << 4)
67#define USB_IRDA_BR_38400 (1 << 3)
68#define USB_IRDA_BR_19200 (1 << 2)
69#define USB_IRDA_BR_9600 (1 << 1)
70#define USB_IRDA_BR_2400 (1 << 0)
71
72/* Additional BOFs */
73
74#define USB_IRDA_AB_0 (1 << 7)
75#define USB_IRDA_AB_1 (1 << 6)
76#define USB_IRDA_AB_2 (1 << 5)
77#define USB_IRDA_AB_3 (1 << 4)
78#define USB_IRDA_AB_6 (1 << 3)
79#define USB_IRDA_AB_12 (1 << 2)
80#define USB_IRDA_AB_24 (1 << 1)
81#define USB_IRDA_AB_48 (1 << 0)
82
83/* IRDA Rate Sniff */
84
85#define USB_IRDA_RATE_SNIFF 1
86
87/*-------------------------------------------------------------------------*/
88
89struct usb_irda_cs_descriptor {
90 __u8 bLength;
91 __u8 bDescriptorType;
92
93 __le16 bcdSpecRevision;
94 __u8 bmDataSize;
95 __u8 bmWindowSize;
96 __u8 bmMinTurnaroundTime;
97 __le16 wBaudRate;
98 __u8 bmAdditionalBOFs;
99 __u8 bIrdaRateSniff;
100 __u8 bMaxUnicastList;
101} __attribute__ ((packed));
102
103/*-------------------------------------------------------------------------*/
104
105/* Data Format */
106
107#define USB_IRDA_STATUS_MEDIA_BUSY (1 << 7)
108
109/* The following is a 4-bit value used for both
110 * inbound and outbound headers:
111 *
112 * 0 - speed ignored
113 * 1 - 2400 bps
114 * 2 - 9600 bps
115 * 3 - 19200 bps
116 * 4 - 38400 bps
117 * 5 - 57600 bps
118 * 6 - 115200 bps
119 * 7 - 576000 bps
120 * 8 - 1.152 Mbps
121 * 9 - 5 mbps
122 * 10..15 - Reserved
123 */
124#define USB_IRDA_STATUS_LINK_SPEED 0x0f
125
126/* The following is a 4-bit value used only for
127 * outbound header:
128 *
129 * 0 - No change (BOF ignored)
130 * 1 - 48 BOFs
131 * 2 - 24 BOFs
132 * 3 - 12 BOFs
133 * 4 - 6 BOFs
134 * 5 - 3 BOFs
135 * 6 - 2 BOFs
136 * 7 - 1 BOFs
137 * 8 - 0 BOFs
138 * 9..15 - Reserved
139 */
140#define USB_IRDA_EXTRA_BOFS 0xf0
141
142struct usb_irda_inbound_header {
143 __u8 bmStatus;
144};
145
146struct usb_irda_outbound_header {
147 __u8 bmChange;
148};
149
150#endif /* __LINUX_USB_IRDA_H */
151
diff --git a/include/linux/usb/musb.h b/include/linux/usb/musb.h
new file mode 100644
index 000000000000..630962c04ca4
--- /dev/null
+++ b/include/linux/usb/musb.h
@@ -0,0 +1,98 @@
1/*
2 * This is used to for host and peripheral modes of the driver for
3 * Inventra (Multidrop) Highspeed Dual-Role Controllers: (M)HDRC.
4 *
5 * Board initialization should put one of these into dev->platform_data,
6 * probably on some platform_device named "musb_hdrc". It encapsulates
7 * key configuration differences between boards.
8 */
9
10/* The USB role is defined by the connector used on the board, so long as
11 * standards are being followed. (Developer boards sometimes won't.)
12 */
13enum musb_mode {
14 MUSB_UNDEFINED = 0,
15 MUSB_HOST, /* A or Mini-A connector */
16 MUSB_PERIPHERAL, /* B or Mini-B connector */
17 MUSB_OTG /* Mini-AB connector */
18};
19
20struct clk;
21
22struct musb_hdrc_eps_bits {
23 const char name[16];
24 u8 bits;
25};
26
27struct musb_hdrc_config {
28 /* MUSB configuration-specific details */
29 unsigned multipoint:1; /* multipoint device */
30 unsigned dyn_fifo:1; /* supports dynamic fifo sizing */
31 unsigned soft_con:1; /* soft connect required */
32 unsigned utm_16:1; /* utm data witdh is 16 bits */
33 unsigned big_endian:1; /* true if CPU uses big-endian */
34 unsigned mult_bulk_tx:1; /* Tx ep required for multbulk pkts */
35 unsigned mult_bulk_rx:1; /* Rx ep required for multbulk pkts */
36 unsigned high_iso_tx:1; /* Tx ep required for HB iso */
37 unsigned high_iso_rx:1; /* Rx ep required for HD iso */
38 unsigned dma:1; /* supports DMA */
39 unsigned vendor_req:1; /* vendor registers required */
40
41 u8 num_eps; /* number of endpoints _with_ ep0 */
42 u8 dma_channels; /* number of dma channels */
43 u8 dyn_fifo_size; /* dynamic size in bytes */
44 u8 vendor_ctrl; /* vendor control reg width */
45 u8 vendor_stat; /* vendor status reg witdh */
46 u8 dma_req_chan; /* bitmask for required dma channels */
47 u8 ram_bits; /* ram address size */
48
49 struct musb_hdrc_eps_bits *eps_bits;
50};
51
52struct musb_hdrc_platform_data {
53 /* MUSB_HOST, MUSB_PERIPHERAL, or MUSB_OTG */
54 u8 mode;
55
56 /* for clk_get() */
57 const char *clock;
58
59 /* (HOST or OTG) switch VBUS on/off */
60 int (*set_vbus)(struct device *dev, int is_on);
61
62 /* (HOST or OTG) mA/2 power supplied on (default = 8mA) */
63 u8 power;
64
65 /* (PERIPHERAL) mA/2 max power consumed (default = 100mA) */
66 u8 min_power;
67
68 /* (HOST or OTG) msec/2 after VBUS on till power good */
69 u8 potpgt;
70
71 /* Power the device on or off */
72 int (*set_power)(int state);
73
74 /* Turn device clock on or off */
75 int (*set_clock)(struct clk *clock, int is_on);
76
77 /* MUSB configuration-specific details */
78 struct musb_hdrc_config *config;
79};
80
81
82/* TUSB 6010 support */
83
84#define TUSB6010_OSCCLK_60 16667 /* psec/clk @ 60.0 MHz */
85#define TUSB6010_REFCLK_24 41667 /* psec/clk @ 24.0 MHz XI */
86#define TUSB6010_REFCLK_19 52083 /* psec/clk @ 19.2 MHz CLKIN */
87
88#ifdef CONFIG_ARCH_OMAP2
89
90extern int __init tusb6010_setup_interface(
91 struct musb_hdrc_platform_data *data,
92 unsigned ps_refclk, unsigned waitpin,
93 unsigned async_cs, unsigned sync_cs,
94 unsigned irq, unsigned dmachan);
95
96extern int tusb6010_platform_retime(unsigned is_refclk);
97
98#endif /* OMAP2 */
diff --git a/include/linux/usb/rndis_host.h b/include/linux/usb/rndis_host.h
index 29d6458ecb8d..0a6e6d4b929a 100644
--- a/include/linux/usb/rndis_host.h
+++ b/include/linux/usb/rndis_host.h
@@ -260,7 +260,8 @@ struct rndis_keepalive_c { /* IN (optionally OUT) */
260 260
261 261
262extern void rndis_status(struct usbnet *dev, struct urb *urb); 262extern void rndis_status(struct usbnet *dev, struct urb *urb);
263extern int rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf); 263extern int
264rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf, int buflen);
264extern int 265extern int
265generic_rndis_bind(struct usbnet *dev, struct usb_interface *intf, int flags); 266generic_rndis_bind(struct usbnet *dev, struct usb_interface *intf, int flags);
266extern void rndis_unbind(struct usbnet *dev, struct usb_interface *intf); 267extern void rndis_unbind(struct usbnet *dev, struct usb_interface *intf);
diff --git a/include/linux/usb/serial.h b/include/linux/usb/serial.h
index 8f891cbaf9ab..0b8617a9176d 100644
--- a/include/linux/usb/serial.h
+++ b/include/linux/usb/serial.h
@@ -17,7 +17,8 @@
17#include <linux/mutex.h> 17#include <linux/mutex.h>
18 18
19#define SERIAL_TTY_MAJOR 188 /* Nice legal number now */ 19#define SERIAL_TTY_MAJOR 188 /* Nice legal number now */
20#define SERIAL_TTY_MINORS 255 /* loads of devices :) */ 20#define SERIAL_TTY_MINORS 254 /* loads of devices :) */
21#define SERIAL_TTY_NO_MINOR 255 /* No minor was assigned */
21 22
22/* The maximum number of ports one device can grab at once */ 23/* The maximum number of ports one device can grab at once */
23#define MAX_NUM_PORTS 8 24#define MAX_NUM_PORTS 8
@@ -62,7 +63,7 @@
62 */ 63 */
63struct usb_serial_port { 64struct usb_serial_port {
64 struct usb_serial *serial; 65 struct usb_serial *serial;
65 struct tty_struct *tty; 66 struct tty_port port;
66 spinlock_t lock; 67 spinlock_t lock;
67 struct mutex mutex; 68 struct mutex mutex;
68 unsigned char number; 69 unsigned char number;
@@ -89,7 +90,6 @@ struct usb_serial_port {
89 90
90 wait_queue_head_t write_wait; 91 wait_queue_head_t write_wait;
91 struct work_struct work; 92 struct work_struct work;
92 int open_count;
93 char throttled; 93 char throttled;
94 char throttle_req; 94 char throttle_req;
95 char console; 95 char console;
@@ -192,7 +192,7 @@ static inline void usb_set_serial_data(struct usb_serial *serial, void *data)
192 * The driver.owner field should be set to the module owner of this driver. 192 * The driver.owner field should be set to the module owner of this driver.
193 * The driver.name field should be set to the name of this driver (remember 193 * The driver.name field should be set to the name of this driver (remember
194 * it will show up in sysfs, so it needs to be short and to the point. 194 * it will show up in sysfs, so it needs to be short and to the point.
195 * Useing the module name is a good idea.) 195 * Using the module name is a good idea.)
196 */ 196 */
197struct usb_serial_driver { 197struct usb_serial_driver {
198 const char *description; 198 const char *description;
@@ -217,22 +217,27 @@ struct usb_serial_driver {
217 int (*resume)(struct usb_serial *serial); 217 int (*resume)(struct usb_serial *serial);
218 218
219 /* serial function calls */ 219 /* serial function calls */
220 int (*open)(struct usb_serial_port *port, struct file *filp); 220 /* Called by console with tty = NULL and by tty */
221 void (*close)(struct usb_serial_port *port, struct file *filp); 221 int (*open)(struct tty_struct *tty,
222 int (*write)(struct usb_serial_port *port, const unsigned char *buf, 222 struct usb_serial_port *port, struct file *filp);
223 int count); 223 void (*close)(struct tty_struct *tty,
224 int (*write_room)(struct usb_serial_port *port); 224 struct usb_serial_port *port, struct file *filp);
225 int (*ioctl)(struct usb_serial_port *port, struct file *file, 225 int (*write)(struct tty_struct *tty, struct usb_serial_port *port,
226 const unsigned char *buf, int count);
227 /* Called only by the tty layer */
228 int (*write_room)(struct tty_struct *tty);
229 int (*ioctl)(struct tty_struct *tty, struct file *file,
226 unsigned int cmd, unsigned long arg); 230 unsigned int cmd, unsigned long arg);
227 void (*set_termios)(struct usb_serial_port *port, struct ktermios *old); 231 void (*set_termios)(struct tty_struct *tty,
228 void (*break_ctl)(struct usb_serial_port *port, int break_state); 232 struct usb_serial_port *port, struct ktermios *old);
229 int (*chars_in_buffer)(struct usb_serial_port *port); 233 void (*break_ctl)(struct tty_struct *tty, int break_state);
230 void (*throttle)(struct usb_serial_port *port); 234 int (*chars_in_buffer)(struct tty_struct *tty);
231 void (*unthrottle)(struct usb_serial_port *port); 235 void (*throttle)(struct tty_struct *tty);
232 int (*tiocmget)(struct usb_serial_port *port, struct file *file); 236 void (*unthrottle)(struct tty_struct *tty);
233 int (*tiocmset)(struct usb_serial_port *port, struct file *file, 237 int (*tiocmget)(struct tty_struct *tty, struct file *file);
238 int (*tiocmset)(struct tty_struct *tty, struct file *file,
234 unsigned int set, unsigned int clear); 239 unsigned int set, unsigned int clear);
235 240 /* USB events */
236 void (*read_int_callback)(struct urb *urb); 241 void (*read_int_callback)(struct urb *urb);
237 void (*write_int_callback)(struct urb *urb); 242 void (*write_int_callback)(struct urb *urb);
238 void (*read_bulk_callback)(struct urb *urb); 243 void (*read_bulk_callback)(struct urb *urb);
@@ -270,19 +275,19 @@ static inline void usb_serial_console_disconnect(struct usb_serial *serial) {}
270/* Functions needed by other parts of the usbserial core */ 275/* Functions needed by other parts of the usbserial core */
271extern struct usb_serial *usb_serial_get_by_index(unsigned int minor); 276extern struct usb_serial *usb_serial_get_by_index(unsigned int minor);
272extern void usb_serial_put(struct usb_serial *serial); 277extern void usb_serial_put(struct usb_serial *serial);
273extern int usb_serial_generic_open(struct usb_serial_port *port, 278extern int usb_serial_generic_open(struct tty_struct *tty,
274 struct file *filp); 279 struct usb_serial_port *port, struct file *filp);
275extern int usb_serial_generic_write(struct usb_serial_port *port, 280extern int usb_serial_generic_write(struct tty_struct *tty,
276 const unsigned char *buf, int count); 281 struct usb_serial_port *port, const unsigned char *buf, int count);
277extern void usb_serial_generic_close(struct usb_serial_port *port, 282extern void usb_serial_generic_close(struct tty_struct *tty,
278 struct file *filp); 283 struct usb_serial_port *port, struct file *filp);
279extern int usb_serial_generic_resume(struct usb_serial *serial); 284extern int usb_serial_generic_resume(struct usb_serial *serial);
280extern int usb_serial_generic_write_room(struct usb_serial_port *port); 285extern int usb_serial_generic_write_room(struct tty_struct *tty);
281extern int usb_serial_generic_chars_in_buffer(struct usb_serial_port *port); 286extern int usb_serial_generic_chars_in_buffer(struct tty_struct *tty);
282extern void usb_serial_generic_read_bulk_callback(struct urb *urb); 287extern void usb_serial_generic_read_bulk_callback(struct urb *urb);
283extern void usb_serial_generic_write_bulk_callback(struct urb *urb); 288extern void usb_serial_generic_write_bulk_callback(struct urb *urb);
284extern void usb_serial_generic_throttle(struct usb_serial_port *port); 289extern void usb_serial_generic_throttle(struct tty_struct *tty);
285extern void usb_serial_generic_unthrottle(struct usb_serial_port *port); 290extern void usb_serial_generic_unthrottle(struct tty_struct *tty);
286extern void usb_serial_generic_shutdown(struct usb_serial *serial); 291extern void usb_serial_generic_shutdown(struct usb_serial *serial);
287extern int usb_serial_generic_register(int debug); 292extern int usb_serial_generic_register(int debug);
288extern void usb_serial_generic_deregister(void); 293extern void usb_serial_generic_deregister(void);
diff --git a/include/linux/usb/tmc.h b/include/linux/usb/tmc.h
new file mode 100644
index 000000000000..c045ae12556c
--- /dev/null
+++ b/include/linux/usb/tmc.h
@@ -0,0 +1,43 @@
1/*
2 * Copyright (C) 2007 Stefan Kopp, Gechingen, Germany
3 * Copyright (C) 2008 Novell, Inc.
4 * Copyright (C) 2008 Greg Kroah-Hartman <gregkh@suse.de>
5 *
6 * This file holds USB constants defined by the USB Device Class
7 * Definition for Test and Measurement devices published by the USB-IF.
8 *
9 * It also has the ioctl definitions for the usbtmc kernel driver that
10 * userspace needs to know about.
11 */
12
13#ifndef __LINUX_USB_TMC_H
14#define __LINUX_USB_TMC_H
15
16/* USB TMC status values */
17#define USBTMC_STATUS_SUCCESS 0x01
18#define USBTMC_STATUS_PENDING 0x02
19#define USBTMC_STATUS_FAILED 0x80
20#define USBTMC_STATUS_TRANSFER_NOT_IN_PROGRESS 0x81
21#define USBTMC_STATUS_SPLIT_NOT_IN_PROGRESS 0x82
22#define USBTMC_STATUS_SPLIT_IN_PROGRESS 0x83
23
24/* USB TMC requests values */
25#define USBTMC_REQUEST_INITIATE_ABORT_BULK_OUT 1
26#define USBTMC_REQUEST_CHECK_ABORT_BULK_OUT_STATUS 2
27#define USBTMC_REQUEST_INITIATE_ABORT_BULK_IN 3
28#define USBTMC_REQUEST_CHECK_ABORT_BULK_IN_STATUS 4
29#define USBTMC_REQUEST_INITIATE_CLEAR 5
30#define USBTMC_REQUEST_CHECK_CLEAR_STATUS 6
31#define USBTMC_REQUEST_GET_CAPABILITIES 7
32#define USBTMC_REQUEST_INDICATOR_PULSE 64
33
34/* Request values for USBTMC driver's ioctl entry point */
35#define USBTMC_IOC_NR 91
36#define USBTMC_IOCTL_INDICATOR_PULSE _IO(USBTMC_IOC_NR, 1)
37#define USBTMC_IOCTL_CLEAR _IO(USBTMC_IOC_NR, 2)
38#define USBTMC_IOCTL_ABORT_BULK_OUT _IO(USBTMC_IOC_NR, 3)
39#define USBTMC_IOCTL_ABORT_BULK_IN _IO(USBTMC_IOC_NR, 4)
40#define USBTMC_IOCTL_CLEAR_OUT_HALT _IO(USBTMC_IOC_NR, 6)
41#define USBTMC_IOCTL_CLEAR_IN_HALT _IO(USBTMC_IOC_NR, 7)
42
43#endif
diff --git a/include/linux/usb/vstusb.h b/include/linux/usb/vstusb.h
new file mode 100644
index 000000000000..1cfac67191ff
--- /dev/null
+++ b/include/linux/usb/vstusb.h
@@ -0,0 +1,71 @@
1/*****************************************************************************
2 * File: drivers/usb/misc/vstusb.h
3 *
4 * Purpose: Support for the bulk USB Vernier Spectrophotometers
5 *
6 * Author: EQware Engineering, Inc.
7 * Oregon City, OR, USA 97045
8 *
9 * Copyright: 2007, 2008
10 * Vernier Software & Technology
11 * Beaverton, OR, USA 97005
12 *
13 * Web: www.vernier.com
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License version 2 as
17 * published by the Free Software Foundation.
18 *
19 *****************************************************************************/
20/*****************************************************************************
21 *
22 * The vstusb module is a standard usb 'client' driver running on top of the
23 * standard usb host controller stack.
24 *
25 * In general, vstusb supports standard bulk usb pipes. It supports multiple
26 * devices and multiple pipes per device.
27 *
28 * The vstusb driver supports two interfaces:
29 * 1 - ioctl SEND_PIPE/RECV_PIPE - a general bulk write/read msg
30 * interface to any pipe with timeout support;
31 * 2 - standard read/write with ioctl config - offers standard read/write
32 * interface with ioctl configured pipes and timeouts.
33 *
34 * Both interfaces can be signal from other process and will abort its i/o
35 * operation.
36 *
37 * A timeout of 0 means NO timeout. The user can still terminate the read via
38 * signal.
39 *
40 * If using multiple threads with this driver, the user should ensure that
41 * any reads, writes, or ioctls are complete before closing the device.
42 * Changing read/write timeouts or pipes takes effect on next read/write.
43 *
44 *****************************************************************************/
45
46struct vstusb_args {
47 union {
48 /* this struct is used for IOCTL_VSTUSB_SEND_PIPE, *
49 * IOCTL_VSTUSB_RECV_PIPE, and read()/write() fops */
50 struct {
51 void __user *buffer;
52 size_t count;
53 unsigned int timeout_ms;
54 int pipe;
55 };
56
57 /* this one is used for IOCTL_VSTUSB_CONFIG_RW */
58 struct {
59 int rd_pipe;
60 int rd_timeout_ms;
61 int wr_pipe;
62 int wr_timeout_ms;
63 };
64 };
65};
66
67#define VST_IOC_MAGIC 'L'
68#define VST_IOC_FIRST 0x20
69#define IOCTL_VSTUSB_SEND_PIPE _IO(VST_IOC_MAGIC, VST_IOC_FIRST)
70#define IOCTL_VSTUSB_RECV_PIPE _IO(VST_IOC_MAGIC, VST_IOC_FIRST + 1)
71#define IOCTL_VSTUSB_CONFIG_RW _IO(VST_IOC_MAGIC, VST_IOC_FIRST + 2)
diff --git a/include/linux/usb/wusb-wa.h b/include/linux/usb/wusb-wa.h
new file mode 100644
index 000000000000..a102561e7026
--- /dev/null
+++ b/include/linux/usb/wusb-wa.h
@@ -0,0 +1,271 @@
1/*
2 * Wireless USB Wire Adapter constants and structures.
3 *
4 * Copyright (C) 2005-2006 Intel Corporation.
5 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License version
9 * 2 as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 * 02110-1301, USA.
20 *
21 *
22 * FIXME: docs
23 * FIXME: organize properly, group logically
24 *
25 * All the event structures are defined in uwb/spec.h, as they are
26 * common to the WHCI and WUSB radio control interfaces.
27 *
28 * References:
29 * [WUSB] Wireless Universal Serial Bus Specification, revision 1.0, ch8
30 */
31#ifndef __LINUX_USB_WUSB_WA_H
32#define __LINUX_USB_WUSB_WA_H
33
34/**
35 * Radio Command Request for the Radio Control Interface
36 *
37 * Radio Control Interface command and event codes are the same as
38 * WHCI, and listed in include/linux/uwb.h:UWB_RC_{CMD,EVT}_*
39 */
40enum {
41 WA_EXEC_RC_CMD = 40, /* Radio Control command Request */
42};
43
44/* Wireless Adapter Requests ([WUSB] table 8-51) */
45enum {
46 WUSB_REQ_ADD_MMC_IE = 20,
47 WUSB_REQ_REMOVE_MMC_IE = 21,
48 WUSB_REQ_SET_NUM_DNTS = 22,
49 WUSB_REQ_SET_CLUSTER_ID = 23,
50 WUSB_REQ_SET_DEV_INFO = 24,
51 WUSB_REQ_GET_TIME = 25,
52 WUSB_REQ_SET_STREAM_IDX = 26,
53 WUSB_REQ_SET_WUSB_MAS = 27,
54};
55
56
57/* Wireless Adapter WUSB Channel Time types ([WUSB] table 8-52) */
58enum {
59 WUSB_TIME_ADJ = 0,
60 WUSB_TIME_BPST = 1,
61 WUSB_TIME_WUSB = 2,
62};
63
64enum {
65 WA_ENABLE = 0x01,
66 WA_RESET = 0x02,
67 RPIPE_PAUSE = 0x1,
68};
69
70/* Responses from Get Status request ([WUSB] section 8.3.1.6) */
71enum {
72 WA_STATUS_ENABLED = 0x01,
73 WA_STATUS_RESETTING = 0x02
74};
75
76enum rpipe_crs {
77 RPIPE_CRS_CTL = 0x01,
78 RPIPE_CRS_ISO = 0x02,
79 RPIPE_CRS_BULK = 0x04,
80 RPIPE_CRS_INTR = 0x08
81};
82
83/**
84 * RPipe descriptor ([WUSB] section 8.5.2.11)
85 *
86 * FIXME: explain rpipes
87 */
88struct usb_rpipe_descriptor {
89 u8 bLength;
90 u8 bDescriptorType;
91 __le16 wRPipeIndex;
92 __le16 wRequests;
93 __le16 wBlocks; /* rw if 0 */
94 __le16 wMaxPacketSize; /* rw? */
95 u8 bHSHubAddress; /* reserved: 0 */
96 u8 bHSHubPort; /* ??? FIXME ??? */
97 u8 bSpeed; /* rw: xfer rate 'enum uwb_phy_rate' */
98 u8 bDeviceAddress; /* rw: Target device address */
99 u8 bEndpointAddress; /* rw: Target EP address */
100 u8 bDataSequence; /* ro: Current Data sequence */
101 __le32 dwCurrentWindow; /* ro */
102 u8 bMaxDataSequence; /* ro?: max supported seq */
103 u8 bInterval; /* rw: */
104 u8 bOverTheAirInterval; /* rw: */
105 u8 bmAttribute; /* ro? */
106 u8 bmCharacteristics; /* ro? enum rpipe_attr, supported xsactions */
107 u8 bmRetryOptions; /* rw? */
108 __le16 wNumTransactionErrors; /* rw */
109} __attribute__ ((packed));
110
111/**
112 * Wire Adapter Notification types ([WUSB] sections 8.4.5 & 8.5.4)
113 *
114 * These are the notifications coming on the notification endpoint of
115 * an HWA and a DWA.
116 */
117enum wa_notif_type {
118 DWA_NOTIF_RWAKE = 0x91,
119 DWA_NOTIF_PORTSTATUS = 0x92,
120 WA_NOTIF_TRANSFER = 0x93,
121 HWA_NOTIF_BPST_ADJ = 0x94,
122 HWA_NOTIF_DN = 0x95,
123};
124
125/**
126 * Wire Adapter notification header
127 *
128 * Notifications coming from a wire adapter use a common header
129 * defined in [WUSB] sections 8.4.5 & 8.5.4.
130 */
131struct wa_notif_hdr {
132 u8 bLength;
133 u8 bNotifyType; /* enum wa_notif_type */
134} __attribute__((packed));
135
136/**
137 * HWA DN Received notification [(WUSB] section 8.5.4.2)
138 *
139 * The DNData is specified in WUSB1.0[7.6]. For each device
140 * notification we received, we just need to dispatch it.
141 *
142 * @dndata: this is really an array of notifications, but all start
143 * with the same header.
144 */
145struct hwa_notif_dn {
146 struct wa_notif_hdr hdr;
147 u8 bSourceDeviceAddr; /* from errata 2005/07 */
148 u8 bmAttributes;
149 struct wusb_dn_hdr dndata[];
150} __attribute__((packed));
151
152/* [WUSB] section 8.3.3 */
153enum wa_xfer_type {
154 WA_XFER_TYPE_CTL = 0x80,
155 WA_XFER_TYPE_BI = 0x81, /* bulk/interrupt */
156 WA_XFER_TYPE_ISO = 0x82,
157 WA_XFER_RESULT = 0x83,
158 WA_XFER_ABORT = 0x84,
159};
160
161/* [WUSB] section 8.3.3 */
162struct wa_xfer_hdr {
163 u8 bLength; /* 0x18 */
164 u8 bRequestType; /* 0x80 WA_REQUEST_TYPE_CTL */
165 __le16 wRPipe; /* RPipe index */
166 __le32 dwTransferID; /* Host-assigned ID */
167 __le32 dwTransferLength; /* Length of data to xfer */
168 u8 bTransferSegment;
169} __attribute__((packed));
170
171struct wa_xfer_ctl {
172 struct wa_xfer_hdr hdr;
173 u8 bmAttribute;
174 __le16 wReserved;
175 struct usb_ctrlrequest baSetupData;
176} __attribute__((packed));
177
178struct wa_xfer_bi {
179 struct wa_xfer_hdr hdr;
180 u8 bReserved;
181 __le16 wReserved;
182} __attribute__((packed));
183
184struct wa_xfer_hwaiso {
185 struct wa_xfer_hdr hdr;
186 u8 bReserved;
187 __le16 wPresentationTime;
188 __le32 dwNumOfPackets;
189 /* FIXME: u8 pktdata[]? */
190} __attribute__((packed));
191
192/* [WUSB] section 8.3.3.5 */
193struct wa_xfer_abort {
194 u8 bLength;
195 u8 bRequestType;
196 __le16 wRPipe; /* RPipe index */
197 __le32 dwTransferID; /* Host-assigned ID */
198} __attribute__((packed));
199
200/**
201 * WA Transfer Complete notification ([WUSB] section 8.3.3.3)
202 *
203 */
204struct wa_notif_xfer {
205 struct wa_notif_hdr hdr;
206 u8 bEndpoint;
207 u8 Reserved;
208} __attribute__((packed));
209
210/** Transfer result basic codes [WUSB] table 8-15 */
211enum {
212 WA_XFER_STATUS_SUCCESS,
213 WA_XFER_STATUS_HALTED,
214 WA_XFER_STATUS_DATA_BUFFER_ERROR,
215 WA_XFER_STATUS_BABBLE,
216 WA_XFER_RESERVED,
217 WA_XFER_STATUS_NOT_FOUND,
218 WA_XFER_STATUS_INSUFFICIENT_RESOURCE,
219 WA_XFER_STATUS_TRANSACTION_ERROR,
220 WA_XFER_STATUS_ABORTED,
221 WA_XFER_STATUS_RPIPE_NOT_READY,
222 WA_XFER_INVALID_FORMAT,
223 WA_XFER_UNEXPECTED_SEGMENT_NUMBER,
224 WA_XFER_STATUS_RPIPE_TYPE_MISMATCH,
225};
226
227/** [WUSB] section 8.3.3.4 */
228struct wa_xfer_result {
229 struct wa_notif_hdr hdr;
230 __le32 dwTransferID;
231 __le32 dwTransferLength;
232 u8 bTransferSegment;
233 u8 bTransferStatus;
234 __le32 dwNumOfPackets;
235} __attribute__((packed));
236
237/**
238 * Wire Adapter Class Descriptor ([WUSB] section 8.5.2.7).
239 *
240 * NOTE: u16 fields are read Little Endian from the hardware.
241 *
242 * @bNumPorts is the original max number of devices that the host can
243 * connect; we might chop this so the stack can handle
244 * it. In case you need to access it, use wusbhc->ports_max
245 * if it is a Wireless USB WA.
246 */
247struct usb_wa_descriptor {
248 u8 bLength;
249 u8 bDescriptorType;
250 u16 bcdWAVersion;
251 u8 bNumPorts; /* don't use!! */
252 u8 bmAttributes; /* Reserved == 0 */
253 u16 wNumRPipes;
254 u16 wRPipeMaxBlock;
255 u8 bRPipeBlockSize;
256 u8 bPwrOn2PwrGood;
257 u8 bNumMMCIEs;
258 u8 DeviceRemovable; /* FIXME: in DWA this is up to 16 bytes */
259} __attribute__((packed));
260
261/**
262 * HWA Device Information Buffer (WUSB1.0[T8.54])
263 */
264struct hwa_dev_info {
265 u8 bmDeviceAvailability[32]; /* FIXME: ignored for now */
266 u8 bDeviceAddress;
267 __le16 wPHYRates;
268 u8 bmDeviceAttribute;
269} __attribute__((packed));
270
271#endif /* #ifndef __LINUX_USB_WUSB_WA_H */
diff --git a/include/linux/usb/wusb.h b/include/linux/usb/wusb.h
new file mode 100644
index 000000000000..5f401b644ed5
--- /dev/null
+++ b/include/linux/usb/wusb.h
@@ -0,0 +1,376 @@
1/*
2 * Wireless USB Standard Definitions
3 * Event Size Tables
4 *
5 * Copyright (C) 2005-2006 Intel Corporation
6 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License version
10 * 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 * 02110-1301, USA.
21 *
22 *
23 * FIXME: docs
24 * FIXME: organize properly, group logically
25 *
26 * All the event structures are defined in uwb/spec.h, as they are
27 * common to the WHCI and WUSB radio control interfaces.
28 */
29
30#ifndef __WUSB_H__
31#define __WUSB_H__
32
33#include <linux/types.h>
34#include <linux/kernel.h>
35#include <linux/uwb/spec.h>
36#include <linux/usb/ch9.h>
37#include <linux/param.h>
38
39/**
40 * WUSB Information Element header
41 *
42 * I don't know why, they decided to make it different to the MBOA MAC
43 * IE Header; beats me.
44 */
45struct wuie_hdr {
46 u8 bLength;
47 u8 bIEIdentifier;
48} __attribute__((packed));
49
50enum {
51 WUIE_ID_WCTA = 0x80,
52 WUIE_ID_CONNECTACK,
53 WUIE_ID_HOST_INFO,
54 WUIE_ID_CHANGE_ANNOUNCE,
55 WUIE_ID_DEVICE_DISCONNECT,
56 WUIE_ID_HOST_DISCONNECT,
57 WUIE_ID_KEEP_ALIVE = 0x89,
58 WUIE_ID_ISOCH_DISCARD,
59 WUIE_ID_RESET_DEVICE,
60};
61
62/**
63 * Maximum number of array elements in a WUSB IE.
64 *
65 * WUSB1.0[7.5 before table 7-38] says that in WUSB IEs that
66 * are "arrays" have to limited to 4 elements. So we define it
67 * like that to ease up and submit only the neeed size.
68 */
69#define WUIE_ELT_MAX 4
70
71/**
72 * Wrapper for the data that defines a CHID, a CDID or a CK
73 *
74 * WUSB defines that CHIDs, CDIDs and CKs are a 16 byte string of
75 * data. In order to avoid confusion and enforce types, we wrap it.
76 *
77 * Make it packed, as we use it in some hw defintions.
78 */
79struct wusb_ckhdid {
80 u8 data[16];
81} __attribute__((packed));
82
83const static
84struct wusb_ckhdid wusb_ckhdid_zero = { .data = { 0 } };
85
86#define WUSB_CKHDID_STRSIZE (3 * sizeof(struct wusb_ckhdid) + 1)
87
88/**
89 * WUSB IE: Host Information (WUSB1.0[7.5.2])
90 *
91 * Used to provide information about the host to the Wireless USB
92 * devices in range (CHID can be used as an ASCII string).
93 */
94struct wuie_host_info {
95 struct wuie_hdr hdr;
96 __le16 attributes;
97 struct wusb_ckhdid CHID;
98} __attribute__((packed));
99
100/**
101 * WUSB IE: Connect Ack (WUSB1.0[7.5.1])
102 *
103 * Used to acknowledge device connect requests. See note for
104 * WUIE_ELT_MAX.
105 */
106struct wuie_connect_ack {
107 struct wuie_hdr hdr;
108 struct {
109 struct wusb_ckhdid CDID;
110 u8 bDeviceAddress; /* 0 means unused */
111 u8 bReserved;
112 } blk[WUIE_ELT_MAX];
113} __attribute__((packed));
114
115/**
116 * WUSB IE Host Information Element, Connect Availability
117 *
118 * WUSB1.0[7.5.2], bmAttributes description
119 */
120enum {
121 WUIE_HI_CAP_RECONNECT = 0,
122 WUIE_HI_CAP_LIMITED,
123 WUIE_HI_CAP_RESERVED,
124 WUIE_HI_CAP_ALL,
125};
126
127/**
128 * WUSB IE: Channel Stop (WUSB1.0[7.5.8])
129 *
130 * Tells devices the host is going to stop sending MMCs and will dissapear.
131 */
132struct wuie_channel_stop {
133 struct wuie_hdr hdr;
134 u8 attributes;
135 u8 timestamp[3];
136} __attribute__((packed));
137
138/**
139 * WUSB IE: Keepalive (WUSB1.0[7.5.9])
140 *
141 * Ask device(s) to send keepalives.
142 */
143struct wuie_keep_alive {
144 struct wuie_hdr hdr;
145 u8 bDeviceAddress[WUIE_ELT_MAX];
146} __attribute__((packed));
147
148/**
149 * WUSB IE: Reset device (WUSB1.0[7.5.11])
150 *
151 * Tell device to reset; in all truth, we can fit 4 CDIDs, but we only
152 * use it for one at the time...
153 *
154 * In any case, this request is a wee bit silly: why don't they target
155 * by address??
156 */
157struct wuie_reset {
158 struct wuie_hdr hdr;
159 struct wusb_ckhdid CDID;
160} __attribute__((packed));
161
162/**
163 * WUSB IE: Disconnect device (WUSB1.0[7.5.11])
164 *
165 * Tell device to disconnect; we can fit 4 addresses, but we only use
166 * it for one at the time...
167 */
168struct wuie_disconnect {
169 struct wuie_hdr hdr;
170 u8 bDeviceAddress;
171 u8 padding;
172} __attribute__((packed));
173
174/**
175 * WUSB IE: Host disconnect ([WUSB] section 7.5.5)
176 *
177 * Tells all connected devices to disconnect.
178 */
179struct wuie_host_disconnect {
180 struct wuie_hdr hdr;
181} __attribute__((packed));
182
183/**
184 * WUSB Device Notification header (WUSB1.0[7.6])
185 */
186struct wusb_dn_hdr {
187 u8 bType;
188 u8 notifdata[];
189} __attribute__((packed));
190
191/** Device Notification codes (WUSB1.0[Table 7-54]) */
192enum WUSB_DN {
193 WUSB_DN_CONNECT = 0x01,
194 WUSB_DN_DISCONNECT = 0x02,
195 WUSB_DN_EPRDY = 0x03,
196 WUSB_DN_MASAVAILCHANGED = 0x04,
197 WUSB_DN_RWAKE = 0x05,
198 WUSB_DN_SLEEP = 0x06,
199 WUSB_DN_ALIVE = 0x07,
200};
201
202/** WUSB Device Notification Connect */
203struct wusb_dn_connect {
204 struct wusb_dn_hdr hdr;
205 __le16 attributes;
206 struct wusb_ckhdid CDID;
207} __attribute__((packed));
208
209static inline int wusb_dn_connect_prev_dev_addr(const struct wusb_dn_connect *dn)
210{
211 return le16_to_cpu(dn->attributes) & 0xff;
212}
213
214static inline int wusb_dn_connect_new_connection(const struct wusb_dn_connect *dn)
215{
216 return (le16_to_cpu(dn->attributes) >> 8) & 0x1;
217}
218
219static inline int wusb_dn_connect_beacon_behavior(const struct wusb_dn_connect *dn)
220{
221 return (le16_to_cpu(dn->attributes) >> 9) & 0x03;
222}
223
224/** Device is alive (aka: pong) (WUSB1.0[7.6.7]) */
225struct wusb_dn_alive {
226 struct wusb_dn_hdr hdr;
227} __attribute__((packed));
228
229/** Device is disconnecting (WUSB1.0[7.6.2]) */
230struct wusb_dn_disconnect {
231 struct wusb_dn_hdr hdr;
232} __attribute__((packed));
233
234/* General constants */
235enum {
236 WUSB_TRUST_TIMEOUT_MS = 4000, /* [WUSB] section 4.15.1 */
237};
238
239static inline size_t ckhdid_printf(char *pr_ckhdid, size_t size,
240 const struct wusb_ckhdid *ckhdid)
241{
242 return scnprintf(pr_ckhdid, size,
243 "%02hx %02hx %02hx %02hx %02hx %02hx %02hx %02hx "
244 "%02hx %02hx %02hx %02hx %02hx %02hx %02hx %02hx",
245 ckhdid->data[0], ckhdid->data[1],
246 ckhdid->data[2], ckhdid->data[3],
247 ckhdid->data[4], ckhdid->data[5],
248 ckhdid->data[6], ckhdid->data[7],
249 ckhdid->data[8], ckhdid->data[9],
250 ckhdid->data[10], ckhdid->data[11],
251 ckhdid->data[12], ckhdid->data[13],
252 ckhdid->data[14], ckhdid->data[15]);
253}
254
255/*
256 * WUSB Crypto stuff (WUSB1.0[6])
257 */
258
259extern const char *wusb_et_name(u8);
260
261/**
262 * WUSB key index WUSB1.0[7.3.2.4], for usage when setting keys for
263 * the host or the device.
264 */
265static inline u8 wusb_key_index(int index, int type, int originator)
266{
267 return (originator << 6) | (type << 4) | index;
268}
269
270#define WUSB_KEY_INDEX_TYPE_PTK 0 /* for HWA only */
271#define WUSB_KEY_INDEX_TYPE_ASSOC 1
272#define WUSB_KEY_INDEX_TYPE_GTK 2
273#define WUSB_KEY_INDEX_ORIGINATOR_HOST 0
274#define WUSB_KEY_INDEX_ORIGINATOR_DEVICE 1
275
276/* A CCM Nonce, defined in WUSB1.0[6.4.1] */
277struct aes_ccm_nonce {
278 u8 sfn[6]; /* Little Endian */
279 u8 tkid[3]; /* LE */
280 struct uwb_dev_addr dest_addr;
281 struct uwb_dev_addr src_addr;
282} __attribute__((packed));
283
284/* A CCM operation label, defined on WUSB1.0[6.5.x] */
285struct aes_ccm_label {
286 u8 data[14];
287} __attribute__((packed));
288
289/*
290 * Input to the key derivation sequence defined in
291 * WUSB1.0[6.5.1]. Rest of the data is in the CCM Nonce passed to the
292 * PRF function.
293 */
294struct wusb_keydvt_in {
295 u8 hnonce[16];
296 u8 dnonce[16];
297} __attribute__((packed));
298
299/*
300 * Output from the key derivation sequence defined in
301 * WUSB1.0[6.5.1].
302 */
303struct wusb_keydvt_out {
304 u8 kck[16];
305 u8 ptk[16];
306} __attribute__((packed));
307
308/* Pseudo Random Function WUSB1.0[6.5] */
309extern int wusb_crypto_init(void);
310extern void wusb_crypto_exit(void);
311extern ssize_t wusb_prf(void *out, size_t out_size,
312 const u8 key[16], const struct aes_ccm_nonce *_n,
313 const struct aes_ccm_label *a,
314 const void *b, size_t blen, size_t len);
315
316static inline int wusb_prf_64(void *out, size_t out_size, const u8 key[16],
317 const struct aes_ccm_nonce *n,
318 const struct aes_ccm_label *a,
319 const void *b, size_t blen)
320{
321 return wusb_prf(out, out_size, key, n, a, b, blen, 64);
322}
323
324static inline int wusb_prf_128(void *out, size_t out_size, const u8 key[16],
325 const struct aes_ccm_nonce *n,
326 const struct aes_ccm_label *a,
327 const void *b, size_t blen)
328{
329 return wusb_prf(out, out_size, key, n, a, b, blen, 128);
330}
331
332static inline int wusb_prf_256(void *out, size_t out_size, const u8 key[16],
333 const struct aes_ccm_nonce *n,
334 const struct aes_ccm_label *a,
335 const void *b, size_t blen)
336{
337 return wusb_prf(out, out_size, key, n, a, b, blen, 256);
338}
339
340/* Key derivation WUSB1.0[6.5.1] */
341static inline int wusb_key_derive(struct wusb_keydvt_out *keydvt_out,
342 const u8 key[16],
343 const struct aes_ccm_nonce *n,
344 const struct wusb_keydvt_in *keydvt_in)
345{
346 const struct aes_ccm_label a = { .data = "Pair-wise keys" };
347 return wusb_prf_256(keydvt_out, sizeof(*keydvt_out), key, n, &a,
348 keydvt_in, sizeof(*keydvt_in));
349}
350
351/*
352 * Out-of-band MIC Generation WUSB1.0[6.5.2]
353 *
354 * Compute the MIC over @key, @n and @hs and place it in @mic_out.
355 *
356 * @mic_out: Where to place the 8 byte MIC tag
357 * @key: KCK from the derivation process
358 * @n: CCM nonce, n->sfn == 0, TKID as established in the
359 * process.
360 * @hs: Handshake struct for phase 2 of the 4-way.
361 * hs->bStatus and hs->bReserved are zero.
362 * hs->bMessageNumber is 2 (WUSB1.0[7.3.2.5.2]
363 * hs->dest_addr is the device's USB address padded with 0
364 * hs->src_addr is the hosts's UWB device address
365 * hs->mic is ignored (as we compute that value).
366 */
367static inline int wusb_oob_mic(u8 mic_out[8], const u8 key[16],
368 const struct aes_ccm_nonce *n,
369 const struct usb_handshake *hs)
370{
371 const struct aes_ccm_label a = { .data = "out-of-bandMIC" };
372 return wusb_prf_64(mic_out, 8, key, n, &a,
373 hs, sizeof(*hs) - sizeof(hs->MIC));
374}
375
376#endif /* #ifndef __WUSB_H__ */
diff --git a/include/linux/usbdevice_fs.h b/include/linux/usbdevice_fs.h
index 3118ede2c67b..0044d9b4cb85 100644
--- a/include/linux/usbdevice_fs.h
+++ b/include/linux/usbdevice_fs.h
@@ -22,8 +22,6 @@
22 * 22 *
23 * History: 23 * History:
24 * 0.1 04.01.2000 Created 24 * 0.1 04.01.2000 Created
25 *
26 * $Id: usbdevice_fs.h,v 1.1 2000/01/06 18:40:41 tom Exp $
27 */ 25 */
28 26
29/*****************************************************************************/ 27/*****************************************************************************/
diff --git a/include/linux/uwb.h b/include/linux/uwb.h
new file mode 100644
index 000000000000..f9ccbd9a2ced
--- /dev/null
+++ b/include/linux/uwb.h
@@ -0,0 +1,765 @@
1/*
2 * Ultra Wide Band
3 * UWB API
4 *
5 * Copyright (C) 2005-2006 Intel Corporation
6 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License version
10 * 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 * 02110-1301, USA.
21 *
22 *
23 * FIXME: doc: overview of the API, different parts and pointers
24 */
25
26#ifndef __LINUX__UWB_H__
27#define __LINUX__UWB_H__
28
29#include <linux/limits.h>
30#include <linux/device.h>
31#include <linux/mutex.h>
32#include <linux/timer.h>
33#include <linux/workqueue.h>
34#include <linux/uwb/spec.h>
35
36struct uwb_dev;
37struct uwb_beca_e;
38struct uwb_rc;
39struct uwb_rsv;
40struct uwb_dbg;
41
42/**
43 * struct uwb_dev - a UWB Device
44 * @rc: UWB Radio Controller that discovered the device (kind of its
45 * parent).
46 * @bce: a beacon cache entry for this device; or NULL if the device
47 * is a local radio controller.
48 * @mac_addr: the EUI-48 address of this device.
49 * @dev_addr: the current DevAddr used by this device.
50 * @beacon_slot: the slot number the beacon is using.
51 * @streams: bitmap of streams allocated to reservations targeted at
52 * this device. For an RC, this is the streams allocated for
53 * reservations targeted at DevAddrs.
54 *
55 * A UWB device may either by a neighbor or part of a local radio
56 * controller.
57 */
58struct uwb_dev {
59 struct mutex mutex;
60 struct list_head list_node;
61 struct device dev;
62 struct uwb_rc *rc; /* radio controller */
63 struct uwb_beca_e *bce; /* Beacon Cache Entry */
64
65 struct uwb_mac_addr mac_addr;
66 struct uwb_dev_addr dev_addr;
67 int beacon_slot;
68 DECLARE_BITMAP(streams, UWB_NUM_STREAMS);
69};
70#define to_uwb_dev(d) container_of(d, struct uwb_dev, dev)
71
72/**
73 * UWB HWA/WHCI Radio Control {Command|Event} Block context IDs
74 *
75 * RC[CE]Bs have a 'context ID' field that matches the command with
76 * the event received to confirm it.
77 *
78 * Maximum number of context IDs
79 */
80enum { UWB_RC_CTX_MAX = 256 };
81
82
83/** Notification chain head for UWB generated events to listeners */
84struct uwb_notifs_chain {
85 struct list_head list;
86 struct mutex mutex;
87};
88
89/**
90 * struct uwb_mas_bm - a bitmap of all MAS in a superframe
91 * @bm: a bitmap of length #UWB_NUM_MAS
92 */
93struct uwb_mas_bm {
94 DECLARE_BITMAP(bm, UWB_NUM_MAS);
95};
96
97/**
98 * uwb_rsv_state - UWB Reservation state.
99 *
100 * NONE - reservation is not active (no DRP IE being transmitted).
101 *
102 * Owner reservation states:
103 *
104 * INITIATED - owner has sent an initial DRP request.
105 * PENDING - target responded with pending Reason Code.
106 * MODIFIED - reservation manager is modifying an established
107 * reservation with a different MAS allocation.
108 * ESTABLISHED - the reservation has been successfully negotiated.
109 *
110 * Target reservation states:
111 *
112 * DENIED - request is denied.
113 * ACCEPTED - request is accepted.
114 * PENDING - PAL has yet to make a decision to whether to accept or
115 * deny.
116 *
117 * FIXME: further target states TBD.
118 */
119enum uwb_rsv_state {
120 UWB_RSV_STATE_NONE,
121 UWB_RSV_STATE_O_INITIATED,
122 UWB_RSV_STATE_O_PENDING,
123 UWB_RSV_STATE_O_MODIFIED,
124 UWB_RSV_STATE_O_ESTABLISHED,
125 UWB_RSV_STATE_T_ACCEPTED,
126 UWB_RSV_STATE_T_DENIED,
127 UWB_RSV_STATE_T_PENDING,
128
129 UWB_RSV_STATE_LAST,
130};
131
132enum uwb_rsv_target_type {
133 UWB_RSV_TARGET_DEV,
134 UWB_RSV_TARGET_DEVADDR,
135};
136
137/**
138 * struct uwb_rsv_target - the target of a reservation.
139 *
140 * Reservations unicast and targeted at a single device
141 * (UWB_RSV_TARGET_DEV); or (e.g., in the case of WUSB) targeted at a
142 * specific (private) DevAddr (UWB_RSV_TARGET_DEVADDR).
143 */
144struct uwb_rsv_target {
145 enum uwb_rsv_target_type type;
146 union {
147 struct uwb_dev *dev;
148 struct uwb_dev_addr devaddr;
149 };
150};
151
152/*
153 * Number of streams reserved for reservations targeted at DevAddrs.
154 */
155#define UWB_NUM_GLOBAL_STREAMS 1
156
157typedef void (*uwb_rsv_cb_f)(struct uwb_rsv *rsv);
158
159/**
160 * struct uwb_rsv - a DRP reservation
161 *
162 * Data structure management:
163 *
164 * @rc: the radio controller this reservation is for
165 * (as target or owner)
166 * @rc_node: a list node for the RC
167 * @pal_node: a list node for the PAL
168 *
169 * Owner and target parameters:
170 *
171 * @owner: the UWB device owning this reservation
172 * @target: the target UWB device
173 * @type: reservation type
174 *
175 * Owner parameters:
176 *
177 * @max_mas: maxiumum number of MAS
178 * @min_mas: minimum number of MAS
179 * @sparsity: owner selected sparsity
180 * @is_multicast: true iff multicast
181 *
182 * @callback: callback function when the reservation completes
183 * @pal_priv: private data for the PAL making the reservation
184 *
185 * Reservation status:
186 *
187 * @status: negotiation status
188 * @stream: stream index allocated for this reservation
189 * @mas: reserved MAS
190 * @drp_ie: the DRP IE
191 * @ie_valid: true iff the DRP IE matches the reservation parameters
192 *
193 * DRP reservations are uniquely identified by the owner, target and
194 * stream index. However, when using a DevAddr as a target (e.g., for
195 * a WUSB cluster reservation) the responses may be received from
196 * devices with different DevAddrs. In this case, reservations are
197 * uniquely identified by just the stream index. A number of stream
198 * indexes (UWB_NUM_GLOBAL_STREAMS) are reserved for this.
199 */
200struct uwb_rsv {
201 struct uwb_rc *rc;
202 struct list_head rc_node;
203 struct list_head pal_node;
204
205 struct uwb_dev *owner;
206 struct uwb_rsv_target target;
207 enum uwb_drp_type type;
208 int max_mas;
209 int min_mas;
210 int sparsity;
211 bool is_multicast;
212
213 uwb_rsv_cb_f callback;
214 void *pal_priv;
215
216 enum uwb_rsv_state state;
217 u8 stream;
218 struct uwb_mas_bm mas;
219 struct uwb_ie_drp *drp_ie;
220 bool ie_valid;
221 struct timer_list timer;
222 bool expired;
223};
224
225static const
226struct uwb_mas_bm uwb_mas_bm_zero = { .bm = { 0 } };
227
228static inline void uwb_mas_bm_copy_le(void *dst, const struct uwb_mas_bm *mas)
229{
230 bitmap_copy_le(dst, mas->bm, UWB_NUM_MAS);
231}
232
233/**
234 * struct uwb_drp_avail - a radio controller's view of MAS usage
235 * @global: MAS unused by neighbors (excluding reservations targetted
236 * or owned by the local radio controller) or the beaon period
237 * @local: MAS unused by local established reservations
238 * @pending: MAS unused by local pending reservations
239 * @ie: DRP Availability IE to be included in the beacon
240 * @ie_valid: true iff @ie is valid and does not need to regenerated from
241 * @global and @local
242 *
243 * Each radio controller maintains a view of MAS usage or
244 * availability. MAS available for a new reservation are determined
245 * from the intersection of @global, @local, and @pending.
246 *
247 * The radio controller must transmit a DRP Availability IE that's the
248 * intersection of @global and @local.
249 *
250 * A set bit indicates the MAS is unused and available.
251 *
252 * rc->rsvs_mutex should be held before accessing this data structure.
253 *
254 * [ECMA-368] section 17.4.3.
255 */
256struct uwb_drp_avail {
257 DECLARE_BITMAP(global, UWB_NUM_MAS);
258 DECLARE_BITMAP(local, UWB_NUM_MAS);
259 DECLARE_BITMAP(pending, UWB_NUM_MAS);
260 struct uwb_ie_drp_avail ie;
261 bool ie_valid;
262};
263
264
265const char *uwb_rsv_state_str(enum uwb_rsv_state state);
266const char *uwb_rsv_type_str(enum uwb_drp_type type);
267
268struct uwb_rsv *uwb_rsv_create(struct uwb_rc *rc, uwb_rsv_cb_f cb,
269 void *pal_priv);
270void uwb_rsv_destroy(struct uwb_rsv *rsv);
271
272int uwb_rsv_establish(struct uwb_rsv *rsv);
273int uwb_rsv_modify(struct uwb_rsv *rsv,
274 int max_mas, int min_mas, int sparsity);
275void uwb_rsv_terminate(struct uwb_rsv *rsv);
276
277void uwb_rsv_accept(struct uwb_rsv *rsv, uwb_rsv_cb_f cb, void *pal_priv);
278
279/**
280 * Radio Control Interface instance
281 *
282 *
283 * Life cycle rules: those of the UWB Device.
284 *
285 * @index: an index number for this radio controller, as used in the
286 * device name.
287 * @version: version of protocol supported by this device
288 * @priv: Backend implementation; rw with uwb_dev.dev.sem taken.
289 * @cmd: Backend implementation to execute commands; rw and call
290 * only with uwb_dev.dev.sem taken.
291 * @reset: Hardware reset of radio controller and any PAL controllers.
292 * @filter: Backend implementation to manipulate data to and from device
293 * to be compliant to specification assumed by driver (WHCI
294 * 0.95).
295 *
296 * uwb_dev.dev.mutex is used to execute commands and update
297 * the corresponding structures; can't use a spinlock
298 * because rc->cmd() can sleep.
299 * @ies: This is a dynamically allocated array cacheing the
300 * IEs (settable by the host) that the beacon of this
301 * radio controller is currently sending.
302 *
303 * In reality, we store here the full command we set to
304 * the radio controller (which is basically a command
305 * prefix followed by all the IEs the beacon currently
306 * contains). This way we don't have to realloc and
307 * memcpy when setting it.
308 *
309 * We set this up in uwb_rc_ie_setup(), where we alloc
310 * this struct, call get_ie() [so we know which IEs are
311 * currently being sent, if any].
312 *
313 * @ies_capacity:Amount of space (in bytes) allocated in @ies. The
314 * amount used is given by sizeof(*ies) plus ies->wIELength
315 * (which is a little endian quantity all the time).
316 * @ies_mutex: protect the IE cache
317 * @dbg: information for the debug interface
318 */
319struct uwb_rc {
320 struct uwb_dev uwb_dev;
321 int index;
322 u16 version;
323
324 struct module *owner;
325 void *priv;
326 int (*start)(struct uwb_rc *rc);
327 void (*stop)(struct uwb_rc *rc);
328 int (*cmd)(struct uwb_rc *, const struct uwb_rccb *, size_t);
329 int (*reset)(struct uwb_rc *rc);
330 int (*filter_cmd)(struct uwb_rc *, struct uwb_rccb **, size_t *);
331 int (*filter_event)(struct uwb_rc *, struct uwb_rceb **, const size_t,
332 size_t *, size_t *);
333
334 spinlock_t neh_lock; /* protects neh_* and ctx_* */
335 struct list_head neh_list; /* Open NE handles */
336 unsigned long ctx_bm[UWB_RC_CTX_MAX / 8 / sizeof(unsigned long)];
337 u8 ctx_roll;
338
339 int beaconing; /* Beaconing state [channel number] */
340 int scanning;
341 enum uwb_scan_type scan_type:3;
342 unsigned ready:1;
343 struct uwb_notifs_chain notifs_chain;
344
345 struct uwb_drp_avail drp_avail;
346 struct list_head reservations;
347 struct mutex rsvs_mutex;
348 struct workqueue_struct *rsv_workq;
349 struct work_struct rsv_update_work;
350
351 struct mutex ies_mutex;
352 struct uwb_rc_cmd_set_ie *ies;
353 size_t ies_capacity;
354
355 spinlock_t pal_lock;
356 struct list_head pals;
357
358 struct uwb_dbg *dbg;
359};
360
361
362/**
363 * struct uwb_pal - a UWB PAL
364 * @name: descriptive name for this PAL (wushc, wlp, etc.).
365 * @device: a device for the PAL. Used to link the PAL and the radio
366 * controller in sysfs.
367 * @new_rsv: called when a peer requests a reservation (may be NULL if
368 * the PAL cannot accept reservation requests).
369 *
370 * A Protocol Adaptation Layer (PAL) is a user of the WiMedia UWB
371 * radio platform (e.g., WUSB, WLP or Bluetooth UWB AMP).
372 *
373 * The PALs using a radio controller must register themselves to
374 * permit the UWB stack to coordinate usage of the radio between the
375 * various PALs or to allow PALs to response to certain requests from
376 * peers.
377 *
378 * A struct uwb_pal should be embedded in a containing structure
379 * belonging to the PAL and initialized with uwb_pal_init()). Fields
380 * should be set appropriately by the PAL before registering the PAL
381 * with uwb_pal_register().
382 */
383struct uwb_pal {
384 struct list_head node;
385 const char *name;
386 struct device *device;
387 void (*new_rsv)(struct uwb_rsv *rsv);
388};
389
390void uwb_pal_init(struct uwb_pal *pal);
391int uwb_pal_register(struct uwb_rc *rc, struct uwb_pal *pal);
392void uwb_pal_unregister(struct uwb_rc *rc, struct uwb_pal *pal);
393
394/*
395 * General public API
396 *
397 * This API can be used by UWB device drivers or by those implementing
398 * UWB Radio Controllers
399 */
400struct uwb_dev *uwb_dev_get_by_devaddr(struct uwb_rc *rc,
401 const struct uwb_dev_addr *devaddr);
402struct uwb_dev *uwb_dev_get_by_rc(struct uwb_dev *, struct uwb_rc *);
403static inline void uwb_dev_get(struct uwb_dev *uwb_dev)
404{
405 get_device(&uwb_dev->dev);
406}
407static inline void uwb_dev_put(struct uwb_dev *uwb_dev)
408{
409 put_device(&uwb_dev->dev);
410}
411struct uwb_dev *uwb_dev_try_get(struct uwb_rc *rc, struct uwb_dev *uwb_dev);
412
413/**
414 * Callback function for 'uwb_{dev,rc}_foreach()'.
415 *
416 * @dev: Linux device instance
417 * 'uwb_dev = container_of(dev, struct uwb_dev, dev)'
418 * @priv: Data passed by the caller to 'uwb_{dev,rc}_foreach()'.
419 *
420 * @returns: 0 to continue the iterations, any other val to stop
421 * iterating and return the value to the caller of
422 * _foreach().
423 */
424typedef int (*uwb_dev_for_each_f)(struct device *dev, void *priv);
425int uwb_dev_for_each(struct uwb_rc *rc, uwb_dev_for_each_f func, void *priv);
426
427struct uwb_rc *uwb_rc_alloc(void);
428struct uwb_rc *uwb_rc_get_by_dev(const struct uwb_dev_addr *);
429struct uwb_rc *uwb_rc_get_by_grandpa(const struct device *);
430void uwb_rc_put(struct uwb_rc *rc);
431
432typedef void (*uwb_rc_cmd_cb_f)(struct uwb_rc *rc, void *arg,
433 struct uwb_rceb *reply, ssize_t reply_size);
434
435int uwb_rc_cmd_async(struct uwb_rc *rc, const char *cmd_name,
436 struct uwb_rccb *cmd, size_t cmd_size,
437 u8 expected_type, u16 expected_event,
438 uwb_rc_cmd_cb_f cb, void *arg);
439ssize_t uwb_rc_cmd(struct uwb_rc *rc, const char *cmd_name,
440 struct uwb_rccb *cmd, size_t cmd_size,
441 struct uwb_rceb *reply, size_t reply_size);
442ssize_t uwb_rc_vcmd(struct uwb_rc *rc, const char *cmd_name,
443 struct uwb_rccb *cmd, size_t cmd_size,
444 u8 expected_type, u16 expected_event,
445 struct uwb_rceb **preply);
446ssize_t uwb_rc_get_ie(struct uwb_rc *, struct uwb_rc_evt_get_ie **);
447int uwb_bg_joined(struct uwb_rc *rc);
448
449size_t __uwb_addr_print(char *, size_t, const unsigned char *, int);
450
451int uwb_rc_dev_addr_set(struct uwb_rc *, const struct uwb_dev_addr *);
452int uwb_rc_dev_addr_get(struct uwb_rc *, struct uwb_dev_addr *);
453int uwb_rc_mac_addr_set(struct uwb_rc *, const struct uwb_mac_addr *);
454int uwb_rc_mac_addr_get(struct uwb_rc *, struct uwb_mac_addr *);
455int __uwb_mac_addr_assigned_check(struct device *, void *);
456int __uwb_dev_addr_assigned_check(struct device *, void *);
457
458/* Print in @buf a pretty repr of @addr */
459static inline size_t uwb_dev_addr_print(char *buf, size_t buf_size,
460 const struct uwb_dev_addr *addr)
461{
462 return __uwb_addr_print(buf, buf_size, addr->data, 0);
463}
464
465/* Print in @buf a pretty repr of @addr */
466static inline size_t uwb_mac_addr_print(char *buf, size_t buf_size,
467 const struct uwb_mac_addr *addr)
468{
469 return __uwb_addr_print(buf, buf_size, addr->data, 1);
470}
471
472/* @returns 0 if device addresses @addr2 and @addr1 are equal */
473static inline int uwb_dev_addr_cmp(const struct uwb_dev_addr *addr1,
474 const struct uwb_dev_addr *addr2)
475{
476 return memcmp(addr1, addr2, sizeof(*addr1));
477}
478
479/* @returns 0 if MAC addresses @addr2 and @addr1 are equal */
480static inline int uwb_mac_addr_cmp(const struct uwb_mac_addr *addr1,
481 const struct uwb_mac_addr *addr2)
482{
483 return memcmp(addr1, addr2, sizeof(*addr1));
484}
485
486/* @returns !0 if a MAC @addr is a broadcast address */
487static inline int uwb_mac_addr_bcast(const struct uwb_mac_addr *addr)
488{
489 struct uwb_mac_addr bcast = {
490 .data = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }
491 };
492 return !uwb_mac_addr_cmp(addr, &bcast);
493}
494
495/* @returns !0 if a MAC @addr is all zeroes*/
496static inline int uwb_mac_addr_unset(const struct uwb_mac_addr *addr)
497{
498 struct uwb_mac_addr unset = {
499 .data = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
500 };
501 return !uwb_mac_addr_cmp(addr, &unset);
502}
503
504/* @returns !0 if the address is in use. */
505static inline unsigned __uwb_dev_addr_assigned(struct uwb_rc *rc,
506 struct uwb_dev_addr *addr)
507{
508 return uwb_dev_for_each(rc, __uwb_dev_addr_assigned_check, addr);
509}
510
511/*
512 * UWB Radio Controller API
513 *
514 * This API is used (in addition to the general API) to implement UWB
515 * Radio Controllers.
516 */
517void uwb_rc_init(struct uwb_rc *);
518int uwb_rc_add(struct uwb_rc *, struct device *dev, void *rc_priv);
519void uwb_rc_rm(struct uwb_rc *);
520void uwb_rc_neh_grok(struct uwb_rc *, void *, size_t);
521void uwb_rc_neh_error(struct uwb_rc *, int);
522void uwb_rc_reset_all(struct uwb_rc *rc);
523
524/**
525 * uwb_rsv_is_owner - is the owner of this reservation the RC?
526 * @rsv: the reservation
527 */
528static inline bool uwb_rsv_is_owner(struct uwb_rsv *rsv)
529{
530 return rsv->owner == &rsv->rc->uwb_dev;
531}
532
533/**
534 * Events generated by UWB that can be passed to any listeners
535 *
536 * Higher layers can register callback functions with the radio
537 * controller using uwb_notifs_register(). The radio controller
538 * maintains a list of all registered handlers and will notify all
539 * nodes when an event occurs.
540 */
541enum uwb_notifs {
542 UWB_NOTIF_BG_JOIN = 0, /* radio controller joined a beacon group */
543 UWB_NOTIF_BG_LEAVE = 1, /* radio controller left a beacon group */
544 UWB_NOTIF_ONAIR,
545 UWB_NOTIF_OFFAIR,
546};
547
548/* Callback function registered with UWB */
549struct uwb_notifs_handler {
550 struct list_head list_node;
551 void (*cb)(void *, struct uwb_dev *, enum uwb_notifs);
552 void *data;
553};
554
555int uwb_notifs_register(struct uwb_rc *, struct uwb_notifs_handler *);
556int uwb_notifs_deregister(struct uwb_rc *, struct uwb_notifs_handler *);
557
558
559/**
560 * UWB radio controller Event Size Entry (for creating entry tables)
561 *
562 * WUSB and WHCI define events and notifications, and they might have
563 * fixed or variable size.
564 *
565 * Each event/notification has a size which is not necessarily known
566 * in advance based on the event code. As well, vendor specific
567 * events/notifications will have a size impossible to determine
568 * unless we know about the device's specific details.
569 *
570 * It was way too smart of the spec writers not to think that it would
571 * be impossible for a generic driver to skip over vendor specific
572 * events/notifications if there are no LENGTH fields in the HEADER of
573 * each message...the transaction size cannot be counted on as the
574 * spec does not forbid to pack more than one event in a single
575 * transaction.
576 *
577 * Thus, we guess sizes with tables (or for events, when you know the
578 * size ahead of time you can use uwb_rc_neh_extra_size*()). We
579 * register tables with the known events and their sizes, and then we
580 * traverse those tables. For those with variable length, we provide a
581 * way to lookup the size inside the event/notification's
582 * payload. This allows device-specific event size tables to be
583 * registered.
584 *
585 * @size: Size of the payload
586 *
587 * @offset: if != 0, at offset @offset-1 starts a field with a length
588 * that has to be added to @size. The format of the field is
589 * given by @type.
590 *
591 * @type: Type and length of the offset field. Most common is LE 16
592 * bits (that's why that is zero); others are there mostly to
593 * cover for bugs and weirdos.
594 */
595struct uwb_est_entry {
596 size_t size;
597 unsigned offset;
598 enum { UWB_EST_16 = 0, UWB_EST_8 = 1 } type;
599};
600
601int uwb_est_register(u8 type, u8 code_high, u16 vendor, u16 product,
602 const struct uwb_est_entry *, size_t entries);
603int uwb_est_unregister(u8 type, u8 code_high, u16 vendor, u16 product,
604 const struct uwb_est_entry *, size_t entries);
605ssize_t uwb_est_find_size(struct uwb_rc *rc, const struct uwb_rceb *rceb,
606 size_t len);
607
608/* -- Misc */
609
610enum {
611 EDC_MAX_ERRORS = 10,
612 EDC_ERROR_TIMEFRAME = HZ,
613};
614
615/* error density counter */
616struct edc {
617 unsigned long timestart;
618 u16 errorcount;
619};
620
621static inline
622void edc_init(struct edc *edc)
623{
624 edc->timestart = jiffies;
625}
626
627/* Called when an error occured.
628 * This is way to determine if the number of acceptable errors per time
629 * period has been exceeded. It is not accurate as there are cases in which
630 * this scheme will not work, for example if there are periodic occurences
631 * of errors that straddle updates to the start time. This scheme is
632 * sufficient for our usage.
633 *
634 * @returns 1 if maximum acceptable errors per timeframe has been exceeded.
635 */
636static inline int edc_inc(struct edc *err_hist, u16 max_err, u16 timeframe)
637{
638 unsigned long now;
639
640 now = jiffies;
641 if (now - err_hist->timestart > timeframe) {
642 err_hist->errorcount = 1;
643 err_hist->timestart = now;
644 } else if (++err_hist->errorcount > max_err) {
645 err_hist->errorcount = 0;
646 err_hist->timestart = now;
647 return 1;
648 }
649 return 0;
650}
651
652
653/* Information Element handling */
654
655/* For representing the state of writing to a buffer when iterating */
656struct uwb_buf_ctx {
657 char *buf;
658 size_t bytes, size;
659};
660
661typedef int (*uwb_ie_f)(struct uwb_dev *, const struct uwb_ie_hdr *,
662 size_t, void *);
663struct uwb_ie_hdr *uwb_ie_next(void **ptr, size_t *len);
664ssize_t uwb_ie_for_each(struct uwb_dev *uwb_dev, uwb_ie_f fn, void *data,
665 const void *buf, size_t size);
666int uwb_ie_dump_hex(struct uwb_dev *, const struct uwb_ie_hdr *,
667 size_t, void *);
668int uwb_rc_set_ie(struct uwb_rc *, struct uwb_rc_cmd_set_ie *);
669struct uwb_ie_hdr *uwb_ie_next(void **ptr, size_t *len);
670
671
672/*
673 * Transmission statistics
674 *
675 * UWB uses LQI and RSSI (one byte values) for reporting radio signal
676 * strength and line quality indication. We do quick and dirty
677 * averages of those. They are signed values, btw.
678 *
679 * For 8 bit quantities, we keep the min, the max, an accumulator
680 * (@sigma) and a # of samples. When @samples gets to 255, we compute
681 * the average (@sigma / @samples), place it in @sigma and reset
682 * @samples to 1 (so we use it as the first sample).
683 *
684 * Now, statistically speaking, probably I am kicking the kidneys of
685 * some books I have in my shelves collecting dust, but I just want to
686 * get an approx, not the Nobel.
687 *
688 * LOCKING: there is no locking per se, but we try to keep a lockless
689 * schema. Only _add_samples() modifies the values--as long as you
690 * have other locking on top that makes sure that no two calls of
691 * _add_sample() happen at the same time, then we are fine. Now, for
692 * resetting the values we just set @samples to 0 and that makes the
693 * next _add_sample() to start with defaults. Reading the values in
694 * _show() currently can race, so you need to make sure the calls are
695 * under the same lock that protects calls to _add_sample(). FIXME:
696 * currently unlocked (It is not ultraprecise but does the trick. Bite
697 * me).
698 */
699struct stats {
700 s8 min, max;
701 s16 sigma;
702 atomic_t samples;
703};
704
705static inline
706void stats_init(struct stats *stats)
707{
708 atomic_set(&stats->samples, 0);
709 wmb();
710}
711
712static inline
713void stats_add_sample(struct stats *stats, s8 sample)
714{
715 s8 min, max;
716 s16 sigma;
717 unsigned samples = atomic_read(&stats->samples);
718 if (samples == 0) { /* it was zero before, so we initialize */
719 min = 127;
720 max = -128;
721 sigma = 0;
722 } else {
723 min = stats->min;
724 max = stats->max;
725 sigma = stats->sigma;
726 }
727
728 if (sample < min) /* compute new values */
729 min = sample;
730 else if (sample > max)
731 max = sample;
732 sigma += sample;
733
734 stats->min = min; /* commit */
735 stats->max = max;
736 stats->sigma = sigma;
737 if (atomic_add_return(1, &stats->samples) > 255) {
738 /* wrapped around! reset */
739 stats->sigma = sigma / 256;
740 atomic_set(&stats->samples, 1);
741 }
742}
743
744static inline ssize_t stats_show(struct stats *stats, char *buf)
745{
746 int min, max, avg;
747 int samples = atomic_read(&stats->samples);
748 if (samples == 0)
749 min = max = avg = 0;
750 else {
751 min = stats->min;
752 max = stats->max;
753 avg = stats->sigma / samples;
754 }
755 return scnprintf(buf, PAGE_SIZE, "%d %d %d\n", min, max, avg);
756}
757
758static inline ssize_t stats_store(struct stats *stats, const char *buf,
759 size_t size)
760{
761 stats_init(stats);
762 return size;
763}
764
765#endif /* #ifndef __LINUX__UWB_H__ */
diff --git a/include/linux/uwb/debug-cmd.h b/include/linux/uwb/debug-cmd.h
new file mode 100644
index 000000000000..1141f41bab5c
--- /dev/null
+++ b/include/linux/uwb/debug-cmd.h
@@ -0,0 +1,57 @@
1/*
2 * Ultra Wide Band
3 * Debug interface commands
4 *
5 * Copyright (C) 2008 Cambridge Silicon Radio Ltd.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License version
9 * 2 as published by the Free Software Foundation.
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, see <http://www.gnu.org/licenses/>.
18 */
19#ifndef __LINUX__UWB__DEBUG_CMD_H__
20#define __LINUX__UWB__DEBUG_CMD_H__
21
22#include <linux/types.h>
23
24/*
25 * Debug interface commands
26 *
27 * UWB_DBG_CMD_RSV_ESTABLISH: Establish a new unicast reservation.
28 *
29 * UWB_DBG_CMD_RSV_TERMINATE: Terminate the Nth reservation.
30 */
31
32enum uwb_dbg_cmd_type {
33 UWB_DBG_CMD_RSV_ESTABLISH = 1,
34 UWB_DBG_CMD_RSV_TERMINATE = 2,
35};
36
37struct uwb_dbg_cmd_rsv_establish {
38 __u8 target[6];
39 __u8 type;
40 __u16 max_mas;
41 __u16 min_mas;
42 __u8 sparsity;
43};
44
45struct uwb_dbg_cmd_rsv_terminate {
46 int index;
47};
48
49struct uwb_dbg_cmd {
50 __u32 type;
51 union {
52 struct uwb_dbg_cmd_rsv_establish rsv_establish;
53 struct uwb_dbg_cmd_rsv_terminate rsv_terminate;
54 };
55};
56
57#endif /* #ifndef __LINUX__UWB__DEBUG_CMD_H__ */
diff --git a/include/linux/uwb/debug.h b/include/linux/uwb/debug.h
new file mode 100644
index 000000000000..a86a73fe303f
--- /dev/null
+++ b/include/linux/uwb/debug.h
@@ -0,0 +1,82 @@
1/*
2 * Ultra Wide Band
3 * Debug Support
4 *
5 * Copyright (C) 2005-2006 Intel Corporation
6 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License version
10 * 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 * 02110-1301, USA.
21 *
22 *
23 * FIXME: doc
24 * Invoke like:
25 *
26 * #define D_LOCAL 4
27 * #include <linux/uwb/debug.h>
28 *
29 * At the end of your include files.
30 */
31#include <linux/types.h>
32
33struct device;
34extern void dump_bytes(struct device *dev, const void *_buf, size_t rsize);
35
36/* Master debug switch; !0 enables, 0 disables */
37#define D_MASTER (!0)
38
39/* Local (per-file) debug switch; #define before #including */
40#ifndef D_LOCAL
41#define D_LOCAL 0
42#endif
43
44#undef __d_printf
45#undef d_fnstart
46#undef d_fnend
47#undef d_printf
48#undef d_dump
49
50#define __d_printf(l, _tag, _dev, f, a...) \
51do { \
52 struct device *__dev = (_dev); \
53 if (D_MASTER && D_LOCAL >= (l)) { \
54 char __head[64] = ""; \
55 if (_dev != NULL) { \
56 if ((unsigned long)__dev < 4096) \
57 printk(KERN_ERR "E: Corrupt dev %p\n", \
58 __dev); \
59 else \
60 snprintf(__head, sizeof(__head), \
61 "%s %s: ", \
62 dev_driver_string(__dev), \
63 __dev->bus_id); \
64 } \
65 printk(KERN_ERR "%s%s" _tag ": " f, __head, \
66 __func__, ## a); \
67 } \
68} while (0 && _dev)
69
70#define d_fnstart(l, _dev, f, a...) \
71 __d_printf(l, " FNSTART", _dev, f, ## a)
72#define d_fnend(l, _dev, f, a...) \
73 __d_printf(l, " FNEND", _dev, f, ## a)
74#define d_printf(l, _dev, f, a...) \
75 __d_printf(l, "", _dev, f, ## a)
76#define d_dump(l, _dev, ptr, size) \
77do { \
78 struct device *__dev = _dev; \
79 if (D_MASTER && D_LOCAL >= (l)) \
80 dump_bytes(__dev, ptr, size); \
81} while (0 && _dev)
82#define d_test(l) (D_MASTER && D_LOCAL >= (l))
diff --git a/include/linux/uwb/spec.h b/include/linux/uwb/spec.h
new file mode 100644
index 000000000000..198c15f8e251
--- /dev/null
+++ b/include/linux/uwb/spec.h
@@ -0,0 +1,727 @@
1/*
2 * Ultra Wide Band
3 * UWB Standard definitions
4 *
5 * Copyright (C) 2005-2006 Intel Corporation
6 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License version
10 * 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 * 02110-1301, USA.
21 *
22 *
23 * All these definitions are based on the ECMA-368 standard.
24 *
25 * Note all definitions are Little Endian in the wire, and we will
26 * convert them to host order before operating on the bitfields (that
27 * yes, we use extensively).
28 */
29
30#ifndef __LINUX__UWB_SPEC_H__
31#define __LINUX__UWB_SPEC_H__
32
33#include <linux/types.h>
34#include <linux/bitmap.h>
35
36#define i1480_FW 0x00000303
37/* #define i1480_FW 0x00000302 */
38
39/**
40 * Number of Medium Access Slots in a superframe.
41 *
42 * UWB divides time in SuperFrames, each one divided in 256 pieces, or
43 * Medium Access Slots. See MBOA MAC[5.4.5] for details. The MAS is the
44 * basic bandwidth allocation unit in UWB.
45 */
46enum { UWB_NUM_MAS = 256 };
47
48/**
49 * Number of Zones in superframe.
50 *
51 * UWB divides the superframe into zones with numbering starting from BPST.
52 * See MBOA MAC[16.8.6]
53 */
54enum { UWB_NUM_ZONES = 16 };
55
56/*
57 * Number of MAS in a zone.
58 */
59#define UWB_MAS_PER_ZONE (UWB_NUM_MAS / UWB_NUM_ZONES)
60
61/*
62 * Number of streams per DRP reservation between a pair of devices.
63 *
64 * [ECMA-368] section 16.8.6.
65 */
66enum { UWB_NUM_STREAMS = 8 };
67
68/*
69 * mMasLength
70 *
71 * The length of a MAS in microseconds.
72 *
73 * [ECMA-368] section 17.16.
74 */
75enum { UWB_MAS_LENGTH_US = 256 };
76
77/*
78 * mBeaconSlotLength
79 *
80 * The length of the beacon slot in microseconds.
81 *
82 * [ECMA-368] section 17.16
83 */
84enum { UWB_BEACON_SLOT_LENGTH_US = 85 };
85
86/*
87 * mMaxLostBeacons
88 *
89 * The number beacons missing in consecutive superframes before a
90 * device can be considered as unreachable.
91 *
92 * [ECMA-368] section 17.16
93 */
94enum { UWB_MAX_LOST_BEACONS = 3 };
95
96/*
97 * Length of a superframe in microseconds.
98 */
99#define UWB_SUPERFRAME_LENGTH_US (UWB_MAS_LENGTH_US * UWB_NUM_MAS)
100
101/**
102 * UWB MAC address
103 *
104 * It is *imperative* that this struct is exactly 6 packed bytes (as
105 * it is also used to define headers sent down and up the wire/radio).
106 */
107struct uwb_mac_addr {
108 u8 data[6];
109} __attribute__((packed));
110
111
112/**
113 * UWB device address
114 *
115 * It is *imperative* that this struct is exactly 6 packed bytes (as
116 * it is also used to define headers sent down and up the wire/radio).
117 */
118struct uwb_dev_addr {
119 u8 data[2];
120} __attribute__((packed));
121
122
123/**
124 * Types of UWB addresses
125 *
126 * Order matters (by size).
127 */
128enum uwb_addr_type {
129 UWB_ADDR_DEV = 0,
130 UWB_ADDR_MAC = 1,
131};
132
133
134/** Size of a char buffer for printing a MAC/device address */
135enum { UWB_ADDR_STRSIZE = 32 };
136
137
138/** UWB WiMedia protocol IDs. */
139enum uwb_prid {
140 UWB_PRID_WLP_RESERVED = 0x0000,
141 UWB_PRID_WLP = 0x0001,
142 UWB_PRID_WUSB_BOT = 0x0010,
143 UWB_PRID_WUSB = 0x0010,
144 UWB_PRID_WUSB_TOP = 0x001F,
145};
146
147
148/** PHY Rate (MBOA MAC[7.8.12, Table 61]) */
149enum uwb_phy_rate {
150 UWB_PHY_RATE_53 = 0,
151 UWB_PHY_RATE_80,
152 UWB_PHY_RATE_106,
153 UWB_PHY_RATE_160,
154 UWB_PHY_RATE_200,
155 UWB_PHY_RATE_320,
156 UWB_PHY_RATE_400,
157 UWB_PHY_RATE_480,
158 UWB_PHY_RATE_INVALID
159};
160
161
162/**
163 * Different ways to scan (MBOA MAC[6.2.2, Table 8], WUSB[Table 8-78])
164 */
165enum uwb_scan_type {
166 UWB_SCAN_ONLY = 0,
167 UWB_SCAN_OUTSIDE_BP,
168 UWB_SCAN_WHILE_INACTIVE,
169 UWB_SCAN_DISABLED,
170 UWB_SCAN_ONLY_STARTTIME,
171 UWB_SCAN_TOP
172};
173
174
175/** ACK Policy types (MBOA MAC[7.2.1.3]) */
176enum uwb_ack_pol {
177 UWB_ACK_NO = 0,
178 UWB_ACK_INM = 1,
179 UWB_ACK_B = 2,
180 UWB_ACK_B_REQ = 3,
181};
182
183
184/** DRP reservation types ([ECMA-368 table 106) */
185enum uwb_drp_type {
186 UWB_DRP_TYPE_ALIEN_BP = 0,
187 UWB_DRP_TYPE_HARD,
188 UWB_DRP_TYPE_SOFT,
189 UWB_DRP_TYPE_PRIVATE,
190 UWB_DRP_TYPE_PCA,
191};
192
193
194/** DRP Reason Codes ([ECMA-368] table 107) */
195enum uwb_drp_reason {
196 UWB_DRP_REASON_ACCEPTED = 0,
197 UWB_DRP_REASON_CONFLICT,
198 UWB_DRP_REASON_PENDING,
199 UWB_DRP_REASON_DENIED,
200 UWB_DRP_REASON_MODIFIED,
201};
202
203/**
204 * DRP Notification Reason Codes (WHCI 0.95 [3.1.4.9])
205 */
206enum uwb_drp_notif_reason {
207 UWB_DRP_NOTIF_DRP_IE_RCVD = 0,
208 UWB_DRP_NOTIF_CONFLICT,
209 UWB_DRP_NOTIF_TERMINATE,
210};
211
212
213/** Allocation of MAS slots in a DRP request MBOA MAC[7.8.7] */
214struct uwb_drp_alloc {
215 __le16 zone_bm;
216 __le16 mas_bm;
217} __attribute__((packed));
218
219
220/** General MAC Header format (ECMA-368[16.2]) */
221struct uwb_mac_frame_hdr {
222 __le16 Frame_Control;
223 struct uwb_dev_addr DestAddr;
224 struct uwb_dev_addr SrcAddr;
225 __le16 Sequence_Control;
226 __le16 Access_Information;
227} __attribute__((packed));
228
229
230/**
231 * uwb_beacon_frame - a beacon frame including MAC headers
232 *
233 * [ECMA] section 16.3.
234 */
235struct uwb_beacon_frame {
236 struct uwb_mac_frame_hdr hdr;
237 struct uwb_mac_addr Device_Identifier; /* may be a NULL EUI-48 */
238 u8 Beacon_Slot_Number;
239 u8 Device_Control;
240 u8 IEData[];
241} __attribute__((packed));
242
243
244/** Information Element codes (MBOA MAC[T54]) */
245enum uwb_ie {
246 UWB_PCA_AVAILABILITY = 2,
247 UWB_IE_DRP_AVAILABILITY = 8,
248 UWB_IE_DRP = 9,
249 UWB_BP_SWITCH_IE = 11,
250 UWB_MAC_CAPABILITIES_IE = 12,
251 UWB_PHY_CAPABILITIES_IE = 13,
252 UWB_APP_SPEC_PROBE_IE = 15,
253 UWB_IDENTIFICATION_IE = 19,
254 UWB_MASTER_KEY_ID_IE = 20,
255 UWB_IE_WLP = 250, /* WiMedia Logical Link Control Protocol WLP 0.99 */
256 UWB_APP_SPEC_IE = 255,
257};
258
259
260/**
261 * Header common to all Information Elements (IEs)
262 */
263struct uwb_ie_hdr {
264 u8 element_id; /* enum uwb_ie */
265 u8 length;
266} __attribute__((packed));
267
268
269/** Dynamic Reservation Protocol IE (MBOA MAC[7.8.6]) */
270struct uwb_ie_drp {
271 struct uwb_ie_hdr hdr;
272 __le16 drp_control;
273 struct uwb_dev_addr dev_addr;
274 struct uwb_drp_alloc allocs[];
275} __attribute__((packed));
276
277static inline int uwb_ie_drp_type(struct uwb_ie_drp *ie)
278{
279 return (le16_to_cpu(ie->drp_control) >> 0) & 0x7;
280}
281
282static inline int uwb_ie_drp_stream_index(struct uwb_ie_drp *ie)
283{
284 return (le16_to_cpu(ie->drp_control) >> 3) & 0x7;
285}
286
287static inline int uwb_ie_drp_reason_code(struct uwb_ie_drp *ie)
288{
289 return (le16_to_cpu(ie->drp_control) >> 6) & 0x7;
290}
291
292static inline int uwb_ie_drp_status(struct uwb_ie_drp *ie)
293{
294 return (le16_to_cpu(ie->drp_control) >> 9) & 0x1;
295}
296
297static inline int uwb_ie_drp_owner(struct uwb_ie_drp *ie)
298{
299 return (le16_to_cpu(ie->drp_control) >> 10) & 0x1;
300}
301
302static inline int uwb_ie_drp_tiebreaker(struct uwb_ie_drp *ie)
303{
304 return (le16_to_cpu(ie->drp_control) >> 11) & 0x1;
305}
306
307static inline int uwb_ie_drp_unsafe(struct uwb_ie_drp *ie)
308{
309 return (le16_to_cpu(ie->drp_control) >> 12) & 0x1;
310}
311
312static inline void uwb_ie_drp_set_type(struct uwb_ie_drp *ie, enum uwb_drp_type type)
313{
314 u16 drp_control = le16_to_cpu(ie->drp_control);
315 drp_control = (drp_control & ~(0x7 << 0)) | (type << 0);
316 ie->drp_control = cpu_to_le16(drp_control);
317}
318
319static inline void uwb_ie_drp_set_stream_index(struct uwb_ie_drp *ie, int stream_index)
320{
321 u16 drp_control = le16_to_cpu(ie->drp_control);
322 drp_control = (drp_control & ~(0x7 << 3)) | (stream_index << 3);
323 ie->drp_control = cpu_to_le16(drp_control);
324}
325
326static inline void uwb_ie_drp_set_reason_code(struct uwb_ie_drp *ie,
327 enum uwb_drp_reason reason_code)
328{
329 u16 drp_control = le16_to_cpu(ie->drp_control);
330 drp_control = (ie->drp_control & ~(0x7 << 6)) | (reason_code << 6);
331 ie->drp_control = cpu_to_le16(drp_control);
332}
333
334static inline void uwb_ie_drp_set_status(struct uwb_ie_drp *ie, int status)
335{
336 u16 drp_control = le16_to_cpu(ie->drp_control);
337 drp_control = (drp_control & ~(0x1 << 9)) | (status << 9);
338 ie->drp_control = cpu_to_le16(drp_control);
339}
340
341static inline void uwb_ie_drp_set_owner(struct uwb_ie_drp *ie, int owner)
342{
343 u16 drp_control = le16_to_cpu(ie->drp_control);
344 drp_control = (drp_control & ~(0x1 << 10)) | (owner << 10);
345 ie->drp_control = cpu_to_le16(drp_control);
346}
347
348static inline void uwb_ie_drp_set_tiebreaker(struct uwb_ie_drp *ie, int tiebreaker)
349{
350 u16 drp_control = le16_to_cpu(ie->drp_control);
351 drp_control = (drp_control & ~(0x1 << 11)) | (tiebreaker << 11);
352 ie->drp_control = cpu_to_le16(drp_control);
353}
354
355static inline void uwb_ie_drp_set_unsafe(struct uwb_ie_drp *ie, int unsafe)
356{
357 u16 drp_control = le16_to_cpu(ie->drp_control);
358 drp_control = (drp_control & ~(0x1 << 12)) | (unsafe << 12);
359 ie->drp_control = cpu_to_le16(drp_control);
360}
361
362/** Dynamic Reservation Protocol IE (MBOA MAC[7.8.7]) */
363struct uwb_ie_drp_avail {
364 struct uwb_ie_hdr hdr;
365 DECLARE_BITMAP(bmp, UWB_NUM_MAS);
366} __attribute__((packed));
367
368/**
369 * The Vendor ID is set to an OUI that indicates the vendor of the device.
370 * ECMA-368 [16.8.10]
371 */
372struct uwb_vendor_id {
373 u8 data[3];
374} __attribute__((packed));
375
376/**
377 * The device type ID
378 * FIXME: clarify what this means
379 * ECMA-368 [16.8.10]
380 */
381struct uwb_device_type_id {
382 u8 data[3];
383} __attribute__((packed));
384
385
386/**
387 * UWB device information types
388 * ECMA-368 [16.8.10]
389 */
390enum uwb_dev_info_type {
391 UWB_DEV_INFO_VENDOR_ID = 0,
392 UWB_DEV_INFO_VENDOR_TYPE,
393 UWB_DEV_INFO_NAME,
394};
395
396/**
397 * UWB device information found in Identification IE
398 * ECMA-368 [16.8.10]
399 */
400struct uwb_dev_info {
401 u8 type; /* enum uwb_dev_info_type */
402 u8 length;
403 u8 data[];
404} __attribute__((packed));
405
406/**
407 * UWB Identification IE
408 * ECMA-368 [16.8.10]
409 */
410struct uwb_identification_ie {
411 struct uwb_ie_hdr hdr;
412 struct uwb_dev_info info[];
413} __attribute__((packed));
414
415/*
416 * UWB Radio Controller
417 *
418 * These definitions are common to the Radio Control layers as
419 * exported by the WUSB1.0 HWA and WHCI interfaces.
420 */
421
422/** Radio Control Command Block (WUSB1.0[Table 8-65] and WHCI 0.95) */
423struct uwb_rccb {
424 u8 bCommandType; /* enum hwa_cet */
425 __le16 wCommand; /* Command code */
426 u8 bCommandContext; /* Context ID */
427} __attribute__((packed));
428
429
430/** Radio Control Event Block (WUSB[table 8-66], WHCI 0.95) */
431struct uwb_rceb {
432 u8 bEventType; /* enum hwa_cet */
433 __le16 wEvent; /* Event code */
434 u8 bEventContext; /* Context ID */
435} __attribute__((packed));
436
437
438enum {
439 UWB_RC_CET_GENERAL = 0, /* General Command/Event type */
440 UWB_RC_CET_EX_TYPE_1 = 1, /* Extended Type 1 Command/Event type */
441};
442
443/* Commands to the radio controller */
444enum uwb_rc_cmd {
445 UWB_RC_CMD_CHANNEL_CHANGE = 16,
446 UWB_RC_CMD_DEV_ADDR_MGMT = 17, /* Device Address Management */
447 UWB_RC_CMD_GET_IE = 18, /* GET Information Elements */
448 UWB_RC_CMD_RESET = 19,
449 UWB_RC_CMD_SCAN = 20, /* Scan management */
450 UWB_RC_CMD_SET_BEACON_FILTER = 21,
451 UWB_RC_CMD_SET_DRP_IE = 22, /* Dynamic Reservation Protocol IEs */
452 UWB_RC_CMD_SET_IE = 23, /* Information Element management */
453 UWB_RC_CMD_SET_NOTIFICATION_FILTER = 24,
454 UWB_RC_CMD_SET_TX_POWER = 25,
455 UWB_RC_CMD_SLEEP = 26,
456 UWB_RC_CMD_START_BEACON = 27,
457 UWB_RC_CMD_STOP_BEACON = 28,
458 UWB_RC_CMD_BP_MERGE = 29,
459 UWB_RC_CMD_SEND_COMMAND_FRAME = 30,
460 UWB_RC_CMD_SET_ASIE_NOTIF = 31,
461};
462
463/* Notifications from the radio controller */
464enum uwb_rc_evt {
465 UWB_RC_EVT_IE_RCV = 0,
466 UWB_RC_EVT_BEACON = 1,
467 UWB_RC_EVT_BEACON_SIZE = 2,
468 UWB_RC_EVT_BPOIE_CHANGE = 3,
469 UWB_RC_EVT_BP_SLOT_CHANGE = 4,
470 UWB_RC_EVT_BP_SWITCH_IE_RCV = 5,
471 UWB_RC_EVT_DEV_ADDR_CONFLICT = 6,
472 UWB_RC_EVT_DRP_AVAIL = 7,
473 UWB_RC_EVT_DRP = 8,
474 UWB_RC_EVT_BP_SWITCH_STATUS = 9,
475 UWB_RC_EVT_CMD_FRAME_RCV = 10,
476 UWB_RC_EVT_CHANNEL_CHANGE_IE_RCV = 11,
477 /* Events (command responses) use the same code as the command */
478 UWB_RC_EVT_UNKNOWN_CMD_RCV = 65535,
479};
480
481enum uwb_rc_extended_type_1_cmd {
482 UWB_RC_SET_DAA_ENERGY_MASK = 32,
483 UWB_RC_SET_NOTIFICATION_FILTER_EX = 33,
484};
485
486enum uwb_rc_extended_type_1_evt {
487 UWB_RC_DAA_ENERGY_DETECTED = 0,
488};
489
490/* Radio Control Result Code. [WHCI] table 3-3. */
491enum {
492 UWB_RC_RES_SUCCESS = 0,
493 UWB_RC_RES_FAIL,
494 UWB_RC_RES_FAIL_HARDWARE,
495 UWB_RC_RES_FAIL_NO_SLOTS,
496 UWB_RC_RES_FAIL_BEACON_TOO_LARGE,
497 UWB_RC_RES_FAIL_INVALID_PARAMETER,
498 UWB_RC_RES_FAIL_UNSUPPORTED_PWR_LEVEL,
499 UWB_RC_RES_FAIL_INVALID_IE_DATA,
500 UWB_RC_RES_FAIL_BEACON_SIZE_EXCEEDED,
501 UWB_RC_RES_FAIL_CANCELLED,
502 UWB_RC_RES_FAIL_INVALID_STATE,
503 UWB_RC_RES_FAIL_INVALID_SIZE,
504 UWB_RC_RES_FAIL_ACK_NOT_RECEIVED,
505 UWB_RC_RES_FAIL_NO_MORE_ASIE_NOTIF,
506 UWB_RC_RES_FAIL_TIME_OUT = 255,
507};
508
509/* Confirm event. [WHCI] section 3.1.3.1 etc. */
510struct uwb_rc_evt_confirm {
511 struct uwb_rceb rceb;
512 u8 bResultCode;
513} __attribute__((packed));
514
515/* Device Address Management event. [WHCI] section 3.1.3.2. */
516struct uwb_rc_evt_dev_addr_mgmt {
517 struct uwb_rceb rceb;
518 u8 baAddr[6];
519 u8 bResultCode;
520} __attribute__((packed));
521
522
523/* Get IE Event. [WHCI] section 3.1.3.3. */
524struct uwb_rc_evt_get_ie {
525 struct uwb_rceb rceb;
526 __le16 wIELength;
527 u8 IEData[];
528} __attribute__((packed));
529
530/* Set DRP IE Event. [WHCI] section 3.1.3.7. */
531struct uwb_rc_evt_set_drp_ie {
532 struct uwb_rceb rceb;
533 __le16 wRemainingSpace;
534 u8 bResultCode;
535} __attribute__((packed));
536
537/* Set IE Event. [WHCI] section 3.1.3.8. */
538struct uwb_rc_evt_set_ie {
539 struct uwb_rceb rceb;
540 __le16 RemainingSpace;
541 u8 bResultCode;
542} __attribute__((packed));
543
544/* Scan command. [WHCI] 3.1.3.5. */
545struct uwb_rc_cmd_scan {
546 struct uwb_rccb rccb;
547 u8 bChannelNumber;
548 u8 bScanState;
549 __le16 wStartTime;
550} __attribute__((packed));
551
552/* Set DRP IE command. [WHCI] section 3.1.3.7. */
553struct uwb_rc_cmd_set_drp_ie {
554 struct uwb_rccb rccb;
555 __le16 wIELength;
556 struct uwb_ie_drp IEData[];
557} __attribute__((packed));
558
559/* Set IE command. [WHCI] section 3.1.3.8. */
560struct uwb_rc_cmd_set_ie {
561 struct uwb_rccb rccb;
562 __le16 wIELength;
563 u8 IEData[];
564} __attribute__((packed));
565
566/* Set DAA Energy Mask event. [WHCI 0.96] section 3.1.3.17. */
567struct uwb_rc_evt_set_daa_energy_mask {
568 struct uwb_rceb rceb;
569 __le16 wLength;
570 u8 result;
571} __attribute__((packed));
572
573/* Set Notification Filter Extended event. [WHCI 0.96] section 3.1.3.18. */
574struct uwb_rc_evt_set_notification_filter_ex {
575 struct uwb_rceb rceb;
576 __le16 wLength;
577 u8 result;
578} __attribute__((packed));
579
580/* IE Received notification. [WHCI] section 3.1.4.1. */
581struct uwb_rc_evt_ie_rcv {
582 struct uwb_rceb rceb;
583 struct uwb_dev_addr SrcAddr;
584 __le16 wIELength;
585 u8 IEData[];
586} __attribute__((packed));
587
588/* Type of the received beacon. [WHCI] section 3.1.4.2. */
589enum uwb_rc_beacon_type {
590 UWB_RC_BEACON_TYPE_SCAN = 0,
591 UWB_RC_BEACON_TYPE_NEIGHBOR,
592 UWB_RC_BEACON_TYPE_OL_ALIEN,
593 UWB_RC_BEACON_TYPE_NOL_ALIEN,
594};
595
596/* Beacon received notification. [WHCI] 3.1.4.2. */
597struct uwb_rc_evt_beacon {
598 struct uwb_rceb rceb;
599 u8 bChannelNumber;
600 u8 bBeaconType;
601 __le16 wBPSTOffset;
602 u8 bLQI;
603 u8 bRSSI;
604 __le16 wBeaconInfoLength;
605 u8 BeaconInfo[];
606} __attribute__((packed));
607
608
609/* Beacon Size Change notification. [WHCI] section 3.1.4.3 */
610struct uwb_rc_evt_beacon_size {
611 struct uwb_rceb rceb;
612 __le16 wNewBeaconSize;
613} __attribute__((packed));
614
615
616/* BPOIE Change notification. [WHCI] section 3.1.4.4. */
617struct uwb_rc_evt_bpoie_change {
618 struct uwb_rceb rceb;
619 __le16 wBPOIELength;
620 u8 BPOIE[];
621} __attribute__((packed));
622
623
624/* Beacon Slot Change notification. [WHCI] section 3.1.4.5. */
625struct uwb_rc_evt_bp_slot_change {
626 struct uwb_rceb rceb;
627 u8 slot_info;
628} __attribute__((packed));
629
630static inline int uwb_rc_evt_bp_slot_change_slot_num(
631 const struct uwb_rc_evt_bp_slot_change *evt)
632{
633 return evt->slot_info & 0x7f;
634}
635
636static inline int uwb_rc_evt_bp_slot_change_no_slot(
637 const struct uwb_rc_evt_bp_slot_change *evt)
638{
639 return (evt->slot_info & 0x80) >> 7;
640}
641
642/* BP Switch IE Received notification. [WHCI] section 3.1.4.6. */
643struct uwb_rc_evt_bp_switch_ie_rcv {
644 struct uwb_rceb rceb;
645 struct uwb_dev_addr wSrcAddr;
646 __le16 wIELength;
647 u8 IEData[];
648} __attribute__((packed));
649
650/* DevAddr Conflict notification. [WHCI] section 3.1.4.7. */
651struct uwb_rc_evt_dev_addr_conflict {
652 struct uwb_rceb rceb;
653} __attribute__((packed));
654
655/* DRP notification. [WHCI] section 3.1.4.9. */
656struct uwb_rc_evt_drp {
657 struct uwb_rceb rceb;
658 struct uwb_dev_addr src_addr;
659 u8 reason;
660 u8 beacon_slot_number;
661 __le16 ie_length;
662 u8 ie_data[];
663} __attribute__((packed));
664
665static inline enum uwb_drp_notif_reason uwb_rc_evt_drp_reason(struct uwb_rc_evt_drp *evt)
666{
667 return evt->reason & 0x0f;
668}
669
670
671/* DRP Availability Change notification. [WHCI] section 3.1.4.8. */
672struct uwb_rc_evt_drp_avail {
673 struct uwb_rceb rceb;
674 DECLARE_BITMAP(bmp, UWB_NUM_MAS);
675} __attribute__((packed));
676
677/* BP switch status notification. [WHCI] section 3.1.4.10. */
678struct uwb_rc_evt_bp_switch_status {
679 struct uwb_rceb rceb;
680 u8 status;
681 u8 slot_offset;
682 __le16 bpst_offset;
683 u8 move_countdown;
684} __attribute__((packed));
685
686/* Command Frame Received notification. [WHCI] section 3.1.4.11. */
687struct uwb_rc_evt_cmd_frame_rcv {
688 struct uwb_rceb rceb;
689 __le16 receive_time;
690 struct uwb_dev_addr wSrcAddr;
691 struct uwb_dev_addr wDstAddr;
692 __le16 control;
693 __le16 reserved;
694 __le16 dataLength;
695 u8 data[];
696} __attribute__((packed));
697
698/* Channel Change IE Received notification. [WHCI] section 3.1.4.12. */
699struct uwb_rc_evt_channel_change_ie_rcv {
700 struct uwb_rceb rceb;
701 struct uwb_dev_addr wSrcAddr;
702 __le16 wIELength;
703 u8 IEData[];
704} __attribute__((packed));
705
706/* DAA Energy Detected notification. [WHCI 0.96] section 3.1.4.14. */
707struct uwb_rc_evt_daa_energy_detected {
708 struct uwb_rceb rceb;
709 __le16 wLength;
710 u8 bandID;
711 u8 reserved;
712 u8 toneBmp[16];
713} __attribute__((packed));
714
715
716/**
717 * Radio Control Interface Class Descriptor
718 *
719 * WUSB 1.0 [8.6.1.2]
720 */
721struct uwb_rc_control_intf_class_desc {
722 u8 bLength;
723 u8 bDescriptorType;
724 __le16 bcdRCIVersion;
725} __attribute__((packed));
726
727#endif /* #ifndef __LINUX__UWB_SPEC_H__ */
diff --git a/include/linux/uwb/umc.h b/include/linux/uwb/umc.h
new file mode 100644
index 000000000000..36a39e34f8d7
--- /dev/null
+++ b/include/linux/uwb/umc.h
@@ -0,0 +1,194 @@
1/*
2 * UWB Multi-interface Controller support.
3 *
4 * Copyright (C) 2007 Cambridge Silicon Radio Ltd.
5 *
6 * This file is released under the GPLv2
7 *
8 * UMC (UWB Multi-interface Controller) capabilities (e.g., radio
9 * controller, host controller) are presented as devices on the "umc"
10 * bus.
11 *
12 * The radio controller is not strictly a UMC capability but it's
13 * useful to present it as such.
14 *
15 * References:
16 *
17 * [WHCI] Wireless Host Controller Interface Specification for
18 * Certified Wireless Universal Serial Bus, revision 0.95.
19 *
20 * How this works is kind of convoluted but simple. The whci.ko driver
21 * loads when WHCI devices are detected. These WHCI devices expose
22 * many devices in the same PCI function (they couldn't have reused
23 * functions, no), so for each PCI function that exposes these many
24 * devices, whci ceates a umc_dev [whci_probe() -> whci_add_cap()]
25 * with umc_device_create() and adds it to the bus with
26 * umc_device_register().
27 *
28 * umc_device_register() calls device_register() which will push the
29 * bus management code to load your UMC driver's somehting_probe()
30 * that you have registered for that capability code.
31 *
32 * Now when the WHCI device is removed, whci_remove() will go over
33 * each umc_dev assigned to each of the PCI function's capabilities
34 * and through whci_del_cap() call umc_device_unregister() each
35 * created umc_dev. Of course, if you are bound to the device, your
36 * driver's something_remove() will be called.
37 */
38
39#ifndef _LINUX_UWB_UMC_H_
40#define _LINUX_UWB_UMC_H_
41
42#include <linux/device.h>
43#include <linux/pci.h>
44
45/*
46 * UMC capability IDs.
47 *
48 * 0x00 is reserved so use it for the radio controller device.
49 *
50 * [WHCI] table 2-8
51 */
52#define UMC_CAP_ID_WHCI_RC 0x00 /* radio controller */
53#define UMC_CAP_ID_WHCI_WUSB_HC 0x01 /* WUSB host controller */
54
55/**
56 * struct umc_dev - UMC capability device
57 *
58 * @version: version of the specification this capability conforms to.
59 * @cap_id: capability ID.
60 * @bar: PCI Bar (64 bit) where the resource lies
61 * @resource: register space resource.
62 * @irq: interrupt line.
63 */
64struct umc_dev {
65 u16 version;
66 u8 cap_id;
67 u8 bar;
68 struct resource resource;
69 unsigned irq;
70 struct device dev;
71};
72
73#define to_umc_dev(d) container_of(d, struct umc_dev, dev)
74
75/**
76 * struct umc_driver - UMC capability driver
77 * @cap_id: supported capability ID.
78 * @match: driver specific capability matching function.
79 * @match_data: driver specific data for match() (e.g., a
80 * table of pci_device_id's if umc_match_pci_id() is used).
81 */
82struct umc_driver {
83 char *name;
84 u8 cap_id;
85 int (*match)(struct umc_driver *, struct umc_dev *);
86 const void *match_data;
87
88 int (*probe)(struct umc_dev *);
89 void (*remove)(struct umc_dev *);
90 int (*suspend)(struct umc_dev *, pm_message_t state);
91 int (*resume)(struct umc_dev *);
92
93 struct device_driver driver;
94};
95
96#define to_umc_driver(d) container_of(d, struct umc_driver, driver)
97
98extern struct bus_type umc_bus_type;
99
100struct umc_dev *umc_device_create(struct device *parent, int n);
101int __must_check umc_device_register(struct umc_dev *umc);
102void umc_device_unregister(struct umc_dev *umc);
103
104int __must_check __umc_driver_register(struct umc_driver *umc_drv,
105 struct module *mod,
106 const char *mod_name);
107
108/**
109 * umc_driver_register - register a UMC capabiltity driver.
110 * @umc_drv: pointer to the driver.
111 */
112static inline int __must_check umc_driver_register(struct umc_driver *umc_drv)
113{
114 return __umc_driver_register(umc_drv, THIS_MODULE, KBUILD_MODNAME);
115}
116void umc_driver_unregister(struct umc_driver *umc_drv);
117
118/*
119 * Utility function you can use to match (umc_driver->match) against a
120 * null-terminated array of 'struct pci_device_id' in
121 * umc_driver->match_data.
122 */
123int umc_match_pci_id(struct umc_driver *umc_drv, struct umc_dev *umc);
124
125/**
126 * umc_parent_pci_dev - return the UMC's parent PCI device or NULL if none
127 * @umc_dev: UMC device whose parent PCI device we are looking for
128 *
129 * DIRTY!!! DON'T RELY ON THIS
130 *
131 * FIXME: This is as dirty as it gets, but we need some way to check
132 * the correct type of umc_dev->parent (so that for example, we can
133 * cast to pci_dev). Casting to pci_dev is necesary because at some
134 * point we need to request resources from the device. Mapping is
135 * easily over come (ioremap and stuff are bus agnostic), but hooking
136 * up to some error handlers (such as pci error handlers) might need
137 * this.
138 *
139 * THIS might (probably will) be removed in the future, so don't count
140 * on it.
141 */
142static inline struct pci_dev *umc_parent_pci_dev(struct umc_dev *umc_dev)
143{
144 struct pci_dev *pci_dev = NULL;
145 if (umc_dev->dev.parent->bus == &pci_bus_type)
146 pci_dev = to_pci_dev(umc_dev->dev.parent);
147 return pci_dev;
148}
149
150/**
151 * umc_dev_get() - reference a UMC device.
152 * @umc_dev: Pointer to UMC device.
153 *
154 * NOTE: we are assuming in this whole scheme that the parent device
155 * is referenced at _probe() time and unreferenced at _remove()
156 * time by the parent's subsystem.
157 */
158static inline struct umc_dev *umc_dev_get(struct umc_dev *umc_dev)
159{
160 get_device(&umc_dev->dev);
161 return umc_dev;
162}
163
164/**
165 * umc_dev_put() - unreference a UMC device.
166 * @umc_dev: Pointer to UMC device.
167 */
168static inline void umc_dev_put(struct umc_dev *umc_dev)
169{
170 put_device(&umc_dev->dev);
171}
172
173/**
174 * umc_set_drvdata - set UMC device's driver data.
175 * @umc_dev: Pointer to UMC device.
176 * @data: Data to set.
177 */
178static inline void umc_set_drvdata(struct umc_dev *umc_dev, void *data)
179{
180 dev_set_drvdata(&umc_dev->dev, data);
181}
182
183/**
184 * umc_get_drvdata - recover UMC device's driver data.
185 * @umc_dev: Pointer to UMC device.
186 */
187static inline void *umc_get_drvdata(struct umc_dev *umc_dev)
188{
189 return dev_get_drvdata(&umc_dev->dev);
190}
191
192int umc_controller_reset(struct umc_dev *umc);
193
194#endif /* #ifndef _LINUX_UWB_UMC_H_ */
diff --git a/include/linux/uwb/whci.h b/include/linux/uwb/whci.h
new file mode 100644
index 000000000000..915ec23042d4
--- /dev/null
+++ b/include/linux/uwb/whci.h
@@ -0,0 +1,117 @@
1/*
2 * Wireless Host Controller Interface for Ultra-Wide-Band and Wireless USB
3 *
4 * Copyright (C) 2005-2006 Intel Corporation
5 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License version
9 * 2 as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 * 02110-1301, USA.
20 *
21 *
22 *
23 * References:
24 * [WHCI] Wireless Host Controller Interface Specification for
25 * Certified Wireless Universal Serial Bus, revision 0.95.
26 */
27#ifndef _LINUX_UWB_WHCI_H_
28#define _LINUX_UWB_WHCI_H_
29
30#include <linux/pci.h>
31
32/*
33 * UWB interface capability registers (offsets from UWBBASE)
34 *
35 * [WHCI] section 2.2
36 */
37#define UWBCAPINFO 0x00 /* == UWBCAPDATA(0) */
38# define UWBCAPINFO_TO_N_CAPS(c) (((c) >> 0) & 0xFull)
39#define UWBCAPDATA(n) (8*(n))
40# define UWBCAPDATA_TO_VERSION(c) (((c) >> 32) & 0xFFFFull)
41# define UWBCAPDATA_TO_OFFSET(c) (((c) >> 18) & 0x3FFFull)
42# define UWBCAPDATA_TO_BAR(c) (((c) >> 16) & 0x3ull)
43# define UWBCAPDATA_TO_SIZE(c) ((((c) >> 8) & 0xFFull) * sizeof(u32))
44# define UWBCAPDATA_TO_CAP_ID(c) (((c) >> 0) & 0xFFull)
45
46/* Size of the WHCI capability data (including the RC capability) for
47 a device with n capabilities. */
48#define UWBCAPDATA_SIZE(n) (8 + 8*(n))
49
50
51/*
52 * URC registers (offsets from URCBASE)
53 *
54 * [WHCI] section 2.3
55 */
56#define URCCMD 0x00
57# define URCCMD_RESET (1 << 31) /* UMC Hardware reset */
58# define URCCMD_RS (1 << 30) /* Run/Stop */
59# define URCCMD_EARV (1 << 29) /* Event Address Register Valid */
60# define URCCMD_ACTIVE (1 << 15) /* Command is active */
61# define URCCMD_IWR (1 << 14) /* Interrupt When Ready */
62# define URCCMD_SIZE_MASK 0x00000fff /* Command size mask */
63#define URCSTS 0x04
64# define URCSTS_EPS (1 << 17) /* Event Processing Status */
65# define URCSTS_HALTED (1 << 16) /* RC halted */
66# define URCSTS_HSE (1 << 10) /* Host System Error...fried */
67# define URCSTS_ER (1 << 9) /* Event Ready */
68# define URCSTS_RCI (1 << 8) /* Ready for Command Interrupt */
69# define URCSTS_INT_MASK 0x00000700 /* URC interrupt sources */
70# define URCSTS_ISI 0x000000ff /* Interrupt Source Identification */
71#define URCINTR 0x08
72# define URCINTR_EN_ALL 0x000007ff /* Enable all interrupt sources */
73#define URCCMDADDR 0x10
74#define URCEVTADDR 0x18
75# define URCEVTADDR_OFFSET_MASK 0xfff /* Event pointer offset mask */
76
77
78/** Write 32 bit @value to little endian register at @addr */
79static inline
80void le_writel(u32 value, void __iomem *addr)
81{
82 iowrite32(value, addr);
83}
84
85
86/** Read from 32 bit little endian register at @addr */
87static inline
88u32 le_readl(void __iomem *addr)
89{
90 return ioread32(addr);
91}
92
93
94/** Write 64 bit @value to little endian register at @addr */
95static inline
96void le_writeq(u64 value, void __iomem *addr)
97{
98 iowrite32(value, addr);
99 iowrite32(value >> 32, addr + 4);
100}
101
102
103/** Read from 64 bit little endian register at @addr */
104static inline
105u64 le_readq(void __iomem *addr)
106{
107 u64 value;
108 value = ioread32(addr);
109 value |= (u64)ioread32(addr + 4) << 32;
110 return value;
111}
112
113extern int whci_wait_for(struct device *dev, u32 __iomem *reg,
114 u32 mask, u32 result,
115 unsigned long max_ms, const char *tag);
116
117#endif /* #ifndef _LINUX_UWB_WHCI_H_ */
diff --git a/include/linux/videodev.h b/include/linux/videodev.h
index 9385a566aed8..15a653d41132 100644
--- a/include/linux/videodev.h
+++ b/include/linux/videodev.h
@@ -17,6 +17,21 @@
17 17
18#if defined(CONFIG_VIDEO_V4L1_COMPAT) || !defined (__KERNEL__) 18#if defined(CONFIG_VIDEO_V4L1_COMPAT) || !defined (__KERNEL__)
19 19
20#define VID_TYPE_CAPTURE 1 /* Can capture */
21#define VID_TYPE_TUNER 2 /* Can tune */
22#define VID_TYPE_TELETEXT 4 /* Does teletext */
23#define VID_TYPE_OVERLAY 8 /* Overlay onto frame buffer */
24#define VID_TYPE_CHROMAKEY 16 /* Overlay by chromakey */
25#define VID_TYPE_CLIPPING 32 /* Can clip */
26#define VID_TYPE_FRAMERAM 64 /* Uses the frame buffer memory */
27#define VID_TYPE_SCALES 128 /* Scalable */
28#define VID_TYPE_MONOCHROME 256 /* Monochrome only */
29#define VID_TYPE_SUBCAPTURE 512 /* Can capture subareas of the image */
30#define VID_TYPE_MPEG_DECODER 1024 /* Can decode MPEG streams */
31#define VID_TYPE_MPEG_ENCODER 2048 /* Can encode MPEG streams */
32#define VID_TYPE_MJPEG_DECODER 4096 /* Can decode MJPEG streams */
33#define VID_TYPE_MJPEG_ENCODER 8192 /* Can encode MJPEG streams */
34
20struct video_capability 35struct video_capability
21{ 36{
22 char name[32]; 37 char name[32];
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index 4a535ea1e123..4669d7e72e75 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -55,13 +55,13 @@
55 */ 55 */
56#ifndef __LINUX_VIDEODEV2_H 56#ifndef __LINUX_VIDEODEV2_H
57#define __LINUX_VIDEODEV2_H 57#define __LINUX_VIDEODEV2_H
58
58#ifdef __KERNEL__ 59#ifdef __KERNEL__
59#include <linux/time.h> /* need struct timeval */ 60#include <linux/time.h> /* need struct timeval */
60#include <linux/compiler.h> /* need __user */
61#else 61#else
62#define __user
63#include <sys/time.h> 62#include <sys/time.h>
64#endif 63#endif
64#include <linux/compiler.h>
65#include <linux/ioctl.h> 65#include <linux/ioctl.h>
66#include <linux/types.h> 66#include <linux/types.h>
67 67
@@ -71,6 +71,11 @@
71 */ 71 */
72#define VIDEO_MAX_FRAME 32 72#define VIDEO_MAX_FRAME 32
73 73
74#ifndef __KERNEL__
75
76/* These defines are V4L1 specific and should not be used with the V4L2 API!
77 They will be removed from this header in the future. */
78
74#define VID_TYPE_CAPTURE 1 /* Can capture */ 79#define VID_TYPE_CAPTURE 1 /* Can capture */
75#define VID_TYPE_TUNER 2 /* Can tune */ 80#define VID_TYPE_TUNER 2 /* Can tune */
76#define VID_TYPE_TELETEXT 4 /* Does teletext */ 81#define VID_TYPE_TELETEXT 4 /* Does teletext */
@@ -85,14 +90,15 @@
85#define VID_TYPE_MPEG_ENCODER 2048 /* Can encode MPEG streams */ 90#define VID_TYPE_MPEG_ENCODER 2048 /* Can encode MPEG streams */
86#define VID_TYPE_MJPEG_DECODER 4096 /* Can decode MJPEG streams */ 91#define VID_TYPE_MJPEG_DECODER 4096 /* Can decode MJPEG streams */
87#define VID_TYPE_MJPEG_ENCODER 8192 /* Can encode MJPEG streams */ 92#define VID_TYPE_MJPEG_ENCODER 8192 /* Can encode MJPEG streams */
93#endif
88 94
89/* 95/*
90 * M I S C E L L A N E O U S 96 * M I S C E L L A N E O U S
91 */ 97 */
92 98
93/* Four-character-code (FOURCC) */ 99/* Four-character-code (FOURCC) */
94#define v4l2_fourcc(a,b,c,d)\ 100#define v4l2_fourcc(a, b, c, d)\
95 (((__u32)(a)<<0)|((__u32)(b)<<8)|((__u32)(c)<<16)|((__u32)(d)<<24)) 101 ((__u32)(a) | ((__u32)(b) << 8) | ((__u32)(c) << 16) | ((__u32)(d) << 24))
96 102
97/* 103/*
98 * E N U M S 104 * E N U M S
@@ -226,8 +232,7 @@ struct v4l2_fract {
226/* 232/*
227 * D R I V E R C A P A B I L I T I E S 233 * D R I V E R C A P A B I L I T I E S
228 */ 234 */
229struct v4l2_capability 235struct v4l2_capability {
230{
231 __u8 driver[16]; /* i.e. "bttv" */ 236 __u8 driver[16]; /* i.e. "bttv" */
232 __u8 card[32]; /* i.e. "Hauppauge WinTV" */ 237 __u8 card[32]; /* i.e. "Hauppauge WinTV" */
233 __u8 bus_info[32]; /* "PCI:" + pci_name(pci_dev) */ 238 __u8 bus_info[32]; /* "PCI:" + pci_name(pci_dev) */
@@ -246,6 +251,7 @@ struct v4l2_capability
246#define V4L2_CAP_SLICED_VBI_OUTPUT 0x00000080 /* Is a sliced VBI output device */ 251#define V4L2_CAP_SLICED_VBI_OUTPUT 0x00000080 /* Is a sliced VBI output device */
247#define V4L2_CAP_RDS_CAPTURE 0x00000100 /* RDS data capture */ 252#define V4L2_CAP_RDS_CAPTURE 0x00000100 /* RDS data capture */
248#define V4L2_CAP_VIDEO_OUTPUT_OVERLAY 0x00000200 /* Can do video output overlay */ 253#define V4L2_CAP_VIDEO_OUTPUT_OVERLAY 0x00000200 /* Can do video output overlay */
254#define V4L2_CAP_HW_FREQ_SEEK 0x00000400 /* Can do hardware frequency seek */
249 255
250#define V4L2_CAP_TUNER 0x00010000 /* has a tuner */ 256#define V4L2_CAP_TUNER 0x00010000 /* has a tuner */
251#define V4L2_CAP_AUDIO 0x00020000 /* has audio support */ 257#define V4L2_CAP_AUDIO 0x00020000 /* has audio support */
@@ -258,8 +264,7 @@ struct v4l2_capability
258/* 264/*
259 * V I D E O I M A G E F O R M A T 265 * V I D E O I M A G E F O R M A T
260 */ 266 */
261struct v4l2_pix_format 267struct v4l2_pix_format {
262{
263 __u32 width; 268 __u32 width;
264 __u32 height; 269 __u32 height;
265 __u32 pixelformat; 270 __u32 pixelformat;
@@ -271,64 +276,78 @@ struct v4l2_pix_format
271}; 276};
272 277
273/* Pixel format FOURCC depth Description */ 278/* Pixel format FOURCC depth Description */
274#define V4L2_PIX_FMT_RGB332 v4l2_fourcc('R','G','B','1') /* 8 RGB-3-3-2 */ 279#define V4L2_PIX_FMT_RGB332 v4l2_fourcc('R', 'G', 'B', '1') /* 8 RGB-3-3-2 */
275#define V4L2_PIX_FMT_RGB444 v4l2_fourcc('R','4','4','4') /* 16 xxxxrrrr ggggbbbb */ 280#define V4L2_PIX_FMT_RGB444 v4l2_fourcc('R', '4', '4', '4') /* 16 xxxxrrrr ggggbbbb */
276#define V4L2_PIX_FMT_RGB555 v4l2_fourcc('R','G','B','O') /* 16 RGB-5-5-5 */ 281#define V4L2_PIX_FMT_RGB555 v4l2_fourcc('R', 'G', 'B', 'O') /* 16 RGB-5-5-5 */
277#define V4L2_PIX_FMT_RGB565 v4l2_fourcc('R','G','B','P') /* 16 RGB-5-6-5 */ 282#define V4L2_PIX_FMT_RGB565 v4l2_fourcc('R', 'G', 'B', 'P') /* 16 RGB-5-6-5 */
278#define V4L2_PIX_FMT_RGB555X v4l2_fourcc('R','G','B','Q') /* 16 RGB-5-5-5 BE */ 283#define V4L2_PIX_FMT_RGB555X v4l2_fourcc('R', 'G', 'B', 'Q') /* 16 RGB-5-5-5 BE */
279#define V4L2_PIX_FMT_RGB565X v4l2_fourcc('R','G','B','R') /* 16 RGB-5-6-5 BE */ 284#define V4L2_PIX_FMT_RGB565X v4l2_fourcc('R', 'G', 'B', 'R') /* 16 RGB-5-6-5 BE */
280#define V4L2_PIX_FMT_BGR24 v4l2_fourcc('B','G','R','3') /* 24 BGR-8-8-8 */ 285#define V4L2_PIX_FMT_BGR24 v4l2_fourcc('B', 'G', 'R', '3') /* 24 BGR-8-8-8 */
281#define V4L2_PIX_FMT_RGB24 v4l2_fourcc('R','G','B','3') /* 24 RGB-8-8-8 */ 286#define V4L2_PIX_FMT_RGB24 v4l2_fourcc('R', 'G', 'B', '3') /* 24 RGB-8-8-8 */
282#define V4L2_PIX_FMT_BGR32 v4l2_fourcc('B','G','R','4') /* 32 BGR-8-8-8-8 */ 287#define V4L2_PIX_FMT_BGR32 v4l2_fourcc('B', 'G', 'R', '4') /* 32 BGR-8-8-8-8 */
283#define V4L2_PIX_FMT_RGB32 v4l2_fourcc('R','G','B','4') /* 32 RGB-8-8-8-8 */ 288#define V4L2_PIX_FMT_RGB32 v4l2_fourcc('R', 'G', 'B', '4') /* 32 RGB-8-8-8-8 */
284#define V4L2_PIX_FMT_GREY v4l2_fourcc('G','R','E','Y') /* 8 Greyscale */ 289#define V4L2_PIX_FMT_GREY v4l2_fourcc('G', 'R', 'E', 'Y') /* 8 Greyscale */
285#define V4L2_PIX_FMT_Y16 v4l2_fourcc('Y','1','6',' ') /* 16 Greyscale */ 290#define V4L2_PIX_FMT_Y16 v4l2_fourcc('Y', '1', '6', ' ') /* 16 Greyscale */
286#define V4L2_PIX_FMT_PAL8 v4l2_fourcc('P','A','L','8') /* 8 8-bit palette */ 291#define V4L2_PIX_FMT_PAL8 v4l2_fourcc('P', 'A', 'L', '8') /* 8 8-bit palette */
287#define V4L2_PIX_FMT_YVU410 v4l2_fourcc('Y','V','U','9') /* 9 YVU 4:1:0 */ 292#define V4L2_PIX_FMT_YVU410 v4l2_fourcc('Y', 'V', 'U', '9') /* 9 YVU 4:1:0 */
288#define V4L2_PIX_FMT_YVU420 v4l2_fourcc('Y','V','1','2') /* 12 YVU 4:2:0 */ 293#define V4L2_PIX_FMT_YVU420 v4l2_fourcc('Y', 'V', '1', '2') /* 12 YVU 4:2:0 */
289#define V4L2_PIX_FMT_YUYV v4l2_fourcc('Y','U','Y','V') /* 16 YUV 4:2:2 */ 294#define V4L2_PIX_FMT_YUYV v4l2_fourcc('Y', 'U', 'Y', 'V') /* 16 YUV 4:2:2 */
290#define V4L2_PIX_FMT_UYVY v4l2_fourcc('U','Y','V','Y') /* 16 YUV 4:2:2 */ 295#define V4L2_PIX_FMT_UYVY v4l2_fourcc('U', 'Y', 'V', 'Y') /* 16 YUV 4:2:2 */
291#define V4L2_PIX_FMT_YUV422P v4l2_fourcc('4','2','2','P') /* 16 YVU422 planar */ 296#define V4L2_PIX_FMT_YUV422P v4l2_fourcc('4', '2', '2', 'P') /* 16 YVU422 planar */
292#define V4L2_PIX_FMT_YUV411P v4l2_fourcc('4','1','1','P') /* 16 YVU411 planar */ 297#define V4L2_PIX_FMT_YUV411P v4l2_fourcc('4', '1', '1', 'P') /* 16 YVU411 planar */
293#define V4L2_PIX_FMT_Y41P v4l2_fourcc('Y','4','1','P') /* 12 YUV 4:1:1 */ 298#define V4L2_PIX_FMT_Y41P v4l2_fourcc('Y', '4', '1', 'P') /* 12 YUV 4:1:1 */
294#define V4L2_PIX_FMT_YUV444 v4l2_fourcc('Y','4','4','4') /* 16 xxxxyyyy uuuuvvvv */ 299#define V4L2_PIX_FMT_YUV444 v4l2_fourcc('Y', '4', '4', '4') /* 16 xxxxyyyy uuuuvvvv */
295#define V4L2_PIX_FMT_YUV555 v4l2_fourcc('Y','U','V','O') /* 16 YUV-5-5-5 */ 300#define V4L2_PIX_FMT_YUV555 v4l2_fourcc('Y', 'U', 'V', 'O') /* 16 YUV-5-5-5 */
296#define V4L2_PIX_FMT_YUV565 v4l2_fourcc('Y','U','V','P') /* 16 YUV-5-6-5 */ 301#define V4L2_PIX_FMT_YUV565 v4l2_fourcc('Y', 'U', 'V', 'P') /* 16 YUV-5-6-5 */
297#define V4L2_PIX_FMT_YUV32 v4l2_fourcc('Y','U','V','4') /* 32 YUV-8-8-8-8 */ 302#define V4L2_PIX_FMT_YUV32 v4l2_fourcc('Y', 'U', 'V', '4') /* 32 YUV-8-8-8-8 */
298 303
299/* two planes -- one Y, one Cr + Cb interleaved */ 304/* two planes -- one Y, one Cr + Cb interleaved */
300#define V4L2_PIX_FMT_NV12 v4l2_fourcc('N','V','1','2') /* 12 Y/CbCr 4:2:0 */ 305#define V4L2_PIX_FMT_NV12 v4l2_fourcc('N', 'V', '1', '2') /* 12 Y/CbCr 4:2:0 */
301#define V4L2_PIX_FMT_NV21 v4l2_fourcc('N','V','2','1') /* 12 Y/CrCb 4:2:0 */ 306#define V4L2_PIX_FMT_NV21 v4l2_fourcc('N', 'V', '2', '1') /* 12 Y/CrCb 4:2:0 */
302 307
303/* The following formats are not defined in the V4L2 specification */ 308/* The following formats are not defined in the V4L2 specification */
304#define V4L2_PIX_FMT_YUV410 v4l2_fourcc('Y','U','V','9') /* 9 YUV 4:1:0 */ 309#define V4L2_PIX_FMT_YUV410 v4l2_fourcc('Y', 'U', 'V', '9') /* 9 YUV 4:1:0 */
305#define V4L2_PIX_FMT_YUV420 v4l2_fourcc('Y','U','1','2') /* 12 YUV 4:2:0 */ 310#define V4L2_PIX_FMT_YUV420 v4l2_fourcc('Y', 'U', '1', '2') /* 12 YUV 4:2:0 */
306#define V4L2_PIX_FMT_YYUV v4l2_fourcc('Y','Y','U','V') /* 16 YUV 4:2:2 */ 311#define V4L2_PIX_FMT_YYUV v4l2_fourcc('Y', 'Y', 'U', 'V') /* 16 YUV 4:2:2 */
307#define V4L2_PIX_FMT_HI240 v4l2_fourcc('H','I','2','4') /* 8 8-bit color */ 312#define V4L2_PIX_FMT_HI240 v4l2_fourcc('H', 'I', '2', '4') /* 8 8-bit color */
308#define V4L2_PIX_FMT_HM12 v4l2_fourcc('H','M','1','2') /* 8 YUV 4:2:0 16x16 macroblocks */ 313#define V4L2_PIX_FMT_HM12 v4l2_fourcc('H', 'M', '1', '2') /* 8 YUV 4:2:0 16x16 macroblocks */
309 314
310/* see http://www.siliconimaging.com/RGB%20Bayer.htm */ 315/* see http://www.siliconimaging.com/RGB%20Bayer.htm */
311#define V4L2_PIX_FMT_SBGGR8 v4l2_fourcc('B','A','8','1') /* 8 BGBG.. GRGR.. */ 316#define V4L2_PIX_FMT_SBGGR8 v4l2_fourcc('B', 'A', '8', '1') /* 8 BGBG.. GRGR.. */
312#define V4L2_PIX_FMT_SBGGR16 v4l2_fourcc('B','Y','R','2') /* 16 BGBG.. GRGR.. */ 317#define V4L2_PIX_FMT_SGBRG8 v4l2_fourcc('G', 'B', 'R', 'G') /* 8 GBGB.. RGRG.. */
318/*
319 * 10bit raw bayer, expanded to 16 bits
320 * xxxxrrrrrrrrrrxxxxgggggggggg xxxxggggggggggxxxxbbbbbbbbbb...
321 */
322#define V4L2_PIX_FMT_SGRBG10 v4l2_fourcc('B', 'A', '1', '0')
323/* 10bit raw bayer DPCM compressed to 8 bits */
324#define V4L2_PIX_FMT_SGRBG10DPCM8 v4l2_fourcc('B', 'D', '1', '0')
325#define V4L2_PIX_FMT_SBGGR16 v4l2_fourcc('B', 'Y', 'R', '2') /* 16 BGBG.. GRGR.. */
313 326
314/* compressed formats */ 327/* compressed formats */
315#define V4L2_PIX_FMT_MJPEG v4l2_fourcc('M','J','P','G') /* Motion-JPEG */ 328#define V4L2_PIX_FMT_MJPEG v4l2_fourcc('M', 'J', 'P', 'G') /* Motion-JPEG */
316#define V4L2_PIX_FMT_JPEG v4l2_fourcc('J','P','E','G') /* JFIF JPEG */ 329#define V4L2_PIX_FMT_JPEG v4l2_fourcc('J', 'P', 'E', 'G') /* JFIF JPEG */
317#define V4L2_PIX_FMT_DV v4l2_fourcc('d','v','s','d') /* 1394 */ 330#define V4L2_PIX_FMT_DV v4l2_fourcc('d', 'v', 's', 'd') /* 1394 */
318#define V4L2_PIX_FMT_MPEG v4l2_fourcc('M','P','E','G') /* MPEG-1/2/4 */ 331#define V4L2_PIX_FMT_MPEG v4l2_fourcc('M', 'P', 'E', 'G') /* MPEG-1/2/4 */
319 332
320/* Vendor-specific formats */ 333/* Vendor-specific formats */
321#define V4L2_PIX_FMT_WNVA v4l2_fourcc('W','N','V','A') /* Winnov hw compress */ 334#define V4L2_PIX_FMT_WNVA v4l2_fourcc('W', 'N', 'V', 'A') /* Winnov hw compress */
322#define V4L2_PIX_FMT_SN9C10X v4l2_fourcc('S','9','1','0') /* SN9C10x compression */ 335#define V4L2_PIX_FMT_SN9C10X v4l2_fourcc('S', '9', '1', '0') /* SN9C10x compression */
323#define V4L2_PIX_FMT_PWC1 v4l2_fourcc('P','W','C','1') /* pwc older webcam */ 336#define V4L2_PIX_FMT_PWC1 v4l2_fourcc('P', 'W', 'C', '1') /* pwc older webcam */
324#define V4L2_PIX_FMT_PWC2 v4l2_fourcc('P','W','C','2') /* pwc newer webcam */ 337#define V4L2_PIX_FMT_PWC2 v4l2_fourcc('P', 'W', 'C', '2') /* pwc newer webcam */
325#define V4L2_PIX_FMT_ET61X251 v4l2_fourcc('E','6','2','5') /* ET61X251 compression */ 338#define V4L2_PIX_FMT_ET61X251 v4l2_fourcc('E', '6', '2', '5') /* ET61X251 compression */
339#define V4L2_PIX_FMT_SPCA501 v4l2_fourcc('S', '5', '0', '1') /* YUYV per line */
340#define V4L2_PIX_FMT_SPCA505 v4l2_fourcc('S', '5', '0', '5') /* YYUV per line */
341#define V4L2_PIX_FMT_SPCA508 v4l2_fourcc('S', '5', '0', '8') /* YUVY per line */
342#define V4L2_PIX_FMT_SPCA561 v4l2_fourcc('S', '5', '6', '1') /* compressed GBRG bayer */
343#define V4L2_PIX_FMT_PAC207 v4l2_fourcc('P', '2', '0', '7') /* compressed BGGR bayer */
344#define V4L2_PIX_FMT_PJPG v4l2_fourcc('P', 'J', 'P', 'G') /* Pixart 73xx JPEG */
345#define V4L2_PIX_FMT_YVYU v4l2_fourcc('Y', 'V', 'Y', 'U') /* 16 YVU 4:2:2 */
326 346
327/* 347/*
328 * F O R M A T E N U M E R A T I O N 348 * F O R M A T E N U M E R A T I O N
329 */ 349 */
330struct v4l2_fmtdesc 350struct v4l2_fmtdesc {
331{
332 __u32 index; /* Format number */ 351 __u32 index; /* Format number */
333 enum v4l2_buf_type type; /* buffer type */ 352 enum v4l2_buf_type type; /* buffer type */
334 __u32 flags; 353 __u32 flags;
@@ -344,21 +363,18 @@ struct v4l2_fmtdesc
344/* 363/*
345 * F R A M E S I Z E E N U M E R A T I O N 364 * F R A M E S I Z E E N U M E R A T I O N
346 */ 365 */
347enum v4l2_frmsizetypes 366enum v4l2_frmsizetypes {
348{
349 V4L2_FRMSIZE_TYPE_DISCRETE = 1, 367 V4L2_FRMSIZE_TYPE_DISCRETE = 1,
350 V4L2_FRMSIZE_TYPE_CONTINUOUS = 2, 368 V4L2_FRMSIZE_TYPE_CONTINUOUS = 2,
351 V4L2_FRMSIZE_TYPE_STEPWISE = 3, 369 V4L2_FRMSIZE_TYPE_STEPWISE = 3,
352}; 370};
353 371
354struct v4l2_frmsize_discrete 372struct v4l2_frmsize_discrete {
355{
356 __u32 width; /* Frame width [pixel] */ 373 __u32 width; /* Frame width [pixel] */
357 __u32 height; /* Frame height [pixel] */ 374 __u32 height; /* Frame height [pixel] */
358}; 375};
359 376
360struct v4l2_frmsize_stepwise 377struct v4l2_frmsize_stepwise {
361{
362 __u32 min_width; /* Minimum frame width [pixel] */ 378 __u32 min_width; /* Minimum frame width [pixel] */
363 __u32 max_width; /* Maximum frame width [pixel] */ 379 __u32 max_width; /* Maximum frame width [pixel] */
364 __u32 step_width; /* Frame width step size [pixel] */ 380 __u32 step_width; /* Frame width step size [pixel] */
@@ -367,8 +383,7 @@ struct v4l2_frmsize_stepwise
367 __u32 step_height; /* Frame height step size [pixel] */ 383 __u32 step_height; /* Frame height step size [pixel] */
368}; 384};
369 385
370struct v4l2_frmsizeenum 386struct v4l2_frmsizeenum {
371{
372 __u32 index; /* Frame size number */ 387 __u32 index; /* Frame size number */
373 __u32 pixel_format; /* Pixel format */ 388 __u32 pixel_format; /* Pixel format */
374 __u32 type; /* Frame size type the device supports. */ 389 __u32 type; /* Frame size type the device supports. */
@@ -384,22 +399,19 @@ struct v4l2_frmsizeenum
384/* 399/*
385 * F R A M E R A T E E N U M E R A T I O N 400 * F R A M E R A T E E N U M E R A T I O N
386 */ 401 */
387enum v4l2_frmivaltypes 402enum v4l2_frmivaltypes {
388{
389 V4L2_FRMIVAL_TYPE_DISCRETE = 1, 403 V4L2_FRMIVAL_TYPE_DISCRETE = 1,
390 V4L2_FRMIVAL_TYPE_CONTINUOUS = 2, 404 V4L2_FRMIVAL_TYPE_CONTINUOUS = 2,
391 V4L2_FRMIVAL_TYPE_STEPWISE = 3, 405 V4L2_FRMIVAL_TYPE_STEPWISE = 3,
392}; 406};
393 407
394struct v4l2_frmival_stepwise 408struct v4l2_frmival_stepwise {
395{
396 struct v4l2_fract min; /* Minimum frame interval [s] */ 409 struct v4l2_fract min; /* Minimum frame interval [s] */
397 struct v4l2_fract max; /* Maximum frame interval [s] */ 410 struct v4l2_fract max; /* Maximum frame interval [s] */
398 struct v4l2_fract step; /* Frame interval step size [s] */ 411 struct v4l2_fract step; /* Frame interval step size [s] */
399}; 412};
400 413
401struct v4l2_frmivalenum 414struct v4l2_frmivalenum {
402{
403 __u32 index; /* Frame format index */ 415 __u32 index; /* Frame format index */
404 __u32 pixel_format; /* Pixel format */ 416 __u32 pixel_format; /* Pixel format */
405 __u32 width; /* Frame width */ 417 __u32 width; /* Frame width */
@@ -418,8 +430,7 @@ struct v4l2_frmivalenum
418/* 430/*
419 * T I M E C O D E 431 * T I M E C O D E
420 */ 432 */
421struct v4l2_timecode 433struct v4l2_timecode {
422{
423 __u32 type; 434 __u32 type;
424 __u32 flags; 435 __u32 flags;
425 __u8 frames; 436 __u8 frames;
@@ -444,8 +455,7 @@ struct v4l2_timecode
444#define V4L2_TC_USERBITS_8BITCHARS 0x0008 455#define V4L2_TC_USERBITS_8BITCHARS 0x0008
445/* The above is based on SMPTE timecodes */ 456/* The above is based on SMPTE timecodes */
446 457
447struct v4l2_jpegcompression 458struct v4l2_jpegcompression {
448{
449 int quality; 459 int quality;
450 460
451 int APPn; /* Number of APP segment to be written, 461 int APPn; /* Number of APP segment to be written,
@@ -477,16 +487,14 @@ struct v4l2_jpegcompression
477/* 487/*
478 * M E M O R Y - M A P P I N G B U F F E R S 488 * M E M O R Y - M A P P I N G B U F F E R S
479 */ 489 */
480struct v4l2_requestbuffers 490struct v4l2_requestbuffers {
481{
482 __u32 count; 491 __u32 count;
483 enum v4l2_buf_type type; 492 enum v4l2_buf_type type;
484 enum v4l2_memory memory; 493 enum v4l2_memory memory;
485 __u32 reserved[2]; 494 __u32 reserved[2];
486}; 495};
487 496
488struct v4l2_buffer 497struct v4l2_buffer {
489{
490 __u32 index; 498 __u32 index;
491 enum v4l2_buf_type type; 499 enum v4l2_buf_type type;
492 __u32 bytesused; 500 __u32 bytesused;
@@ -520,13 +528,12 @@ struct v4l2_buffer
520/* 528/*
521 * O V E R L A Y P R E V I E W 529 * O V E R L A Y P R E V I E W
522 */ 530 */
523struct v4l2_framebuffer 531struct v4l2_framebuffer {
524{
525 __u32 capability; 532 __u32 capability;
526 __u32 flags; 533 __u32 flags;
527/* FIXME: in theory we should pass something like PCI device + memory 534/* FIXME: in theory we should pass something like PCI device + memory
528 * region + offset instead of some physical address */ 535 * region + offset instead of some physical address */
529 void* base; 536 void *base;
530 struct v4l2_pix_format fmt; 537 struct v4l2_pix_format fmt;
531}; 538};
532/* Flags for the 'capability' field. Read only */ 539/* Flags for the 'capability' field. Read only */
@@ -545,14 +552,12 @@ struct v4l2_framebuffer
545#define V4L2_FBUF_FLAG_GLOBAL_ALPHA 0x0010 552#define V4L2_FBUF_FLAG_GLOBAL_ALPHA 0x0010
546#define V4L2_FBUF_FLAG_LOCAL_INV_ALPHA 0x0020 553#define V4L2_FBUF_FLAG_LOCAL_INV_ALPHA 0x0020
547 554
548struct v4l2_clip 555struct v4l2_clip {
549{
550 struct v4l2_rect c; 556 struct v4l2_rect c;
551 struct v4l2_clip __user *next; 557 struct v4l2_clip __user *next;
552}; 558};
553 559
554struct v4l2_window 560struct v4l2_window {
555{
556 struct v4l2_rect w; 561 struct v4l2_rect w;
557 enum v4l2_field field; 562 enum v4l2_field field;
558 __u32 chromakey; 563 __u32 chromakey;
@@ -565,8 +570,7 @@ struct v4l2_window
565/* 570/*
566 * C A P T U R E P A R A M E T E R S 571 * C A P T U R E P A R A M E T E R S
567 */ 572 */
568struct v4l2_captureparm 573struct v4l2_captureparm {
569{
570 __u32 capability; /* Supported modes */ 574 __u32 capability; /* Supported modes */
571 __u32 capturemode; /* Current mode */ 575 __u32 capturemode; /* Current mode */
572 struct v4l2_fract timeperframe; /* Time per frame in .1us units */ 576 struct v4l2_fract timeperframe; /* Time per frame in .1us units */
@@ -579,8 +583,7 @@ struct v4l2_captureparm
579#define V4L2_MODE_HIGHQUALITY 0x0001 /* High quality imaging mode */ 583#define V4L2_MODE_HIGHQUALITY 0x0001 /* High quality imaging mode */
580#define V4L2_CAP_TIMEPERFRAME 0x1000 /* timeperframe field is supported */ 584#define V4L2_CAP_TIMEPERFRAME 0x1000 /* timeperframe field is supported */
581 585
582struct v4l2_outputparm 586struct v4l2_outputparm {
583{
584 __u32 capability; /* Supported modes */ 587 __u32 capability; /* Supported modes */
585 __u32 outputmode; /* Current mode */ 588 __u32 outputmode; /* Current mode */
586 struct v4l2_fract timeperframe; /* Time per frame in seconds */ 589 struct v4l2_fract timeperframe; /* Time per frame in seconds */
@@ -697,8 +700,7 @@ typedef __u64 v4l2_std_id;
697#define V4L2_STD_ALL (V4L2_STD_525_60 |\ 700#define V4L2_STD_ALL (V4L2_STD_525_60 |\
698 V4L2_STD_625_50) 701 V4L2_STD_625_50)
699 702
700struct v4l2_standard 703struct v4l2_standard {
701{
702 __u32 index; 704 __u32 index;
703 v4l2_std_id id; 705 v4l2_std_id id;
704 __u8 name[24]; 706 __u8 name[24];
@@ -710,8 +712,7 @@ struct v4l2_standard
710/* 712/*
711 * V I D E O I N P U T S 713 * V I D E O I N P U T S
712 */ 714 */
713struct v4l2_input 715struct v4l2_input {
714{
715 __u32 index; /* Which input */ 716 __u32 index; /* Which input */
716 __u8 name[32]; /* Label */ 717 __u8 name[32]; /* Label */
717 __u32 type; /* Type of input */ 718 __u32 type; /* Type of input */
@@ -748,8 +749,7 @@ struct v4l2_input
748/* 749/*
749 * V I D E O O U T P U T S 750 * V I D E O O U T P U T S
750 */ 751 */
751struct v4l2_output 752struct v4l2_output {
752{
753 __u32 index; /* Which output */ 753 __u32 index; /* Which output */
754 __u8 name[32]; /* Label */ 754 __u8 name[32]; /* Label */
755 __u32 type; /* Type of output */ 755 __u32 type; /* Type of output */
@@ -766,14 +766,12 @@ struct v4l2_output
766/* 766/*
767 * C O N T R O L S 767 * C O N T R O L S
768 */ 768 */
769struct v4l2_control 769struct v4l2_control {
770{
771 __u32 id; 770 __u32 id;
772 __s32 value; 771 __s32 value;
773}; 772};
774 773
775struct v4l2_ext_control 774struct v4l2_ext_control {
776{
777 __u32 id; 775 __u32 id;
778 __u32 reserved2[2]; 776 __u32 reserved2[2];
779 union { 777 union {
@@ -783,8 +781,7 @@ struct v4l2_ext_control
783 }; 781 };
784} __attribute__ ((packed)); 782} __attribute__ ((packed));
785 783
786struct v4l2_ext_controls 784struct v4l2_ext_controls {
787{
788 __u32 ctrl_class; 785 __u32 ctrl_class;
789 __u32 count; 786 __u32 count;
790 __u32 error_idx; 787 __u32 error_idx;
@@ -802,8 +799,7 @@ struct v4l2_ext_controls
802#define V4L2_CTRL_DRIVER_PRIV(id) (((id) & 0xffff) >= 0x1000) 799#define V4L2_CTRL_DRIVER_PRIV(id) (((id) & 0xffff) >= 0x1000)
803 800
804/* Used in the VIDIOC_QUERYCTRL ioctl for querying controls */ 801/* Used in the VIDIOC_QUERYCTRL ioctl for querying controls */
805struct v4l2_queryctrl 802struct v4l2_queryctrl {
806{
807 __u32 id; 803 __u32 id;
808 enum v4l2_ctrl_type type; 804 enum v4l2_ctrl_type type;
809 __u8 name[32]; /* Whatever */ 805 __u8 name[32]; /* Whatever */
@@ -816,8 +812,7 @@ struct v4l2_queryctrl
816}; 812};
817 813
818/* Used in the VIDIOC_QUERYMENU ioctl for querying menu items */ 814/* Used in the VIDIOC_QUERYMENU ioctl for querying menu items */
819struct v4l2_querymenu 815struct v4l2_querymenu {
820{
821 __u32 id; 816 __u32 id;
822 __u32 index; 817 __u32 index;
823 __u8 name[32]; /* Whatever */ 818 __u8 name[32]; /* Whatever */
@@ -922,6 +917,8 @@ enum v4l2_mpeg_audio_encoding {
922 V4L2_MPEG_AUDIO_ENCODING_LAYER_1 = 0, 917 V4L2_MPEG_AUDIO_ENCODING_LAYER_1 = 0,
923 V4L2_MPEG_AUDIO_ENCODING_LAYER_2 = 1, 918 V4L2_MPEG_AUDIO_ENCODING_LAYER_2 = 1,
924 V4L2_MPEG_AUDIO_ENCODING_LAYER_3 = 2, 919 V4L2_MPEG_AUDIO_ENCODING_LAYER_3 = 2,
920 V4L2_MPEG_AUDIO_ENCODING_AAC = 3,
921 V4L2_MPEG_AUDIO_ENCODING_AC3 = 4,
925}; 922};
926#define V4L2_CID_MPEG_AUDIO_L1_BITRATE (V4L2_CID_MPEG_BASE+102) 923#define V4L2_CID_MPEG_AUDIO_L1_BITRATE (V4L2_CID_MPEG_BASE+102)
927enum v4l2_mpeg_audio_l1_bitrate { 924enum v4l2_mpeg_audio_l1_bitrate {
@@ -1000,12 +997,36 @@ enum v4l2_mpeg_audio_crc {
1000 V4L2_MPEG_AUDIO_CRC_CRC16 = 1, 997 V4L2_MPEG_AUDIO_CRC_CRC16 = 1,
1001}; 998};
1002#define V4L2_CID_MPEG_AUDIO_MUTE (V4L2_CID_MPEG_BASE+109) 999#define V4L2_CID_MPEG_AUDIO_MUTE (V4L2_CID_MPEG_BASE+109)
1000#define V4L2_CID_MPEG_AUDIO_AAC_BITRATE (V4L2_CID_MPEG_BASE+110)
1001#define V4L2_CID_MPEG_AUDIO_AC3_BITRATE (V4L2_CID_MPEG_BASE+111)
1002enum v4l2_mpeg_audio_ac3_bitrate {
1003 V4L2_MPEG_AUDIO_AC3_BITRATE_32K = 0,
1004 V4L2_MPEG_AUDIO_AC3_BITRATE_40K = 1,
1005 V4L2_MPEG_AUDIO_AC3_BITRATE_48K = 2,
1006 V4L2_MPEG_AUDIO_AC3_BITRATE_56K = 3,
1007 V4L2_MPEG_AUDIO_AC3_BITRATE_64K = 4,
1008 V4L2_MPEG_AUDIO_AC3_BITRATE_80K = 5,
1009 V4L2_MPEG_AUDIO_AC3_BITRATE_96K = 6,
1010 V4L2_MPEG_AUDIO_AC3_BITRATE_112K = 7,
1011 V4L2_MPEG_AUDIO_AC3_BITRATE_128K = 8,
1012 V4L2_MPEG_AUDIO_AC3_BITRATE_160K = 9,
1013 V4L2_MPEG_AUDIO_AC3_BITRATE_192K = 10,
1014 V4L2_MPEG_AUDIO_AC3_BITRATE_224K = 11,
1015 V4L2_MPEG_AUDIO_AC3_BITRATE_256K = 12,
1016 V4L2_MPEG_AUDIO_AC3_BITRATE_320K = 13,
1017 V4L2_MPEG_AUDIO_AC3_BITRATE_384K = 14,
1018 V4L2_MPEG_AUDIO_AC3_BITRATE_448K = 15,
1019 V4L2_MPEG_AUDIO_AC3_BITRATE_512K = 16,
1020 V4L2_MPEG_AUDIO_AC3_BITRATE_576K = 17,
1021 V4L2_MPEG_AUDIO_AC3_BITRATE_640K = 18,
1022};
1003 1023
1004/* MPEG video */ 1024/* MPEG video */
1005#define V4L2_CID_MPEG_VIDEO_ENCODING (V4L2_CID_MPEG_BASE+200) 1025#define V4L2_CID_MPEG_VIDEO_ENCODING (V4L2_CID_MPEG_BASE+200)
1006enum v4l2_mpeg_video_encoding { 1026enum v4l2_mpeg_video_encoding {
1007 V4L2_MPEG_VIDEO_ENCODING_MPEG_1 = 0, 1027 V4L2_MPEG_VIDEO_ENCODING_MPEG_1 = 0,
1008 V4L2_MPEG_VIDEO_ENCODING_MPEG_2 = 1, 1028 V4L2_MPEG_VIDEO_ENCODING_MPEG_2 = 1,
1029 V4L2_MPEG_VIDEO_ENCODING_MPEG_4_AVC = 2,
1009}; 1030};
1010#define V4L2_CID_MPEG_VIDEO_ASPECT (V4L2_CID_MPEG_BASE+201) 1031#define V4L2_CID_MPEG_VIDEO_ASPECT (V4L2_CID_MPEG_BASE+201)
1011enum v4l2_mpeg_video_aspect { 1032enum v4l2_mpeg_video_aspect {
@@ -1099,8 +1120,7 @@ enum v4l2_exposure_auto_type {
1099/* 1120/*
1100 * T U N I N G 1121 * T U N I N G
1101 */ 1122 */
1102struct v4l2_tuner 1123struct v4l2_tuner {
1103{
1104 __u32 index; 1124 __u32 index;
1105 __u8 name[32]; 1125 __u8 name[32];
1106 enum v4l2_tuner_type type; 1126 enum v4l2_tuner_type type;
@@ -1114,8 +1134,7 @@ struct v4l2_tuner
1114 __u32 reserved[4]; 1134 __u32 reserved[4];
1115}; 1135};
1116 1136
1117struct v4l2_modulator 1137struct v4l2_modulator {
1118{
1119 __u32 index; 1138 __u32 index;
1120 __u8 name[32]; 1139 __u8 name[32];
1121 __u32 capability; 1140 __u32 capability;
@@ -1148,19 +1167,25 @@ struct v4l2_modulator
1148#define V4L2_TUNER_MODE_LANG1 0x0003 1167#define V4L2_TUNER_MODE_LANG1 0x0003
1149#define V4L2_TUNER_MODE_LANG1_LANG2 0x0004 1168#define V4L2_TUNER_MODE_LANG1_LANG2 0x0004
1150 1169
1151struct v4l2_frequency 1170struct v4l2_frequency {
1152{
1153 __u32 tuner; 1171 __u32 tuner;
1154 enum v4l2_tuner_type type; 1172 enum v4l2_tuner_type type;
1155 __u32 frequency; 1173 __u32 frequency;
1156 __u32 reserved[8]; 1174 __u32 reserved[8];
1157}; 1175};
1158 1176
1177struct v4l2_hw_freq_seek {
1178 __u32 tuner;
1179 enum v4l2_tuner_type type;
1180 __u32 seek_upward;
1181 __u32 wrap_around;
1182 __u32 reserved[8];
1183};
1184
1159/* 1185/*
1160 * A U D I O 1186 * A U D I O
1161 */ 1187 */
1162struct v4l2_audio 1188struct v4l2_audio {
1163{
1164 __u32 index; 1189 __u32 index;
1165 __u8 name[32]; 1190 __u8 name[32];
1166 __u32 capability; 1191 __u32 capability;
@@ -1175,8 +1200,7 @@ struct v4l2_audio
1175/* Flags for the 'mode' field */ 1200/* Flags for the 'mode' field */
1176#define V4L2_AUDMODE_AVL 0x00001 1201#define V4L2_AUDMODE_AVL 0x00001
1177 1202
1178struct v4l2_audioout 1203struct v4l2_audioout {
1179{
1180 __u32 index; 1204 __u32 index;
1181 __u8 name[32]; 1205 __u8 name[32];
1182 __u32 capability; 1206 __u32 capability;
@@ -1240,8 +1264,7 @@ struct v4l2_encoder_cmd {
1240 */ 1264 */
1241 1265
1242/* Raw VBI */ 1266/* Raw VBI */
1243struct v4l2_vbi_format 1267struct v4l2_vbi_format {
1244{
1245 __u32 sampling_rate; /* in 1 Hz */ 1268 __u32 sampling_rate; /* in 1 Hz */
1246 __u32 offset; 1269 __u32 offset;
1247 __u32 samples_per_line; 1270 __u32 samples_per_line;
@@ -1253,8 +1276,8 @@ struct v4l2_vbi_format
1253}; 1276};
1254 1277
1255/* VBI flags */ 1278/* VBI flags */
1256#define V4L2_VBI_UNSYNC (1<< 0) 1279#define V4L2_VBI_UNSYNC (1 << 0)
1257#define V4L2_VBI_INTERLACED (1<< 1) 1280#define V4L2_VBI_INTERLACED (1 << 1)
1258 1281
1259/* Sliced VBI 1282/* Sliced VBI
1260 * 1283 *
@@ -1263,8 +1286,7 @@ struct v4l2_vbi_format
1263 * notice in the definitive implementation. 1286 * notice in the definitive implementation.
1264 */ 1287 */
1265 1288
1266struct v4l2_sliced_vbi_format 1289struct v4l2_sliced_vbi_format {
1267{
1268 __u16 service_set; 1290 __u16 service_set;
1269 /* service_lines[0][...] specifies lines 0-23 (1-23 used) of the first field 1291 /* service_lines[0][...] specifies lines 0-23 (1-23 used) of the first field
1270 service_lines[1][...] specifies lines 0-23 (1-23 used) of the second field 1292 service_lines[1][...] specifies lines 0-23 (1-23 used) of the second field
@@ -1288,8 +1310,7 @@ struct v4l2_sliced_vbi_format
1288#define V4L2_SLICED_VBI_525 (V4L2_SLICED_CAPTION_525) 1310#define V4L2_SLICED_VBI_525 (V4L2_SLICED_CAPTION_525)
1289#define V4L2_SLICED_VBI_625 (V4L2_SLICED_TELETEXT_B | V4L2_SLICED_VPS | V4L2_SLICED_WSS_625) 1311#define V4L2_SLICED_VBI_625 (V4L2_SLICED_TELETEXT_B | V4L2_SLICED_VPS | V4L2_SLICED_WSS_625)
1290 1312
1291struct v4l2_sliced_vbi_cap 1313struct v4l2_sliced_vbi_cap {
1292{
1293 __u16 service_set; 1314 __u16 service_set;
1294 /* service_lines[0][...] specifies lines 0-23 (1-23 used) of the first field 1315 /* service_lines[0][...] specifies lines 0-23 (1-23 used) of the first field
1295 service_lines[1][...] specifies lines 0-23 (1-23 used) of the second field 1316 service_lines[1][...] specifies lines 0-23 (1-23 used) of the second field
@@ -1300,8 +1321,7 @@ struct v4l2_sliced_vbi_cap
1300 __u32 reserved[3]; /* must be 0 */ 1321 __u32 reserved[3]; /* must be 0 */
1301}; 1322};
1302 1323
1303struct v4l2_sliced_vbi_data 1324struct v4l2_sliced_vbi_data {
1304{
1305 __u32 id; 1325 __u32 id;
1306 __u32 field; /* 0: first field, 1: second field */ 1326 __u32 field; /* 0: first field, 1: second field */
1307 __u32 line; /* 1-23 */ 1327 __u32 line; /* 1-23 */
@@ -1315,27 +1335,23 @@ struct v4l2_sliced_vbi_data
1315 1335
1316/* Stream data format 1336/* Stream data format
1317 */ 1337 */
1318struct v4l2_format 1338struct v4l2_format {
1319{
1320 enum v4l2_buf_type type; 1339 enum v4l2_buf_type type;
1321 union 1340 union {
1322 { 1341 struct v4l2_pix_format pix; /* V4L2_BUF_TYPE_VIDEO_CAPTURE */
1323 struct v4l2_pix_format pix; // V4L2_BUF_TYPE_VIDEO_CAPTURE 1342 struct v4l2_window win; /* V4L2_BUF_TYPE_VIDEO_OVERLAY */
1324 struct v4l2_window win; // V4L2_BUF_TYPE_VIDEO_OVERLAY 1343 struct v4l2_vbi_format vbi; /* V4L2_BUF_TYPE_VBI_CAPTURE */
1325 struct v4l2_vbi_format vbi; // V4L2_BUF_TYPE_VBI_CAPTURE 1344 struct v4l2_sliced_vbi_format sliced; /* V4L2_BUF_TYPE_SLICED_VBI_CAPTURE */
1326 struct v4l2_sliced_vbi_format sliced; // V4L2_BUF_TYPE_SLICED_VBI_CAPTURE 1345 __u8 raw_data[200]; /* user-defined */
1327 __u8 raw_data[200]; // user-defined
1328 } fmt; 1346 } fmt;
1329}; 1347};
1330 1348
1331 1349
1332/* Stream type-dependent parameters 1350/* Stream type-dependent parameters
1333 */ 1351 */
1334struct v4l2_streamparm 1352struct v4l2_streamparm {
1335{
1336 enum v4l2_buf_type type; 1353 enum v4l2_buf_type type;
1337 union 1354 union {
1338 {
1339 struct v4l2_captureparm capture; 1355 struct v4l2_captureparm capture;
1340 struct v4l2_outputparm output; 1356 struct v4l2_outputparm output;
1341 __u8 raw_data[200]; /* user-defined */ 1357 __u8 raw_data[200]; /* user-defined */
@@ -1373,91 +1389,86 @@ struct v4l2_chip_ident {
1373 * I O C T L C O D E S F O R V I D E O D E V I C E S 1389 * I O C T L C O D E S F O R V I D E O D E V I C E S
1374 * 1390 *
1375 */ 1391 */
1376#define VIDIOC_QUERYCAP _IOR ('V', 0, struct v4l2_capability) 1392#define VIDIOC_QUERYCAP _IOR('V', 0, struct v4l2_capability)
1377#define VIDIOC_RESERVED _IO ('V', 1) 1393#define VIDIOC_RESERVED _IO('V', 1)
1378#define VIDIOC_ENUM_FMT _IOWR ('V', 2, struct v4l2_fmtdesc) 1394#define VIDIOC_ENUM_FMT _IOWR('V', 2, struct v4l2_fmtdesc)
1379#define VIDIOC_G_FMT _IOWR ('V', 4, struct v4l2_format) 1395#define VIDIOC_G_FMT _IOWR('V', 4, struct v4l2_format)
1380#define VIDIOC_S_FMT _IOWR ('V', 5, struct v4l2_format) 1396#define VIDIOC_S_FMT _IOWR('V', 5, struct v4l2_format)
1381#define VIDIOC_REQBUFS _IOWR ('V', 8, struct v4l2_requestbuffers) 1397#define VIDIOC_REQBUFS _IOWR('V', 8, struct v4l2_requestbuffers)
1382#define VIDIOC_QUERYBUF _IOWR ('V', 9, struct v4l2_buffer) 1398#define VIDIOC_QUERYBUF _IOWR('V', 9, struct v4l2_buffer)
1383#define VIDIOC_G_FBUF _IOR ('V', 10, struct v4l2_framebuffer) 1399#define VIDIOC_G_FBUF _IOR('V', 10, struct v4l2_framebuffer)
1384#define VIDIOC_S_FBUF _IOW ('V', 11, struct v4l2_framebuffer) 1400#define VIDIOC_S_FBUF _IOW('V', 11, struct v4l2_framebuffer)
1385#define VIDIOC_OVERLAY _IOW ('V', 14, int) 1401#define VIDIOC_OVERLAY _IOW('V', 14, int)
1386#define VIDIOC_QBUF _IOWR ('V', 15, struct v4l2_buffer) 1402#define VIDIOC_QBUF _IOWR('V', 15, struct v4l2_buffer)
1387#define VIDIOC_DQBUF _IOWR ('V', 17, struct v4l2_buffer) 1403#define VIDIOC_DQBUF _IOWR('V', 17, struct v4l2_buffer)
1388#define VIDIOC_STREAMON _IOW ('V', 18, int) 1404#define VIDIOC_STREAMON _IOW('V', 18, int)
1389#define VIDIOC_STREAMOFF _IOW ('V', 19, int) 1405#define VIDIOC_STREAMOFF _IOW('V', 19, int)
1390#define VIDIOC_G_PARM _IOWR ('V', 21, struct v4l2_streamparm) 1406#define VIDIOC_G_PARM _IOWR('V', 21, struct v4l2_streamparm)
1391#define VIDIOC_S_PARM _IOWR ('V', 22, struct v4l2_streamparm) 1407#define VIDIOC_S_PARM _IOWR('V', 22, struct v4l2_streamparm)
1392#define VIDIOC_G_STD _IOR ('V', 23, v4l2_std_id) 1408#define VIDIOC_G_STD _IOR('V', 23, v4l2_std_id)
1393#define VIDIOC_S_STD _IOW ('V', 24, v4l2_std_id) 1409#define VIDIOC_S_STD _IOW('V', 24, v4l2_std_id)
1394#define VIDIOC_ENUMSTD _IOWR ('V', 25, struct v4l2_standard) 1410#define VIDIOC_ENUMSTD _IOWR('V', 25, struct v4l2_standard)
1395#define VIDIOC_ENUMINPUT _IOWR ('V', 26, struct v4l2_input) 1411#define VIDIOC_ENUMINPUT _IOWR('V', 26, struct v4l2_input)
1396#define VIDIOC_G_CTRL _IOWR ('V', 27, struct v4l2_control) 1412#define VIDIOC_G_CTRL _IOWR('V', 27, struct v4l2_control)
1397#define VIDIOC_S_CTRL _IOWR ('V', 28, struct v4l2_control) 1413#define VIDIOC_S_CTRL _IOWR('V', 28, struct v4l2_control)
1398#define VIDIOC_G_TUNER _IOWR ('V', 29, struct v4l2_tuner) 1414#define VIDIOC_G_TUNER _IOWR('V', 29, struct v4l2_tuner)
1399#define VIDIOC_S_TUNER _IOW ('V', 30, struct v4l2_tuner) 1415#define VIDIOC_S_TUNER _IOW('V', 30, struct v4l2_tuner)
1400#define VIDIOC_G_AUDIO _IOR ('V', 33, struct v4l2_audio) 1416#define VIDIOC_G_AUDIO _IOR('V', 33, struct v4l2_audio)
1401#define VIDIOC_S_AUDIO _IOW ('V', 34, struct v4l2_audio) 1417#define VIDIOC_S_AUDIO _IOW('V', 34, struct v4l2_audio)
1402#define VIDIOC_QUERYCTRL _IOWR ('V', 36, struct v4l2_queryctrl) 1418#define VIDIOC_QUERYCTRL _IOWR('V', 36, struct v4l2_queryctrl)
1403#define VIDIOC_QUERYMENU _IOWR ('V', 37, struct v4l2_querymenu) 1419#define VIDIOC_QUERYMENU _IOWR('V', 37, struct v4l2_querymenu)
1404#define VIDIOC_G_INPUT _IOR ('V', 38, int) 1420#define VIDIOC_G_INPUT _IOR('V', 38, int)
1405#define VIDIOC_S_INPUT _IOWR ('V', 39, int) 1421#define VIDIOC_S_INPUT _IOWR('V', 39, int)
1406#define VIDIOC_G_OUTPUT _IOR ('V', 46, int) 1422#define VIDIOC_G_OUTPUT _IOR('V', 46, int)
1407#define VIDIOC_S_OUTPUT _IOWR ('V', 47, int) 1423#define VIDIOC_S_OUTPUT _IOWR('V', 47, int)
1408#define VIDIOC_ENUMOUTPUT _IOWR ('V', 48, struct v4l2_output) 1424#define VIDIOC_ENUMOUTPUT _IOWR('V', 48, struct v4l2_output)
1409#define VIDIOC_G_AUDOUT _IOR ('V', 49, struct v4l2_audioout) 1425#define VIDIOC_G_AUDOUT _IOR('V', 49, struct v4l2_audioout)
1410#define VIDIOC_S_AUDOUT _IOW ('V', 50, struct v4l2_audioout) 1426#define VIDIOC_S_AUDOUT _IOW('V', 50, struct v4l2_audioout)
1411#define VIDIOC_G_MODULATOR _IOWR ('V', 54, struct v4l2_modulator) 1427#define VIDIOC_G_MODULATOR _IOWR('V', 54, struct v4l2_modulator)
1412#define VIDIOC_S_MODULATOR _IOW ('V', 55, struct v4l2_modulator) 1428#define VIDIOC_S_MODULATOR _IOW('V', 55, struct v4l2_modulator)
1413#define VIDIOC_G_FREQUENCY _IOWR ('V', 56, struct v4l2_frequency) 1429#define VIDIOC_G_FREQUENCY _IOWR('V', 56, struct v4l2_frequency)
1414#define VIDIOC_S_FREQUENCY _IOW ('V', 57, struct v4l2_frequency) 1430#define VIDIOC_S_FREQUENCY _IOW('V', 57, struct v4l2_frequency)
1415#define VIDIOC_CROPCAP _IOWR ('V', 58, struct v4l2_cropcap) 1431#define VIDIOC_CROPCAP _IOWR('V', 58, struct v4l2_cropcap)
1416#define VIDIOC_G_CROP _IOWR ('V', 59, struct v4l2_crop) 1432#define VIDIOC_G_CROP _IOWR('V', 59, struct v4l2_crop)
1417#define VIDIOC_S_CROP _IOW ('V', 60, struct v4l2_crop) 1433#define VIDIOC_S_CROP _IOW('V', 60, struct v4l2_crop)
1418#define VIDIOC_G_JPEGCOMP _IOR ('V', 61, struct v4l2_jpegcompression) 1434#define VIDIOC_G_JPEGCOMP _IOR('V', 61, struct v4l2_jpegcompression)
1419#define VIDIOC_S_JPEGCOMP _IOW ('V', 62, struct v4l2_jpegcompression) 1435#define VIDIOC_S_JPEGCOMP _IOW('V', 62, struct v4l2_jpegcompression)
1420#define VIDIOC_QUERYSTD _IOR ('V', 63, v4l2_std_id) 1436#define VIDIOC_QUERYSTD _IOR('V', 63, v4l2_std_id)
1421#define VIDIOC_TRY_FMT _IOWR ('V', 64, struct v4l2_format) 1437#define VIDIOC_TRY_FMT _IOWR('V', 64, struct v4l2_format)
1422#define VIDIOC_ENUMAUDIO _IOWR ('V', 65, struct v4l2_audio) 1438#define VIDIOC_ENUMAUDIO _IOWR('V', 65, struct v4l2_audio)
1423#define VIDIOC_ENUMAUDOUT _IOWR ('V', 66, struct v4l2_audioout) 1439#define VIDIOC_ENUMAUDOUT _IOWR('V', 66, struct v4l2_audioout)
1424#define VIDIOC_G_PRIORITY _IOR ('V', 67, enum v4l2_priority) 1440#define VIDIOC_G_PRIORITY _IOR('V', 67, enum v4l2_priority)
1425#define VIDIOC_S_PRIORITY _IOW ('V', 68, enum v4l2_priority) 1441#define VIDIOC_S_PRIORITY _IOW('V', 68, enum v4l2_priority)
1426#define VIDIOC_G_SLICED_VBI_CAP _IOWR ('V', 69, struct v4l2_sliced_vbi_cap) 1442#define VIDIOC_G_SLICED_VBI_CAP _IOWR('V', 69, struct v4l2_sliced_vbi_cap)
1427#define VIDIOC_LOG_STATUS _IO ('V', 70) 1443#define VIDIOC_LOG_STATUS _IO('V', 70)
1428#define VIDIOC_G_EXT_CTRLS _IOWR ('V', 71, struct v4l2_ext_controls) 1444#define VIDIOC_G_EXT_CTRLS _IOWR('V', 71, struct v4l2_ext_controls)
1429#define VIDIOC_S_EXT_CTRLS _IOWR ('V', 72, struct v4l2_ext_controls) 1445#define VIDIOC_S_EXT_CTRLS _IOWR('V', 72, struct v4l2_ext_controls)
1430#define VIDIOC_TRY_EXT_CTRLS _IOWR ('V', 73, struct v4l2_ext_controls) 1446#define VIDIOC_TRY_EXT_CTRLS _IOWR('V', 73, struct v4l2_ext_controls)
1431#if 1 1447#if 1
1432#define VIDIOC_ENUM_FRAMESIZES _IOWR ('V', 74, struct v4l2_frmsizeenum) 1448#define VIDIOC_ENUM_FRAMESIZES _IOWR('V', 74, struct v4l2_frmsizeenum)
1433#define VIDIOC_ENUM_FRAMEINTERVALS _IOWR ('V', 75, struct v4l2_frmivalenum) 1449#define VIDIOC_ENUM_FRAMEINTERVALS _IOWR('V', 75, struct v4l2_frmivalenum)
1434#define VIDIOC_G_ENC_INDEX _IOR ('V', 76, struct v4l2_enc_idx) 1450#define VIDIOC_G_ENC_INDEX _IOR('V', 76, struct v4l2_enc_idx)
1435#define VIDIOC_ENCODER_CMD _IOWR ('V', 77, struct v4l2_encoder_cmd) 1451#define VIDIOC_ENCODER_CMD _IOWR('V', 77, struct v4l2_encoder_cmd)
1436#define VIDIOC_TRY_ENCODER_CMD _IOWR ('V', 78, struct v4l2_encoder_cmd) 1452#define VIDIOC_TRY_ENCODER_CMD _IOWR('V', 78, struct v4l2_encoder_cmd)
1437 1453
1438/* Experimental, only implemented if CONFIG_VIDEO_ADV_DEBUG is defined */ 1454/* Experimental, only implemented if CONFIG_VIDEO_ADV_DEBUG is defined */
1439#define VIDIOC_DBG_S_REGISTER _IOW ('V', 79, struct v4l2_register) 1455#define VIDIOC_DBG_S_REGISTER _IOW('V', 79, struct v4l2_register)
1440#define VIDIOC_DBG_G_REGISTER _IOWR ('V', 80, struct v4l2_register) 1456#define VIDIOC_DBG_G_REGISTER _IOWR('V', 80, struct v4l2_register)
1441 1457
1442#define VIDIOC_G_CHIP_IDENT _IOWR ('V', 81, struct v4l2_chip_ident) 1458#define VIDIOC_G_CHIP_IDENT _IOWR('V', 81, struct v4l2_chip_ident)
1443#endif 1459#endif
1460#define VIDIOC_S_HW_FREQ_SEEK _IOW('V', 82, struct v4l2_hw_freq_seek)
1444 1461
1445#ifdef __OLD_VIDIOC_ 1462#ifdef __OLD_VIDIOC_
1446/* for compatibility, will go away some day */ 1463/* for compatibility, will go away some day */
1447#define VIDIOC_OVERLAY_OLD _IOWR ('V', 14, int) 1464#define VIDIOC_OVERLAY_OLD _IOWR('V', 14, int)
1448#define VIDIOC_S_PARM_OLD _IOW ('V', 22, struct v4l2_streamparm) 1465#define VIDIOC_S_PARM_OLD _IOW('V', 22, struct v4l2_streamparm)
1449#define VIDIOC_S_CTRL_OLD _IOW ('V', 28, struct v4l2_control) 1466#define VIDIOC_S_CTRL_OLD _IOW('V', 28, struct v4l2_control)
1450#define VIDIOC_G_AUDIO_OLD _IOWR ('V', 33, struct v4l2_audio) 1467#define VIDIOC_G_AUDIO_OLD _IOWR('V', 33, struct v4l2_audio)
1451#define VIDIOC_G_AUDOUT_OLD _IOWR ('V', 49, struct v4l2_audioout) 1468#define VIDIOC_G_AUDOUT_OLD _IOWR('V', 49, struct v4l2_audioout)
1452#define VIDIOC_CROPCAP_OLD _IOR ('V', 58, struct v4l2_cropcap) 1469#define VIDIOC_CROPCAP_OLD _IOR('V', 58, struct v4l2_cropcap)
1453#endif 1470#endif
1454 1471
1455#define BASE_VIDIOC_PRIVATE 192 /* 192-255 are private */ 1472#define BASE_VIDIOC_PRIVATE 192 /* 192-255 are private */
1456 1473
1457#endif /* __LINUX_VIDEODEV2_H */ 1474#endif /* __LINUX_VIDEODEV2_H */
1458
1459/*
1460 * Local variables:
1461 * c-basic-offset: 8
1462 * End:
1463 */
diff --git a/include/linux/videotext.h b/include/linux/videotext.h
index 018f92047ff8..3e68c8d1c7f7 100644
--- a/include/linux/videotext.h
+++ b/include/linux/videotext.h
@@ -45,10 +45,10 @@
45#define VTXIOCCLRCACHE_OLD 0x710b /* clear cache on VTX-interface (if avail.) */ 45#define VTXIOCCLRCACHE_OLD 0x710b /* clear cache on VTX-interface (if avail.) */
46#define VTXIOCSETVIRT_OLD 0x710c /* turn on virtual mode (this disables TV-display) */ 46#define VTXIOCSETVIRT_OLD 0x710c /* turn on virtual mode (this disables TV-display) */
47 47
48/* 48/*
49 * Definitions for VTXIOCGETINFO 49 * Definitions for VTXIOCGETINFO
50 */ 50 */
51 51
52#define SAA5243 0 52#define SAA5243 0
53#define SAA5246 1 53#define SAA5246 1
54#define SAA5249 2 54#define SAA5249 2
@@ -57,10 +57,10 @@
57 57
58typedef struct { 58typedef struct {
59 int version_major, version_minor; /* version of driver; if version_major changes, driver */ 59 int version_major, version_minor; /* version of driver; if version_major changes, driver */
60 /* is not backward compatible!!! CHECK THIS!!! */ 60 /* is not backward compatible!!! CHECK THIS!!! */
61 int numpages; /* number of page-buffers of vtx-chipset */ 61 int numpages; /* number of page-buffers of vtx-chipset */
62 int cct_type; /* type of vtx-chipset (SAA5243, SAA5246, SAA5248 or 62 int cct_type; /* type of vtx-chipset (SAA5243, SAA5246, SAA5248 or
63 * SAA5249) */ 63 * SAA5249) */
64} 64}
65vtx_info_t; 65vtx_info_t;
66 66
@@ -81,7 +81,7 @@ vtx_info_t;
81#define PGMASK_HOUR (HR_TEN | HR_UNIT) 81#define PGMASK_HOUR (HR_TEN | HR_UNIT)
82#define PGMASK_MINUTE (MIN_TEN | MIN_UNIT) 82#define PGMASK_MINUTE (MIN_TEN | MIN_UNIT)
83 83
84typedef struct 84typedef struct
85{ 85{
86 int page; /* number of requested page (hexadecimal) */ 86 int page; /* number of requested page (hexadecimal) */
87 int hour; /* requested hour (hexadecimal) */ 87 int hour; /* requested hour (hexadecimal) */
@@ -98,11 +98,11 @@ vtx_pagereq_t;
98/* 98/*
99 * Definitions for VTXIOC{GETSTAT,PUTSTAT} 99 * Definitions for VTXIOC{GETSTAT,PUTSTAT}
100 */ 100 */
101 101
102#define VTX_PAGESIZE (40 * 24) 102#define VTX_PAGESIZE (40 * 24)
103#define VTX_VIRTUALSIZE (40 * 49) 103#define VTX_VIRTUALSIZE (40 * 49)
104 104
105typedef struct 105typedef struct
106{ 106{
107 int pagenum; /* number of page (hexadecimal) */ 107 int pagenum; /* number of page (hexadecimal) */
108 int hour; /* hour (hexadecimal) */ 108 int hour; /* hour (hexadecimal) */
@@ -121,5 +121,5 @@ typedef struct
121 unsigned hamming : 1; /* hamming-error occurred */ 121 unsigned hamming : 1; /* hamming-error occurred */
122} 122}
123vtx_pageinfo_t; 123vtx_pageinfo_t;
124 124
125#endif /* _VTX_H */ 125#endif /* _VTX_H */
diff --git a/include/linux/virtio_9p.h b/include/linux/virtio_9p.h
index 8eff0b53910b..b3c4a60ceeb3 100644
--- a/include/linux/virtio_9p.h
+++ b/include/linux/virtio_9p.h
@@ -1,5 +1,7 @@
1#ifndef _LINUX_VIRTIO_9P_H 1#ifndef _LINUX_VIRTIO_9P_H
2#define _LINUX_VIRTIO_9P_H 2#define _LINUX_VIRTIO_9P_H
3/* This header is BSD licensed so anyone can use the definitions to implement
4 * compatible drivers/servers. */
3#include <linux/virtio_config.h> 5#include <linux/virtio_config.h>
4 6
5/* The ID for virtio console */ 7/* The ID for virtio console */
diff --git a/include/linux/virtio_balloon.h b/include/linux/virtio_balloon.h
index 979524ee75b7..c30c7bfbf39b 100644
--- a/include/linux/virtio_balloon.h
+++ b/include/linux/virtio_balloon.h
@@ -1,5 +1,7 @@
1#ifndef _LINUX_VIRTIO_BALLOON_H 1#ifndef _LINUX_VIRTIO_BALLOON_H
2#define _LINUX_VIRTIO_BALLOON_H 2#define _LINUX_VIRTIO_BALLOON_H
3/* This header is BSD licensed so anyone can use the definitions to implement
4 * compatible drivers/servers. */
3#include <linux/virtio_config.h> 5#include <linux/virtio_config.h>
4 6
5/* The ID for virtio_balloon */ 7/* The ID for virtio_balloon */
diff --git a/include/linux/virtio_blk.h b/include/linux/virtio_blk.h
index 5f79a5f9de79..c1aef85243bf 100644
--- a/include/linux/virtio_blk.h
+++ b/include/linux/virtio_blk.h
@@ -1,5 +1,7 @@
1#ifndef _LINUX_VIRTIO_BLK_H 1#ifndef _LINUX_VIRTIO_BLK_H
2#define _LINUX_VIRTIO_BLK_H 2#define _LINUX_VIRTIO_BLK_H
3/* This header is BSD licensed so anyone can use the definitions to implement
4 * compatible drivers/servers. */
3#include <linux/virtio_config.h> 5#include <linux/virtio_config.h>
4 6
5/* The ID for virtio_block */ 7/* The ID for virtio_block */
@@ -11,6 +13,7 @@
11#define VIRTIO_BLK_F_SEG_MAX 2 /* Indicates maximum # of segments */ 13#define VIRTIO_BLK_F_SEG_MAX 2 /* Indicates maximum # of segments */
12#define VIRTIO_BLK_F_GEOMETRY 4 /* Legacy geometry available */ 14#define VIRTIO_BLK_F_GEOMETRY 4 /* Legacy geometry available */
13#define VIRTIO_BLK_F_RO 5 /* Disk is read-only */ 15#define VIRTIO_BLK_F_RO 5 /* Disk is read-only */
16#define VIRTIO_BLK_F_BLK_SIZE 6 /* Block size of disk is available*/
14 17
15struct virtio_blk_config 18struct virtio_blk_config
16{ 19{
@@ -26,6 +29,8 @@ struct virtio_blk_config
26 __u8 heads; 29 __u8 heads;
27 __u8 sectors; 30 __u8 sectors;
28 } geometry; 31 } geometry;
32 /* block size of device (if VIRTIO_BLK_F_BLK_SIZE) */
33 __u32 blk_size;
29} __attribute__((packed)); 34} __attribute__((packed));
30 35
31/* These two define direction. */ 36/* These two define direction. */
diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h
index f364bbf63c34..bf8ec283b232 100644
--- a/include/linux/virtio_config.h
+++ b/include/linux/virtio_config.h
@@ -1,5 +1,8 @@
1#ifndef _LINUX_VIRTIO_CONFIG_H 1#ifndef _LINUX_VIRTIO_CONFIG_H
2#define _LINUX_VIRTIO_CONFIG_H 2#define _LINUX_VIRTIO_CONFIG_H
3/* This header, excluding the #ifdef __KERNEL__ part, is BSD licensed so
4 * anyone can use the definitions to implement compatible drivers/servers. */
5
3/* Virtio devices use a standardized configuration space to define their 6/* Virtio devices use a standardized configuration space to define their
4 * features and pass configuration information, but each implementation can 7 * features and pass configuration information, but each implementation can
5 * store and access that space differently. */ 8 * store and access that space differently. */
@@ -15,6 +18,12 @@
15/* We've given up on this device. */ 18/* We've given up on this device. */
16#define VIRTIO_CONFIG_S_FAILED 0x80 19#define VIRTIO_CONFIG_S_FAILED 0x80
17 20
21/* Some virtio feature bits (currently bits 28 through 31) are reserved for the
22 * transport being used (eg. virtio_ring), the rest are per-device feature
23 * bits. */
24#define VIRTIO_TRANSPORT_F_START 28
25#define VIRTIO_TRANSPORT_F_END 32
26
18/* Do we get callbacks when the ring is completely used, even if we've 27/* Do we get callbacks when the ring is completely used, even if we've
19 * suppressed them? */ 28 * suppressed them? */
20#define VIRTIO_F_NOTIFY_ON_EMPTY 24 29#define VIRTIO_F_NOTIFY_ON_EMPTY 24
@@ -52,9 +61,10 @@
52 * @get_features: get the array of feature bits for this device. 61 * @get_features: get the array of feature bits for this device.
53 * vdev: the virtio_device 62 * vdev: the virtio_device
54 * Returns the first 32 feature bits (all we currently need). 63 * Returns the first 32 feature bits (all we currently need).
55 * @set_features: confirm what device features we'll be using. 64 * @finalize_features: confirm what device features we'll be using.
56 * vdev: the virtio_device 65 * vdev: the virtio_device
57 * feature: the first 32 feature bits 66 * This gives the final feature bits for the device: it can change
67 * the dev->feature bits if it wants.
58 */ 68 */
59struct virtio_config_ops 69struct virtio_config_ops
60{ 70{
@@ -70,7 +80,7 @@ struct virtio_config_ops
70 void (*callback)(struct virtqueue *)); 80 void (*callback)(struct virtqueue *));
71 void (*del_vq)(struct virtqueue *vq); 81 void (*del_vq)(struct virtqueue *vq);
72 u32 (*get_features)(struct virtio_device *vdev); 82 u32 (*get_features)(struct virtio_device *vdev);
73 void (*set_features)(struct virtio_device *vdev, u32 features); 83 void (*finalize_features)(struct virtio_device *vdev);
74}; 84};
75 85
76/* If driver didn't advertise the feature, it will never appear. */ 86/* If driver didn't advertise the feature, it will never appear. */
diff --git a/include/linux/virtio_console.h b/include/linux/virtio_console.h
index ed2d4ead7eb7..19a0da0dba41 100644
--- a/include/linux/virtio_console.h
+++ b/include/linux/virtio_console.h
@@ -1,6 +1,8 @@
1#ifndef _LINUX_VIRTIO_CONSOLE_H 1#ifndef _LINUX_VIRTIO_CONSOLE_H
2#define _LINUX_VIRTIO_CONSOLE_H 2#define _LINUX_VIRTIO_CONSOLE_H
3#include <linux/virtio_config.h> 3#include <linux/virtio_config.h>
4/* This header, excluding the #ifdef __KERNEL__ part, is BSD licensed so
5 * anyone can use the definitions to implement compatible drivers/servers. */
4 6
5/* The ID for virtio console */ 7/* The ID for virtio console */
6#define VIRTIO_ID_CONSOLE 3 8#define VIRTIO_ID_CONSOLE 3
diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h
index 38c0571820fb..5e33761b9b8a 100644
--- a/include/linux/virtio_net.h
+++ b/include/linux/virtio_net.h
@@ -1,5 +1,7 @@
1#ifndef _LINUX_VIRTIO_NET_H 1#ifndef _LINUX_VIRTIO_NET_H
2#define _LINUX_VIRTIO_NET_H 2#define _LINUX_VIRTIO_NET_H
3/* This header is BSD licensed so anyone can use the definitions to implement
4 * compatible drivers/servers. */
3#include <linux/virtio_config.h> 5#include <linux/virtio_config.h>
4 6
5/* The ID for virtio_net */ 7/* The ID for virtio_net */
diff --git a/include/linux/virtio_pci.h b/include/linux/virtio_pci.h
index b3151659cf49..cdef35742932 100644
--- a/include/linux/virtio_pci.h
+++ b/include/linux/virtio_pci.h
@@ -9,9 +9,8 @@
9 * Authors: 9 * Authors:
10 * Anthony Liguori <aliguori@us.ibm.com> 10 * Anthony Liguori <aliguori@us.ibm.com>
11 * 11 *
12 * This work is licensed under the terms of the GNU GPL, version 2 or later. 12 * This header is BSD licensed so anyone can use the definitions to implement
13 * See the COPYING file in the top-level directory. 13 * compatible drivers/servers.
14 *
15 */ 14 */
16 15
17#ifndef _LINUX_VIRTIO_PCI_H 16#ifndef _LINUX_VIRTIO_PCI_H
diff --git a/include/linux/virtio_ring.h b/include/linux/virtio_ring.h
index abe481ed990e..c4a598fb3826 100644
--- a/include/linux/virtio_ring.h
+++ b/include/linux/virtio_ring.h
@@ -120,6 +120,8 @@ struct virtqueue *vring_new_virtqueue(unsigned int num,
120 void (*notify)(struct virtqueue *vq), 120 void (*notify)(struct virtqueue *vq),
121 void (*callback)(struct virtqueue *vq)); 121 void (*callback)(struct virtqueue *vq));
122void vring_del_virtqueue(struct virtqueue *vq); 122void vring_del_virtqueue(struct virtqueue *vq);
123/* Filter out transport-specific feature bits. */
124void vring_transport_features(struct virtio_device *vdev);
123 125
124irqreturn_t vring_interrupt(int irq, void *_vq); 126irqreturn_t vring_interrupt(int irq, void *_vq);
125#endif /* __KERNEL__ */ 127#endif /* __KERNEL__ */
diff --git a/include/linux/virtio_rng.h b/include/linux/virtio_rng.h
index 331afb6c9f62..1a85dab8a940 100644
--- a/include/linux/virtio_rng.h
+++ b/include/linux/virtio_rng.h
@@ -1,5 +1,7 @@
1#ifndef _LINUX_VIRTIO_RNG_H 1#ifndef _LINUX_VIRTIO_RNG_H
2#define _LINUX_VIRTIO_RNG_H 2#define _LINUX_VIRTIO_RNG_H
3/* This header is BSD licensed so anyone can use the definitions to implement
4 * compatible drivers/servers. */
3#include <linux/virtio_config.h> 5#include <linux/virtio_config.h>
4 6
5/* The ID for virtio_rng */ 7/* The ID for virtio_rng */
diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
index 364789aae9f3..307b88577eaa 100644
--- a/include/linux/vmalloc.h
+++ b/include/linux/vmalloc.h
@@ -2,11 +2,12 @@
2#define _LINUX_VMALLOC_H 2#define _LINUX_VMALLOC_H
3 3
4#include <linux/spinlock.h> 4#include <linux/spinlock.h>
5#include <linux/init.h>
5#include <asm/page.h> /* pgprot_t */ 6#include <asm/page.h> /* pgprot_t */
6 7
7struct vm_area_struct; 8struct vm_area_struct; /* vma defining user mapping in mm_types.h */
8 9
9/* bits in vm_struct->flags */ 10/* bits in flags of vmalloc's vm_struct below */
10#define VM_IOREMAP 0x00000001 /* ioremap() and friends */ 11#define VM_IOREMAP 0x00000001 /* ioremap() and friends */
11#define VM_ALLOC 0x00000002 /* vmalloc() */ 12#define VM_ALLOC 0x00000002 /* vmalloc() */
12#define VM_MAP 0x00000004 /* vmap()ed pages */ 13#define VM_MAP 0x00000004 /* vmap()ed pages */
@@ -23,7 +24,6 @@ struct vm_area_struct;
23#endif 24#endif
24 25
25struct vm_struct { 26struct vm_struct {
26 /* keep next,addr,size together to speedup lookups */
27 struct vm_struct *next; 27 struct vm_struct *next;
28 void *addr; 28 void *addr;
29 unsigned long size; 29 unsigned long size;
@@ -37,6 +37,19 @@ struct vm_struct {
37/* 37/*
38 * Highlevel APIs for driver use 38 * Highlevel APIs for driver use
39 */ 39 */
40extern void vm_unmap_ram(const void *mem, unsigned int count);
41extern void *vm_map_ram(struct page **pages, unsigned int count,
42 int node, pgprot_t prot);
43extern void vm_unmap_aliases(void);
44
45#ifdef CONFIG_MMU
46extern void __init vmalloc_init(void);
47#else
48static inline void vmalloc_init(void)
49{
50}
51#endif
52
40extern void *vmalloc(unsigned long size); 53extern void *vmalloc(unsigned long size);
41extern void *vmalloc_user(unsigned long size); 54extern void *vmalloc_user(unsigned long size);
42extern void *vmalloc_node(unsigned long size, int node); 55extern void *vmalloc_node(unsigned long size, int node);
@@ -90,6 +103,4 @@ extern void free_vm_area(struct vm_struct *area);
90extern rwlock_t vmlist_lock; 103extern rwlock_t vmlist_lock;
91extern struct vm_struct *vmlist; 104extern struct vm_struct *vmlist;
92 105
93extern const struct seq_operations vmalloc_op;
94
95#endif /* _LINUX_VMALLOC_H */ 106#endif /* _LINUX_VMALLOC_H */
diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
index e83b69346d23..524cd1b28ecb 100644
--- a/include/linux/vmstat.h
+++ b/include/linux/vmstat.h
@@ -41,9 +41,21 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
41#ifdef CONFIG_HUGETLB_PAGE 41#ifdef CONFIG_HUGETLB_PAGE
42 HTLB_BUDDY_PGALLOC, HTLB_BUDDY_PGALLOC_FAIL, 42 HTLB_BUDDY_PGALLOC, HTLB_BUDDY_PGALLOC_FAIL,
43#endif 43#endif
44#ifdef CONFIG_UNEVICTABLE_LRU
45 UNEVICTABLE_PGCULLED, /* culled to noreclaim list */
46 UNEVICTABLE_PGSCANNED, /* scanned for reclaimability */
47 UNEVICTABLE_PGRESCUED, /* rescued from noreclaim list */
48 UNEVICTABLE_PGMLOCKED,
49 UNEVICTABLE_PGMUNLOCKED,
50 UNEVICTABLE_PGCLEARED, /* on COW, page truncate */
51 UNEVICTABLE_PGSTRANDED, /* unable to isolate on unlock */
52 UNEVICTABLE_MLOCKFREED,
53#endif
44 NR_VM_EVENT_ITEMS 54 NR_VM_EVENT_ITEMS
45}; 55};
46 56
57extern int sysctl_stat_interval;
58
47#ifdef CONFIG_VM_EVENT_COUNTERS 59#ifdef CONFIG_VM_EVENT_COUNTERS
48/* 60/*
49 * Light weight per cpu counter implementation. 61 * Light weight per cpu counter implementation.
@@ -153,6 +165,16 @@ static inline unsigned long zone_page_state(struct zone *zone,
153 return x; 165 return x;
154} 166}
155 167
168extern unsigned long global_lru_pages(void);
169
170static inline unsigned long zone_lru_pages(struct zone *zone)
171{
172 return (zone_page_state(zone, NR_ACTIVE_ANON)
173 + zone_page_state(zone, NR_ACTIVE_FILE)
174 + zone_page_state(zone, NR_INACTIVE_ANON)
175 + zone_page_state(zone, NR_INACTIVE_FILE));
176}
177
156#ifdef CONFIG_NUMA 178#ifdef CONFIG_NUMA
157/* 179/*
158 * Determine the per node value of a stat item. This function 180 * Determine the per node value of a stat item. This function
diff --git a/include/linux/vt_kern.h b/include/linux/vt_kern.h
index 9448ffbdcbf6..2f1113467f70 100644
--- a/include/linux/vt_kern.h
+++ b/include/linux/vt_kern.h
@@ -12,6 +12,7 @@
12#include <linux/mutex.h> 12#include <linux/mutex.h>
13#include <linux/console_struct.h> 13#include <linux/console_struct.h>
14#include <linux/mm.h> 14#include <linux/mm.h>
15#include <linux/consolemap.h>
15 16
16/* 17/*
17 * Presently, a lot of graphics programs do not restore the contents of 18 * Presently, a lot of graphics programs do not restore the contents of
@@ -34,7 +35,6 @@ extern int fg_console, last_console, want_console;
34int vc_allocate(unsigned int console); 35int vc_allocate(unsigned int console);
35int vc_cons_allocated(unsigned int console); 36int vc_cons_allocated(unsigned int console);
36int vc_resize(struct vc_data *vc, unsigned int cols, unsigned int lines); 37int vc_resize(struct vc_data *vc, unsigned int cols, unsigned int lines);
37int vc_lock_resize(struct vc_data *vc, unsigned int cols, unsigned int lines);
38void vc_deallocate(unsigned int console); 38void vc_deallocate(unsigned int console);
39void reset_palette(struct vc_data *vc); 39void reset_palette(struct vc_data *vc);
40void do_blank_screen(int entering_gfx); 40void do_blank_screen(int entering_gfx);
@@ -54,6 +54,7 @@ void redraw_screen(struct vc_data *vc, int is_switch);
54struct tty_struct; 54struct tty_struct;
55int tioclinux(struct tty_struct *tty, unsigned long arg); 55int tioclinux(struct tty_struct *tty, unsigned long arg);
56 56
57#ifdef CONFIG_CONSOLE_TRANSLATIONS
57/* consolemap.c */ 58/* consolemap.c */
58 59
59struct unimapinit; 60struct unimapinit;
@@ -71,13 +72,31 @@ void con_free_unimap(struct vc_data *vc);
71void con_protect_unimap(struct vc_data *vc, int rdonly); 72void con_protect_unimap(struct vc_data *vc, int rdonly);
72int con_copy_unimap(struct vc_data *dst_vc, struct vc_data *src_vc); 73int con_copy_unimap(struct vc_data *dst_vc, struct vc_data *src_vc);
73 74
75#define vc_translate(vc, c) ((vc)->vc_translate[(c) | \
76 ((vc)->vc_toggle_meta ? 0x80 : 0)])
77#else
78#define con_set_trans_old(arg) (0)
79#define con_get_trans_old(arg) (-EINVAL)
80#define con_set_trans_new(arg) (0)
81#define con_get_trans_new(arg) (-EINVAL)
82#define con_clear_unimap(vc, ui) (0)
83#define con_set_unimap(vc, ct, list) (0)
84#define con_set_default_unimap(vc) (0)
85#define con_copy_unimap(d, s) (0)
86#define con_get_unimap(vc, ct, uct, list) (-EINVAL)
87#define con_free_unimap(vc) do { ; } while (0)
88#define con_protect_unimap(vc, rdonly) do { ; } while (0)
89
90#define vc_translate(vc, c) (c)
91#endif
92
74/* vt.c */ 93/* vt.c */
75int vt_waitactive(int vt); 94int vt_waitactive(int vt);
76void change_console(struct vc_data *new_vc); 95void change_console(struct vc_data *new_vc);
77void reset_vc(struct vc_data *vc); 96void reset_vc(struct vc_data *vc);
78extern int unbind_con_driver(const struct consw *csw, int first, int last, 97extern int unbind_con_driver(const struct consw *csw, int first, int last,
79 int deflt); 98 int deflt);
80int vty_init(void); 99int vty_init(const struct file_operations *console_fops);
81 100
82/* 101/*
83 * vc_screen.c shares this temporary buffer with the console write code so that 102 * vc_screen.c shares this temporary buffer with the console write code so that
diff --git a/include/linux/wait.h b/include/linux/wait.h
index 0081147a9fe8..ef609f842fac 100644
--- a/include/linux/wait.h
+++ b/include/linux/wait.h
@@ -108,15 +108,6 @@ static inline int waitqueue_active(wait_queue_head_t *q)
108 return !list_empty(&q->task_list); 108 return !list_empty(&q->task_list);
109} 109}
110 110
111/*
112 * Used to distinguish between sync and async io wait context:
113 * sync i/o typically specifies a NULL wait queue entry or a wait
114 * queue entry bound to a task (current task) to wake up.
115 * aio specifies a wait queue entry with an async notification
116 * callback routine, not associated with any task.
117 */
118#define is_sync_wait(wait) (!(wait) || ((wait)->private))
119
120extern void add_wait_queue(wait_queue_head_t *q, wait_queue_t *wait); 111extern void add_wait_queue(wait_queue_head_t *q, wait_queue_t *wait);
121extern void add_wait_queue_exclusive(wait_queue_head_t *q, wait_queue_t *wait); 112extern void add_wait_queue_exclusive(wait_queue_head_t *q, wait_queue_t *wait);
122extern void remove_wait_queue(wait_queue_head_t *q, wait_queue_t *wait); 113extern void remove_wait_queue(wait_queue_head_t *q, wait_queue_t *wait);
diff --git a/include/linux/wanrouter.h b/include/linux/wanrouter.h
index 3add87465b1f..e0aa39612eba 100644
--- a/include/linux/wanrouter.h
+++ b/include/linux/wanrouter.h
@@ -522,7 +522,7 @@ extern int wanrouter_proc_init(void);
522extern void wanrouter_proc_cleanup(void); 522extern void wanrouter_proc_cleanup(void);
523extern int wanrouter_proc_add(struct wan_device *wandev); 523extern int wanrouter_proc_add(struct wan_device *wandev);
524extern int wanrouter_proc_delete(struct wan_device *wandev); 524extern int wanrouter_proc_delete(struct wan_device *wandev);
525extern int wanrouter_ioctl( struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg); 525extern long wanrouter_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
526 526
527/* Public Data */ 527/* Public Data */
528/* list of registered devices */ 528/* list of registered devices */
diff --git a/include/linux/wireless.h b/include/linux/wireless.h
index 0a9b5b41ed67..d7958f9b52cb 100644
--- a/include/linux/wireless.h
+++ b/include/linux/wireless.h
@@ -611,6 +611,7 @@
611#define IW_ENCODE_ALG_WEP 1 611#define IW_ENCODE_ALG_WEP 1
612#define IW_ENCODE_ALG_TKIP 2 612#define IW_ENCODE_ALG_TKIP 2
613#define IW_ENCODE_ALG_CCMP 3 613#define IW_ENCODE_ALG_CCMP 3
614#define IW_ENCODE_ALG_PMK 4
614/* struct iw_encode_ext ->ext_flags */ 615/* struct iw_encode_ext ->ext_flags */
615#define IW_ENCODE_EXT_TX_SEQ_VALID 0x00000001 616#define IW_ENCODE_EXT_TX_SEQ_VALID 0x00000001
616#define IW_ENCODE_EXT_RX_SEQ_VALID 0x00000002 617#define IW_ENCODE_EXT_RX_SEQ_VALID 0x00000002
@@ -630,6 +631,7 @@
630#define IW_ENC_CAPA_WPA2 0x00000002 631#define IW_ENC_CAPA_WPA2 0x00000002
631#define IW_ENC_CAPA_CIPHER_TKIP 0x00000004 632#define IW_ENC_CAPA_CIPHER_TKIP 0x00000004
632#define IW_ENC_CAPA_CIPHER_CCMP 0x00000008 633#define IW_ENC_CAPA_CIPHER_CCMP 0x00000008
634#define IW_ENC_CAPA_4WAY_HANDSHAKE 0x00000010
633 635
634/* Event capability macros - in (struct iw_range *)->event_capa 636/* Event capability macros - in (struct iw_range *)->event_capa
635 * Because we have more than 32 possible events, we use an array of 637 * Because we have more than 32 possible events, we use an array of
@@ -675,6 +677,19 @@ struct iw_point
675 __u16 flags; /* Optional params */ 677 __u16 flags; /* Optional params */
676}; 678};
677 679
680#ifdef __KERNEL__
681#ifdef CONFIG_COMPAT
682
683#include <linux/compat.h>
684
685struct compat_iw_point {
686 compat_caddr_t pointer;
687 __u16 length;
688 __u16 flags;
689};
690#endif
691#endif
692
678/* 693/*
679 * A frequency 694 * A frequency
680 * For numbers lower than 10^9, we encode the number in 'm' and 695 * For numbers lower than 10^9, we encode the number in 'm' and
@@ -1098,6 +1113,21 @@ struct iw_event
1098#define IW_EV_POINT_LEN (IW_EV_LCP_LEN + sizeof(struct iw_point) - \ 1113#define IW_EV_POINT_LEN (IW_EV_LCP_LEN + sizeof(struct iw_point) - \
1099 IW_EV_POINT_OFF) 1114 IW_EV_POINT_OFF)
1100 1115
1116#ifdef __KERNEL__
1117#ifdef CONFIG_COMPAT
1118struct __compat_iw_event {
1119 __u16 len; /* Real length of this stuff */
1120 __u16 cmd; /* Wireless IOCTL */
1121 compat_caddr_t pointer;
1122};
1123#define IW_EV_COMPAT_LCP_LEN offsetof(struct __compat_iw_event, pointer)
1124#define IW_EV_COMPAT_POINT_OFF offsetof(struct compat_iw_point, length)
1125#define IW_EV_COMPAT_POINT_LEN \
1126 (IW_EV_COMPAT_LCP_LEN + sizeof(struct compat_iw_point) - \
1127 IW_EV_COMPAT_POINT_OFF)
1128#endif
1129#endif
1130
1101/* Size of the Event prefix when packed in stream */ 1131/* Size of the Event prefix when packed in stream */
1102#define IW_EV_LCP_PK_LEN (4) 1132#define IW_EV_LCP_PK_LEN (4)
1103/* Size of the various events when packed in stream */ 1133/* Size of the various events when packed in stream */
diff --git a/include/linux/wlp.h b/include/linux/wlp.h
new file mode 100644
index 000000000000..033545e145c7
--- /dev/null
+++ b/include/linux/wlp.h
@@ -0,0 +1,735 @@
1/*
2 * WiMedia Logical Link Control Protocol (WLP)
3 *
4 * Copyright (C) 2005-2006 Intel Corporation
5 * Reinette Chatre <reinette.chatre@intel.com>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License version
9 * 2 as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 * 02110-1301, USA.
20 *
21 *
22 * FIXME: docs
23 *
24 * - Does not (yet) include support for WLP control frames
25 * WLP Draft 0.99 [6.5].
26 *
27 * A visual representation of the data structures.
28 *
29 * wssidB wssidB
30 * ^ ^
31 * | |
32 * wssidA wssidA
33 * wlp interface { ^ ^
34 * ... | |
35 * ... ... wssid wssid ...
36 * wlp --- ... | |
37 * }; neighbors --> neighbA --> neighbB
38 * ...
39 * wss
40 * ...
41 * eda cache --> neighborA --> neighborB --> neighborC ...
42 */
43
44#ifndef __LINUX__WLP_H_
45#define __LINUX__WLP_H_
46
47#include <linux/netdevice.h>
48#include <linux/skbuff.h>
49#include <linux/list.h>
50#include <linux/uwb.h>
51
52/**
53 * WLP Protocol ID
54 * WLP Draft 0.99 [6.2]
55 *
56 * The MUX header for all WLP frames
57 */
58#define WLP_PROTOCOL_ID 0x0100
59
60/**
61 * WLP Version
62 * WLP version placed in the association frames (WLP 0.99 [6.6])
63 */
64#define WLP_VERSION 0x10
65
66/**
67 * Bytes needed to print UUID as string
68 */
69#define WLP_WSS_UUID_STRSIZE 48
70
71/**
72 * Bytes needed to print nonce as string
73 */
74#define WLP_WSS_NONCE_STRSIZE 48
75
76
77/**
78 * Size used for WLP name size
79 *
80 * The WSS name is set to 65 bytes, 1 byte larger than the maximum
81 * allowed by the WLP spec. This is to have a null terminated string
82 * for display to the user. A maximum of 64 bytes will still be used
83 * when placing the WSS name field in association frames.
84 */
85#define WLP_WSS_NAME_SIZE 65
86
87/**
88 * Number of bytes added by WLP to data frame
89 *
90 * A data frame transmitted from a host will be placed in a Standard or
91 * Abbreviated WLP frame. These have an extra 4 bytes of header (struct
92 * wlp_frame_std_abbrv_hdr).
93 * When the stack sends this data frame for transmission it needs to ensure
94 * there is enough headroom for this header.
95 */
96#define WLP_DATA_HLEN 4
97
98/**
99 * State of device regarding WLP Service Set
100 *
101 * WLP_WSS_STATE_NONE: the host does not participate in any WSS
102 * WLP_WSS_STATE_PART_ENROLLED: used as part of the enrollment sequence
103 * ("Partial Enroll"). This state is used to
104 * indicate the first part of enrollment that is
105 * unsecure. If the WSS is unsecure then the
106 * state will promptly go to WLP_WSS_STATE_ENROLLED,
107 * if the WSS is not secure then the enrollment
108 * procedure is a few more steps before we are
109 * enrolled.
110 * WLP_WSS_STATE_ENROLLED: the host is enrolled in a WSS
111 * WLP_WSS_STATE_ACTIVE: WSS is activated
112 * WLP_WSS_STATE_CONNECTED: host is connected to neighbor in WSS
113 *
114 */
115enum wlp_wss_state {
116 WLP_WSS_STATE_NONE = 0,
117 WLP_WSS_STATE_PART_ENROLLED,
118 WLP_WSS_STATE_ENROLLED,
119 WLP_WSS_STATE_ACTIVE,
120 WLP_WSS_STATE_CONNECTED,
121};
122
123/**
124 * WSS Secure status
125 * WLP 0.99 Table 6
126 *
127 * Set to one if the WSS is secure, zero if it is not secure
128 */
129enum wlp_wss_sec_status {
130 WLP_WSS_UNSECURE = 0,
131 WLP_WSS_SECURE,
132};
133
134/**
135 * WLP frame type
136 * WLP Draft 0.99 [6.2 Table 1]
137 */
138enum wlp_frame_type {
139 WLP_FRAME_STANDARD = 0,
140 WLP_FRAME_ABBREVIATED,
141 WLP_FRAME_CONTROL,
142 WLP_FRAME_ASSOCIATION,
143};
144
145/**
146 * WLP Association Message Type
147 * WLP Draft 0.99 [6.6.1.2 Table 8]
148 */
149enum wlp_assoc_type {
150 WLP_ASSOC_D1 = 2,
151 WLP_ASSOC_D2 = 3,
152 WLP_ASSOC_M1 = 4,
153 WLP_ASSOC_M2 = 5,
154 WLP_ASSOC_M3 = 7,
155 WLP_ASSOC_M4 = 8,
156 WLP_ASSOC_M5 = 9,
157 WLP_ASSOC_M6 = 10,
158 WLP_ASSOC_M7 = 11,
159 WLP_ASSOC_M8 = 12,
160 WLP_ASSOC_F0 = 14,
161 WLP_ASSOC_E1 = 32,
162 WLP_ASSOC_E2 = 33,
163 WLP_ASSOC_C1 = 34,
164 WLP_ASSOC_C2 = 35,
165 WLP_ASSOC_C3 = 36,
166 WLP_ASSOC_C4 = 37,
167};
168
169/**
170 * WLP Attribute Type
171 * WLP Draft 0.99 [6.6.1 Table 6]
172 */
173enum wlp_attr_type {
174 WLP_ATTR_AUTH = 0x1005, /* Authenticator */
175 WLP_ATTR_DEV_NAME = 0x1011, /* Device Name */
176 WLP_ATTR_DEV_PWD_ID = 0x1012, /* Device Password ID */
177 WLP_ATTR_E_HASH1 = 0x1014, /* E-Hash1 */
178 WLP_ATTR_E_HASH2 = 0x1015, /* E-Hash2 */
179 WLP_ATTR_E_SNONCE1 = 0x1016, /* E-SNonce1 */
180 WLP_ATTR_E_SNONCE2 = 0x1017, /* E-SNonce2 */
181 WLP_ATTR_ENCR_SET = 0x1018, /* Encrypted Settings */
182 WLP_ATTR_ENRL_NONCE = 0x101A, /* Enrollee Nonce */
183 WLP_ATTR_KEYWRAP_AUTH = 0x101E, /* Key Wrap Authenticator */
184 WLP_ATTR_MANUF = 0x1021, /* Manufacturer */
185 WLP_ATTR_MSG_TYPE = 0x1022, /* Message Type */
186 WLP_ATTR_MODEL_NAME = 0x1023, /* Model Name */
187 WLP_ATTR_MODEL_NR = 0x1024, /* Model Number */
188 WLP_ATTR_PUB_KEY = 0x1032, /* Public Key */
189 WLP_ATTR_REG_NONCE = 0x1039, /* Registrar Nonce */
190 WLP_ATTR_R_HASH1 = 0x103D, /* R-Hash1 */
191 WLP_ATTR_R_HASH2 = 0x103E, /* R-Hash2 */
192 WLP_ATTR_R_SNONCE1 = 0x103F, /* R-SNonce1 */
193 WLP_ATTR_R_SNONCE2 = 0x1040, /* R-SNonce2 */
194 WLP_ATTR_SERIAL = 0x1042, /* Serial number */
195 WLP_ATTR_UUID_E = 0x1047, /* UUID-E */
196 WLP_ATTR_UUID_R = 0x1048, /* UUID-R */
197 WLP_ATTR_PRI_DEV_TYPE = 0x1054, /* Primary Device Type */
198 WLP_ATTR_SEC_DEV_TYPE = 0x1055, /* Secondary Device Type */
199 WLP_ATTR_PORT_DEV = 0x1056, /* Portable Device */
200 WLP_ATTR_APP_EXT = 0x1058, /* Application Extension */
201 WLP_ATTR_WLP_VER = 0x2000, /* WLP Version */
202 WLP_ATTR_WSSID = 0x2001, /* WSSID */
203 WLP_ATTR_WSS_NAME = 0x2002, /* WSS Name */
204 WLP_ATTR_WSS_SEC_STAT = 0x2003, /* WSS Secure Status */
205 WLP_ATTR_WSS_BCAST = 0x2004, /* WSS Broadcast Address */
206 WLP_ATTR_WSS_M_KEY = 0x2005, /* WSS Master Key */
207 WLP_ATTR_ACC_ENRL = 0x2006, /* Accepting Enrollment */
208 WLP_ATTR_WSS_INFO = 0x2007, /* WSS Information */
209 WLP_ATTR_WSS_SEL_MTHD = 0x2008, /* WSS Selection Method */
210 WLP_ATTR_ASSC_MTHD_LIST = 0x2009, /* Association Methods List */
211 WLP_ATTR_SEL_ASSC_MTHD = 0x200A, /* Selected Association Method */
212 WLP_ATTR_ENRL_HASH_COMM = 0x200B, /* Enrollee Hash Commitment */
213 WLP_ATTR_WSS_TAG = 0x200C, /* WSS Tag */
214 WLP_ATTR_WSS_VIRT = 0x200D, /* WSS Virtual EUI-48 */
215 WLP_ATTR_WLP_ASSC_ERR = 0x200E, /* WLP Association Error */
216 WLP_ATTR_VNDR_EXT = 0x200F, /* Vendor Extension */
217};
218
219/**
220 * WLP Category ID of primary/secondary device
221 * WLP Draft 0.99 [6.6.1.8 Table 12]
222 */
223enum wlp_dev_category_id {
224 WLP_DEV_CAT_COMPUTER = 1,
225 WLP_DEV_CAT_INPUT,
226 WLP_DEV_CAT_PRINT_SCAN_FAX_COPIER,
227 WLP_DEV_CAT_CAMERA,
228 WLP_DEV_CAT_STORAGE,
229 WLP_DEV_CAT_INFRASTRUCTURE,
230 WLP_DEV_CAT_DISPLAY,
231 WLP_DEV_CAT_MULTIM,
232 WLP_DEV_CAT_GAMING,
233 WLP_DEV_CAT_TELEPHONE,
234 WLP_DEV_CAT_OTHER = 65535,
235};
236
237/**
238 * WLP WSS selection method
239 * WLP Draft 0.99 [6.6.1.6 Table 10]
240 */
241enum wlp_wss_sel_mthd {
242 WLP_WSS_ENRL_SELECT = 1, /* Enrollee selects */
243 WLP_WSS_REG_SELECT, /* Registrar selects */
244};
245
246/**
247 * WLP association error values
248 * WLP Draft 0.99 [6.6.1.5 Table 9]
249 */
250enum wlp_assc_error {
251 WLP_ASSOC_ERROR_NONE,
252 WLP_ASSOC_ERROR_AUTH, /* Authenticator Failure */
253 WLP_ASSOC_ERROR_ROGUE, /* Rogue activity suspected */
254 WLP_ASSOC_ERROR_BUSY, /* Device busy */
255 WLP_ASSOC_ERROR_LOCK, /* Setup Locked */
256 WLP_ASSOC_ERROR_NOT_READY, /* Registrar not ready */
257 WLP_ASSOC_ERROR_INV, /* Invalid WSS selection */
258 WLP_ASSOC_ERROR_MSG_TIME, /* Message timeout */
259 WLP_ASSOC_ERROR_ENR_TIME, /* Enrollment session timeout */
260 WLP_ASSOC_ERROR_PW, /* Device password invalid */
261 WLP_ASSOC_ERROR_VER, /* Unsupported version */
262 WLP_ASSOC_ERROR_INT, /* Internal error */
263 WLP_ASSOC_ERROR_UNDEF, /* Undefined error */
264 WLP_ASSOC_ERROR_NUM, /* Numeric comparison failure */
265 WLP_ASSOC_ERROR_WAIT, /* Waiting for user input */
266};
267
268/**
269 * WLP Parameters
270 * WLP 0.99 [7.7]
271 */
272enum wlp_parameters {
273 WLP_PER_MSG_TIMEOUT = 15, /* Seconds to wait for response to
274 association message. */
275};
276
277/**
278 * WLP IE
279 *
280 * The WLP IE should be included in beacons by all devices.
281 *
282 * The driver can set only a few of the fields in this information element,
283 * most fields are managed by the device self. When the driver needs to set
284 * a field it will only provide values for the fields of interest, the rest
285 * will be filled with zeroes. The fields of interest are:
286 *
287 * Element ID
288 * Length
289 * Capabilities (only to include WSSID Hash list length)
290 * WSSID Hash List fields
291 *
292 * WLP 0.99 [6.7]
293 *
294 * Only the fields that will be used are detailed in this structure, rest
295 * are not detailed or marked as "notused".
296 */
297struct wlp_ie {
298 struct uwb_ie_hdr hdr;
299 __le16 capabilities;
300 __le16 cycle_param;
301 __le16 acw_anchor_addr;
302 u8 wssid_hash_list[];
303} __attribute__((packed));
304
305static inline int wlp_ie_hash_length(struct wlp_ie *ie)
306{
307 return (le16_to_cpu(ie->capabilities) >> 12) & 0xf;
308}
309
310static inline void wlp_ie_set_hash_length(struct wlp_ie *ie, int hash_length)
311{
312 u16 caps = le16_to_cpu(ie->capabilities);
313 caps = (caps & ~(0xf << 12)) | (hash_length << 12);
314 ie->capabilities = cpu_to_le16(caps);
315}
316
317/**
318 * WLP nonce
319 * WLP Draft 0.99 [6.6.1 Table 6]
320 *
321 * A 128-bit random number often used (E-SNonce1, E-SNonce2, Enrollee
322 * Nonce, Registrar Nonce, R-SNonce1, R-SNonce2). It is passed to HW so
323 * it is packed.
324 */
325struct wlp_nonce {
326 u8 data[16];
327} __attribute__((packed));
328
329/**
330 * WLP UUID
331 * WLP Draft 0.99 [6.6.1 Table 6]
332 *
333 * Universally Unique Identifier (UUID) encoded as an octet string in the
334 * order the octets are shown in string representation in RFC4122. A UUID
335 * is often used (UUID-E, UUID-R, WSSID). It is passed to HW so it is packed.
336 */
337struct wlp_uuid {
338 u8 data[16];
339} __attribute__((packed));
340
341
342/**
343 * Primary and secondary device type attributes
344 * WLP Draft 0.99 [6.6.1.8]
345 */
346struct wlp_dev_type {
347 enum wlp_dev_category_id category:16;
348 u8 OUI[3];
349 u8 OUIsubdiv;
350 __le16 subID;
351} __attribute__((packed));
352
353/**
354 * WLP frame header
355 * WLP Draft 0.99 [6.2]
356 */
357struct wlp_frame_hdr {
358 __le16 mux_hdr; /* WLP_PROTOCOL_ID */
359 enum wlp_frame_type type:8;
360} __attribute__((packed));
361
362/**
363 * WLP attribute field header
364 * WLP Draft 0.99 [6.6.1]
365 *
366 * Header of each attribute found in an association frame
367 */
368struct wlp_attr_hdr {
369 __le16 type;
370 __le16 length;
371} __attribute__((packed));
372
373/**
374 * Device information commonly used together
375 *
376 * Each of these device information elements has a specified range in which it
377 * should fit (WLP 0.99 [Table 6]). This range provided in the spec does not
378 * include the termination null '\0' character (when used in the
379 * association protocol the attribute fields are accompanied
380 * with a "length" field so the full range from the spec can be used for
381 * the value). We thus allocate an extra byte to be able to store a string
382 * of max length with a terminating '\0'.
383 */
384struct wlp_device_info {
385 char name[33];
386 char model_name[33];
387 char manufacturer[65];
388 char model_nr[33];
389 char serial[33];
390 struct wlp_dev_type prim_dev_type;
391};
392
393/**
394 * Macros for the WLP attributes
395 *
396 * There are quite a few attributes (total is 43). The attribute layout can be
397 * in one of three categories: one value, an array, an enum forced to 8 bits.
398 * These macros help with their definitions.
399 */
400#define wlp_attr(type, name) \
401struct wlp_attr_##name { \
402 struct wlp_attr_hdr hdr; \
403 type name; \
404} __attribute__((packed));
405
406#define wlp_attr_array(type, name) \
407struct wlp_attr_##name { \
408 struct wlp_attr_hdr hdr; \
409 type name[]; \
410} __attribute__((packed));
411
412/**
413 * WLP association attribute fields
414 * WLP Draft 0.99 [6.6.1 Table 6]
415 *
416 * Attributes appear in same order as the Table in the spec
417 * FIXME Does not define all attributes yet
418 */
419
420/* Device name: Friendly name of sending device */
421wlp_attr_array(u8, dev_name)
422
423/* Enrollee Nonce: Random number generated by enrollee for an enrollment
424 * session */
425wlp_attr(struct wlp_nonce, enonce)
426
427/* Manufacturer name: Name of manufacturer of the sending device */
428wlp_attr_array(u8, manufacturer)
429
430/* WLP Message Type */
431wlp_attr(u8, msg_type)
432
433/* WLP Model name: Model name of sending device */
434wlp_attr_array(u8, model_name)
435
436/* WLP Model number: Model number of sending device */
437wlp_attr_array(u8, model_nr)
438
439/* Registrar Nonce: Random number generated by registrar for an enrollment
440 * session */
441wlp_attr(struct wlp_nonce, rnonce)
442
443/* Serial number of device */
444wlp_attr_array(u8, serial)
445
446/* UUID of enrollee */
447wlp_attr(struct wlp_uuid, uuid_e)
448
449/* UUID of registrar */
450wlp_attr(struct wlp_uuid, uuid_r)
451
452/* WLP Primary device type */
453wlp_attr(struct wlp_dev_type, prim_dev_type)
454
455/* WLP Secondary device type */
456wlp_attr(struct wlp_dev_type, sec_dev_type)
457
458/* WLP protocol version */
459wlp_attr(u8, version)
460
461/* WLP service set identifier */
462wlp_attr(struct wlp_uuid, wssid)
463
464/* WLP WSS name */
465wlp_attr_array(u8, wss_name)
466
467/* WLP WSS Secure Status */
468wlp_attr(u8, wss_sec_status)
469
470/* WSS Broadcast Address */
471wlp_attr(struct uwb_mac_addr, wss_bcast)
472
473/* WLP Accepting Enrollment */
474wlp_attr(u8, accept_enrl)
475
476/**
477 * WSS information attributes
478 * WLP Draft 0.99 [6.6.3 Table 15]
479 */
480struct wlp_wss_info {
481 struct wlp_attr_wssid wssid;
482 struct wlp_attr_wss_name name;
483 struct wlp_attr_accept_enrl accept;
484 struct wlp_attr_wss_sec_status sec_stat;
485 struct wlp_attr_wss_bcast bcast;
486} __attribute__((packed));
487
488/* WLP WSS Information */
489wlp_attr_array(struct wlp_wss_info, wss_info)
490
491/* WLP WSS Selection method */
492wlp_attr(u8, wss_sel_mthd)
493
494/* WLP WSS tag */
495wlp_attr(u8, wss_tag)
496
497/* WSS Virtual Address */
498wlp_attr(struct uwb_mac_addr, wss_virt)
499
500/* WLP association error */
501wlp_attr(u8, wlp_assc_err)
502
503/**
504 * WLP standard and abbreviated frames
505 *
506 * WLP Draft 0.99 [6.3] and [6.4]
507 *
508 * The difference between the WLP standard frame and the WLP
509 * abbreviated frame is that the standard frame includes the src
510 * and dest addresses from the Ethernet header, the abbreviated frame does
511 * not.
512 * The src/dest (as well as the type/length and client data) are already
513 * defined as part of the Ethernet header, we do not do this here.
514 * From this perspective the standard and abbreviated frames appear the
515 * same - they will be treated differently though.
516 *
517 * The size of this header is also captured in WLP_DATA_HLEN to enable
518 * interfaces to prepare their headroom.
519 */
520struct wlp_frame_std_abbrv_hdr {
521 struct wlp_frame_hdr hdr;
522 u8 tag;
523} __attribute__((packed));
524
525/**
526 * WLP association frames
527 *
528 * WLP Draft 0.99 [6.6]
529 */
530struct wlp_frame_assoc {
531 struct wlp_frame_hdr hdr;
532 enum wlp_assoc_type type:8;
533 struct wlp_attr_version version;
534 struct wlp_attr_msg_type msg_type;
535 u8 attr[];
536} __attribute__((packed));
537
538/* Ethernet to dev address mapping */
539struct wlp_eda {
540 spinlock_t lock;
541 struct list_head cache; /* Eth<->Dev Addr cache */
542};
543
544/**
545 * WSS information temporary storage
546 *
547 * This information is only stored temporarily during discovery. It should
548 * not be stored unless the device is enrolled in the advertised WSS. This
549 * is done mainly because we follow the letter of the spec in this regard.
550 * See WLP 0.99 [7.2.3].
551 * When the device does become enrolled in a WSS the WSS information will
552 * be stored as part of the more comprehensive struct wlp_wss.
553 */
554struct wlp_wss_tmp_info {
555 char name[WLP_WSS_NAME_SIZE];
556 u8 accept_enroll;
557 u8 sec_status;
558 struct uwb_mac_addr bcast;
559};
560
561struct wlp_wssid_e {
562 struct list_head node;
563 struct wlp_uuid wssid;
564 struct wlp_wss_tmp_info *info;
565};
566
567/**
568 * A cache entry of WLP neighborhood
569 *
570 * @node: head of list is wlp->neighbors
571 * @wssid: list of wssids of this neighbor, element is wlp_wssid_e
572 * @info: temporary storage for information learned during discovery. This
573 * storage is used together with the wssid_e temporary storage
574 * during discovery.
575 */
576struct wlp_neighbor_e {
577 struct list_head node;
578 struct wlp_uuid uuid;
579 struct uwb_dev *uwb_dev;
580 struct list_head wssid; /* Elements are wlp_wssid_e */
581 struct wlp_device_info *info;
582};
583
584struct wlp;
585/**
586 * Information for an association session in progress.
587 *
588 * @exp_message: The type of the expected message. Both this message and a
589 * F0 message (which can be sent in response to any
590 * association frame) will be accepted as a valid message for
591 * this session.
592 * @cb: The function that will be called upon receipt of this
593 * message.
594 * @cb_priv: Private data of callback
595 * @data: Data used in association process (always a sk_buff?)
596 * @neighbor: Address of neighbor with which association session is in
597 * progress.
598 */
599struct wlp_session {
600 enum wlp_assoc_type exp_message;
601 void (*cb)(struct wlp *);
602 void *cb_priv;
603 void *data;
604 struct uwb_dev_addr neighbor_addr;
605};
606
607/**
608 * WLP Service Set
609 *
610 * @mutex: used to protect entire WSS structure.
611 *
612 * @name: The WSS name is set to 65 bytes, 1 byte larger than the maximum
613 * allowed by the WLP spec. This is to have a null terminated string
614 * for display to the user. A maximum of 64 bytes will still be used
615 * when placing the WSS name field in association frames.
616 *
617 * @accept_enroll: Accepting enrollment: Set to one if registrar is
618 * accepting enrollment in WSS, or zero otherwise.
619 *
620 * Global and local information for each WSS in which we are enrolled.
621 * WLP 0.99 Section 7.2.1 and Section 7.2.2
622 */
623struct wlp_wss {
624 struct mutex mutex;
625 struct kobject kobj;
626 /* Global properties. */
627 struct wlp_uuid wssid;
628 u8 hash;
629 char name[WLP_WSS_NAME_SIZE];
630 struct uwb_mac_addr bcast;
631 u8 secure_status:1;
632 u8 master_key[16];
633 /* Local properties. */
634 u8 tag;
635 struct uwb_mac_addr virtual_addr;
636 /* Extra */
637 u8 accept_enroll:1;
638 enum wlp_wss_state state;
639};
640
641/**
642 * WLP main structure
643 * @mutex: protect changes to WLP structure. We only allow changes to the
644 * uuid, so currently this mutex only protects this field.
645 */
646struct wlp {
647 struct mutex mutex;
648 struct uwb_rc *rc; /* UWB radio controller */
649 struct uwb_pal pal;
650 struct wlp_eda eda;
651 struct wlp_uuid uuid;
652 struct wlp_session *session;
653 struct wlp_wss wss;
654 struct mutex nbmutex; /* Neighbor mutex protects neighbors list */
655 struct list_head neighbors; /* Elements are wlp_neighbor_e */
656 struct uwb_notifs_handler uwb_notifs_handler;
657 struct wlp_device_info *dev_info;
658 void (*fill_device_info)(struct wlp *wlp, struct wlp_device_info *info);
659 int (*xmit_frame)(struct wlp *, struct sk_buff *,
660 struct uwb_dev_addr *);
661 void (*stop_queue)(struct wlp *);
662 void (*start_queue)(struct wlp *);
663};
664
665/* sysfs */
666
667
668struct wlp_wss_attribute {
669 struct attribute attr;
670 ssize_t (*show)(struct wlp_wss *wss, char *buf);
671 ssize_t (*store)(struct wlp_wss *wss, const char *buf, size_t count);
672};
673
674#define WSS_ATTR(_name, _mode, _show, _store) \
675static struct wlp_wss_attribute wss_attr_##_name = __ATTR(_name, _mode, \
676 _show, _store)
677
678extern int wlp_setup(struct wlp *, struct uwb_rc *);
679extern void wlp_remove(struct wlp *);
680extern ssize_t wlp_neighborhood_show(struct wlp *, char *);
681extern int wlp_wss_setup(struct net_device *, struct wlp_wss *);
682extern void wlp_wss_remove(struct wlp_wss *);
683extern ssize_t wlp_wss_activate_show(struct wlp_wss *, char *);
684extern ssize_t wlp_wss_activate_store(struct wlp_wss *, const char *, size_t);
685extern ssize_t wlp_eda_show(struct wlp *, char *);
686extern ssize_t wlp_eda_store(struct wlp *, const char *, size_t);
687extern ssize_t wlp_uuid_show(struct wlp *, char *);
688extern ssize_t wlp_uuid_store(struct wlp *, const char *, size_t);
689extern ssize_t wlp_dev_name_show(struct wlp *, char *);
690extern ssize_t wlp_dev_name_store(struct wlp *, const char *, size_t);
691extern ssize_t wlp_dev_manufacturer_show(struct wlp *, char *);
692extern ssize_t wlp_dev_manufacturer_store(struct wlp *, const char *, size_t);
693extern ssize_t wlp_dev_model_name_show(struct wlp *, char *);
694extern ssize_t wlp_dev_model_name_store(struct wlp *, const char *, size_t);
695extern ssize_t wlp_dev_model_nr_show(struct wlp *, char *);
696extern ssize_t wlp_dev_model_nr_store(struct wlp *, const char *, size_t);
697extern ssize_t wlp_dev_serial_show(struct wlp *, char *);
698extern ssize_t wlp_dev_serial_store(struct wlp *, const char *, size_t);
699extern ssize_t wlp_dev_prim_category_show(struct wlp *, char *);
700extern ssize_t wlp_dev_prim_category_store(struct wlp *, const char *,
701 size_t);
702extern ssize_t wlp_dev_prim_OUI_show(struct wlp *, char *);
703extern ssize_t wlp_dev_prim_OUI_store(struct wlp *, const char *, size_t);
704extern ssize_t wlp_dev_prim_OUI_sub_show(struct wlp *, char *);
705extern ssize_t wlp_dev_prim_OUI_sub_store(struct wlp *, const char *,
706 size_t);
707extern ssize_t wlp_dev_prim_subcat_show(struct wlp *, char *);
708extern ssize_t wlp_dev_prim_subcat_store(struct wlp *, const char *,
709 size_t);
710extern int wlp_receive_frame(struct device *, struct wlp *, struct sk_buff *,
711 struct uwb_dev_addr *);
712extern int wlp_prepare_tx_frame(struct device *, struct wlp *,
713 struct sk_buff *, struct uwb_dev_addr *);
714void wlp_reset_all(struct wlp *wlp);
715
716/**
717 * Initialize WSS
718 */
719static inline
720void wlp_wss_init(struct wlp_wss *wss)
721{
722 mutex_init(&wss->mutex);
723}
724
725static inline
726void wlp_init(struct wlp *wlp)
727{
728 INIT_LIST_HEAD(&wlp->neighbors);
729 mutex_init(&wlp->mutex);
730 mutex_init(&wlp->nbmutex);
731 wlp_wss_init(&wlp->wss);
732}
733
734
735#endif /* #ifndef __LINUX__WLP_H_ */
diff --git a/include/linux/wm97xx_batt.h b/include/linux/wm97xx_batt.h
new file mode 100644
index 000000000000..9681d1ab0e4f
--- /dev/null
+++ b/include/linux/wm97xx_batt.h
@@ -0,0 +1,26 @@
1#ifndef _LINUX_WM97XX_BAT_H
2#define _LINUX_WM97XX_BAT_H
3
4#include <linux/wm97xx.h>
5
6struct wm97xx_batt_info {
7 int batt_aux;
8 int temp_aux;
9 int charge_gpio;
10 int min_voltage;
11 int max_voltage;
12 int batt_div;
13 int batt_mult;
14 int temp_div;
15 int temp_mult;
16 int batt_tech;
17 char *batt_name;
18};
19
20#ifdef CONFIG_BATTERY_WM97XX
21void __init wm97xx_bat_set_pdata(struct wm97xx_batt_info *data);
22#else
23static inline void wm97xx_bat_set_pdata(struct wm97xx_batt_info *data) {}
24#endif
25
26#endif
diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h
index 542526c6e8ef..89a5a1231ffb 100644
--- a/include/linux/workqueue.h
+++ b/include/linux/workqueue.h
@@ -149,11 +149,11 @@ struct execute_work {
149 149
150extern struct workqueue_struct * 150extern struct workqueue_struct *
151__create_workqueue_key(const char *name, int singlethread, 151__create_workqueue_key(const char *name, int singlethread,
152 int freezeable, struct lock_class_key *key, 152 int freezeable, int rt, struct lock_class_key *key,
153 const char *lock_name); 153 const char *lock_name);
154 154
155#ifdef CONFIG_LOCKDEP 155#ifdef CONFIG_LOCKDEP
156#define __create_workqueue(name, singlethread, freezeable) \ 156#define __create_workqueue(name, singlethread, freezeable, rt) \
157({ \ 157({ \
158 static struct lock_class_key __key; \ 158 static struct lock_class_key __key; \
159 const char *__lock_name; \ 159 const char *__lock_name; \
@@ -164,21 +164,25 @@ __create_workqueue_key(const char *name, int singlethread,
164 __lock_name = #name; \ 164 __lock_name = #name; \
165 \ 165 \
166 __create_workqueue_key((name), (singlethread), \ 166 __create_workqueue_key((name), (singlethread), \
167 (freezeable), &__key, \ 167 (freezeable), (rt), &__key, \
168 __lock_name); \ 168 __lock_name); \
169}) 169})
170#else 170#else
171#define __create_workqueue(name, singlethread, freezeable) \ 171#define __create_workqueue(name, singlethread, freezeable, rt) \
172 __create_workqueue_key((name), (singlethread), (freezeable), NULL, NULL) 172 __create_workqueue_key((name), (singlethread), (freezeable), (rt), \
173 NULL, NULL)
173#endif 174#endif
174 175
175#define create_workqueue(name) __create_workqueue((name), 0, 0) 176#define create_workqueue(name) __create_workqueue((name), 0, 0, 0)
176#define create_freezeable_workqueue(name) __create_workqueue((name), 1, 1) 177#define create_rt_workqueue(name) __create_workqueue((name), 0, 0, 1)
177#define create_singlethread_workqueue(name) __create_workqueue((name), 1, 0) 178#define create_freezeable_workqueue(name) __create_workqueue((name), 1, 1, 0)
179#define create_singlethread_workqueue(name) __create_workqueue((name), 1, 0, 0)
178 180
179extern void destroy_workqueue(struct workqueue_struct *wq); 181extern void destroy_workqueue(struct workqueue_struct *wq);
180 182
181extern int queue_work(struct workqueue_struct *wq, struct work_struct *work); 183extern int queue_work(struct workqueue_struct *wq, struct work_struct *work);
184extern int queue_work_on(int cpu, struct workqueue_struct *wq,
185 struct work_struct *work);
182extern int queue_delayed_work(struct workqueue_struct *wq, 186extern int queue_delayed_work(struct workqueue_struct *wq,
183 struct delayed_work *work, unsigned long delay); 187 struct delayed_work *work, unsigned long delay);
184extern int queue_delayed_work_on(int cpu, struct workqueue_struct *wq, 188extern int queue_delayed_work_on(int cpu, struct workqueue_struct *wq,
@@ -188,6 +192,7 @@ extern void flush_workqueue(struct workqueue_struct *wq);
188extern void flush_scheduled_work(void); 192extern void flush_scheduled_work(void);
189 193
190extern int schedule_work(struct work_struct *work); 194extern int schedule_work(struct work_struct *work);
195extern int schedule_work_on(int cpu, struct work_struct *work);
191extern int schedule_delayed_work(struct delayed_work *work, unsigned long delay); 196extern int schedule_delayed_work(struct delayed_work *work, unsigned long delay);
192extern int schedule_delayed_work_on(int cpu, struct delayed_work *work, 197extern int schedule_delayed_work_on(int cpu, struct delayed_work *work,
193 unsigned long delay); 198 unsigned long delay);
@@ -198,6 +203,8 @@ extern int keventd_up(void);
198extern void init_workqueues(void); 203extern void init_workqueues(void);
199int execute_in_process_context(work_func_t fn, struct execute_work *); 204int execute_in_process_context(work_func_t fn, struct execute_work *);
200 205
206extern int flush_work(struct work_struct *work);
207
201extern int cancel_work_sync(struct work_struct *work); 208extern int cancel_work_sync(struct work_struct *work);
202 209
203/* 210/*
diff --git a/include/linux/writeback.h b/include/linux/writeback.h
index 12b15c561a1f..e585657e9831 100644
--- a/include/linux/writeback.h
+++ b/include/linux/writeback.h
@@ -63,7 +63,15 @@ struct writeback_control {
63 unsigned for_writepages:1; /* This is a writepages() call */ 63 unsigned for_writepages:1; /* This is a writepages() call */
64 unsigned range_cyclic:1; /* range_start is cyclic */ 64 unsigned range_cyclic:1; /* range_start is cyclic */
65 unsigned more_io:1; /* more io to be dispatched */ 65 unsigned more_io:1; /* more io to be dispatched */
66 unsigned range_cont:1; 66 /*
67 * write_cache_pages() won't update wbc->nr_to_write and
68 * mapping->writeback_index if no_nrwrite_index_update
69 * is set. write_cache_pages() may write more than we
70 * requested and we want to make sure nr_to_write and
71 * writeback_index are updated in a consistent manner
72 * so we use a single control to update them
73 */
74 unsigned no_nrwrite_index_update:1;
67}; 75};
68 76
69/* 77/*
diff --git a/include/linux/xfrm.h b/include/linux/xfrm.h
index fb0c215a3051..4bc1e6b86cb2 100644
--- a/include/linux/xfrm.h
+++ b/include/linux/xfrm.h
@@ -279,6 +279,7 @@ enum xfrm_attr_type_t {
279 XFRMA_POLICY_TYPE, /* struct xfrm_userpolicy_type */ 279 XFRMA_POLICY_TYPE, /* struct xfrm_userpolicy_type */
280 XFRMA_MIGRATE, 280 XFRMA_MIGRATE,
281 XFRMA_ALG_AEAD, /* struct xfrm_algo_aead */ 281 XFRMA_ALG_AEAD, /* struct xfrm_algo_aead */
282 XFRMA_KMADDRESS, /* struct xfrm_user_kmaddress */
282 __XFRMA_MAX 283 __XFRMA_MAX
283 284
284#define XFRMA_MAX (__XFRMA_MAX - 1) 285#define XFRMA_MAX (__XFRMA_MAX - 1)
@@ -415,6 +416,15 @@ struct xfrm_user_report {
415 struct xfrm_selector sel; 416 struct xfrm_selector sel;
416}; 417};
417 418
419/* Used by MIGRATE to pass addresses IKE should use to perform
420 * SA negotiation with the peer */
421struct xfrm_user_kmaddress {
422 xfrm_address_t local;
423 xfrm_address_t remote;
424 __u32 reserved;
425 __u16 family;
426};
427
418struct xfrm_user_migrate { 428struct xfrm_user_migrate {
419 xfrm_address_t old_daddr; 429 xfrm_address_t old_daddr;
420 xfrm_address_t old_saddr; 430 xfrm_address_t old_saddr;